diff options
Diffstat (limited to 'source/gameengine/Converter/BL_ActionActuator.cpp')
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 7e353d590bb..fd16519335a 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,90 @@ 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; + float start = m_startframe, end = m_endframe; + + // If we don't have an action, we can't do anything + if (!m_action) + return false; + + // 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; + else if (m_playtype == ACT_ACTION_FROM_PROP) + { + CValue* prop = GetParent()->GetProperty(m_propname); + + play_mode = BL_Action::ACT_MODE_PLAY; + start = end = prop->GetNumber(); + m_is_going = false; + } + + // 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, start, end, m_layer, m_blendin, play_mode, 0, m_ipo_flags); + if (m_end_reset) + obj->SetActionFrame(m_layer, m_localtime); + } + else if (m_is_going && bNegativeEvent) + { + m_is_going = false; + + if (!m_end_reset) + { + obj->StopAction(m_layer); + return false; + } + + m_localtime = obj->GetActionFrame(m_layer); + obj->StopAction(m_layer); // Stop the action after getting the frame + } + + // Handle a frame property if it's defined + if (m_framepropname[0] != 0) + { + CValue* oldprop = obj->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer)); + if (oldprop) + oldprop->SetValue(newval); + else + obj->SetProperty(m_framepropname, newval); + + newval->Release(); + } + if (m_playtype == ACT_ACTION_FROM_PROP) + { + return true; + } + // Handle a finished animation + else if (m_is_going && obj->IsActionDone(m_layer)) + { + 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 +533,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) } return keepgoing; }; +#endif #ifdef WITH_PYTHON |