diff --git a/examples/DeformableDemo/DeformableSelfCollision.cpp b/examples/DeformableDemo/DeformableSelfCollision.cpp index 576f8f488..aad40ecd7 100644 --- a/examples/DeformableDemo/DeformableSelfCollision.cpp +++ b/examples/DeformableDemo/DeformableSelfCollision.cpp @@ -93,7 +93,7 @@ void DeformableSelfCollision::initPhysics() { ///create a ground btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(2.5), btScalar(150.))); - groundShape->setMargin(0.0001); + groundShape->setMargin(0.02); m_collisionShapes.push_back(groundShape); btTransform groundTransform; @@ -152,6 +152,7 @@ void DeformableSelfCollision::addCloth(btVector3 origin) clothTransform.setOrigin(btVector3(0,0.2,0)+origin); psb->transform(clothTransform); psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD; + psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN; psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDF; psb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD; getDeformableDynamicsWorld()->addSoftBody(psb); @@ -164,6 +165,7 @@ void DeformableSelfCollision::addCloth(btVector3 origin) btVector3 gravity = btVector3(0, -9.8, 0); btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity); getDeformableDynamicsWorld()->addForce(psb, gravity_force); + getDeformableDynamicsWorld()->setUseProjection(true); m_forces.push_back(gravity_force); } diff --git a/src/BulletSoftBody/btDeformableContactConstraint.cpp b/src/BulletSoftBody/btDeformableContactConstraint.cpp index b2f40f818..09398d79a 100644 --- a/src/BulletSoftBody/btDeformableContactConstraint.cpp +++ b/src/BulletSoftBody/btDeformableContactConstraint.cpp @@ -290,6 +290,7 @@ btScalar btDeformableRigidContactConstraint::solveConstraint(const btContactSolv if (m_total_normal_dv.dot(cti.m_normal) < 0) { // separating in the normal direction + m_binding = false; m_static = false; impulse_tangent.setZero(); } diff --git a/src/BulletSoftBody/btSoftBody.h b/src/BulletSoftBody/btSoftBody.h index 4a89c0b46..efe3f5f3c 100644 --- a/src/BulletSoftBody/btSoftBody.h +++ b/src/BulletSoftBody/btSoftBody.h @@ -1328,7 +1328,7 @@ public: int face_penetration = 0, node_penetration = node->m_constrained; for (int i = 0; i < 3; ++i) face_penetration |= face->m_n[i]->m_constrained; - btScalar I_tilde = .5 * I / (1.0 + w.length2()); + btScalar I_tilde = 2.0 * I / (1.0 + w.length2()); // double the impulse if node or face is constrained. if (face_penetration > 0 || node_penetration > 0) @@ -1354,10 +1354,10 @@ public: btScalar vt_new = btMax(btScalar(1) - mu * delta_vn / (vt_norm + SIMD_EPSILON), btScalar(0)) * vt_norm; I = 0.5 * mass * (vt_norm - vt_new); vt.safeNormalize(); - I_tilde = .5 * I / (1.0 + w.length2()); + I_tilde = 2.0 * I / (1.0 + w.length2()); // double the impulse if node or face is constrained. - // if (face_penetration > 0 || node_penetration > 0) - // I_tilde *= 2.0; + if (face_penetration > 0 || node_penetration > 0) + I_tilde *= 2.0; if (face_penetration <= 0) { for (int j = 0; j < 3; ++j)