diff options
Diffstat (limited to 'src/BulletSoftBody/btDeformableBodySolver.h')
-rw-r--r-- | src/BulletSoftBody/btDeformableBodySolver.h | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/src/BulletSoftBody/btDeformableBodySolver.h b/src/BulletSoftBody/btDeformableBodySolver.h index ae674d6e8..68354f199 100644 --- a/src/BulletSoftBody/btDeformableBodySolver.h +++ b/src/BulletSoftBody/btDeformableBodySolver.h @@ -24,8 +24,8 @@ #include "btConjugateResidual.h" #include "btConjugateGradient.h" struct btCollisionObjectWrapper; -class btDeformableBackwardEulerObjective; -class btDeformableMultiBodyDynamicsWorld; +// class btDeformableBackwardEulerObjective; +// class btDeformableMultiBodyDynamicsWorld; class btDeformableBodySolver : public btSoftBodySolver { @@ -46,6 +46,7 @@ protected: int m_maxNewtonIterations; // max number of newton iterations btScalar m_newtonTolerance; // stop newton iterations if f(x) < m_newtonTolerance bool m_lineSearch; // If true, use newton's method with line search under implicit scheme + bool m_reducedSolver; // flag for reduced soft body solver public: // handles data related to objective function btDeformableBackwardEulerObjective* m_objective; @@ -68,11 +69,18 @@ public: // solve the momentum equation virtual void solveDeformableConstraints(btScalar solverdt); + // set gravity (get from deformable world) + virtual void setGravity(const btVector3& gravity) + { + // for full deformable object, we don't store gravity in the solver + // this function is overriden in the reduced deformable object + } + // resize/clear data structures - void reinitialize(const btAlignedObjectArray<btSoftBody*>& softBodies, btScalar dt); + virtual void reinitialize(const btAlignedObjectArray<btSoftBody*>& softBodies, btScalar dt); // set up contact constraints - void setConstraints(const btContactSolverInfo& infoGlobal); + virtual void setConstraints(const btContactSolverInfo& infoGlobal); // add in elastic forces and gravity to obtain v_{n+1}^* and calls predictDeformableMotion virtual void predictMotion(btScalar solverdt); @@ -85,7 +93,7 @@ public: void backupVelocity(); // set m_dv and m_backupVelocity to desired value to prepare for momentum solve - void setupDeformableSolve(bool implicit); + virtual void setupDeformableSolve(bool implicit); // set the current velocity to that backed up in m_backupVelocity void revertVelocity(); @@ -150,6 +158,62 @@ public: // used in line search btScalar kineticEnergy(); + // add explicit force to the velocity in the objective class + virtual void applyExplicitForce(); + + // execute position/velocity update and apply anchor constraints in the integrateTransforms from the Dynamics world + virtual void applyTransforms(btScalar timeStep); + + virtual void setStrainLimiting(bool opt) + { + m_objective->m_projection.m_useStrainLimiting = opt; + } + + virtual void setPreconditioner(int opt) + { + switch (opt) + { + case btDeformableBackwardEulerObjective::Mass_preconditioner: + m_objective->m_preconditioner = m_objective->m_massPreconditioner; + break; + + case btDeformableBackwardEulerObjective::KKT_preconditioner: + m_objective->m_preconditioner = m_objective->m_KKTPreconditioner; + break; + + default: + btAssert(false); + break; + } + } + + virtual btAlignedObjectArray<btDeformableLagrangianForce*>* getLagrangianForceArray() + { + return &(m_objective->m_lf); + } + + virtual const btAlignedObjectArray<btSoftBody::Node*>* getIndices() + { + return m_objective->getIndices(); + } + + virtual void setProjection() + { + m_objective->m_projection.setProjection(); + } + + virtual void setLagrangeMultiplier() + { + m_objective->m_projection.setLagrangeMultiplier(); + } + + virtual bool isReducedSolver() + { + return m_reducedSolver; + } + + virtual void deformableBodyInternalWriteBack() {} + // unused functions virtual void optimize(btAlignedObjectArray<btSoftBody*>& softBodies, bool forceUpdate = false) {} virtual void solveConstraints(btScalar dt) {} |