diff --git a/Demos/AllBulletDemos/CMakeLists.txt b/Demos/AllBulletDemos/CMakeLists.txt index c2f461be4..8c2030ca7 100644 --- a/Demos/AllBulletDemos/CMakeLists.txt +++ b/Demos/AllBulletDemos/CMakeLists.txt @@ -27,7 +27,6 @@ ADD_EXECUTABLE(AppAllBulletDemos DemoEntries.cpp ../CcdPhysicsDemo/CcdPhysicsDemo.cpp ../BasicDemo/BasicDemo.cpp - ../Benchmarks/BenchmarkDemo.cpp ../BspDemo/BspDemo.cpp ../BspDemo/BspConverter.cpp ../BspDemo/BspLoader.cpp diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp index a0269b020..f0e85ca35 100644 --- a/Demos/AllBulletDemos/DemoEntries.cpp +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -30,7 +30,7 @@ subject to the following restrictions: #include "../GjkConvexCastDemo/LinearConvexCastDemo.h" #include "../ForkLiftDemo/ForkLiftDemo.h" #include "../ConstraintDemo/ConstraintDemo.h" -#include "../Benchmarks/BenchmarkDemo.h" +//#include "../Benchmarks/BenchmarkDemo.h" #include "../SoftDemo/SoftDemo.h" #include "GLDebugFont.h" @@ -109,12 +109,13 @@ btDemoEntry g_demoEntries[] = {"ForkLift Demo",ForkLiftDemo::Create}, {"Ragdoll Demo",RagdollDemo::Create}, {"Basic Demo", BasicDemo::Create}, + {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, {"Convex Decomposition",ConvexDecompositionDemo::Create}, {"Concave Moving", GimpactConcaveDemo::Create}, {"Dynamic Control Demo",MotorDemo::Create}, - //{"ConcaveDemo",ConcaveDemo::Create}, + {"ConcaveDemo",ConcaveDemo::Create}, {"Concave Convexcast Demo",ConcaveConvexcastDemo::Create}, - // {"SoftBody Cloth",SoftDemo0::Create}, + {"SoftBody Cloth",SoftDemo0::Create}, {"SoftBody Ropes Attach",SoftDemo4::Create}, {"SoftBody Cloth Attach",SoftDemo5::Create}, @@ -125,12 +126,12 @@ btDemoEntry g_demoEntries[] = {"SoftBody Cluster Robot",SoftDemo25::Create}, // {"SoftBody Ropes",SoftDemo3::Create}, {"SoftBody Sticks",SoftDemo6::Create}, -// {"SoftBody Collide",SoftDemo7::Create}, -// {"SoftBody Collide2",SoftDemo8::Create}, + {"SoftBody Collide",SoftDemo7::Create}, + {"SoftBody Collide2",SoftDemo8::Create}, // {"SoftBody Collide3",SoftDemo9::Create}, // {"SoftBody Impact",SoftDemo10::Create}, {"SoftBody Aero",SoftDemo11::Create}, -// {"SoftBody Friction",SoftDemo12::Create}, + {"SoftBody Friction",SoftDemo12::Create}, // {"SoftBody Torus",SoftDemo13::Create}, // {"SoftBody Torus Match",SoftDemo14::Create}, // {"SoftBody Bunny",SoftDemo15::Create}, @@ -140,24 +141,24 @@ btDemoEntry g_demoEntries[] = // {"SoftBody Cluster Collide2",SoftDemo20::Create}, // {"SoftBody Cluster Socket",SoftDemo21::Create}, -// {"SoftBody Cluster Hinge",SoftDemo22::Create}, -// {"SoftBody Cluster Combine",SoftDemo23::Create}, + {"SoftBody Cluster Hinge",SoftDemo22::Create}, + {"SoftBody Cluster Combine",SoftDemo23::Create}, // {"SoftBody Cluster Stack Soft",SoftDemo26::Create}, {"SoftBody Cluster Stack Mixed",SoftDemo27::Create}, // {"SliderConstraint",SliderConstraintDemo::Create}, - {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, + // {"ConcaveRaycastDemo",ConcaveRaycastDemo::Create}, //{"BspDemo", BspDemo::Create}, // {"Raytracer Test",Raytracer::Create}, // {"GjkConvexCast",LinearConvexCastDemo::Create}, - {"Benchmark 3000 FALL",BenchmarkDemo1::Create}, - {"Benchmark 1000 STACK",BenchmarkDemo2::Create}, - {"Benchmark 136 RAGDOLLS",BenchmarkDemo3::Create}, - {"Benchmark 1000 CONVEX",BenchmarkDemo4::Create}, - {"Benchmark Mesh-Prim",BenchmarkDemo5::Create}, - {"Benchmark Mesh-Convex",BenchmarkDemo6::Create}, - {"Benchmark Raycast",BenchmarkDemo7::Create}, +// {"Benchmark 3000 FALL",BenchmarkDemo1::Create}, +// {"Benchmark 1000 STACK",BenchmarkDemo2::Create}, +// {"Benchmark 136 RAGDOLLS",BenchmarkDemo3::Create}, +// {"Benchmark 1000 CONVEX",BenchmarkDemo4::Create}, +// {"Benchmark Mesh-Prim",BenchmarkDemo5::Create}, +// {"Benchmark Mesh-Convex",BenchmarkDemo6::Create}, +// {"Benchmark Raycast",BenchmarkDemo7::Create}, {"MemoryLeak Checker",btEmptyDebugDemo::Create}, {0, 0} diff --git a/Demos/AllBulletDemos/Jamfile b/Demos/AllBulletDemos/Jamfile index 8aa7dd025..5c8e9459e 100644 --- a/Demos/AllBulletDemos/Jamfile +++ b/Demos/AllBulletDemos/Jamfile @@ -4,7 +4,6 @@ FrameWorkDemo AllBulletDemos : [ Wildcard *.h *.cpp ] ../CcdPhysicsDemo/CcdPhysicsDemo.cpp ../BasicDemo/BasicDemo.cpp - ../Benchmarks/BenchmarkDemo.cpp ../BspDemo/BspDemo.cpp ../BspDemo/BspConverter.cpp ../BspDemo/BspLoader.cpp diff --git a/Demos/AllBulletDemos/Makefile.am b/Demos/AllBulletDemos/Makefile.am index e9441266e..d4e8a2e1b 100644 --- a/Demos/AllBulletDemos/Makefile.am +++ b/Demos/AllBulletDemos/Makefile.am @@ -2,7 +2,6 @@ noinst_PROGRAMS=AllBulletDemo AllBulletDemo_SOURCES=\ ../SoftDemo/SoftDemo.cpp \ - ../Benchmarks/BenchmarkDemo.cpp \ ../ConstraintDemo/ConstraintDemo.cpp \ ../ForkLiftDemo/ForkLiftDemo.cpp \ ../RagdollDemo/RagdollDemo.cpp \ @@ -30,6 +29,5 @@ AllBulletDemo_CXXFLAGS=\ -I@top_builddir@/Extras \ -I@top_builddir@/Demos/OpenGL \ -I@top_builddir@/Demos/SoftDemo \ - -I@top_builddir@/Demos/Benchmarks \ $(CXXFLAGS) AllBulletDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -L../../Extras -lgimpactutils -lconvexdecomposition -lbulletsoftbody -lbulletdynamics -lbulletcollision -lbulletmath -lglui @opengl_LIBS@ diff --git a/Demos/Benchmarks/BenchmarkDemo.cpp b/Demos/Benchmarks/BenchmarkDemo.cpp index 9fd11614d..c42700d64 100644 --- a/Demos/Benchmarks/BenchmarkDemo.cpp +++ b/Demos/Benchmarks/BenchmarkDemo.cpp @@ -16,10 +16,11 @@ subject to the following restrictions: // Collision Radius #define COLLISION_RADIUS 0.0f - - #include "BenchmarkDemo.h" +#ifdef USE_GLUT_DEMO_APPLICATION #include "GlutStuff.h" +#endif //USE_GLUT_DEMO_APPLICATION + ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include //printf debugging @@ -177,6 +178,7 @@ public: void draw () { +#ifdef USE_GLUT_DEMO_APPLICATION glDisable (GL_LIGHTING); glColor3f (0.0, 1.0, 0.0); glBegin (GL_LINES); @@ -204,6 +206,8 @@ public: } glEnd (); glEnable (GL_LIGHTING); +#endif //USE_GLUT_DEMO_APPLICATION + } }; @@ -213,7 +217,9 @@ static btRaycastBar2 raycastBar; void BenchmarkDemo::clientMoveAndDisplay() { +#ifdef USE_GLUT_DEMO_APPLICATION glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#endif //USE_GLUT_DEMO_APPLICATION //simple dynamics world doesn't handle fixed-time-stepping float ms = getDeltaTimeMicroseconds(); @@ -236,16 +242,20 @@ void BenchmarkDemo::clientMoveAndDisplay() renderme(); +#ifdef USE_GLUT_DEMO_APPLICATION glFlush(); glutSwapBuffers(); +#endif //USE_GLUT_DEMO_APPLICATION } -void BenchmarkDemo::displayCallback(void) { +void BenchmarkDemo::displayCallback(void) +{ +#ifdef USE_GLUT_DEMO_APPLICATION glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderme(); @@ -256,6 +266,7 @@ void BenchmarkDemo::displayCallback(void) { glFlush(); glutSwapBuffers(); +#endif //USE_GLUT_DEMO_APPLICATION } @@ -1213,5 +1224,26 @@ void BenchmarkDemo::exitPhysics() +#ifndef USE_GLUT_DEMO_APPLICATION +btRigidBody* DemoApplication::localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape) +{ + btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); + //rigidbody is dynamic if and only if mass is non zero, otherwise static + bool isDynamic = (mass != 0.f); + + btVector3 localInertia(0,0,0); + if (isDynamic) + shape->calculateLocalInertia(mass,localInertia); + + //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects + + btRigidBody* body = new btRigidBody(mass,0,shape,localInertia); + body->setWorldTransform(startTransform); + + m_dynamicsWorld->addRigidBody(body); + + return body; +} +#endif //USE_GLUT_DEMO_APPLICATION diff --git a/Demos/Benchmarks/BenchmarkDemo.h b/Demos/Benchmarks/BenchmarkDemo.h index 3751f4887..6a533ced6 100644 --- a/Demos/Benchmarks/BenchmarkDemo.h +++ b/Demos/Benchmarks/BenchmarkDemo.h @@ -15,10 +15,15 @@ subject to the following restrictions: #ifndef BENCHMARK_DEMO_H #define BENCHMARK_DEMO_H -#include "GlutDemoApplication.h" + #include "LinearMath/btAlignedObjectArray.h" +#include "LinearMath/btTransform.h" + +class btDynamicsWorld; + #define NUMRAYS 500 +class btRigidBody; class btBroadphaseInterface; class btCollisionShape; class btOverlappingPairCache; @@ -27,8 +32,39 @@ class btConstraintSolver; struct btCollisionAlgorithmCreateFunc; class btDefaultCollisionConfiguration; +#ifndef USE_GLUT_DEMO_APPLICATION +///empty placeholder +class DemoApplication +{ +protected: + + btDynamicsWorld* m_dynamicsWorld; +public: + virtual void myinit() {} + virtual btDynamicsWorld* getDynamicsWorld() + { + return m_dynamicsWorld; + } + + btScalar getDeltaTimeMicroseconds() + { + return 1.f; + } + + void renderme() {} + void setCameraDistance(btScalar dist){} + void clientResetScene(){} + btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape); + +}; ///BenchmarkDemo is provides several performance tests +class BenchmarkDemo : public DemoApplication +#else +#include "GlutDemoApplication.h" class BenchmarkDemo : public GlutDemoApplication +#endif + + { //keep the collision shapes, for deletion/cleanup diff --git a/Demos/Benchmarks/CMakeLists.txt b/Demos/Benchmarks/CMakeLists.txt index fe144fab0..1888bc685 100644 --- a/Demos/Benchmarks/CMakeLists.txt +++ b/Demos/Benchmarks/CMakeLists.txt @@ -15,7 +15,7 @@ ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL } ) LINK_LIBRARIES( -OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} + BulletDynamics BulletCollision LinearMath ) ADD_EXECUTABLE(AppBenchmarks diff --git a/Demos/Benchmarks/Jamfile b/Demos/Benchmarks/Jamfile index 01d51385c..c5608815b 100644 --- a/Demos/Benchmarks/Jamfile +++ b/Demos/Benchmarks/Jamfile @@ -1,3 +1,3 @@ SubDir TOP Demos Benchmarks ; -BulletDemo Benchmarks : [ Wildcard *.h *.cpp ] ; +BulletBasicDemo Benchmarks : [ Wildcard *.h *.cpp ] ; diff --git a/Demos/Benchmarks/main.cpp b/Demos/Benchmarks/main.cpp index a4b30c465..1331aa7da 100644 --- a/Demos/Benchmarks/main.cpp +++ b/Demos/Benchmarks/main.cpp @@ -14,32 +14,70 @@ subject to the following restrictions: */ #include "BenchmarkDemo.h" -#include "GlutStuff.h" -#include "GLDebugDrawer.h" #include "btBulletDynamicsCommon.h" #include "LinearMath/btHashMap.h" +#include + +#ifdef USE_GLUT_DEMO_APPLICATION + #include "GlutStuff.h" + #include "GLDebugDrawer.h" + GLDebugDrawer gDebugDrawer; +#endif //USE_GLUT_DEMO_APPLICATION +#define NUM_DEMOS 7 +#define NUM_TESTS 650 + +extern bool gDisableDeactivation; - int main(int argc,char** argv) { - GLDebugDrawer gDebugDrawer; + gDisableDeactivation = true; -// BenchmarkDemo1 benchmarkDemo; -// BenchmarkDemo2 benchmarkDemo; -// BenchmarkDemo3 benchmarkDemo; - BenchmarkDemo4 benchmarkDemo; -// BenchmarkDemo5 benchmarkDemo; -// BenchmarkDemo6 benchmarkDemo; -// BenchmarkDemo7 benchmarkDemo; + BenchmarkDemo1 benchmarkDemo1; + BenchmarkDemo2 benchmarkDemo2; + BenchmarkDemo3 benchmarkDemo3; + BenchmarkDemo4 benchmarkDemo4; + BenchmarkDemo5 benchmarkDemo5; + BenchmarkDemo6 benchmarkDemo6; + BenchmarkDemo7 benchmarkDemo7; + BenchmarkDemo* demoArray[NUM_DEMOS] = {&benchmarkDemo1,&benchmarkDemo2,&benchmarkDemo3,&benchmarkDemo4,&benchmarkDemo5,&benchmarkDemo6,&benchmarkDemo7}; + char* demoNames[NUM_DEMOS] = {"3000 fall", "1000 stack", "136 ragdolls","1000 convex", "prim-trimesh", "convex-trimesh","raytests"}; + float totalTime[NUM_DEMOS] = {0.f,0.f,0.f,0.f,0.f,0.f,0.f}; - benchmarkDemo.initPhysics(); +#ifdef USE_GLUT_DEMO_APPLICATION benchmarkDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer); - return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.com",&benchmarkDemo); - - //default glut doesn't return from mainloop +#else + int d; + + for (d=0;dinitPhysics(); + + + for (int i=0;iclientMoveAndDisplay(); + float frameTime = CProfileManager::Get_Time_Since_Reset(); + if ((i % 25)==0) + { + printf("BenchmarkDemo: %s, Frame %d, Duration (ms): %f\n",demoNames[d],i,frameTime); + } + totalTime[d] += frameTime; + if (i==NUM_TESTS-1) + CProfileManager::dumpAll(); + + + } + } + + for (d=0;dsetLowerLimit(-SIMD_HALF_PI * 0.5f, -SIMD_HALF_PI * 0.5f); pUniv->setUpperLimit(SIMD_HALF_PI * 0.5f, SIMD_HALF_PI * 0.5f); diff --git a/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h b/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h index 128c8c7ba..dd591332c 100644 --- a/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h +++ b/Demos/ContinuousConvexCollision/ContinuousConvexCollision.h @@ -18,13 +18,8 @@ subject to the following restrictions: ///ContinuousConvexCollisionDemo shows the working of the continuous collision detection, including linear and angular motion -#ifdef _WINDOWS -#include "Win32DemoApplication.h" -class btContinuousConvexCollisionDemo : public Win32DemoApplication -#else #include "GlutDemoApplication.h" class btContinuousConvexCollisionDemo : public GlutDemoApplication -#endif { public: diff --git a/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp b/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp index 3e9752e7c..932484509 100644 --- a/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp +++ b/Demos/ContinuousConvexCollision/ContinuousConvexCollisionDemo.cpp @@ -63,7 +63,7 @@ btTransform toTrans[maxNumObjects]; int screenWidth = 640; int screenHeight = 480; -#ifndef _WINDOWS + int main(int argc,char** argv) { btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo(); @@ -74,16 +74,6 @@ int main(int argc,char** argv) return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo",ccdDemo); } -#else -DemoApplication* createDemo() -{ - btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo(); - - ccdDemo->setCameraDistance(40.f); - return ccdDemo; - -} -#endif //_WINDOWS void btContinuousConvexCollisionDemo::initPhysics() diff --git a/Demos/ConvexDecompositionDemo/main.cpp b/Demos/ConvexDecompositionDemo/main.cpp index 944b80405..1f99d83b7 100644 --- a/Demos/ConvexDecompositionDemo/main.cpp +++ b/Demos/ConvexDecompositionDemo/main.cpp @@ -5,7 +5,6 @@ #include "GLDebugDrawer.h" #include "btBulletDynamicsCommon.h" -#ifndef _WINDOWS GLDebugDrawer gDebugDrawer; @@ -31,10 +30,3 @@ int main(int argc,char** argv) return 0; } -#else -DemoApplication* createDemo() -{ - ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo(); - return convexDecompDemo; -} -#endif _WINDOWS diff --git a/Demos/OpenGL/GlutDemoApplication.cpp b/Demos/OpenGL/GlutDemoApplication.cpp index ffafabf7e..5e77c7503 100644 --- a/Demos/OpenGL/GlutDemoApplication.cpp +++ b/Demos/OpenGL/GlutDemoApplication.cpp @@ -1,5 +1,5 @@ -#ifndef _WINDOWS + #include "GlutDemoApplication.h" #include "GlutStuff.h" @@ -81,5 +81,5 @@ void GlutDemoApplication::swapBuffers() } -#endif //_WINDOWS + diff --git a/Demos/OpenGL/GlutStuff.cpp b/Demos/OpenGL/GlutStuff.cpp index cf79b5966..766c6bb01 100644 --- a/Demos/OpenGL/GlutStuff.cpp +++ b/Demos/OpenGL/GlutStuff.cpp @@ -70,7 +70,7 @@ static void glutDisplayCallback(void) gDemoApplication->displayCallback(); } -#ifndef _WINDOWS + int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) { gDemoApplication = demoApp; @@ -104,4 +104,4 @@ int glutmain(int argc, char **argv,int width,int height,const char* title,DemoAp return 0; } -#endif //_WINDOWS + diff --git a/Demos/OpenGL/GlutStuff.h b/Demos/OpenGL/GlutStuff.h index 1a1fca3a7..01ff53394 100644 --- a/Demos/OpenGL/GlutStuff.h +++ b/Demos/OpenGL/GlutStuff.h @@ -34,26 +34,7 @@ subject to the following restrictions: #endif #endif -#ifdef _WINDOWS -#define BT_KEY_K 'K' -#define BT_KEY_LEFT VK_LEFT -#define BT_KEY_RIGHT VK_RIGHT -#define BT_KEY_UP VK_UP -#define BT_KEY_DOWN VK_DOWN -#define BT_KEY_F1 VK_F1 -#define BT_KEY_F2 VK_F2 -#define BT_KEY_F3 VK_F3 -#define BT_KEY_F4 VK_F4 -#define BT_KEY_F5 VK_F5 -#define BT_KEY_PAGEUP VK_PRIOR -#define BT_KEY_PAGEDOWN VK_NEXT -#define BT_KEY_END VK_END -#define BT_KEY_HOME VK_HOME -#define BT_ACTIVE_ALT VK_LMENU - - -#else #define BT_KEY_K 'k' #define BT_KEY_LEFT GLUT_KEY_LEFT #define BT_KEY_RIGHT GLUT_KEY_RIGHT @@ -72,7 +53,6 @@ subject to the following restrictions: #define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT #define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT -#endif #if BT_USE_FREEGLUT diff --git a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp index 967068f1b..767a8b400 100644 --- a/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp @@ -215,9 +215,10 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl #ifdef USE_SEPDISTANCE_UTIL2 if (dispatchInfo.m_useConvexConservativeDistanceUtil) { - sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold; + sepDist = gjkPairDetector.getCachedSeparatingDistance(); if (sepDist>SIMD_EPSILON) { + sepDist += dispatchInfo.m_convexConservativeDistanceThreshold; //now perturbe directions to get multiple contact points sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); btPlaneSpace1(sepNormalWorldSpace,v0,v1);