demo changes

This commit is contained in:
Xuchen Han 2020-05-03 00:51:53 -07:00
parent a9449601cd
commit 9a35ccfd5f
2 changed files with 45 additions and 2 deletions

View File

@ -53,6 +53,48 @@ public:
//use a smaller internal timestep, there are stability issues
float internalTimeStep = 1. / 240.f;
m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep);
//
// btCollisionShape* boxShape = new btBoxShape(btVector3(1, 1, 1));
// boxShape->setMargin(1e-3);
// if (0)
// {
// btVector3 p(0.99,1.01,0.99);
// for (int i = 0; i < 40; ++i)
// {
// p[1] -= 0.001;
// btScalar margin(.000001);
// btTransform trans;
// trans.setIdentity();
// btGjkEpaSolver2::sResults results;
// const btConvexShape* csh = static_cast<const btConvexShape*>(boxShape);
// btScalar d = btGjkEpaSolver2::SignedDistance(p, margin, csh, trans, results);
// printf("d = %f\n", d);
// printf("----\n");
// }
// }
//
// btVector3 p(.991,1.01,.99);
// for (int i = 0; i < 40; ++i)
// {
// p[1] -= 0.001;
// btScalar margin(.006);
// btTransform trans;
// trans.setIdentity();
// btScalar dst;
// btGjkEpaSolver2::sResults results;
// btTransform point_transform;
// point_transform.setIdentity();
// point_transform.setOrigin(p);
// btSphereShape sphere(margin);
// btVector3 guess(0,0,0);
// const btConvexShape* csh = static_cast<const btConvexShape*>(boxShape);
// btGjkEpaSolver2::SignedDistance(&sphere, point_transform, csh, trans, guess, results);
// dst = results.distance-csh->getMargin();
// dst -= margin;
// printf("d = %f\n", dst);
// printf("----\n");
// }
}
void Ctor_RbUpStack(int count)
@ -214,7 +256,7 @@ void DeformableRigid::initPhysics()
2,2,
0, true);
psb->getCollisionShape()->setMargin(0.1);
psb->getCollisionShape()->setMargin(0.5);
psb->generateBendingConstraints(2);
psb->setTotalMass(1);
psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects

View File

@ -361,8 +361,9 @@ void GraspDeformable::initPhysics()
psb->m_cfg.kCHR = 1; // collision hardness with rigid body
psb->m_cfg.kDF = 1;
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDF;
// psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN;
psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_MDF;
psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDF;
getDeformableDynamicsWorld()->addSoftBody(psb);
getDeformableDynamicsWorld()->addForce(psb, new btDeformableMassSpringForce(0.05,0.005, true));
getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity*0.1));