Merge pull request #2449 from xhan0619/fix-deformable-performance

Fix deformable performance
This commit is contained in:
erwincoumans 2019-10-24 17:54:48 -07:00 committed by GitHub
commit 74b173c30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 9 deletions

View File

@ -104,6 +104,8 @@ void ClothFriction::initPhysics()
btVector3 gravity = btVector3(0, -10, 0);
m_dynamicsWorld->setGravity(gravity);
getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity;
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25);
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset();
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);

View File

@ -113,6 +113,8 @@ void DeformableMultibody::initPhysics()
btVector3 gravity = btVector3(0, -10, 0);
m_dynamicsWorld->setGravity(gravity);
getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity;
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25);
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset();
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
{

View File

@ -154,6 +154,8 @@ void DeformableRigid::initPhysics()
btVector3 gravity = btVector3(0, -10, 0);
m_dynamicsWorld->setGravity(gravity);
getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity;
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25);
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset();
// getDeformableDynamicsWorld()->before_solver_callbacks.push_back(dynamics);
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);

View File

@ -166,6 +166,7 @@ void DeformableSelfCollision::initPhysics()
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
psb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD;
getDeformableDynamicsWorld()->addSoftBody(psb);
psb->setSelfCollision(true);
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(10,0.2, true);
getDeformableDynamicsWorld()->addForce(psb, mass_spring);

View File

@ -112,9 +112,9 @@ void dynamics2(btScalar time, btDeformableMultiBodyDynamicsWorld* world)
if (rbs.size()<2)
return;
btRigidBody* rb0 = rbs[0];
btScalar pressTime = 0.9;
btScalar liftTime = 10;
btScalar shiftTime = 3.5;
btScalar pressTime = 0.45;
btScalar liftTime = 5;
btScalar shiftTime = 1.75;
btScalar holdTime = 4.5*1000;
btScalar dropTime = 5.3*1000;
btTransform rbTransform;
@ -124,9 +124,9 @@ void dynamics2(btScalar time, btDeformableMultiBodyDynamicsWorld* world)
btVector3 initialTranslationLeft = btVector3(0.5,3,4);
btVector3 initialTranslationRight = btVector3(0.5,3,-4);
btVector3 PinchFrictionVelocityLeft = btVector3(0,0,-1);
btVector3 PinchFrictionVelocityRight = btVector3(0,0,1);
btVector3 liftVelocity = btVector3(0,1,0);
btVector3 PinchFrictionVelocityLeft = btVector3(0,0,-2);
btVector3 PinchFrictionVelocityRight = btVector3(0,0,2);
btVector3 liftVelocity = btVector3(0,2,0);
btVector3 shiftVelocity = btVector3(0,0,0);
btVector3 holdVelocity = btVector3(0,0,0);
btVector3 openVelocityLeft = btVector3(0,0,4);
@ -230,7 +230,8 @@ void PinchFriction::initPhysics()
btVector3 gravity = btVector3(0, -10, 0);
m_dynamicsWorld->setGravity(gravity);
getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity;
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25);
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset();
getDeformableDynamicsWorld()->setSolverCallback(dynamics2);
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);

View File

@ -169,6 +169,8 @@ void VolumetricDeformable::initPhysics()
btVector3 gravity = btVector3(0, -100, 0);
m_dynamicsWorld->setGravity(gravity);
getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity;
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25);
getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.Reset();
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
{
@ -223,7 +225,7 @@ void VolumetricDeformable::initPhysics()
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
m_forces.push_back(gravity_force);
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(30,100,0.02);
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(30,100,0.05);
getDeformableDynamicsWorld()->addForce(psb, neohookean);
m_forces.push_back(neohookean);

View File

@ -188,7 +188,13 @@ struct MultiBodyInplaceSolverIslandCallback : public btSimulationIslandManager::
//} else
{
for (i = 0; i < numBodies; i++)
m_bodies.push_back(bodies[i]);
{
bool isSoftBodyType = (bodies[i]->getInternalType() & btCollisionObject::CO_SOFT_BODY);
if (!isSoftBodyType)
{
m_bodies.push_back(bodies[i]);
}
}
for (i = 0; i < numManifolds; i++)
m_manifolds.push_back(manifolds[i]);
for (i = 0; i < numCurConstraints; i++)

View File

@ -119,6 +119,7 @@ void btSoftBody::initDefaults()
m_dampingCoefficient = 1;
m_sleepingThreshold = 0.1;
m_useFaceContact = false;
m_useSelfCollision = false;
m_collisionFlags = 0;
}