BsCoreSceneManager.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. #include "BsGameObject.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Manages all objects in the scene and provides various query methods
  9. * for finding objects. This is just the base class with basic query
  10. * functionality. You should override it with your own version that
  11. * implements a spatial data structure of your choice for faster queries.
  12. */
  13. class BS_CORE_EXPORT CoreSceneManager : public Module<CoreSceneManager>
  14. {
  15. public:
  16. CoreSceneManager();
  17. virtual ~CoreSceneManager();
  18. /**
  19. * @brief Returns the root scene object.
  20. */
  21. HSceneObject getRootNode() const { return mRootNode; }
  22. /**
  23. * @brief Called every frame.
  24. *
  25. * @note Internal method.
  26. */
  27. virtual void _update();
  28. protected:
  29. friend class SceneObject;
  30. /**
  31. * @brief Register a new node in the scene manager, on the top-most level of the hierarchy.
  32. *
  33. * @note After you add a node in the scene manager, it takes ownership of its memory and is responsible for releasing it.
  34. * Do NOT add nodes that have already been added (i.e. if you just want to change their parent). Normally this method will only be called by SceneObject.
  35. *
  36. * @param [in] node Node you wish to add. It's your responsibility not to add duplicate or null nodes. This method won't check.
  37. */
  38. void registerNewSO(const HSceneObject& node);
  39. /**
  40. * @brief SceneObjects call this when they have a component added to them.
  41. */
  42. virtual void notifyComponentAdded(const HComponent& component);
  43. /**
  44. * @brief SceneObjects call this when they have a component removed from them.
  45. */
  46. virtual void notifyComponentRemoved(const HComponent& component);
  47. protected:
  48. HSceneObject mRootNode;
  49. };
  50. /**
  51. * @brief Provides easy access to the scene manager.
  52. */
  53. BS_CORE_EXPORT CoreSceneManager& gSceneManager();
  54. }