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
Notes: blender-bot 2023-02-14 10:47:20 +01:00
Referenced by commit 728d1ec504, BGE: Fix T46381 : last action frame not updated.
Referenced by issue #40379, Cycles : CUDA Rendering : Environment with MIS uses double memory usage
Referenced by issue #40217, Incredibly slow render on newer builds with cycles of smoke simulations
Referenced by issue #40111, replaceMesh() Crashes BGE When Used on a Parented Object
Referenced by issue #40054, Cycles Bake requires to save externally first/won't let me save file externally
Referenced by issue #39928, Blender crash/freeze when game engine is started with animation played directly on camera object with parents.
Referenced by issue #39779, Blender Game Engine Seg Fault When Playing Game
7 changed files with 43 additions and 1 deletions

View File

@ -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);
}

View File

@ -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();

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -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);

View File

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

View File

@ -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)