fixed some outstanding issues with Bullet soft bodies:
[blender.git] / extern / bullet2 / src / BulletSoftBody / btSoftBodyConcaveCollisionAlgorithm.h
index adb91329a4c4d7e3b7abea69b65117403165eb72..08ac3f11e2020dd5a0d11ea8c67dc144abfba9b1 100644 (file)
@@ -25,6 +25,39 @@ class btDispatcher;
 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
 class btSoftBody;
+class btCollisionShape;
+
+#include "LinearMath/btHashMap.h"
+
+#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" //for definition of MAX_NUM_PARTS_IN_BITS
+
+struct btTriIndex
+{
+       int m_PartIdTriangleIndex;
+       class btCollisionShape* m_childShape;
+       
+       btTriIndex(int partId,int triangleIndex,btCollisionShape* shape)
+       {
+               m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
+               m_childShape = shape;
+       }
+
+       int     getTriangleIndex() const
+       {
+               // Get only the lower bits where the triangle index is stored
+               return (m_PartIdTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
+       }
+       int     getPartId() const
+       {
+               // Get only the highest bits where the part index is stored
+               return (m_PartIdTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
+       }
+       int     getUid() const
+       {
+               return m_PartIdTriangleIndex;
+       }
+};
+
 
 ///For each triangle in the concave mesh that overlaps with the AABB of a soft body (m_softBody), processTriangle is called.
 class btSoftBodyTriangleCallback : public btTriangleCallback
@@ -40,6 +73,8 @@ class btSoftBodyTriangleCallback : public btTriangleCallback
        btDispatcher*   m_dispatcher;
        const btDispatcherInfo* m_dispatchInfoPtr;
        btScalar m_collisionMarginTriangle;
+
+       btHashMap<btHashKey<btTriIndex>,btTriIndex> m_shapeCache;
        
 public:
 int    m_triangleCount;