BsCoreSceneManager.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "BsCoreSceneManager.h"
  2. #include "BsSceneObject.h"
  3. #include "BsComponent.h"
  4. namespace BansheeEngine
  5. {
  6. CoreSceneManager::CoreSceneManager()
  7. {
  8. mRootNode = SceneObject::createInternal("SceneRoot");
  9. }
  10. CoreSceneManager::~CoreSceneManager()
  11. {
  12. if(mRootNode != nullptr)
  13. mRootNode->destroy();
  14. }
  15. void CoreSceneManager::_update()
  16. {
  17. Stack<HSceneObject> todo;
  18. todo.push(mRootNode);
  19. while(!todo.empty())
  20. {
  21. HSceneObject currentGO = todo.top();
  22. todo.pop();
  23. const Vector<HComponent>& components = currentGO->getComponents();
  24. for(auto iter = components.begin(); iter != components.end(); ++iter)
  25. {
  26. (*iter)->update();
  27. }
  28. for(UINT32 i = 0; i < currentGO->getNumChildren(); i++)
  29. todo.push(currentGO->getChild(i));
  30. }
  31. }
  32. void CoreSceneManager::registerNewSO(const HSceneObject& node)
  33. {
  34. if(mRootNode) // If root node is null, then this new node is the root node
  35. node->setParent(mRootNode);
  36. }
  37. void CoreSceneManager::notifyComponentAdded(const HComponent& component) { }
  38. void CoreSceneManager::notifyComponentRemoved(const HComponent& component) { }
  39. CoreSceneManager& gSceneManager()
  40. {
  41. return CoreSceneManager::instance();
  42. }
  43. }