mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-08-11 07:49:32 +00:00
fix bug in deformable replulsion force and adjust parameter in deformable self collision
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user