[Bf-blender-cvs] [362b25b3] master: Fix T39928: Blender crash/freeze when game engine is started with animation played directly on camera object with parents.

Mitchell Stokes noreply at git.blender.org
Mon May 5 00:42:45 CEST 2014


Commit: 362b25b38287cb75e4d22b30bdbc7f47e8eb3fdf
Author: Mitchell Stokes
Date:   Sun May 4 15:37:18 2014 -0700
https://developer.blender.org/rB362b25b38287cb75e4d22b30bdbc7f47e8eb3fdf

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.

===================================================================

M	source/gameengine/Ketsji/BL_Action.cpp
M	source/gameengine/Ketsji/BL_Action.h
M	source/gameengine/Ketsji/BL_ActionManager.cpp
M	source/gameengine/Ketsji/BL_ActionManager.h
M	source/gameengine/Ketsji/KX_GameObject.cpp
M	source/gameengine/Ketsji/KX_GameObject.h
M	source/gameengine/Ketsji/KX_Scene.cpp

===================================================================

diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index e4ab2d5..a50c07a 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -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);
+}
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index 463d177..dd1cd1f 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -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();
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 2e882ce..404f276 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -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();
+		}
+	}
+}
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index 8c5b8e9..be9097c 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -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
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 7042e6e..9ea7698 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -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);
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index ac0afca..7450be4 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -300,6 +300,12 @@ public:
 	 */
 	void UpdateActionManager(float curtime);
 
+	/**
+	 * Have the action manager update IPOs
+	 * note: not thread-safe!
+	 */
+	void UpdateActionIPOs();
+
 	/*********************************
 	 * End Animation API
 	 *********************************/
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 5a33a61..4c9fba8 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -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)




More information about the Bf-blender-cvs mailing list