Depth libgdx

Hello,
After a project which i recently made, i came up with a question. How is depth handled normally? The way i do it is draw upper sprites later on. But what if you want to make an isometric game for example? Then you’d have to check if the player is in front of the tree or behind the tree, and after that youd move the tree to a list which will get drawed after the player. With 1 player or moving object i dont see a big issue here.
But what if you are trying to achieve the same effect with say 200 units? You’d have to check for every single unit on the map within the viewport. Is that right?

Is there some other way to draw a sprite “deeper” than another sprite? Instead of just having it drawn later in the draw function?

If you’re using Actors and Stage, you can use setZIndex.
If you’re using SpriteBatch and textures, you will have to order your sprites before rendering them.



Alternatively, you can use the depth buffer for “hardware sorting” so to speak. There are some downsides, like alpha transparency issues. Often CPU sorting is “fast enough” so just stick with Painter’s Algorithm until you find it to be a bottleneck.

Yeah i too found the first 2 links. The third one seems rather intresting. A more math based explanation. Thanks. I’ll have a look at the drawing of the Actors and Stage.