diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2009-03-29 23:54:05 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2009-03-29 23:54:05 +0400 |
commit | b182778e7155abe09bd2101b851fb1178c9babb8 (patch) | |
tree | 79c20d43506d05d8a46d1290d00d589e3fe9f669 /source/gameengine/Physics/Bullet | |
parent | 30fa7a7286a2d4b5f8abedc2ce43602fb229b25c (diff) |
Applied patch #18446, to do versions on damping
Re-enable vertex welding, only for soft bodies. They require it. Future versions could expose such vertexWeldingThreshold.
Diffstat (limited to 'source/gameengine/Physics/Bullet')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 33 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.h | 12 |
2 files changed, 31 insertions, 14 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 35602b4095a..cc6be9a7ae3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1569,14 +1569,31 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() if (!m_unscaledShape) { - btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray( - m_polygonIndexArray.size(), - &m_triFaceArray[0], - 3*sizeof(int), - m_vertexArray.size(), - (btScalar*) &m_vertexArray[0].x(), - sizeof(btVector3) - ); + btTriangleIndexVertexArray* indexVertexArrays = 0; + + ///enable welding, only for the objects that need it (such as soft bodies) + if (0.f != m_weldingThreshold1) + { + btTriangleMesh* collisionMeshData = new btTriangleMesh(true,false); + collisionMeshData->m_weldingThreshold = m_weldingThreshold1; + bool removeDuplicateVertices=true; + // m_vertexArray is necessarily a multiple of 3 + for (int i=0;i<m_vertexArray.size(); i+=3 ) + { + collisionMeshData->addTriangle(m_vertexArray[i+2],m_vertexArray[i+1],m_vertexArray[i],removeDuplicateVertices); + } + indexVertexArrays = collisionMeshData; + + } else + { + indexVertexArrays = new btTriangleIndexVertexArray( + m_polygonIndexArray.size(), + &m_triFaceArray[0], + 3*sizeof(int), + m_vertexArray.size(), + (btScalar*) &m_vertexArray[0].x(), + sizeof(btVector3)); + } // this shape will be shared and not deleted until shapeInfo is deleted m_unscaledShape = new btBvhTriangleMeshShape( indexVertexArrays, true ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 67dd82db5cc..510454a7b63 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -72,7 +72,7 @@ public: m_meshObject(NULL), m_unscaledShape(NULL), m_useGimpact(false), - m_weldingThreshold(0.f), + m_weldingThreshold1(0.f), m_shapeProxy(NULL) { m_childTrans.setIdentity(); @@ -171,13 +171,13 @@ public: std::vector<int> m_triFaceArray; // Contains an array of triplets of face indicies // quads turn into 2 tris - void setVertexWeldingThreshold(float threshold) + void setVertexWeldingThreshold1(float threshold) { - m_weldingThreshold = threshold; + m_weldingThreshold1 = threshold; } - float getVertexWeldingThreshold() const + float getVertexWeldingThreshold1() const { - return m_weldingThreshold; + return m_weldingThreshold1; } protected: static std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> m_meshShapeMap; @@ -188,7 +188,7 @@ protected: // the actual shape is of type btScaledBvhTriangleMeshShape std::vector<CcdShapeConstructionInfo*> m_shapeArray; // for compound shapes bool m_useGimpact; //use gimpact for concave dynamic/moving collision detection - float m_weldingThreshold; //welding closeby vertices together can improve softbody stability etc. // Not used at the moment, maybe remove? + float m_weldingThreshold1; //welding closeby vertices together can improve softbody stability etc. CcdShapeConstructionInfo* m_shapeProxy; // only used for PHY_SHAPE_PROXY, pointer to actual shape info }; |