bug fix in neohookean force
This commit is contained in:
@@ -357,7 +357,7 @@ void GraspDeformable::initPhysics()
|
|||||||
// getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity));
|
// getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity));
|
||||||
// getDeformableDynamicsWorld()->addForce(psb, new btDeformableCorotatedForce(0,6));
|
// getDeformableDynamicsWorld()->addForce(psb, new btDeformableCorotatedForce(0,6));
|
||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(.5,0.04, true);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(.0,0.04, true);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
m_forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
|
|||||||
@@ -87,18 +87,20 @@ public:
|
|||||||
btMatrix3x3 C = F.transpose()*F;
|
btMatrix3x3 C = F.transpose()*F;
|
||||||
btScalar J = F.determinant();
|
btScalar J = F.determinant();
|
||||||
btScalar trace = C[0].getX() + C[1].getY() + C[2].getZ();
|
btScalar trace = C[0].getX() + C[1].getY() + C[2].getZ();
|
||||||
P = F * m_mu * ( 1. - 1. / (trace + 1.)) + F.adjoint() * (m_lambda * (J - 1) - 0.75 * m_mu);
|
P = F * m_mu * ( 1. - 1. / (trace + 1.)) + F.adjoint().transpose() * (m_lambda * (J - 1) - 0.75 * m_mu);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addScaledForceDifferential(btScalar scale, const TVStack& dv, TVStack& df)
|
virtual void addScaledForceDifferential(btScalar scale, const TVStack& dv, TVStack& df)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void firstPiolaDifferential(const btMatrix3x3& F, const btMatrix3x3& G, btMatrix3x3& P)
|
void firstPiolaDifferential(const btMatrix3x3& F, const btMatrix3x3& dF, btMatrix3x3& dP)
|
||||||
{
|
{
|
||||||
btScalar J = F.determinant();
|
btScalar J = F.determinant();
|
||||||
addScaledCofactorMatrixDifferential(F, G, m_lambda*(J-1), P);
|
addScaledCofactorMatrixDifferential(F, dF, m_lambda*(J-1) - 0.75*m_mu, dP);
|
||||||
P += F.adjoint() * m_lambda * DotProduct(F.adjoint(), G);
|
dP += F.adjoint().transpose() * m_lambda * DotProduct(F.adjoint().transpose(), dF);
|
||||||
|
|
||||||
|
//todo @xuchenhan: add the dP of the m_mu term.
|
||||||
}
|
}
|
||||||
|
|
||||||
btScalar DotProduct(const btMatrix3x3& A, const btMatrix3x3& B)
|
btScalar DotProduct(const btMatrix3x3& A, const btMatrix3x3& B)
|
||||||
|
|||||||
Reference in New Issue
Block a user