diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c00e7ec7e29..15727cc3f71 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -36,6 +36,7 @@ #include "BL_ActionActuator.h" #include "BL_ArmatureObject.h" #include "BL_SkinDeformer.h" +#include "BL_Action.h" #include "KX_GameObject.h" #include "STR_HashedString.h" #include "MEM_guardedalloc.h" @@ -143,7 +144,53 @@ void BL_ActionActuator::SetLocalTime(float curtime) m_localtime = m_endframe - delta_time; } +bool BL_ActionActuator::Update(double curtime, bool frame) +{ + bool bNegativeEvent = false; + bool bPositiveEvent = false; + KX_GameObject *obj = (KX_GameObject*)GetParent(); + short play_mode = BL_Action::ACT_MODE_PLAY; + // Don't do anything if we're not "active" + if (!frame) + return true; + + // Convert playmode + if (m_playtype == ACT_ACTION_LOOP_END) + play_mode = BL_Action::ACT_MODE_LOOP; + else if (m_playtype == ACT_ACTION_LOOP_STOP) + play_mode = BL_Action::ACT_MODE_LOOP; + else if (m_playtype == ACT_ACTION_PINGPONG) + play_mode = BL_Action::ACT_MODE_PING_PONG; + + + // Handle events + bNegativeEvent = m_negevent; + bPositiveEvent = m_posevent; + RemoveAllEvents(); + + if (!m_is_going && bPositiveEvent) + { + m_is_going = true; + obj->PlayAction(m_action->id.name+2, m_startframe, m_endframe, 0, m_blendin, play_mode); + } + else if (m_is_going && bNegativeEvent) + { + m_is_going = false; + obj->StopAction(0); + return false; + } + + // Handle a finished animation + if (m_is_going && obj->IsActionDone(0)) + { + return false; + } + + return true; +} + +#if 0 // Kept around as reference for now bool BL_ActionActuator::Update(double curtime, bool frame) { bool bNegativeEvent = false; @@ -449,6 +496,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) } return keepgoing; }; +#endif #ifdef WITH_PYTHON diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index ff4ca785a96..1530ccda00b 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -70,6 +70,7 @@ public: m_playtype(playtype), m_priority(priority), m_end_reset(end_reset), + m_is_going(false), m_pose(NULL), m_blendpose(NULL), m_userpose(NULL), @@ -163,6 +164,7 @@ protected: short m_playtype; short m_priority; bool m_end_reset; + bool m_is_going; struct bPose* m_pose; struct bPose* m_blendpose; struct bPose* m_userpose;