diff options
author | Xuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com> | 2019-07-10 16:09:38 -0700 |
---|---|---|
committer | Xuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com> | 2019-08-02 13:12:41 -0700 |
commit | b7e512a5f9e099c3aefaf5a5ffb79a37ababde29 (patch) | |
tree | 927a04461e534038b6a100fcb1537393f8447989 | |
parent | 77d670ae416d77d078e09099e57f743afd239acb (diff) | |
download | bullet3-b7e512a5f9e099c3aefaf5a5ffb79a37ababde29.tar.gz |
sync gravity with substeps
-rw-r--r-- | src/BulletSoftBody/btDeformableRigidDynamicsWorld.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/BulletSoftBody/btDeformableRigidDynamicsWorld.cpp b/src/BulletSoftBody/btDeformableRigidDynamicsWorld.cpp index ded4762e0..5fdf01a18 100644 --- a/src/BulletSoftBody/btDeformableRigidDynamicsWorld.cpp +++ b/src/BulletSoftBody/btDeformableRigidDynamicsWorld.cpp @@ -50,13 +50,24 @@ void btDeformableRigidDynamicsWorld::internalSingleStepSimulation(btScalar timeS (*m_internalTickCallback)(this, timeStep); } - // incorporate gravity into velocity and clear force + // TODO: This is an ugly hack to get the desired gravity behavior. + // gravity is applied in stepSimulation and then cleared here and then applied here and then cleared here again + // so that 1) gravity is applied to velocity before constraint solve and 2) gravity is applied in each substep + // when there are multiple substeps + + clearForces(); + clearMultiBodyForces(); + btMultiBodyDynamicsWorld::applyGravity(); + // integrate rigid body gravity for (int i = 0; i < m_nonStaticRigidBodies.size(); ++i) { btRigidBody* rb = m_nonStaticRigidBodies[i]; rb->integrateVelocities(timeStep); } + // integrate multibody gravity + btMultiBodyDynamicsWorld::solveExternalForces(btMultiBodyDynamicsWorld::getSolverInfo()); clearForces(); + clearMultiBodyForces(); ///solve deformable bodies constraints solveDeformableBodiesConstraints(timeStep); |