Event.cpp 1.2 KB

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