summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com>2019-08-02 10:19:31 -0700
committerXuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com>2019-08-02 13:15:06 -0700
commit3dc8abcf36b03aeeedb7643a4fea9c238a59bfba (patch)
treef18552f3b434c1a18ee3239b15cecb6329890fad
parentf1e7ce9ce14ce220c80a572c555eef0150f76df7 (diff)
downloadbullet3-3dc8abcf36b03aeeedb7643a4fea9c238a59bfba.tar.gz
only call buildIslands once for multibody in each timestep
-rw-r--r--src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp6
-rw-r--r--src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp8
-rw-r--r--src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h1
-rw-r--r--src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp8
-rw-r--r--src/BulletSoftBody/btDeformableBackwardEulerObjective.h5
-rw-r--r--src/BulletSoftBody/btDeformableBodySolver.cpp2
6 files changed, 20 insertions, 10 deletions
diff --git a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
index 11fa97cdd..57e1bb494 100644
--- a/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
+++ b/src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
@@ -233,7 +233,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher, btCollisi
// printf("error in island management\n");
}
-// btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+ btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId)
{
if (colObj0->getActivationState() == ACTIVE_TAG ||
@@ -257,7 +257,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher, btCollisi
// printf("error in island management\n");
}
-// btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+ btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId)
{
@@ -278,7 +278,7 @@ void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher, btCollisi
// printf("error in island management\n");
}
-// btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+ btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
if (colObj0->getIslandTag() == islandId)
diff --git a/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp b/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
index d1ac5e26f..2e6dbc440 100644
--- a/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
+++ b/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
@@ -428,14 +428,18 @@ void btMultiBodyDynamicsWorld::forwardKinematics()
void btMultiBodyDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
{
solveExternalForces(solverInfo);
+ buildIslands();
solveInternalConstraints(solverInfo);
}
+void btMultiBodyDynamicsWorld::buildIslands()
+{
+ m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(), getCollisionWorld(), m_solverMultiBodyIslandCallback);
+}
+
void btMultiBodyDynamicsWorld::solveInternalConstraints(btContactSolverInfo& solverInfo)
{
/// solve all the constraints for this island
- m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(), getCollisionWorld(), m_solverMultiBodyIslandCallback);
-
m_solverMultiBodyIslandCallback->processConstraints();
m_constraintSolver->allSolved(solverInfo, m_debugDrawer);
diff --git a/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h b/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
index e82c17b31..04707bf2d 100644
--- a/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
+++ b/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h
@@ -116,6 +116,7 @@ public:
virtual void solveExternalForces(btContactSolverInfo& solverInfo);
virtual void solveInternalConstraints(btContactSolverInfo& solverInfo);
+ void buildIslands();
};
#endif //BT_MULTIBODY_DYNAMICS_WORLD_H
diff --git a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp
index 9ffd63a3c..7b084af0e 100644
--- a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp
+++ b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp
@@ -128,3 +128,11 @@ void btDeformableBackwardEulerObjective::initialGuess(TVStack& dv, const TVStack
}
}
}
+
+//set constraints as projections
+void btDeformableBackwardEulerObjective::setConstraints()
+{
+ // build islands for multibody solve
+ m_world->btMultiBodyDynamicsWorld::buildIslands();
+ projection.setConstraints();
+}
diff --git a/src/BulletSoftBody/btDeformableBackwardEulerObjective.h b/src/BulletSoftBody/btDeformableBackwardEulerObjective.h
index e22b42b0b..a736315b7 100644
--- a/src/BulletSoftBody/btDeformableBackwardEulerObjective.h
+++ b/src/BulletSoftBody/btDeformableBackwardEulerObjective.h
@@ -73,10 +73,7 @@ public:
void updateVelocity(const TVStack& dv);
//set constraints as projections
- void setConstraints()
- {
- projection.setConstraints();
- }
+ void setConstraints();
// update the projections and project the residual
void project(TVStack& r)
diff --git a/src/BulletSoftBody/btDeformableBodySolver.cpp b/src/BulletSoftBody/btDeformableBodySolver.cpp
index e3009dcbb..a1616a460 100644
--- a/src/BulletSoftBody/btDeformableBodySolver.cpp
+++ b/src/BulletSoftBody/btDeformableBodySolver.cpp
@@ -31,7 +31,7 @@ void btDeformableBodySolver::solveConstraints(float solverdt)
backupVelocity();
m_objective->computeResidual(solverdt, m_residual);
-// m_objective->initialGuess(m_dv, m_residual);
+
computeStep(m_dv, m_residual);
updateVelocity();
}