Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-07-10 06:05:06 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-07-10 06:05:06 +0400
commit1f9adff26fd79f03f9d6616ef70976f0fc81ee0c (patch)
treed2283e12045d66095ee88c55ce82201da194aaf9 /source/gameengine/Physics/Bullet
parent565f10a5416fca5fb794c313d37dfdccdea505cc (diff)
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.
Diffstat (limited to 'source/gameengine/Physics/Bullet')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index e63724fffc6..0a105ee1c1a 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -2048,6 +2048,15 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA
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*>::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) {