diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 4e1048823..e4919a820 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -732,7 +732,7 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m } -btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** /*bodies */,int /*numBodies */,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) +btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) { BT_PROFILE("solveGroupCacheFriendlySetup"); (void)stackAlloc; @@ -745,6 +745,33 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol return 0.f; } + if (infoGlobal.m_splitImpulse) + { + for (int i = 0; i < numBodies; i++) + { + btRigidBody* body = btRigidBody::upcast(bodies[i]); + if (body) + { + body->internalGetDeltaLinearVelocity().setZero(); + body->internalGetDeltaAngularVelocity().setZero(); + body->internalGetPushVelocity().setZero(); + body->internalGetTurnVelocity().setZero(); + } + } + } + else + { + for (int i = 0; i < numBodies; i++) + { + btRigidBody* body = btRigidBody::upcast(bodies[i]); + if (body) + { + body->internalGetDeltaLinearVelocity().setZero(); + body->internalGetDeltaAngularVelocity().setZero(); + } + } + } + if (1) { int j; diff --git a/src/BulletDynamics/Dynamics/btRigidBody.cpp b/src/BulletDynamics/Dynamics/btRigidBody.cpp index 35de8e475..532a5c4b0 100644 --- a/src/BulletDynamics/Dynamics/btRigidBody.cpp +++ b/src/BulletDynamics/Dynamics/btRigidBody.cpp @@ -328,10 +328,10 @@ void btRigidBody::internalWritebackVelocity(btScalar timeStep) setWorldTransform(newTransform); //m_originalBody->setCompanionId(-1); } - m_deltaLinearVelocity.setZero(); - m_deltaAngularVelocity .setZero(); - m_pushVelocity.setZero(); - m_turnVelocity.setZero(); +// m_deltaLinearVelocity.setZero(); +// m_deltaAngularVelocity .setZero(); +// m_pushVelocity.setZero(); +// m_turnVelocity.setZero(); } diff --git a/src/BulletDynamics/Dynamics/btRigidBody.h b/src/BulletDynamics/Dynamics/btRigidBody.h index 571a30ce6..7034a8219 100644 --- a/src/BulletDynamics/Dynamics/btRigidBody.h +++ b/src/BulletDynamics/Dynamics/btRigidBody.h @@ -519,6 +519,26 @@ public: return m_rigidbodyFlags; } + const btVector3& getDeltaLinearVelocity() const + { + return m_deltaLinearVelocity; + } + + const btVector3& getDeltaAngularVelocity() const + { + return m_deltaAngularVelocity; + } + + const btVector3& getPushVelocity() const + { + return m_pushVelocity; + } + + const btVector3& getTurnVelocity() const + { + return m_turnVelocity; + } + //////////////////////////////////////////////// ///some internal methods, don't use them @@ -589,8 +609,8 @@ public: { setLinearVelocity(getLinearVelocity()+ m_deltaLinearVelocity); setAngularVelocity(getAngularVelocity()+m_deltaAngularVelocity); - m_deltaLinearVelocity.setZero(); - m_deltaAngularVelocity .setZero(); + //m_deltaLinearVelocity.setZero(); + //m_deltaAngularVelocity .setZero(); //m_originalBody->setCompanionId(-1); } } diff --git a/src/BulletMultiThreaded/MiniCL.cpp b/src/BulletMultiThreaded/MiniCL.cpp index b7f5a6993..129ee2734 100644 --- a/src/BulletMultiThreaded/MiniCL.cpp +++ b/src/BulletMultiThreaded/MiniCL.cpp @@ -28,6 +28,60 @@ subject to the following restrictions: //#define DEBUG_MINICL_KERNELS 1 +static char* spPlatformID = "MiniCL, SCEA"; + +CL_API_ENTRY cl_int CL_API_CALL clGetPlatformIDs( + cl_uint num_entries, + cl_platform_id * platforms, + cl_uint * num_platforms ) CL_API_SUFFIX__VERSION_1_0 +{ + if(platforms != NULL) + { + if(num_entries <= 0) + { + return CL_INVALID_VALUE; + } + *((char**)platforms) = spPlatformID; + } + if(num_platforms != NULL) + { + *num_platforms = 1; + } + return CL_SUCCESS; +} + + +CL_API_ENTRY cl_int CL_API_CALL clGetPlatformInfo( + cl_platform_id platform, + cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0 +{ + char* pId = (char*)platform; + if(strcmp(pId, spPlatformID)) + { + return CL_INVALID_PLATFORM; + } + switch(param_name) + { + case CL_PLATFORM_VENDOR : + if(param_value_size < (strlen(spPlatformID) + 1)) + { + return CL_INVALID_VALUE; + } + strcpy((char*)param_value, spPlatformID); + if(param_value_size_ret != NULL) + { + *param_value_size_ret = strlen(spPlatformID) + 1; + } + break; + default : + return CL_INVALID_VALUE; + } + return CL_SUCCESS; +} + @@ -262,7 +316,7 @@ static void* localBufMalloc(int size) if((sLocalBufUsed + size16) > LOCAL_BUF_SIZE) { // reset spLocalBufCurr = sLocalMemBuf; - while((long)spLocalBufCurr & 0x0F) spLocalBufCurr++; // align to 16 bytes + while((int)spLocalBufCurr & 0x0F) spLocalBufCurr++; // align to 16 bytes sLocalBufUsed = 0; } void* ret = spLocalBufCurr; @@ -487,8 +541,11 @@ CL_API_ENTRY cl_int CL_API_CALL clReleaseContext(cl_context context ) CL_API_SU return 0; } extern CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0 +clFinish(cl_command_queue command_queue ) CL_API_SUFFIX__VERSION_1_0 { + MiniCLTaskScheduler* scheduler = (MiniCLTaskScheduler*) command_queue; + ///wait for all work items to be completed + scheduler->flush(); return CL_SUCCESS; }