Fix Action & IPO actuators: (Bugs #1921 & #1920)

This commit is contained in:
Kester Maddock 2004-12-05 02:50:57 +00:00
parent 5d04d876f7
commit ef971de66d
3 changed files with 38 additions and 29 deletions

@ -166,18 +166,28 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
if (frame)
{
i--;
if ((*i)->GetNumber() == 0.0f)
for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
{
bNegativeEvent = true;
i--;
if ((*i)->GetNumber() == 0.0f)
bNegativeEvent = true;
else
bPositiveEvent= true;
(*i)->Release();
m_events.pop_back();
}
if (bPositiveEvent)
m_flag |= ACT_FLAG_ACTIVE;
if (bNegativeEvent)
{
if (!(m_flag & ACT_FLAG_ACTIVE))
return false;
m_flag &= ~ACT_FLAG_ACTIVE;
}
else
bPositiveEvent= true;
(*i)->Release();
m_events.pop_back();
}
/* We know that action actuators have been discarded from all non armature objects:
@ -236,7 +246,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
m_flag &= ~ACT_FLAG_REVERSE;
m_flag |= ACT_FLAG_LOCKINPUT;
m_starttime = curtime;
SetStartTime(curtime);
}
}
else if (bNegativeEvent){
@ -324,6 +334,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
m_localtime = m_endframe;
m_flag &= ~ACT_FLAG_LOCKINPUT;
}
SetStartTime(curtime);
}
break;
case ACT_ACTION_PLAY:

@ -52,22 +52,22 @@ public:
PyTypeObject* T=&Type)
: SCA_IActuator(gameobj,T),
m_blendframe(0),
m_lastpos(0, 0, 0),
m_blendframe(0),
m_flag(0),
m_startframe (starttime),
m_endframe(endtime) ,
m_localtime(starttime),
m_lastUpdate(-1),
m_playtype(playtype),
m_blendin(blendin),
m_priority(priority),
m_stridelength(stride),
m_playtype(playtype),
m_priority(priority),
m_pose(NULL),
m_blendpose(NULL),
m_userpose(NULL),
m_propname(propname),
m_action(action)
m_action(action),
m_propname(propname)
{
};
virtual ~BL_ActionActuator();
@ -115,8 +115,8 @@ protected:
void SetLocalTime(float curtime);
bool ClampLocalTime();
float m_blendframe;
MT_Point3 m_lastpos;
float m_blendframe;
int m_flag;
/** The frame this action starts */
float m_startframe;
@ -128,23 +128,23 @@ protected:
float m_localtime;
float m_lastUpdate;
short m_playtype;
float m_blendin;
float m_blendstart;
short m_priority;
float m_stridelength;
short m_playtype;
short m_priority;
struct bPose* m_pose;
struct bPose* m_blendpose;
struct bPose* m_userpose;
STR_String m_propname;
struct bAction *m_action;
STR_String m_propname;
};
enum {
ACT_FLAG_REVERSE = 0x00000001,
ACT_FLAG_LOCKINPUT = 0x00000002,
ACT_FLAG_KEYUP = 0x00000004
ACT_FLAG_KEYUP = 0x00000004,
ACT_FLAG_ACTIVE = 0x00000008
};
#endif

@ -112,14 +112,13 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
m_endframe(endtime),
m_recurse(recurse),
m_localtime(starttime),
m_starttime(-1.0),
m_direction(1),
m_propname(propname),
m_ipo_as_force(ipo_as_force),
m_force_ipo_local(force_ipo_local),
m_type((IpoActType)acttype)
{
// intentionally empty
m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0;
}
void KX_IpoActuator::SetStart(float starttime)
@ -189,10 +188,11 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
bool bNegativeEvent = false;
int numevents = m_events.size();
int numevents = 0;
if (frame)
{
numevents = m_events.size();
for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
{
--i;
@ -204,15 +204,13 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
m_events.clear();
if (bNegativeEvent)
{
RemoveAllEvents();
}
}
double start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0);
bool result=true;
if (m_starttime < 0.0)
if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe))
m_starttime = curtime;
switch (m_type)
@ -273,7 +271,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
}
case KX_ACT_IPO_FLIPPER:
{
result = true;
result = !(bNegativeEvent && (m_localtime == m_startframe));
if (numevents)
{
if (bNegativeEvent)
@ -404,7 +402,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
}
if (!result && m_type != KX_ACT_IPO_LOOPSTOP)
m_starttime = -1.0;
m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0;
return result;
}