btThreadSupportInterface* createSolverThreadSupport(int maxNumThreads) { #define SEQUENTIAL #ifdef SEQUENTIAL SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc); SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); threadSupport->startSPU(); #else #ifdef _WIN32 Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads",SolverThreadFunc,SolverlsMemoryFunc,maxNumThreads); Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); threadSupport->startSPU(); #elif defined (USE_PTHREADS) PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); #else SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc); SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); threadSupport->startSPU(); #endif #endif return threadSupport; }
//#define SEQUENTIAL btThreadSupportInterface* createSolverThreadSupport(int maxNumThreads) { #ifdef SEQUENTIAL SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", SolverThreadFunc, SolverlsMemoryFunc); SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); threadSupport->startSPU(); #else Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); threadSupport->startSPU(); #endif return threadSupport; }
void timer::process(const clock_info& ci) { // calculate timer delta time instead of clock delta time double dt = ci.time - start_clock_info_.time; clock_info tci(ci.time, dt); // reset first start_clock_info_.time = ci.time; fire_ += frequency_; kernel_.enqueue( this ); if(handler_) { handler_(tci); } }
btThreadSupportInterface* jmePhysicsSpace::createDispatchThreadSupport(int maxNumThreads) { #ifdef _WIN32 Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", processCollisionTask, createCollisionLocalStoreMemory, maxNumThreads); Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); threadSupport->startSPU(); #elif defined (USE_PTHREADS) PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", processCollisionTask, createCollisionLocalStoreMemory, maxNumThreads); PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); threadSupport->startSPU(); #else SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", processCollisionTask, createCollisionLocalStoreMemory); SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); threadSupport->startSPU(); #endif return threadSupport; }
btThreadSupportInterface* jmePhysicsSpace::createSolverThreadSupport(int maxNumThreads) { #ifdef _WIN32 Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); threadSupport->startSPU(); #elif defined (USE_PTHREADS) PosixThreadSupport::ThreadConstructionInfo constructionInfo("collision", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); PosixThreadSupport* threadSupport = new PosixThreadSupport(constructionInfo); threadSupport->startSPU(); #else SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", SolverThreadFunc, SolverlsMemoryFunc); SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); threadSupport->startSPU(); #endif return threadSupport; }
void ConcaveRaycastDemo::initPhysics() { #define TRISIZE 10.f int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); gVertices = new btVector3[totalVerts]; gIndices = new int[totalTriangles*3]; int i; setVertexPositions(waveheight,0.f); int index=0; for ( i=0;i<NUM_VERTS_X-1;i++) { for (int j=0;j<NUM_VERTS_Y-1;j++) { gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = j*NUM_VERTS_X+i+1; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = (j+1)*NUM_VERTS_X+i; } } m_indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(btScalar*) &gVertices[0].x(),vertStride); bool useQuantizedAabbCompression = true; trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression); m_collisionShapes.push_back(trimeshShape); btCollisionShape* groundShape = trimeshShape; m_collisionConfiguration = new btDefaultCollisionConfiguration(); m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); btVector3 worldMin(-1000,-1000,-1000); btVector3 worldMax(1000,1000,1000); m_broadphase = new btAxisSweep3(worldMin,worldMax); m_solver = new btSequentialImpulseConstraintSolver(); m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_dynamicsWorld->getSolverInfo().m_splitImpulse=true; m_dynamicsWorld->setDebugDrawer(&sDebugDraw); float mass = 0.f; btTransform startTransform; startTransform.setIdentity(); startTransform.setOrigin(btVector3(0,-2,0)); btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1)); m_collisionShapes.push_back(colShape); { for (int i=0;i<10;i++) { //btCollisionShape* colShape = new btCapsuleShape(0.5,2.0);//boxShape = new btSphereShape(1.f); startTransform.setOrigin(btVector3(2*i,10,1)); localCreateRigidBody(1, startTransform,colShape); } } startTransform.setIdentity(); staticBody = localCreateRigidBody(mass, startTransform,groundShape); staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); #ifdef BATCH_RAYCASTER int maxNumOutstandingTasks = 4; #ifdef USE_WIN32_THREADING Win32ThreadSupport::Win32ThreadConstructionInfo tci("batch raycast", processRaycastTask, createRaycastLocalStoreMemory, maxNumOutstandingTasks); m_threadSupportRaycast = new Win32ThreadSupport(tci); printf("m_threadSupportRaycast = %p\n", m_threadSupportRaycast); #endif gBatchRaycaster = new SpuBatchRaycaster (m_threadSupportRaycast, maxNumOutstandingTasks, m_dynamicsWorld->getCollisionObjectArray(), m_dynamicsWorld->getNumCollisionObjects()); #endif raycastBar = btRaycastBar (4000.0, 0.0); //raycastBar = btRaycastBar (true, 40.0, -50.0, 50.0); }