Last (hopefully) soft body fixes:
authorErwin Coumans <blender@erwincoumans.com>
Sat, 11 Oct 2008 20:19:04 +0000 (20:19 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Sat, 11 Oct 2008 20:19:04 +0000 (20:19 +0000)
Enable soft body collision clusters by default.
Add option to 'disable collision' button between soft body and rigid body connected by constraint (option was already available between two rigid bodies)

extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
extern/bullet2/src/BulletSoftBody/btSoftBody.h
extern/bullet2/src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp
source/blender/blenkernel/intern/bullet.c
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 1604167b6efa7e674ab9d8c4ab1d51f7736fa7bc..1ec668c9c78dca09461b673b592857abd1a37cb0 100644 (file)
@@ -306,8 +306,16 @@ void                       btSoftBody::appendFace(int node0,int node1,int node2,Material* mat)
 }
 
 //
-void                   btSoftBody::appendAnchor(int node,btRigidBody* body)
+void                   btSoftBody::appendAnchor(int node,btRigidBody* body,bool disableCollisionWithBody=false)
 {
+       if (disableCollisionWithBody)
+       {
+               if (m_collisionDisabledObjects.findLinearSearch(body)==m_collisionDisabledObjects.size())
+               {
+                       m_collisionDisabledObjects.push_back(body);
+               }
+       }
+
        Anchor  a;
        a.m_node                        =       &m_nodes[node];
        a.m_body                        =       body;
index 79d272765e01c04ddd9ca245585b1540e3baf20c..743462d259a48a7d1c9bc2203016692ce420616e 100644 (file)
@@ -49,6 +49,8 @@ struct        btSoftBodyWorldInfo
 class  btSoftBody : public btCollisionObject
 {
 public:
+       btAlignedObjectArray<class btCollisionObject*> m_collisionDisabledObjects;
+
        //
        // Enumerations
        //
@@ -667,7 +669,7 @@ public:
                                                                        Material* mat=0);
        /* Append anchor                                                                                                                */ 
        void                            appendAnchor(   int node,
-                                                                               btRigidBody* body);
+                                                                               btRigidBody* body,bool disableCollision);
        /* Append linear joint                                                                                                  */ 
        void                            appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
        void                            appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
index 835a03b8e3c79610bb9715095c72017354297982..e5feb5ef749d4ad6b15aabb9203ebfc0469cc86f 100644 (file)
@@ -59,7 +59,10 @@ void btSoftRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,b
        btSoftBody* softBody =  m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
        btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
        
-       softBody->defaultCollisionHandler(rigidCollisionObject);
+       if (softBody->m_collisionDisabledObjects.findLinearSearch(rigidCollisionObject)==softBody->m_collisionDisabledObjects.size())
+       {
+               softBody->defaultCollisionHandler(rigidCollisionObject);
+       }
 
 
 }
index eeec4d0bd4e8ce5570e93270d81c1041cd8931be..b389f8c0536aa912e8fb0195138e478c2213925b 100644 (file)
@@ -78,6 +78,7 @@ BulletSoftBody *bsbNew(void)
 
        bsb->kSHR                       =       1.0f;
        bsb->kAHR                       =       0.7f;
+       
        bsb->collisionflags = 0;
        //bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
        bsb->numclusteriterations = 64;
index 505db944097f4b163966ac09df316915653eb648..4fe356307841978c137beba0e2cfa77c88e2e3dd 100644 (file)
@@ -1581,7 +1581,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        {
                                if (rb1)
                                {
-                                       sb0->appendAnchor(node,rb1);
+                                       sb0->appendAnchor(node,rb1,disableCollisionBetweenLinkedBodies);
                                } else
                                {
                                        sb0->setMass(node,0.f);
@@ -1643,7 +1643,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        {
                                if (rb0)
                                {
-                                       sb1->appendAnchor(node,rb0);
+                                       sb1->appendAnchor(node,rb0,disableCollisionBetweenLinkedBodies);
                                } else
                                {
                                        sb1->setMass(node,0.f);