Properly propagate the applied impulse for the MLCP solvers, so it will be available for contact and non-contact constraints.
Use real-time clock in AllBullet2Demos, rather than hard-coded 1./60.
This commit is contained in:
@@ -145,6 +145,27 @@ void BasicDemo::renderScene()
|
||||
void BasicDemo::stepSimulation(float dt)
|
||||
{
|
||||
m_dynamicsWorld->stepSimulation(dt);
|
||||
/*
|
||||
//print applied force
|
||||
//contact points
|
||||
for (int i=0;i<m_dynamicsWorld->getDispatcher()->getNumManifolds();i++)
|
||||
{
|
||||
btPersistentManifold* contact = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
|
||||
for (int c=0;c<contact->getNumContacts();c++)
|
||||
{
|
||||
btManifoldPoint& pt = contact->getContactPoint(c);
|
||||
btScalar dist = pt.getDistance();
|
||||
if (dist< contact->getContactProcessingThreshold())
|
||||
{
|
||||
printf("normalImpulse[%d.%d] = %f\n",i,c,pt.m_appliedImpulse);
|
||||
|
||||
} else
|
||||
{
|
||||
printf("?\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -304,12 +304,18 @@ void HingeDemo::initPhysics()
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PGS_HINGE:
|
||||
{
|
||||
btSolveProjectedGaussSeidel* mlcp = new btSolveProjectedGaussSeidel;
|
||||
m_solver = new btMLCPSolver(mlcp);
|
||||
break;
|
||||
}
|
||||
case SI_HINGE:
|
||||
{
|
||||
m_solver = new btSequentialImpulseConstraintSolver();
|
||||
break;
|
||||
}
|
||||
case INERTIA_HINGE:
|
||||
{
|
||||
m_solver = new btSequentialImpulseConstraintSolver();
|
||||
@@ -415,7 +421,7 @@ void HingeDemo::initPhysics()
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,startTransform.getOrigin(),startTransform.getRotation(),color,halfExtents);
|
||||
btBoxShape* box = new btBoxShape(halfExtents);
|
||||
|
||||
float mass = 1000.f;
|
||||
float mass = 1.f;
|
||||
btVector3 localInertia;
|
||||
box->calculateLocalInertia(mass,localInertia);
|
||||
btRigidBody* body = new btRigidBody(mass,0,box,localInertia);
|
||||
@@ -423,6 +429,7 @@ void HingeDemo::initPhysics()
|
||||
body->setWorldTransform(startTransform);
|
||||
body->setUserIndex(index);
|
||||
body->setAngularVelocity(btVector3(0,1,0));
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ enum HINGE_CREATION_METHOD
|
||||
DANTZIG_HINGE,
|
||||
LEMKE_HINGE,
|
||||
PGS_HINGE,
|
||||
SI_HINGE,
|
||||
INERTIA_HINGE
|
||||
};
|
||||
|
||||
@@ -34,6 +35,13 @@ public:
|
||||
{
|
||||
return new HingeDemo(app, PGS_HINGE);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* SICreateFunc(SimpleOpenGL3App* app)
|
||||
{
|
||||
return new HingeDemo(app, SI_HINGE);
|
||||
}
|
||||
|
||||
|
||||
static BulletDemoInterface* InertiaCreateFunc(SimpleOpenGL3App* app)
|
||||
{
|
||||
return new HingeDemo(app, INERTIA_HINGE);
|
||||
|
||||
Reference in New Issue
Block a user