code clean up and optimization
This commit is contained in:
@@ -174,12 +174,6 @@ void btDeformableContactProjection::enforceConstraint(TVStack& x)
|
||||
btAlignedObjectArray<btDeformableFaceRigidContactConstraint*>& constraintsList = *m_faceRigidConstraints.getAtIndex(index);
|
||||
// i is node index
|
||||
int i = m_faceRigidConstraints.getKeyAtIndex(index).getUid1();
|
||||
int numConstraints = 1;
|
||||
// int numConstraints = constraintsList.size();
|
||||
// if (m_nodeRigidConstraints.find(i) != NULL)
|
||||
// {
|
||||
// numConstraints += m_nodeRigidConstraints[i]->size();
|
||||
// }
|
||||
for (int j = 0; j < constraintsList.size(); ++j)
|
||||
{
|
||||
const btDeformableFaceRigidContactConstraint* constraint = constraintsList[j];
|
||||
@@ -194,7 +188,7 @@ void btDeformableContactProjection::enforceConstraint(TVStack& x)
|
||||
break;
|
||||
}
|
||||
}
|
||||
x[i] += constraint->getDv(node) / btScalar(numConstraints);
|
||||
x[i] += constraint->getDv(node);
|
||||
}
|
||||
}
|
||||
// todo xuchenhan@: add deformable deformable constraints' contribution to dv
|
||||
@@ -206,31 +200,6 @@ void btDeformableContactProjection::enforceConstraint(TVStack& x)
|
||||
int i = m_staticConstraints.getKeyAtIndex(index).getUid1();
|
||||
x[i] = constraint.getDv(constraint.m_node);
|
||||
}
|
||||
//
|
||||
// for (int i = 0; i < x.size(); ++i)
|
||||
// {
|
||||
// x[i].setZero();
|
||||
// if (m_staticConstraints.find(i) != NULL)
|
||||
// {
|
||||
// // if a node is fixed, dv = 0
|
||||
// continue;
|
||||
// }
|
||||
// if (m_nodeRigidConstraints.find(i) != NULL)
|
||||
// {
|
||||
// btAlignedObjectArray<btDeformableNodeRigidContactConstraint>& constraintsList = *m_nodeRigidConstraints[i];
|
||||
// for (int j = 0; j < constraintsList.size(); ++j)
|
||||
// {
|
||||
// const btDeformableNodeRigidContactConstraint& constraint = constraintsList[j];
|
||||
//// x[i] += constraint.getDv(m_nodes->at(i));
|
||||
// x[i] += constraint.getDv(constraint.getContact()->m_node);
|
||||
// }
|
||||
// }
|
||||
// todo xuchenhan@
|
||||
// if (m_faceRigidConstraints.find(i) != NULL)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void btDeformableContactProjection::project(TVStack& x)
|
||||
@@ -376,6 +345,7 @@ void btDeformableContactProjection::applyDynamicFriction(TVStack& f)
|
||||
}
|
||||
}
|
||||
|
||||
// add friction contribution from Face vs. Node
|
||||
if (m_nodeRigidConstraints.find(i) != NULL)
|
||||
{
|
||||
btAlignedObjectArray<btDeformableNodeRigidContactConstraint>& constraintsList = *m_nodeRigidConstraints[i];
|
||||
@@ -388,7 +358,8 @@ void btDeformableContactProjection::applyDynamicFriction(TVStack& f)
|
||||
f[i] += constraint.getDv(node)* (1./node->m_im);
|
||||
}
|
||||
}
|
||||
// todo xuchenhan@
|
||||
|
||||
// add friction contribution from Face vs. Rigid
|
||||
if (m_faceRigidConstraints.find(i) != NULL)
|
||||
{
|
||||
btAlignedObjectArray<btDeformableFaceRigidContactConstraint*>& constraintsList = *m_faceRigidConstraints[i];
|
||||
@@ -398,40 +369,17 @@ void btDeformableContactProjection::applyDynamicFriction(TVStack& f)
|
||||
btSoftBody::Face* face = constraint->getContact()->m_face;
|
||||
|
||||
// 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.
|
||||
// todo xuchenhan@: figure out the index for m_faceRigidConstraints
|
||||
// f[i] += constraint.getDv(face->m_n[0])* (1./face->m_n[0]->m_im);
|
||||
// f[i] += constraint.getDv(face->m_n[1])* (1./face->m_n[1]->m_im);
|
||||
// f[i] += constraint.getDv(face->m_n[2])* (1./face->m_n[2]->m_im);
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
if (face->m_n[0]->index == i)
|
||||
{
|
||||
f[i] += constraint->getDv(face->m_n[k])* (1./face->m_n[k]->m_im);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (int index = 0; index < m_constraints.size(); ++index)
|
||||
// {
|
||||
// const DeformableContactConstraint& constraint = *m_constraints.getAtIndex(index);
|
||||
// const btSoftBody::Node* node = constraint.m_node;
|
||||
// if (node == NULL)
|
||||
// continue;
|
||||
// size_t i = m_constraints.getKeyAtIndex(index).getUid1();
|
||||
// bool has_static_constraint = false;
|
||||
//
|
||||
// // apply dynamic friction force (scaled by dt) if the node does not have static friction constraint
|
||||
// for (int j = 0; j < constraint.m_static.size(); ++j)
|
||||
// {
|
||||
// if (constraint.m_static[j])
|
||||
// {
|
||||
// has_static_constraint = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// for (int j = 0; j < constraint.m_total_tangent_dv.size(); ++j)
|
||||
// {
|
||||
// btVector3 friction_force = constraint.m_total_tangent_dv[j] * (1./node->m_im);
|
||||
// if (!has_static_constraint)
|
||||
// {
|
||||
// f[i] += friction_force;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void btDeformableContactProjection::reinitialize(bool nodeUpdated)
|
||||
|
||||
Reference in New Issue
Block a user