| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include "CmSceneManager.h"
- #include "CmSceneObject.h"
- #include "CmComponent.h"
- #include "CmCamera.h"
- #include "CmRenderable.h"
- namespace CamelotEngine
- {
- SceneManager::SceneManager()
- {
- mRootNode = SceneObject::createInternal("SceneRoot");
- }
- SceneManager::~SceneManager()
- {
- if(mRootNode != nullptr)
- mRootNode->destroy();
- }
- void SceneManager::update()
- {
- stack<HSceneObject>::type todo;
- todo.push(mRootNode);
- while(!todo.empty())
- {
- HSceneObject currentGO = todo.top();
- todo.pop();
-
- vector<HComponent>::type components = currentGO->getComponents();
- for(auto iter = components.begin(); iter != components.end(); ++iter)
- {
- (*iter)->update();
- }
- for(UINT32 i = 0; i < currentGO->getNumChildren(); i++)
- todo.push(currentGO->getChild(i));
- }
- }
- void SceneManager::registerNewGO(const HSceneObject& node)
- {
- if(mRootNode) // If root node is null, then this new node is the root node
- node->setParent(mRootNode);
- }
- void SceneManager::notifyComponentAdded(const HComponent& component) { }
- void SceneManager::notifyComponentRemoved(const HComponent& component) { }
- SceneManager& gSceneManager()
- {
- return SceneManager::instance();
- }
- }
|