BGE: Fix T45945: Action bouncing.

Bug introduced in 583fa7d1e, KX_GameObject.setActionFrame can make BL_Action::m_starttime negative. But in BL_Action::Update m_starttime is set to the current time if it's negative.
To fix it we use a boolean BL_Action::m_initializedTime to know if we should initialize the time in BL_Action::Update, it's more stable than comparing times.

Tested with bug task T45945 and T32054, with an extra patch about to fix suspend resume scene issues with actions : D1569
This commit is contained in:
2015-10-28 14:30:52 +01:00
parent e0c60985b6
commit f10db730bc
2 changed files with 8 additions and 2 deletions

View File

@@ -84,7 +84,8 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_blendmode(ACT_BLEND_BLEND),
m_ipo_flags(0),
m_done(true),
m_calc_localtime(true)
m_calc_localtime(true),
m_initializedTime(false)
{
}
@@ -271,6 +272,7 @@ bool BL_Action::Play(const char* name,
m_layer_weight = layer_weight;
m_done = false;
m_initializedTime = false;
return true;
}
@@ -400,8 +402,10 @@ void BL_Action::Update(float curtime)
// Grab the start time here so we don't end up with a negative m_localframe when
// suspending and resuming scenes.
if (m_starttime < 0)
if (!m_initializedTime) {
m_starttime = curtime;
m_initializedTime = true;
}
if (m_calc_localtime)
SetLocalTime(curtime);

View File

@@ -69,6 +69,8 @@ private:
bool m_done;
bool m_calc_localtime;
/// Set to true when m_starttime is initialized in Update.
bool m_initializedTime;
void ClearControllerList();
void InitIPO();