Avoid collision detection/response between anchored (static) soft body cluster and a static/kinematic rigid body
This commit is contained in:
@@ -2116,11 +2116,17 @@ void btSoftBody::initializeClusters()
|
|||||||
c.m_masses.resize(c.m_nodes.size());
|
c.m_masses.resize(c.m_nodes.size());
|
||||||
for(int j=0;j<c.m_nodes.size();++j)
|
for(int j=0;j<c.m_nodes.size();++j)
|
||||||
{
|
{
|
||||||
c.m_masses[j] = c.m_nodes[j]->m_im>0?1/c.m_nodes[j]->m_im: BT_LARGE_FLOAT;
|
if (c.m_nodes[j]->m_im==0)
|
||||||
//c.m_masses[j] = c.m_nodes[j]->m_im>0?1/c.m_nodes[j]->m_im: 0.f;
|
{
|
||||||
|
c.m_containsAnchor = true;
|
||||||
|
c.m_masses[j] = BT_LARGE_FLOAT;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
c.m_masses[j] = btScalar(1.)/c.m_nodes[j]->m_im;
|
||||||
|
}
|
||||||
c.m_imass += c.m_masses[j];
|
c.m_imass += c.m_masses[j];
|
||||||
}
|
}
|
||||||
c.m_imass = 1/c.m_imass;
|
c.m_imass = btScalar(1.)/c.m_imass;
|
||||||
c.m_com = btSoftBody::clusterCom(&c);
|
c.m_com = btSoftBody::clusterCom(&c);
|
||||||
c.m_lv = btVector3(0,0,0);
|
c.m_lv = btVector3(0,0,0);
|
||||||
c.m_av = btVector3(0,0,0);
|
c.m_av = btVector3(0,0,0);
|
||||||
|
|||||||
@@ -310,11 +310,13 @@ public:
|
|||||||
btScalar m_matching;
|
btScalar m_matching;
|
||||||
btScalar m_maxSelfCollisionImpulse;
|
btScalar m_maxSelfCollisionImpulse;
|
||||||
btScalar m_selfCollisionImpulseFactor;
|
btScalar m_selfCollisionImpulseFactor;
|
||||||
|
bool m_containsAnchor;
|
||||||
bool m_collide;
|
bool m_collide;
|
||||||
int m_clusterIndex;
|
int m_clusterIndex;
|
||||||
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0)
|
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0)
|
||||||
,m_maxSelfCollisionImpulse(100.f),
|
,m_maxSelfCollisionImpulse(100.f),
|
||||||
m_selfCollisionImpulseFactor(0.01f)
|
m_selfCollisionImpulseFactor(0.01f),
|
||||||
|
m_containsAnchor(false)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
/* Impulse */
|
/* Impulse */
|
||||||
|
|||||||
@@ -726,6 +726,11 @@ struct btSoftColliders
|
|||||||
btSoftClusterCollisionShape cshape(cluster);
|
btSoftClusterCollisionShape cshape(cluster);
|
||||||
|
|
||||||
const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape();
|
const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape();
|
||||||
|
|
||||||
|
///don't collide an anchored cluster with a static/kinematic object
|
||||||
|
if(m_colObj->isStaticOrKinematicObject() && cluster->m_containsAnchor)
|
||||||
|
return;
|
||||||
|
|
||||||
btGjkEpaSolver2::sResults res;
|
btGjkEpaSolver2::sResults res;
|
||||||
if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(),
|
if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(),
|
||||||
rshape,m_colObj->getInterpolationWorldTransform(),
|
rshape,m_colObj->getInterpolationWorldTransform(),
|
||||||
|
|||||||
Reference in New Issue
Block a user