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:
@@ -25,14 +25,15 @@ static BulletDemoEntry allDemos[]=
|
||||
//{"emptydemo",EmptyBulletDemo::MyCreateFunc},
|
||||
{"BasicDemo",BasicDemo::MyCreateFunc},
|
||||
|
||||
/*
|
||||
|
||||
{"ChainDemo",ChainDemo::MyCreateFunc},
|
||||
{"SIHingeDemo",HingeDemo::SICreateFunc},
|
||||
{"PGSHingeDemo",HingeDemo::PGSCreateFunc},
|
||||
{"DantzigHingeDemo",HingeDemo::DantzigCreateFunc},
|
||||
{"LemkeHingeDemo",HingeDemo::LemkeCreateFunc},
|
||||
{"InertiaHingeDemo",HingeDemo::InertiaCreateFunc},
|
||||
{"ABMHingeDemo",HingeDemo::FeatherstoneCreateFunc},
|
||||
*/
|
||||
|
||||
|
||||
{"Ragdoll",RagDollDemo::MyCreateFunc},
|
||||
{"MultiBody1",FeatherstoneDemo1::MyCreateFunc},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../GpuDemos/gwenUserInterface.h"
|
||||
#include "BulletDemoEntries.h"
|
||||
|
||||
#include "../../btgui/Timing/b3Clock.h"
|
||||
#define DEMO_SELECTION_COMBOBOX 13
|
||||
const char* startFileName = "bulletDemo.txt";
|
||||
static SimpleOpenGL3App* app=0;
|
||||
@@ -132,7 +132,8 @@ void MyComboBoxCallback(int comboId, const char* item)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
b3Clock clock;
|
||||
|
||||
float dt = 1./120.f;
|
||||
int width = 1024;
|
||||
int height=768;
|
||||
@@ -167,6 +168,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
gui->setComboBoxCallback(MyComboBoxCallback);
|
||||
|
||||
unsigned long int prevTimeInMicroseconds = clock.getTimeMicroseconds();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -191,7 +193,13 @@ int main(int argc, char* argv[])
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
if (!pauseSimulation)
|
||||
sCurrentDemo->stepSimulation(1./60.f);
|
||||
{
|
||||
unsigned long int curTimeInMicroseconds = clock.getTimeMicroseconds();
|
||||
unsigned long int diff = curTimeInMicroseconds-prevTimeInMicroseconds;
|
||||
float deltaTimeInSeconds = (diff)*1.e-6;
|
||||
sCurrentDemo->stepSimulation(deltaTimeInSeconds);//1./60.f);
|
||||
prevTimeInMicroseconds = curTimeInMicroseconds;
|
||||
}
|
||||
sCurrentDemo->renderScene();
|
||||
}
|
||||
|
||||
|
||||
@@ -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