Update Bullet to version 2.80 (bullet svn revision 2537)
[blender.git] / extern / bullet2 / patches / ghost_softbody.patch
1 Index: extern/bullet2/src/BulletSoftBody/btSoftBody.cpp
2 ===================================================================
3 --- extern/bullet2/src/BulletSoftBody/btSoftBody.cpp    (Revision 43904)
4 +++ extern/bullet2/src/BulletSoftBody/btSoftBody.cpp    (Revision 43905)
5 @@ -2780,21 +2780,23 @@
6         {
7                 const RContact&         c = psb->m_rcontacts[i];
8                 const sCti&                     cti = c.m_cti;  
9 -               btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj);
10  
11 -               const btVector3         va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
12 -               const btVector3         vb = c.m_node->m_x-c.m_node->m_q;       
13 -               const btVector3         vr = vb-va;
14 -               const btScalar          dn = btDot(vr, cti.m_normal);           
15 -               if(dn<=SIMD_EPSILON)
16 -               {
17 -                       const btScalar          dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg );
18 -                       const btVector3         fv = vr - (cti.m_normal * dn);
19 -                       // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient
20 -                       const btVector3         impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst );
21 -                       c.m_node->m_x -= impulse * c.m_c2;
22 -                       if (tmpRigid)
23 -                               tmpRigid->applyImpulse(impulse,c.m_c1);
24 +               if (cti.m_colObj->hasContactResponse()) {
25 +                       btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj);
26 +                       const btVector3         va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
27 +                       const btVector3         vb = c.m_node->m_x-c.m_node->m_q;       
28 +                       const btVector3         vr = vb-va;
29 +                       const btScalar          dn = btDot(vr, cti.m_normal);           
30 +                       if(dn<=SIMD_EPSILON)
31 +                       {
32 +                               const btScalar          dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg );
33 +                               const btVector3         fv = vr - (cti.m_normal * dn);
34 +                               // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient
35 +                               const btVector3         impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst );
36 +                               c.m_node->m_x -= impulse * c.m_c2;
37 +                               if (tmpRigid)
38 +                                       tmpRigid->applyImpulse(impulse,c.m_c1);
39 +                       }
40                 }
41         }
42  }