add a flag to switch between the reduced deformable and full deformable

This commit is contained in:
jingyuc 2021-11-23 17:40:04 -05:00
parent 8efd0296ab
commit 9fae47667b
3 changed files with 15 additions and 11 deletions

View File

@ -28,7 +28,8 @@ int main(int argc, char* argv[])
return -1;
}
sim->resetSimulation(RESET_USE_DEFORMABLE_WORLD);
// sim->resetSimulation(RESET_USE_DEFORMABLE_WORLD);
sim->resetSimulation(RESET_USE_REDUCED_DEFORMABLE_WORLD);
//Can also use eCONNECT_DIRECT,eCONNECT_SHARED_MEMORY,eCONNECT_UDP,eCONNECT_TCP, for example:
//sim->connect(eCONNECT_UDP, "localhost", 1234);
@ -54,8 +55,8 @@ int main(int argc, char* argv[])
sim->loadURDF("plane.urdf");
{
// int deformableUID = sim->loadURDF("reduced_cube/reduced_cube.urdf");
int deformableUID = sim->loadURDF("reduced_cube/deform_cube.urdf");
int deformableUID = sim->loadURDF("reduced_cube/reduced_cube.urdf");
// int deformableUID = sim->loadURDF("reduced_cube/deform_cube.urdf");
// int deformableUID = sim->loadURDF("reduced_torus/reduced_torus.urdf");
// int deformableUID = sim->loadURDF("torus_deform.urdf");
btVector3 basePosition = btVector3(0, 0, 2);

View File

@ -2725,24 +2725,26 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld(int flags)
m_data->m_broadphase = bv;
}
#ifndef SKIP_DEFORMABLE_BODY
if (flags & RESET_USE_DEFORMABLE_WORLD)
{
#ifndef SKIP_DEFORMABLE_BODY
// deformable
// m_data->m_deformablebodySolver = new btDeformableBodySolver();
// btDeformableMultiBodyConstraintSolver* solver = new btDeformableMultiBodyConstraintSolver;
// m_data->m_solver = solver;
// solver->setDeformableSolver(m_data->m_deformablebodySolver);
// m_data->m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, solver, m_data->m_collisionConfiguration, m_data->m_deformablebodySolver);
m_data->m_deformablebodySolver = new btDeformableBodySolver();
btDeformableMultiBodyConstraintSolver* solver = new btDeformableMultiBodyConstraintSolver;
m_data->m_solver = solver;
solver->setDeformableSolver(m_data->m_deformablebodySolver);
m_data->m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, solver, m_data->m_collisionConfiguration, m_data->m_deformablebodySolver);
}
else if (flags & RESET_USE_REDUCED_DEFORMABLE_WORLD)
{
// reduced deformable
m_data->m_reducedSoftBodySolver = new btReducedSoftBodySolver();
btDeformableMultiBodyConstraintSolver* solver = new btDeformableMultiBodyConstraintSolver;
m_data->m_solver = solver;
solver->setDeformableSolver(m_data->m_reducedSoftBodySolver);
m_data->m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, solver, m_data->m_collisionConfiguration, m_data->m_reducedSoftBodySolver);
#endif
}
#endif

View File

@ -617,6 +617,7 @@ enum b3ResetSimulationFlags
RESET_USE_DEFORMABLE_WORLD=1,
RESET_USE_DISCRETE_DYNAMICS_WORLD=2,
RESET_USE_SIMPLE_BROADPHASE=4,
RESET_USE_REDUCED_DEFORMABLE_WORLD=8,
};
struct b3BodyNotificationArgs