Event.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2009-2021, 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/Events/Event.h>
  6. #include <AnKi/Scene/Events/EventManager.h>
  7. #include <AnKi/Scene/SceneGraph.h>
  8. #include <AnKi/Util/HighRezTimer.h>
  9. namespace anki {
  10. Event::Event(EventManager* manager)
  11. : m_manager(manager)
  12. {
  13. }
  14. Event::~Event()
  15. {
  16. m_associatedNodes.destroy(getAllocator());
  17. }
  18. void Event::init(Second startTime, Second duration)
  19. {
  20. m_startTime = startTime;
  21. m_duration = (duration < 0.0) ? MAX_SECOND : duration;
  22. if(duration < 0.0)
  23. {
  24. m_reanimate = true;
  25. }
  26. }
  27. SceneAllocator<U8> Event::getAllocator() const
  28. {
  29. return m_manager->getSceneGraph().getAllocator();
  30. }
  31. void Event::setMarkedForDeletion()
  32. {
  33. m_manager->markEventForDeletion(this);
  34. }
  35. Second Event::getDelta(Second crntTime) const
  36. {
  37. Second d = crntTime - m_startTime; // delta
  38. Second dp = d / m_duration; // delta as persentage
  39. return dp;
  40. }
  41. SceneGraph& Event::getSceneGraph()
  42. {
  43. return m_manager->getSceneGraph();
  44. }
  45. const SceneGraph& Event::getSceneGraph() const
  46. {
  47. return m_manager->getSceneGraph();
  48. }
  49. } // end namespace anki