diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-08-21 19:19:54 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-08-21 19:19:54 +0400 |
commit | e912ca9331d7f9637664e4588bdb72b0ebe76e5c (patch) | |
tree | 1e0c5acf6c732223c9daf4fc3505c9dbd5d5c2e2 /source/gameengine/Ketsji/KX_Scene.cpp | |
parent | 4b9f5b2710fd90946dd378d3f004ddfd6e09cfb9 (diff) |
BGE bug #17491 fixed: BGE, Dupli instance with different scale, massive slowdown.
The root cause of this bug is the fact that Bullet shapes
are shared between duplicated game objects. As the physics
object scale is stored in the shape, all duplicas must
have the same scale otherwise the physics representation
is incorrect.
This fix introduces a mechanism to duplicate shapes at
runtime so that Bullet shapes are not shared anymore.
The drawback is an increased memory consuption.
A reference count mechanism will be introduced in a
later revision to keep Bullet shape shared between
duplicas that have the same scale.
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2828663c63d..ab3692d2411 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -234,40 +234,9 @@ KX_Scene::~KX_Scene() { delete m_bucketmanager; } -#ifdef USE_BULLET - // This is a fix for memory leaks in bullet: the collision shapes is not destroyed - // when the physical controllers are destroyed. The reason is that shapes are shared - // between replicas of an object. There is no reference count in Bullet so the - // only workaround that does not involve changes in Bullet is to save in this array - // the list of shapes that are created when the scene is created (see KX_ConvertPhysicsObjects.cpp) - class btCollisionShape* shape; - class btTriangleMeshShape* meshShape; - vector<class btCollisionShape*>::iterator it = m_shapes.begin(); - while (it != m_shapes.end()) { - shape = *it; - if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) - { - meshShape = static_cast<btTriangleMeshShape*>(shape); - // shapes based on meshes use an interface that contains the vertices. - // Again the idea is to be able to share the interface between shapes but - // this is not used in Blender: each base object will have its own interface - btStridingMeshInterface* meshInterface = meshShape->getMeshInterface(); - if (meshInterface) - delete meshInterface; - } - delete shape; - it++; - } -#endif //Py_DECREF(m_attrlist); } -void KX_Scene::AddShape(class btCollisionShape*shape) -{ - m_shapes.push_back(shape); -} - - void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat) { m_projectionmat = pmat; |