BsCoreSceneManager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Destroys all scene objects in the scene.
  24. */
  25. void clearScene();
  26. /**
  27. * @brief Called every frame.
  28. *
  29. * @note Internal method.
  30. */
  31. virtual void _update();
  32. protected:
  33. friend class SceneObject;
  34. /**
  35. * @brief Register a new node in the scene manager, on the top-most level of the hierarchy.
  36. *
  37. * @note After you add a node in the scene manager, it takes ownership of its memory and is responsible for releasing it.
  38. * 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.
  39. *
  40. * @param [in] node Node you wish to add. It's your responsibility not to add duplicate or null nodes. This method won't check.
  41. */
  42. void registerNewSO(const HSceneObject& node);
  43. /**
  44. * @brief SceneObjects call this when they have a component added to them.
  45. */
  46. virtual void notifyComponentAdded(const HComponent& component);
  47. /**
  48. * @brief SceneObjects call this when they have a component removed from them.
  49. */
  50. virtual void notifyComponentRemoved(const HComponent& component);
  51. protected:
  52. HSceneObject mRootNode;
  53. };
  54. /**
  55. * @brief Provides easy access to the scene manager.
  56. */
  57. BS_CORE_EXPORT CoreSceneManager& gCoreSceneManager();
  58. }