I have a scene containing primitives created by the user (mostly cubes and spheres with custom colors and sizes).
Now, if I draw them all in the order they appeared, obviously I get problems, like a cube added later behind another one showing up on top of it even though it should not be visible without moving the camera.
If I check for their location on the z axis, that would make everything better, but it would still look bad if two cubes with different rotations were on top of each other. Instead of seeing part of both.
The “expected” result would be something like that
But it wouldn’t work with this technique.
So what is the recommended way to select the order of drawing in order to get a scene as realistic as possible? There’s probably more to it than just the order, so I’d like to know how should those primitive be drawn to obtain a realistic result?