BsCoreSceneManager.cpp 1.5 KB

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