code clean up
This commit is contained in:
@@ -53,49 +53,6 @@ struct DeformableContactConstraint
|
||||
}
|
||||
};
|
||||
|
||||
struct DeformableFrictionConstraint
|
||||
{
|
||||
btAlignedObjectArray<bool> m_static; // whether the friction is static
|
||||
btAlignedObjectArray<btScalar> m_impulse; // the impulse magnitude the node feels
|
||||
btAlignedObjectArray<btScalar> m_dv; // the dv magnitude of the node
|
||||
btAlignedObjectArray<btVector3> m_direction; // the direction of the friction for the node
|
||||
|
||||
|
||||
btAlignedObjectArray<bool> m_static_prev;
|
||||
btAlignedObjectArray<btScalar> m_impulse_prev;
|
||||
btAlignedObjectArray<btScalar> m_dv_prev;
|
||||
btAlignedObjectArray<btVector3> m_direction_prev;
|
||||
|
||||
btAlignedObjectArray<bool> m_released; // whether the contact is released
|
||||
|
||||
|
||||
// the total impulse the node applied to the rb in the tangential direction in the cg solve
|
||||
btAlignedObjectArray<btVector3> m_accumulated_tangent_impulse;
|
||||
|
||||
DeformableFrictionConstraint()
|
||||
{
|
||||
append();
|
||||
}
|
||||
|
||||
void append()
|
||||
{
|
||||
m_static.push_back(false);
|
||||
m_static_prev.push_back(false);
|
||||
|
||||
m_direction_prev.push_back(btVector3(0,0,0));
|
||||
m_direction.push_back(btVector3(0,0,0));
|
||||
|
||||
m_impulse.push_back(0);
|
||||
m_impulse_prev.push_back(0);
|
||||
|
||||
m_dv.push_back(0);
|
||||
m_dv_prev.push_back(0);
|
||||
|
||||
m_accumulated_tangent_impulse.push_back(btVector3(0,0,0));
|
||||
m_released.push_back(false);
|
||||
}
|
||||
};
|
||||
|
||||
class btCGProjection
|
||||
{
|
||||
public:
|
||||
@@ -104,7 +61,6 @@ public:
|
||||
typedef btAlignedObjectArray<btAlignedObjectArray<btScalar> > TArrayStack;
|
||||
btAlignedObjectArray<btSoftBody *>& m_softBodies;
|
||||
btDeformableRigidDynamicsWorld* m_world;
|
||||
// const btAlignedObjectArray<btSoftBody::Node*>* m_nodes;
|
||||
const btScalar& m_dt;
|
||||
|
||||
btCGProjection(btAlignedObjectArray<btSoftBody *>& softBodies, const btScalar& dt)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
btDeformableBodySolver::btDeformableBodySolver()
|
||||
: m_numNodes(0)
|
||||
, m_cg(10)
|
||||
, m_contact_iterations(10)
|
||||
{
|
||||
m_objective = new btDeformableBackwardEulerObjective(m_softBodySet, m_backupVelocity);
|
||||
}
|
||||
@@ -46,7 +47,7 @@ void btDeformableBodySolver::solveConstraints(float solverdt)
|
||||
void btDeformableBodySolver::computeStep(TVStack& dv, const TVStack& residual)
|
||||
{
|
||||
|
||||
btScalar tolerance = std::numeric_limits<float>::epsilon() * m_objective->computeNorm(residual);
|
||||
btScalar tolerance = std::numeric_limits<float>::epsilon() * 1024 * m_objective->computeNorm(residual);
|
||||
m_cg.solve(*m_objective, dv, residual, tolerance);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ void btDeformableBodySolver::setConstraints()
|
||||
{
|
||||
BT_PROFILE("setConstraint");
|
||||
m_objective->setConstraints();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int i = 0; i < m_contact_iterations; ++i)
|
||||
{
|
||||
m_objective->projection.update();
|
||||
m_objective->enforceConstraint(m_dv);
|
||||
|
||||
@@ -37,6 +37,7 @@ protected:
|
||||
|
||||
btAlignedObjectArray<btVector3> m_backupVelocity;
|
||||
btScalar m_dt;
|
||||
btScalar m_contact_iterations;
|
||||
btConjugateGradient<btDeformableBackwardEulerObjective> m_cg;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user