VisibilityTester.cpp 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "anki/scene/VisibilityTester.h"
  2. #include "anki/scene/Scene.h"
  3. #include "anki/scene/Camera.h"
  4. #include "anki/scene/Renderable.h"
  5. #include "anki/scene/Light.h"
  6. namespace anki {
  7. //==============================================================================
  8. VisibilityTester::~VisibilityTester()
  9. {}
  10. //==============================================================================
  11. void VisibilityTester::test(Frustumable& cam, Scene& scene,
  12. VisibilityInfo& vinfo)
  13. {
  14. vinfo.renderables.clear();
  15. vinfo.lights.clear();
  16. for(SceneNode* node : scene.getAllNodes())
  17. {
  18. Spatial* sp = node->getSpatial();
  19. if(!sp)
  20. {
  21. continue;
  22. }
  23. if(!cam.insideFrustum(*sp))
  24. {
  25. continue;
  26. }
  27. Renderable* r = node->getRenderable();
  28. if(r)
  29. {
  30. r->enableFlag(Renderable::RF_VISIBLE);
  31. vinfo.renderables.push_back(r);
  32. }
  33. Light* l = node->getLight();
  34. if(l)
  35. {
  36. vinfo.lights.push_back(l);
  37. }
  38. }
  39. }
  40. } // end namespace