updated demos to show debug display with new AllBulletDemos (AllInOne),
added btDynamicsWorld::getWorldType
This commit is contained in:
@@ -24,6 +24,12 @@
|
||||
|
||||
#include "DemoApplication.h"
|
||||
#include "DemoEntries.h"
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
|
||||
static GLDebugDrawer gDebugDrawer;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -42,8 +48,13 @@ namespace
|
||||
float viewX = 0.0f;
|
||||
float viewY = 0.0f;
|
||||
int tx, ty, tw, th;
|
||||
int gDrawAabb=0;
|
||||
int gDebugDraw=0;
|
||||
int gDebugContacts=0;
|
||||
int gDebugNoDeactivation = 0;
|
||||
}
|
||||
|
||||
|
||||
void Resize(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
@@ -61,6 +72,18 @@ void Resize(int w, int h)
|
||||
demo->reshape(w, h);
|
||||
}
|
||||
|
||||
DemoApplication* CreatDemo(btDemoEntry* entry)
|
||||
{
|
||||
DemoApplication* demo = entry->createFcn();
|
||||
btAssert(demo);
|
||||
if (demo->getDynamicsWorld())
|
||||
{
|
||||
demo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||
}
|
||||
return demo;
|
||||
|
||||
}
|
||||
|
||||
/*b2Vec2 ConvertScreenToWorld(int x, int y)
|
||||
{
|
||||
b2Vec2 p;
|
||||
@@ -91,6 +114,45 @@ void SimulationLoop()
|
||||
|
||||
//test->SetTextLine(30);
|
||||
//test->Step(&settings);
|
||||
//sync debugging options
|
||||
if (gDrawAabb)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawAabb);
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawAabb));
|
||||
}
|
||||
if (gDebugDraw)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawWireframe);
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawWireframe));
|
||||
|
||||
}
|
||||
if (gDebugContacts)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawContactPoints);
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints));
|
||||
}
|
||||
|
||||
if (gDebugNoDeactivation)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_NoDeactivation);
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoDeactivation));
|
||||
}
|
||||
|
||||
if (demo->getDynamicsWorld()->getWorldType() == BT_DISCRETE_DYNAMICS_WORLD)
|
||||
{
|
||||
btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld();
|
||||
discreteWorld->getSolverInfo().m_numIterations = iterationCount;
|
||||
}
|
||||
|
||||
|
||||
demo->clientMoveAndDisplay();
|
||||
|
||||
|
||||
@@ -103,7 +165,7 @@ void SimulationLoop()
|
||||
testIndex = testSelection;
|
||||
delete demo;
|
||||
entry = g_demoEntries + testIndex;
|
||||
demo = entry->createFcn();
|
||||
demo = CreatDemo(entry);
|
||||
viewZoom = 20.0f;
|
||||
viewX = 0.0f;
|
||||
viewY = 0.0f;
|
||||
@@ -123,7 +185,7 @@ void Keyboard(unsigned char key, int x, int y)
|
||||
// Press 'r' to reset.
|
||||
case 'r':
|
||||
delete demo;
|
||||
demo = entry->createFcn();
|
||||
demo = CreatDemo(entry);
|
||||
Resize(width,height);
|
||||
break;
|
||||
|
||||
@@ -170,8 +232,8 @@ int main(int argc, char** argv)
|
||||
//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
||||
|
||||
entry = g_demoEntries + testIndex;
|
||||
demo = entry->createFcn();
|
||||
|
||||
demo = CreatDemo(entry);
|
||||
|
||||
glutDisplayFunc(SimulationLoop);
|
||||
GLUI_Master.set_glutReshapeFunc(Resize);
|
||||
GLUI_Master.set_glutKeyboardFunc(Keyboard);
|
||||
@@ -193,22 +255,27 @@ int main(int argc, char** argv)
|
||||
glui->add_spinner("Iterations", GLUI_SPINNER_INT, &iterationCount);
|
||||
iterationSpinner->set_int_limits(1, 100);
|
||||
|
||||
GLUI_Spinner* hertzSpinner =
|
||||
/* GLUI_Spinner* hertzSpinner =
|
||||
glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &hz);
|
||||
hertzSpinner->set_float_limits(5.0f, 200.0f);
|
||||
*/
|
||||
|
||||
// glui->add_checkbox("Position Correction", &settings.enablePositionCorrection);
|
||||
// glui->add_checkbox("Warm Starting", &settings.enablePositionCorrection);
|
||||
glui->add_checkbox("DisableDeactivation", &gDebugNoDeactivation);
|
||||
|
||||
glui->add_separator();
|
||||
|
||||
GLUI_Panel* drawPanel = glui->add_panel("Draw");
|
||||
// glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs);
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Contacts", &settings.drawContacts);
|
||||
|
||||
glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb);
|
||||
glui->add_checkbox_to_panel(drawPanel, "DebugDrawer", &gDebugDraw);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts);
|
||||
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Impulses", &settings.drawImpulses);
|
||||
// glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
|
||||
|
||||
|
||||
int testCount = 0;
|
||||
btDemoEntry* e = g_demoEntries;
|
||||
while (e->createFcn)
|
||||
|
||||
@@ -121,6 +121,9 @@ void BasicDemo::displayCallback(void) {
|
||||
void BasicDemo::initPhysics()
|
||||
{
|
||||
|
||||
setCameraDistance(btScalar(50.));
|
||||
|
||||
|
||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
|
||||
#ifdef USE_PARALLEL_DISPATCHER
|
||||
|
||||
@@ -23,7 +23,7 @@ int main(int argc,char** argv)
|
||||
|
||||
BasicDemo ccdDemo;
|
||||
ccdDemo.initPhysics();
|
||||
ccdDemo.setCameraDistance(btScalar(50.));
|
||||
|
||||
|
||||
#ifdef CHECK_MEMORY_LEAKS
|
||||
ccdDemo.exitPhysics();
|
||||
|
||||
@@ -101,6 +101,8 @@ void BspDemo::initPhysics(char* bspfilename)
|
||||
m_cameraUp = btVector3(0,0,1);
|
||||
m_forwardAxis = 1;
|
||||
|
||||
setCameraDistance(22.f);
|
||||
|
||||
///Setup a Physics Simulation Environment
|
||||
|
||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
|
||||
@@ -47,7 +47,7 @@ int main(int argc,char** argv)
|
||||
// Enrico: TODO: Should change parameter type of initPhysics() to std::string or at least const char *
|
||||
bspDemo->initPhysics((char*)bspfilename);
|
||||
|
||||
bspDemo->setCameraDistance(22.f);
|
||||
|
||||
|
||||
return glutmain(argc, argv,640,480,"Bullet Quake BSP Physics Viewer http://bullet.sourceforge.net",bspDemo);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ void drawLimit()
|
||||
|
||||
void ConstraintDemo::initPhysics()
|
||||
{
|
||||
setCameraDistance(26.f);
|
||||
|
||||
// btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
||||
|
||||
@@ -8,7 +8,7 @@ int main(int argc,char** argv)
|
||||
|
||||
constraintDemo->initPhysics();
|
||||
|
||||
constraintDemo->setCameraDistance(26.f);
|
||||
|
||||
|
||||
return glutmain(argc, argv,640,480,"Constraint Demo. http://www.continuousphysics.com/Bullet/phpBB2/",constraintDemo);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ GLDebugDrawer debugDrawer;
|
||||
|
||||
void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
{
|
||||
setCameraDistance(26.f);
|
||||
|
||||
ConvexDecomposition::WavefrontObj wo;
|
||||
|
||||
tcount = wo.loadObj(filename);
|
||||
|
||||
@@ -17,7 +17,7 @@ int main(int argc,char** argv)
|
||||
|
||||
convexDecompDemo->clientResetScene();
|
||||
|
||||
convexDecompDemo->setCameraDistance(26.f);
|
||||
|
||||
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",convexDecompDemo);
|
||||
}
|
||||
|
||||
@@ -405,6 +405,9 @@ btCollisionShape * GimpactConcaveDemo::createBunnyShape()
|
||||
//------------------------------------------------------------------------------
|
||||
void GimpactConcaveDemo::initPhysics()
|
||||
{
|
||||
setCameraDistance(45.f);
|
||||
|
||||
|
||||
gContactAddedCallback = CustomMaterialCombinerCallback;
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ int main(int argc,char** argv)
|
||||
|
||||
GimpactConcaveDemo* concaveDemo = new GimpactConcaveDemo(); /// This will not be Deleted!!!
|
||||
concaveDemo->initPhysics();
|
||||
concaveDemo->setCameraDistance(45.f);
|
||||
|
||||
|
||||
return glutmain(argc, argv,640,480,"DevO,s GIMPACT Test Demo",concaveDemo);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ void DrawRasterizerLine(float const* , float const*, int)
|
||||
|
||||
void LinearConvexCastDemo::initPhysics()
|
||||
{
|
||||
setCameraDistance(30.f);
|
||||
|
||||
setCameraDistance(50.f);
|
||||
tr[0].setOrigin(btVector3(0,0,0));
|
||||
tr[1].setOrigin(btVector3(0,10,0));
|
||||
|
||||
|
||||
@@ -372,6 +372,14 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y)
|
||||
|
||||
}
|
||||
|
||||
void DemoApplication::setDebugMode(int mode)
|
||||
{
|
||||
m_debugMode = mode;
|
||||
if (getDynamicsWorld() && getDynamicsWorld()->getDebugDrawer())
|
||||
getDynamicsWorld()->getDebugDrawer()->setDebugMode(mode);
|
||||
}
|
||||
|
||||
|
||||
void DemoApplication::specialKeyboardUp(int key, int x, int y)
|
||||
{
|
||||
|
||||
|
||||
@@ -100,11 +100,8 @@ public:
|
||||
return m_debugMode ;
|
||||
}
|
||||
|
||||
void setDebugMode(int mode)
|
||||
{
|
||||
m_debugMode = mode;
|
||||
}
|
||||
|
||||
void setDebugMode(int mode);
|
||||
|
||||
|
||||
void setCameraUp(const btVector3& camUp)
|
||||
{
|
||||
|
||||
@@ -307,6 +307,8 @@ void RagdollDemo::initPhysics()
|
||||
{
|
||||
// Setup the basic world
|
||||
|
||||
setCameraDistance(btScalar(5.));
|
||||
|
||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
|
||||
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
||||
|
||||
@@ -7,7 +7,7 @@ int main(int argc,char* argv[])
|
||||
RagdollDemo demoApp;
|
||||
|
||||
demoApp.initPhysics();
|
||||
demoApp.setCameraDistance(btScalar(10.));
|
||||
|
||||
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&demoApp);
|
||||
}
|
||||
|
||||
@@ -541,11 +541,13 @@ void VehicleDemo::specialKeyboard(int key, int x, int y)
|
||||
case GLUT_KEY_UP :
|
||||
{
|
||||
gEngineForce = maxEngineForce;
|
||||
gBreakingForce = 0.f;
|
||||
break;
|
||||
}
|
||||
case GLUT_KEY_DOWN :
|
||||
{
|
||||
gBreakingForce = maxBreakingForce;
|
||||
gEngineForce = 0.f;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -36,6 +36,11 @@ class btContinuousDynamicsWorld : public btDiscreteDynamicsWorld
|
||||
|
||||
virtual void calculateTimeOfImpacts(btScalar timeStep);
|
||||
|
||||
virtual btDynamicsWorldType getWorldType() const
|
||||
{
|
||||
return BT_CONTINUOUS_DYNAMICS_WORLD;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_CONTINUOUS_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -153,6 +153,11 @@ public:
|
||||
return m_solverInfo;
|
||||
}
|
||||
|
||||
virtual btDynamicsWorldType getWorldType() const
|
||||
{
|
||||
return BT_DISCRETE_DYNAMICS_WORLD;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,13 @@ class btRaycastVehicle;
|
||||
class btConstraintSolver;
|
||||
|
||||
|
||||
enum btDynamicsWorldType
|
||||
{
|
||||
BT_SIMPLE_DYNAMICS_WORLD=1,
|
||||
BT_DISCRETE_DYNAMICS_WORLD=2,
|
||||
BT_CONTINUOUS_DYNAMICS_WORLD=3
|
||||
};
|
||||
|
||||
///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous
|
||||
class btDynamicsWorld : public btCollisionWorld
|
||||
{
|
||||
@@ -74,6 +81,8 @@ class btDynamicsWorld : public btCollisionWorld
|
||||
|
||||
virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; }
|
||||
|
||||
virtual btDynamicsWorldType getWorldType() const=0;
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -79,6 +79,11 @@ public:
|
||||
|
||||
virtual btConstraintSolver* getConstraintSolver();
|
||||
|
||||
virtual btDynamicsWorldType getWorldType() const
|
||||
{
|
||||
return BT_SIMPLE_DYNAMICS_WORLD;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_SIMPLE_DYNAMICS_WORLD_H
|
||||
|
||||
Reference in New Issue
Block a user