1
\$\begingroup\$

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:

  1. In each update in my SceneHandler, do this:
  2. Retrieve all renderable components that currently are in the current scene
  3. Send these components to the RenderManager
  4. Call RenderManager.Update

  5. In each update in RenderManager, do this:

  6. Iterate over the given list and perform an occlusion test

  7. If the object is visible, put it in a new list of visible items

  8. Sort the list of visible items in the order of their layer depth

  9. 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.

\$\endgroup\$
1
\$\begingroup\$

Might want to consider a priority queue instead of that list, if you want to keep the build sequence like you have, because it will automatically sort on insert.

I'm unsure how you're doing an occlusion test in step 7 before you've even sorted them into depth order in step 8...

Since it sounds like you normally keep these renderables in a big bag of chaos maybe consider keeping them instead in a spatial partitioning structure like an octree which maintains relative positioning (which would replace the caching you're considering in your discussion).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.