allow some existing demos to run in the TestFrameWork
This commit is contained in:
@@ -16,7 +16,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#define USE_GROUND_BOX 1
|
#define USE_GROUND_BOX 1
|
||||||
//#define PRINT_CONTACT_STATISTICS 1
|
//#define PRINT_CONTACT_STATISTICS 1
|
||||||
//#define CHECK_MEMORY_LEAKS 1
|
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
//#define USE_PARALLEL_DISPATCHER 1
|
||||||
|
|
||||||
#define START_POS_X -5
|
#define START_POS_X -5
|
||||||
@@ -65,22 +64,7 @@ class myTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
BasicDemo ccdDemo;
|
|
||||||
ccdDemo.initPhysics();
|
|
||||||
ccdDemo.setCameraDistance(btScalar(50.));
|
|
||||||
|
|
||||||
#ifdef CHECK_MEMORY_LEAKS
|
|
||||||
ccdDemo.exitPhysics();
|
|
||||||
#else
|
|
||||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&ccdDemo);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//default glut doesn't return from mainloop
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ subject to the following restrictions:
|
|||||||
#define BASIC_DEMO_H
|
#define BASIC_DEMO_H
|
||||||
|
|
||||||
#include "DemoApplication.h"
|
#include "DemoApplication.h"
|
||||||
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
|
class btBroadphaseInterface;
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
class btOverlappingPairCache;
|
class btOverlappingPairCache;
|
||||||
class btCollisionDispatcher;
|
class btCollisionDispatcher;
|
||||||
|
|||||||
36
Demos/BasicDemo/main.cpp
Normal file
36
Demos/BasicDemo/main.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BasicDemo.h"
|
||||||
|
#include "GlutStuff.h"
|
||||||
|
|
||||||
|
//#define CHECK_MEMORY_LEAKS 1
|
||||||
|
|
||||||
|
int main(int argc,char** argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
BasicDemo ccdDemo;
|
||||||
|
ccdDemo.initPhysics();
|
||||||
|
ccdDemo.setCameraDistance(btScalar(50.));
|
||||||
|
|
||||||
|
#ifdef CHECK_MEMORY_LEAKS
|
||||||
|
ccdDemo.exitPhysics();
|
||||||
|
#else
|
||||||
|
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&ccdDemo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//default glut doesn't return from mainloop
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ subject to the following restrictions:
|
|||||||
#include "BMF_Api.h"
|
#include "BMF_Api.h"
|
||||||
#include <stdio.h> //printf debugging
|
#include <stdio.h> //printf debugging
|
||||||
|
|
||||||
float deltaTime = 1.f/60.f;
|
|
||||||
#include "BspDemo.h"
|
#include "BspDemo.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
@@ -85,41 +85,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLDebugDrawer debugDrawer;
|
|
||||||
|
|
||||||
char* makeExeToBspFilename(const char* lpCmdLine);
|
|
||||||
char* getLastFileName();
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
BspDemo* bspDemo = new BspDemo();
|
|
||||||
|
|
||||||
const char* bspfilename = "BspDemo.bsp";
|
|
||||||
|
|
||||||
printf("argc=%i\n",argc);
|
|
||||||
{
|
|
||||||
for (int i=0;i<argc;i++)
|
|
||||||
{
|
|
||||||
printf("argv[%i]=%s\n",i,argv[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
bspfilename = makeExeToBspFilename(argv[0]);
|
|
||||||
printf("new name=%s\n",bspfilename);
|
|
||||||
}
|
|
||||||
if (argc>1)
|
|
||||||
{
|
|
||||||
bspfilename = argv[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
BspDemo::~BspDemo()
|
BspDemo::~BspDemo()
|
||||||
{
|
{
|
||||||
@@ -147,7 +115,6 @@ void BspDemo::initPhysics(char* bspfilename)
|
|||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
|
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef QUAKE_BSP_IMPORTING
|
#ifdef QUAKE_BSP_IMPORTING
|
||||||
@@ -225,8 +192,6 @@ void BspDemo::displayCallback(void) {
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
//m_dynamicsWorld->UpdateAabbs(deltaTime);
|
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
54
Demos/BspDemo/main.cpp
Normal file
54
Demos/BspDemo/main.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "BspDemo.h"
|
||||||
|
#include "GlutStuff.h"
|
||||||
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
|
char* makeExeToBspFilename(const char* lpCmdLine);
|
||||||
|
char* getLastFileName();
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,char** argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
BspDemo* bspDemo = new BspDemo();
|
||||||
|
|
||||||
|
const char* bspfilename = "BspDemo.bsp";
|
||||||
|
|
||||||
|
printf("argc=%i\n",argc);
|
||||||
|
{
|
||||||
|
for (int i=0;i<argc;i++)
|
||||||
|
{
|
||||||
|
printf("argv[%i]=%s\n",i,argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bspfilename = makeExeToBspFilename(argv[0]);
|
||||||
|
printf("new name=%s\n",bspfilename);
|
||||||
|
}
|
||||||
|
if (argc>1)
|
||||||
|
{
|
||||||
|
bspfilename = argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,6 @@ subject to the following restrictions:
|
|||||||
#include "BMF_Api.h"
|
#include "BMF_Api.h"
|
||||||
#include <stdio.h> //printf debugging
|
#include <stdio.h> //printf debugging
|
||||||
|
|
||||||
float deltaTime = 1.f/60.f;
|
|
||||||
float gCollisionMargin = 0.05f;
|
float gCollisionMargin = 0.05f;
|
||||||
#include "CcdPhysicsDemo.h"
|
#include "CcdPhysicsDemo.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
@@ -172,6 +171,11 @@ void CcdPhysicsDemo::createStack( btCollisionShape* boxShape, float halfCubeSize
|
|||||||
|
|
||||||
btRigidBody* body = 0;
|
btRigidBody* body = 0;
|
||||||
body = localCreateRigidBody(mass,trans,boxShape);
|
body = localCreateRigidBody(mass,trans,boxShape);
|
||||||
|
#ifdef USER_DEFINED_FRICTION_MODEL
|
||||||
|
///Advanced use: override the friction solver
|
||||||
|
body->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1;
|
||||||
|
#endif //USER_DEFINED_FRICTION_MODEL
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,25 +224,10 @@ void customNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher&
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLDebugDrawer debugDrawer;
|
|
||||||
|
|
||||||
//experimental jitter damping (1 = no damping, 0 = total damping once motion below threshold)
|
//experimental jitter damping (1 = no damping, 0 = total damping once motion below threshold)
|
||||||
extern btScalar gJitterVelocityDampingFactor;
|
extern btScalar gJitterVelocityDampingFactor;
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
gJitterVelocityDampingFactor = 0.7;
|
|
||||||
|
|
||||||
CcdPhysicsDemo* ccdDemo = new CcdPhysicsDemo();
|
|
||||||
|
|
||||||
ccdDemo->initPhysics();
|
|
||||||
|
|
||||||
#ifdef DO_BENCHMARK_PYRAMIDS
|
|
||||||
ccdDemo->setCameraDistance(26.f);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -371,6 +360,11 @@ float myFrictionModel( btRigidBody& body1, btRigidBody& body2, btManifoldPoint&
|
|||||||
|
|
||||||
void CcdPhysicsDemo::initPhysics()
|
void CcdPhysicsDemo::initPhysics()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef DO_BENCHMARK_PYRAMIDS
|
||||||
|
setCameraDistance(2.5f);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DO_BENCHMARK_PYRAMIDS
|
#ifdef DO_BENCHMARK_PYRAMIDS
|
||||||
m_azi = 90.f;
|
m_azi = 90.f;
|
||||||
#endif //DO_BENCHMARK_PYRAMIDS
|
#endif //DO_BENCHMARK_PYRAMIDS
|
||||||
@@ -487,7 +481,6 @@ int maxNumOutstandingTasks = 4;
|
|||||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||||
|
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USER_DEFINED_FRICTION_MODEL
|
#ifdef USER_DEFINED_FRICTION_MODEL
|
||||||
|
|||||||
29
Demos/CcdPhysicsDemo/main.cpp
Normal file
29
Demos/CcdPhysicsDemo/main.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CcdPhysicsDemo.h"
|
||||||
|
#include "GlutStuff.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,char** argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
CcdPhysicsDemo* ccdDemo = new CcdPhysicsDemo();
|
||||||
|
|
||||||
|
ccdDemo->initPhysics();
|
||||||
|
|
||||||
|
|
||||||
|
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo);
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
SubDir TOP Examples TestBed Framework ;
|
SubDir TOP Examples TestBed Framework ;
|
||||||
|
|
||||||
BulletDemo FrameWork : [ Wildcard *.h *.cpp ] ;
|
FrameWorkDemo FrameWork : [ Wildcard *.h *.cpp ] ;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ SubDir TOP Examples TestBed ;
|
|||||||
if $(GLUT.AVAILABLE) = "yes"
|
if $(GLUT.AVAILABLE) = "yes"
|
||||||
{
|
{
|
||||||
# All demo apps have a lot in common, so use this rule to simply things
|
# All demo apps have a lot in common, so use this rule to simply things
|
||||||
rule BulletDemo
|
rule FrameWorkDemo
|
||||||
{
|
{
|
||||||
Application $(<) : $(>) : noinstall console nomanifest ;
|
Application $(<) : $(>) : noinstall console nomanifest ;
|
||||||
LinkWith $(<) : Tests bulletdynamics bulletcollision bulletmath glui ;
|
LinkWith $(<) : Tests bulletdynamics bulletcollision bulletmath glui ;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
class CollisionProcessing : public Test
|
class CollisionProcessing : public Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Step(Settings* settings)
|
void Step(const Settings* settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,63 @@
|
|||||||
#include "../FrameWork/Test.h"
|
#include "../FrameWork/Test.h"
|
||||||
#include "CollisionProcessing.h"
|
#include "CollisionProcessing.h"
|
||||||
|
|
||||||
TestEntry g_testEntries[] =
|
#include "../../Demos/CcdPhysicsDemo/CcdPhysicsDemo.h"
|
||||||
|
|
||||||
|
class CcdPhysicsTest : public Test
|
||||||
{
|
{
|
||||||
{"Collision Processing", CollisionProcessing::Create}
|
CcdPhysicsDemo* m_demo;
|
||||||
|
CcdPhysicsTest()
|
||||||
|
{
|
||||||
|
m_demo = new CcdPhysicsDemo();
|
||||||
|
m_demo->initPhysics();
|
||||||
|
}
|
||||||
|
virtual ~CcdPhysicsTest()
|
||||||
|
{
|
||||||
|
delete m_demo;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
void Step(const Settings* settings)
|
||||||
|
{
|
||||||
|
m_demo->clientMoveAndDisplay();
|
||||||
|
}
|
||||||
|
static Test* Create()
|
||||||
|
{
|
||||||
|
return new CcdPhysicsTest;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "../../Demos/BspDemo/BspDemo.h"
|
||||||
|
|
||||||
|
class BspDemoTest : public Test
|
||||||
|
{
|
||||||
|
BspDemo* m_demo;
|
||||||
|
|
||||||
|
BspDemoTest()
|
||||||
|
{
|
||||||
|
m_demo = new BspDemo();
|
||||||
|
m_demo->initPhysics("BspDemo.bsp");
|
||||||
|
}
|
||||||
|
virtual ~BspDemoTest()
|
||||||
|
{
|
||||||
|
delete m_demo;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
void Step(const Settings* settings)
|
||||||
|
{
|
||||||
|
m_demo->clientMoveAndDisplay();
|
||||||
|
}
|
||||||
|
static Test* Create()
|
||||||
|
{
|
||||||
|
return new BspDemoTest;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
TestEntry g_testEntries[] =
|
||||||
|
{
|
||||||
|
{"CcdPhysics Test", CcdPhysicsTest::Create},
|
||||||
|
{"BspDemo Test", BspDemoTest::Create},
|
||||||
|
{"Collision Processing", CollisionProcessing::Create},
|
||||||
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user