From 8f181b5604c3ce3429d3a2f03e17d0dc1c3ec71c Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Sun, 2 Nov 2008 10:34:24 +0000 Subject: [PATCH] more work on IBM Cell SDK 3.1 build --- Demos/CellSpuDemo/BasicDemo2.cpp | 72 +++++++-------------- Demos/CellSpuDemo/BasicDemo2.h | 12 ++-- Demos/CellSpuDemo/ibmsdk/Makefile | 4 +- src/BulletCollision/ibmsdk/Makefile | 9 ++- src/BulletMultiThreaded/SpuLibspe2Support.h | 7 ++ 5 files changed, 46 insertions(+), 58 deletions(-) diff --git a/Demos/CellSpuDemo/BasicDemo2.cpp b/Demos/CellSpuDemo/BasicDemo2.cpp index 0a0d8e9bd..825ff052d 100644 --- a/Demos/CellSpuDemo/BasicDemo2.cpp +++ b/Demos/CellSpuDemo/BasicDemo2.cpp @@ -15,8 +15,7 @@ subject to the following restrictions: //#define USE_GROUND_BOX 1 -//#define PRINT_CONTACT_STATISTICS 1 -//#define CHECK_MEMORY_LEAKS 1 +#define PRINT_CONTACT_STATISTICS 1 #define USE_PARALLEL_DISPATCHER 1 @@ -27,19 +26,16 @@ int gNumObjects = 120; #include "btBulletDynamicsCommon.h" #include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h" #include "LinearMath/btIDebugDraw.h" -#include "GLDebugDrawer.h" #include //printf debugging btScalar deltaTime = btScalar(1./60.); btScalar gCollisionMargin = btScalar(0.05); #include "BasicDemo2.h" -#include "GL_ShapeDrawer.h" -#include "GlutStuff.h" #ifdef USE_PARALLEL_DISPATCHER -#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h" -#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h" -#include "../../Extras/BulletMultiThreaded/SpuLibspe2Support.h" -#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" +#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h" +#include "BulletMultiThreaded/Win32ThreadSupport.h" +#include "BulletMultiThreaded/SpuLibspe2Support.h" +#include "BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" #endif//USE_PARALLEL_DISPATCHER @@ -47,12 +43,6 @@ btScalar gCollisionMargin = btScalar(0.05); //////////////////////////////////// -GLDebugDrawer debugDrawer; - -class myTest -{ - -}; @@ -61,15 +51,12 @@ int main(int argc,char** argv) BasicDemo ccdDemo; ccdDemo.initPhysics(); - ccdDemo.setCameraDistance(btScalar(50.)); -#ifdef CHECK_MEMORY_LEAKS + int i; + for (i=0;i<1000;i++) + ccdDemo.clientMoveAndDisplay(); 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; } @@ -81,7 +68,6 @@ extern int gTotalContactPoints; void BasicDemo::clientMoveAndDisplay() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //simple dynamics world doesn't handle fixed-time-stepping float ms = m_clock.getTimeMicroseconds(); @@ -93,9 +79,6 @@ void BasicDemo::clientMoveAndDisplay() if (m_dynamicsWorld) m_dynamicsWorld->stepSimulation(ms / 1000000.f); - renderme(); - - glFlush(); //some additional debugging info #ifdef PRINT_CONTACT_STATISTICS printf("num manifolds: %i\n",gNumManifold); @@ -104,27 +87,11 @@ void BasicDemo::clientMoveAndDisplay() #endif //PRINT_CONTACT_STATISTICS gTotalContactPoints = 0; - glutSwapBuffers(); } -void BasicDemo::displayCallback(void) { - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (m_dynamicsWorld) - m_dynamicsWorld->updateAabbs(); - - renderme(); - - glFlush(); - glutSwapBuffers(); -} - - - void BasicDemo::initPhysics() @@ -146,7 +113,7 @@ void BasicDemo::initPhysics() spe_program_handle_t * program_handle; #ifndef USE_CESOF - char* spuFileName = "../../../Extras/BulletMultiThreaded/out/spuCollision.elf"; + char* spuFileName = "../../../src/BulletMultiThreaded/out/spuCollision.elf"; program_handle = spe_image_open (spuFileName); if (program_handle == NULL) @@ -193,18 +160,11 @@ void BasicDemo::initPhysics() m_solver = sol; -#ifdef USE_SIMPLE_DYNAMICS_WORLD - //btSimpleDynamicsWorld doesn't support 'cache friendly' optimization, so disable this - sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); - m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver); -#else m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration); -#endif //USE_SIMPLE_DYNAMICS_WORLD m_dynamicsWorld->getDispatchInfo().m_enableSPU = true; m_dynamicsWorld->setGravity(btVector3(0,-10,0)); - m_dynamicsWorld->setDebugDrawer(&debugDrawer); ///create a few basic rigid bodies @@ -248,10 +208,22 @@ void BasicDemo::initPhysics() localCreateRigidBody(btScalar(1.),trans,sphereShape); } - clientResetScene(); + //clientResetScene(); } +btRigidBody* BasicDemo::localCreateRigidBody(btScalar mass,const btTransform& startTrans,btCollisionShape* colShape) +{ +btVector3 inertia(0,0,0); +if (mass) + colShape->calculateLocalInertia(mass,inertia); + btRigidBody::btRigidBodyConstructionInfo rbci(mass,0,colShape,inertia); + rbci.m_startWorldTransform = startTrans; +btRigidBody* body = new btRigidBody(rbci); + m_dynamicsWorld->addRigidBody(body); +return body; + +} void BasicDemo::exitPhysics() { diff --git a/Demos/CellSpuDemo/BasicDemo2.h b/Demos/CellSpuDemo/BasicDemo2.h index b530c6292..61422b846 100644 --- a/Demos/CellSpuDemo/BasicDemo2.h +++ b/Demos/CellSpuDemo/BasicDemo2.h @@ -15,9 +15,9 @@ subject to the following restrictions: #ifndef BASIC_DEMO_H #define BASIC_DEMO_H -#include "DemoApplication.h" - +#include "LinearMath/btQuickprof.h" +class btDiscreteDynamicsworld; class btCollisionShape; class btOverlappingPairCache; class btCollisionDispatcher; @@ -25,8 +25,9 @@ class btConstraintSolver; struct btCollisionAlgorithmCreateFunc; ///BasicDemo is good starting point for learning the code base and porting. -class BasicDemo : public DemoApplication +class BasicDemo { + btClock m_clock; //keep the collision shapes, for deletion/cleanup btAlignedObjectArray m_collisionShapes; @@ -36,11 +37,15 @@ class BasicDemo : public DemoApplication btCollisionDispatcher* m_dispatcher; btDefaultCollisionConfiguration* m_collisionConfiguration; btConstraintSolver* m_solver; + btDiscreteDynamicsWorld* m_dynamicsWorld; btCollisionAlgorithmCreateFunc* m_sphereSphereCF; btCollisionAlgorithmCreateFunc* m_sphereBoxCF; btCollisionAlgorithmCreateFunc* m_boxSphereCF; + btRigidBody* localCreateRigidBody(btScalar mass,const btTransform& startTrans,btCollisionShape* colShape); + + public: void initPhysics(); @@ -49,7 +54,6 @@ class BasicDemo : public DemoApplication virtual void clientMoveAndDisplay(); - virtual void displayCallback(); }; diff --git a/Demos/CellSpuDemo/ibmsdk/Makefile b/Demos/CellSpuDemo/ibmsdk/Makefile index b5aad1553..9777906e7 100755 --- a/Demos/CellSpuDemo/ibmsdk/Makefile +++ b/Demos/CellSpuDemo/ibmsdk/Makefile @@ -34,12 +34,10 @@ INCLUDE = -DUSE_LIBSPE2 \ -I$(ROOT)/src \ -I$(ROOT)/Demos/OpenGL \ -I$(HOSTINC) -SYS_LIBS := -lspe2 -lglut -lGLU -lGL -lm -lXext -lXmu -lX11 +SYS_LIBS := -lspe2 -lm IMPORTS = $(ROOT)/lib/ibmsdk/bulletmultithreaded.a \ - $(ROOT)/lib/ibmsdk/bulletopenglsupport.a \ $(ROOT)/lib/ibmsdk/bulletdynamics.a \ - $(ROOT)/lib/ibmsdk/bulletconvexhull.a \ $(ROOT)/lib/ibmsdk/bulletcollision.a \ $(ROOT)/lib/ibmsdk/bulletmath.a diff --git a/src/BulletCollision/ibmsdk/Makefile b/src/BulletCollision/ibmsdk/Makefile index ce21904e5..2fc66c095 100644 --- a/src/BulletCollision/ibmsdk/Makefile +++ b/src/BulletCollision/ibmsdk/Makefile @@ -28,15 +28,19 @@ CC_OPT_LEVEL = -O3 OBJS = \ btAxisSweep3.o \ +btQuantizedBvh.o \ btBroadphaseProxy.o \ btCollisionAlgorithm.o \ btDispatcher.o \ -btOverlappingPairCache.o \ +btDbvtBroadphase.o \ +btDbvt.o \ +btOverlappingPairCache.o \ btSimpleBroadphase.o \ btContinuousConvexCollision.o \ btConvexCast.o \ btGjkConvexCast.o \ btGjkEpa.o \ +btGjkEpa2.o \ btGjkEpaPenetrationDepthSolver.o \ btGjkPairDetector.o \ btDefaultCollisionConfiguration.o \ @@ -49,9 +53,12 @@ btCollisionDispatcher.o \ btCollisionObject.o \ btCollisionWorld.o \ btCompoundCollisionAlgorithm.o \ +btBoxBoxCollisionAlgorithm.o \ +btBoxBoxDetector.o \ btConvexPlaneCollisionAlgorithm.o \ btConvexConcaveCollisionAlgorithm.o \ btConvexConvexAlgorithm.o \ +btDefaultCollisionConfiguration.o \ btEmptyCollisionAlgorithm.o \ btManifoldResult.o \ btSimulationIslandManager.o \ diff --git a/src/BulletMultiThreaded/SpuLibspe2Support.h b/src/BulletMultiThreaded/SpuLibspe2Support.h index 4e542c5af..a6d6baca4 100644 --- a/src/BulletMultiThreaded/SpuLibspe2Support.h +++ b/src/BulletMultiThreaded/SpuLibspe2Support.h @@ -152,10 +152,17 @@ public: //tell the task scheduler we are done with the SPU tasks virtual void stopSPU(); + virtual void setNumTasks(int numTasks) + { + //changing the number of tasks after initialization is not implemented (yet) + } + private: ///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) void internal_startSPU(); + + int numThreads;