SceneNode.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Scene/SceneNode.h>
  6. #include <AnKi/Scene/SceneGraph.h>
  7. namespace anki {
  8. SceneNode::SceneNode(SceneGraph* scene, CString name)
  9. : m_scene(scene)
  10. , m_uuid(scene->getNewUuid())
  11. {
  12. if(name)
  13. {
  14. m_name.create(getAllocator(), name);
  15. }
  16. }
  17. SceneNode::~SceneNode()
  18. {
  19. auto alloc = getAllocator();
  20. auto it = m_components.getBegin();
  21. auto end = m_components.getEnd();
  22. for(; it != end; ++it)
  23. {
  24. alloc.deleteInstance(*it);
  25. }
  26. Base::destroy(alloc);
  27. m_name.destroy(alloc);
  28. m_components.destroy(alloc);
  29. m_componentInfos.destroy(alloc);
  30. }
  31. void SceneNode::setMarkedForDeletion()
  32. {
  33. // Mark for deletion only when it's not already marked because we don't want to increase the counter again
  34. if(!getMarkedForDeletion())
  35. {
  36. m_markedForDeletion = true;
  37. m_scene->increaseObjectsMarkedForDeletion();
  38. }
  39. [[maybe_unused]] const Error err = visitChildren([](SceneNode& obj) -> Error {
  40. obj.setMarkedForDeletion();
  41. return Error::NONE;
  42. });
  43. }
  44. Timestamp SceneNode::getGlobalTimestamp() const
  45. {
  46. return m_scene->getGlobalTimestamp();
  47. }
  48. SceneAllocator<U8> SceneNode::getAllocator() const
  49. {
  50. ANKI_ASSERT(m_scene);
  51. return m_scene->getAllocator();
  52. }
  53. SceneFrameAllocator<U8> SceneNode::getFrameAllocator() const
  54. {
  55. ANKI_ASSERT(m_scene);
  56. return m_scene->getFrameAllocator();
  57. }
  58. ResourceManager& SceneNode::getResourceManager()
  59. {
  60. return m_scene->getResourceManager();
  61. }
  62. const ConfigSet& SceneNode::getConfig() const
  63. {
  64. return m_scene->getConfig();
  65. }
  66. } // end namespace anki