forked from bartvdbraak/blender
BGE Animations: Beginning work on the new action actuator.
* Converted BL_ActionActuator::Update() to use the new action api (still just armatures) * Not all of the functionality of the old Update() have been ported (Lood end, continued animation, etc) * Things are still pretty messy. Once have things more flushed out, I'll start stripping more of the old actuator out.
This commit is contained in:
parent
54a37ba855
commit
38d87ee48e
@ -36,6 +36,7 @@
|
|||||||
#include "BL_ActionActuator.h"
|
#include "BL_ActionActuator.h"
|
||||||
#include "BL_ArmatureObject.h"
|
#include "BL_ArmatureObject.h"
|
||||||
#include "BL_SkinDeformer.h"
|
#include "BL_SkinDeformer.h"
|
||||||
|
#include "BL_Action.h"
|
||||||
#include "KX_GameObject.h"
|
#include "KX_GameObject.h"
|
||||||
#include "STR_HashedString.h"
|
#include "STR_HashedString.h"
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
@ -143,7 +144,53 @@ void BL_ActionActuator::SetLocalTime(float curtime)
|
|||||||
m_localtime = m_endframe - delta_time;
|
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 BL_ActionActuator::Update(double curtime, bool frame)
|
||||||
{
|
{
|
||||||
bool bNegativeEvent = false;
|
bool bNegativeEvent = false;
|
||||||
@ -449,6 +496,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
|||||||
}
|
}
|
||||||
return keepgoing;
|
return keepgoing;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
m_playtype(playtype),
|
m_playtype(playtype),
|
||||||
m_priority(priority),
|
m_priority(priority),
|
||||||
m_end_reset(end_reset),
|
m_end_reset(end_reset),
|
||||||
|
m_is_going(false),
|
||||||
m_pose(NULL),
|
m_pose(NULL),
|
||||||
m_blendpose(NULL),
|
m_blendpose(NULL),
|
||||||
m_userpose(NULL),
|
m_userpose(NULL),
|
||||||
@ -163,6 +164,7 @@ protected:
|
|||||||
short m_playtype;
|
short m_playtype;
|
||||||
short m_priority;
|
short m_priority;
|
||||||
bool m_end_reset;
|
bool m_end_reset;
|
||||||
|
bool m_is_going;
|
||||||
struct bPose* m_pose;
|
struct bPose* m_pose;
|
||||||
struct bPose* m_blendpose;
|
struct bPose* m_blendpose;
|
||||||
struct bPose* m_userpose;
|
struct bPose* m_userpose;
|
||||||
|
Loading…
Reference in New Issue
Block a user