I'm just wondering whether there is a more effective way to handle the ordering and visibility of renderable components that fits into the design of my already existing engine.
How I do it now:
- In each update in my SceneHandler, do this:
- Retrieve all renderable components that currently are in the current scene
- Send these components to the RenderManager
In each update in RenderManager, do this:
Iterate over the given list and perform an occlusion test
If the object is visible, put it in a new list of visible items
Sort the list of visible items in the order of their layer depth
When RenderManager.Draw() is called the RenderManager iterates over the list of visible items and draws them
Is there any way that is obviously better than this or is this how you usually do? Maybe I could keep a sorted list of all the current scene objects and then just perform occlusion testing and thus not having the need to sort each update?
Pros and cons of the suggested method are greatly appreciated.