[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48784] trunk/blender/source/gameengine/ Physics/Bullet/CcdPhysicsController.cpp: Fix for a crash caused by ReplaceMesh changing an objects physics shape.
Mitchell Stokes
mogurijin at gmail.com
Tue Jul 10 04:05:10 CEST 2012
Revision: 48784
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48784
Author: moguri
Date: 2012-07-10 02:05:06 +0000 (Tue, 10 Jul 2012)
Log Message:
-----------
Fix for a crash caused by ReplaceMesh changing an objects physics shape. CcdShapeConstructionInfo::UpdateMesh() would change the CcdShapeConstructionInfo's m_meshObject, but didn't change m_meshShapeMap, which means the CcdShapeConstructionInfo object's destructor would not find it's m_meshObject in the m_meshShapeMap. This leaves some nasty dangling pointers laying around which caused issues if the scene was re-run, or the scene was changed to one that also had the mesh.
Note: This fix could cause other issues with shared physics meshes. In general, we may want to re-evaluate how we handle updating potentially shared physics meshes.
Modified Paths:
--------------
trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 2012-07-10 01:30:33 UTC (rev 48783)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 2012-07-10 02:05:06 UTC (rev 48784)
@@ -2048,6 +2048,15 @@
m_forceReInstance= true;
}
+ // Make sure to also replace the mesh in the shape map! Otherwise we leave dangling references when we free.
+ // Note, this whole business could cause issues with shared meshes. If we update one mesh, do we replace
+ // them all?
+ std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::const_iterator mit = m_meshShapeMap.find(m_meshObject);
+ if (mit != m_meshShapeMap.end()) {
+ m_meshShapeMap.erase(mit);
+ m_meshShapeMap[meshobj] = this;
+ }
+
m_meshObject= meshobj;
if (dm) {
More information about the Bf-blender-cvs
mailing list