Fix T39928: Blender crash/freeze when game engine is started with animation played directly on camera object with parents.

Updating object IPOs is not currently thread-safe since it also updates
children. This leads to problems when parents and children are both
animated. For now, updating object IPOs is done in its own loop to avoid
threading issues.
This commit is contained in:
Mitchell Stokes 2014-05-04 15:37:18 -07:00
parent d27eea6dc6
commit 362b25b382
7 changed files with 43 additions and 1 deletions

@ -485,8 +485,15 @@ void BL_Action::Update(float curtime)
}
}
m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
// This isn't thread-safe, so we move it into it's own function for now
//m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
if (m_done)
ClearControllerList();
}
void BL_Action::UpdateIPOs()
{
if (!m_done)
m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
}

@ -105,6 +105,10 @@ public:
* Update the action's frame, etc.
*/
void Update(float curtime);
/**
* Update object IPOs (note: not thread-safe!)
*/
void UpdateIPOs();
// Accessors
float GetFrame();

@ -102,3 +102,14 @@ void BL_ActionManager::Update(float curtime)
}
}
}
void BL_ActionManager::UpdateIPOs()
{
for (int i=0; i<MAX_ACTION_LAYERS; ++i)
{
if (!m_layers[i]->IsDone())
{
m_layers[i]->UpdateIPOs();
}
}
}

@ -98,6 +98,11 @@ public:
*/
void Update(float);
/**
* Update object IPOs (note: not thread-safe!)
*/
void UpdateIPOs();
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ActionManager")
#endif

@ -462,6 +462,11 @@ void KX_GameObject::UpdateActionManager(float curtime)
GetActionManager()->Update(curtime);
}
void KX_GameObject::UpdateActionIPOs()
{
GetActionManager()->UpdateIPOs();
}
float KX_GameObject::GetActionFrame(short layer)
{
return GetActionManager()->GetActionFrame(layer);

@ -300,6 +300,12 @@ public:
*/
void UpdateActionManager(float curtime);
/**
* Have the action manager update IPOs
* note: not thread-safe!
*/
void UpdateActionIPOs();
/*********************************
* End Animation API
*********************************/

@ -1658,6 +1658,10 @@ void KX_Scene::UpdateAnimations(double curtime)
BLI_task_pool_work_and_wait(pool);
BLI_task_pool_free(pool);
for (int i=0; i<m_animatedlist->GetCount(); ++i) {
((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionIPOs();
}
}
void KX_Scene::LogicUpdateFrame(double curtime, bool frame)