Skip to main content
2 of 2
added 285 characters in body

How to check if an AABB is behind another AABB while isometric depth sorting?

I have an isometric scene in a custom engine where my world sim is 3D, but I'm rendering sprites. To depth sort, I follow the approach in this blog post. Basically: wrap each sprite in an AABB, then sort them by depth.

The condition it uses to test if one of the sprite's AABBs is behind another is:

if (b.minX < a.maxX && b.minY < a.maxY && b.minZ < a.maxZ) { // b is behind a } 

however, this doesn't produce the result I would like in a few situations. Say I have two boxes, where one is intersecting the other: Separated boxes, and intersecting boxes

// BoundingBox is {minX, maxX, minY, maxY, minZ, maxZ} BoundingBox spriteABounds{0, 7, 0, 32, 0, 78}; BoundingBox spriteBBounds{0, 32, 0, 32, 0, 78}; 

The desired behavior would be for sprite A to be behind sprite B, but the above condition considers both boxes to be behind eachother.

Another situation is when dealing with planes (note that the floor tile isn't graphically a plane, but should be treated as one in the world sim): Floor tile drawing over a wall

BoundingBox spriteABounds{0, 32, 0, 32, 78, 78}; BoundingBox spriteBBounds{32, 64, 0, 32, 0, 78}; 

The desired behavior would be for sprite A to be behind sprite B, but the above condition considers neither to be behind eachother.

Is there a way that I can set up the condition to handle these cases appropriately, or would I need to switch to a different approach? If the latter, what approach would be more appropriate?