add dynamic friction for deformable contact
This commit is contained in:
@@ -387,14 +387,51 @@ void btDeformableContactProjection::applyDynamicFriction(TVStack& f)
|
|||||||
// it's ok to add the friction force generated by the entire impulse here because the normal component of the residual will be projected out anyway.
|
// it's ok to add the friction force generated by the entire impulse here because the normal component of the residual will be projected out anyway.
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
{
|
{
|
||||||
if (face->m_n[0]->index == i)
|
if (face->m_n[k]->index == i)
|
||||||
|
{
|
||||||
|
if (face->m_n[k]->m_im != 0)
|
||||||
{
|
{
|
||||||
f[i] += constraint->getDv(face->m_n[k])* (1./face->m_n[k]->m_im);
|
f[i] += constraint->getDv(face->m_n[k])* (1./face->m_n[k]->m_im);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_deformableConstraints.find(i) != NULL)
|
||||||
|
{
|
||||||
|
btAlignedObjectArray<btDeformableFaceNodeContactConstraint*>& constraintsList = *m_deformableConstraints[i];
|
||||||
|
for (int j = 0; j < constraintsList.size(); ++j)
|
||||||
|
{
|
||||||
|
const btDeformableFaceNodeContactConstraint* constraint = constraintsList[j];
|
||||||
|
btSoftBody::Face* face = constraint->getContact()->m_face;
|
||||||
|
btSoftBody::Node* node = constraint->getContact()->m_node;
|
||||||
|
|
||||||
|
// it's ok to add the friction force generated by the entire impulse here because the normal component of the residual will be projected out anyway.
|
||||||
|
if (node->index == i)
|
||||||
|
{
|
||||||
|
if (node->m_im != 0)
|
||||||
|
{
|
||||||
|
f[i] += constraint->getDv(node)*(1./node->m_im);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
|
if (face->m_n[k]->index == i)
|
||||||
|
{
|
||||||
|
if (face->m_n[k]->m_im != 0)
|
||||||
|
{
|
||||||
|
f[i] += constraint->getDv(face->m_n[k])* (1./face->m_n[k]->m_im);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user