Override btCollisionWorld::addCollisionObject with flags more appropriate for btDynamicsWorld (StaticFilter)

Minor fixes (#ifndef SPU_COLLISION_OBJECT_WRAPPER_H block etc)
Only update 'setNumTasks' when necessary
Revert vectormath.h include (can't resolve conflicts with PS3 SDK, need additional #include path)
This commit is contained in:
erwin.coumans
2009-09-09 22:49:43 +00:00
parent df550730da
commit 659b215a69
17 changed files with 159 additions and 114 deletions

View File

@@ -88,6 +88,8 @@ btCollisionWorld::~btCollisionWorld()
void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
{ {
btAssert(collisionObject);
//check that the object isn't already added //check that the object isn't already added
btAssert( m_collisionObjects.findLinearSearch(collisionObject) == m_collisionObjects.size()); btAssert( m_collisionObjects.findLinearSearch(collisionObject) == m_collisionObjects.size());
@@ -705,7 +707,7 @@ struct btSingleRayCallback : public btBroadphaseRayCallback
void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
{ {
BT_PROFILE("rayTest"); //BT_PROFILE("rayTest");
/// use the broadphase to accelerate the search for objects, based on their aabb /// use the broadphase to accelerate the search for objects, based on their aabb
/// and for each object with ray-aabb overlap, perform an exact ray test /// and for each object with ray-aabb overlap, perform an exact ray test
btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback); btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback);

View File

@@ -32,6 +32,11 @@ public:
return 3; return 3;
} }
btVector3& getVertexPtr(int index)
{
return m_vertices1[index];
}
const btVector3& getVertexPtr(int index) const const btVector3& getVertexPtr(int index) const
{ {
return m_vertices1[index]; return m_vertices1[index];
@@ -77,7 +82,10 @@ public:
} }
btTriangleShape() : btPolyhedralConvexShape ()
{
m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
}
btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape () btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape ()
{ {

View File

@@ -421,6 +421,11 @@ btVector3 btDiscreteDynamicsWorld::getGravity () const
return m_gravity; return m_gravity;
} }
void btDiscreteDynamicsWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
{
btCollisionWorld::addCollisionObject(collisionObject,collisionFilterGroup,collisionFilterMask);
}
void btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject) void btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject)
{ {
btRigidBody* body = btRigidBody::upcast(collisionObject); btRigidBody* body = btRigidBody::upcast(collisionObject);
@@ -436,6 +441,7 @@ void btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body)
btCollisionWorld::removeCollisionObject(body); btCollisionWorld::removeCollisionObject(body);
} }
void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body) void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body)
{ {
if (!body->isStaticOrKinematicObject()) if (!body->isStaticOrKinematicObject())

View File

@@ -124,6 +124,8 @@ public:
virtual btVector3 getGravity () const; virtual btVector3 getGravity () const;
virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::StaticFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
virtual void addRigidBody(btRigidBody* body); virtual void addRigidBody(btRigidBody* body);
virtual void addRigidBody(btRigidBody* body, short group, short mask); virtual void addRigidBody(btRigidBody* body, short group, short mask);

View File

@@ -13,6 +13,9 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef SPU_COLLISION_OBJECT_WRAPPER_H
#define SPU_COLLISION_OBJECT_WRAPPER_H
#include "PlatformDefinitions.h" #include "PlatformDefinitions.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
@@ -33,3 +36,5 @@ public:
ppu_address_t getCollisionObjectPtr () const; ppu_address_t getCollisionObjectPtr () const;
}; };
#endif //SPU_COLLISION_OBJECT_WRAPPER_H

View File

@@ -26,31 +26,34 @@ subject to the following restrictions:
void SpuCollisionTaskProcess::setNumTasks(int maxNumTasks) void SpuCollisionTaskProcess::setNumTasks(int maxNumTasks)
{ {
m_maxNumOutstandingTasks = maxNumTasks; if (m_maxNumOutstandingTasks != maxNumTasks)
m_taskBusy.resize(m_maxNumOutstandingTasks);
m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks);
for (int i = 0; i < m_taskBusy.size(); i++)
{ {
m_taskBusy[i] = false; m_maxNumOutstandingTasks = maxNumTasks;
} m_taskBusy.resize(m_maxNumOutstandingTasks);
m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks);
///re-allocate task memory buffers for (int i = 0; i < m_taskBusy.size(); i++)
if (m_workUnitTaskBuffers != 0) {
{ m_taskBusy[i] = false;
btAlignedFree(m_workUnitTaskBuffers); }
///re-allocate task memory buffers
if (m_workUnitTaskBuffers != 0)
{
btAlignedFree(m_workUnitTaskBuffers);
}
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128);
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*6, 128);
} }
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128);
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*6, 128);
} }
SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks) SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks)
:m_threadInterface(threadInterface), :m_threadInterface(threadInterface),
m_maxNumOutstandingTasks(maxNumOutstandingTasks) m_maxNumOutstandingTasks(0)
{ {
m_workUnitTaskBuffers = (unsigned char *)0; m_workUnitTaskBuffers = (unsigned char *)0;
setNumTasks(maxNumOutstandingTasks); setNumTasks(maxNumOutstandingTasks);
@@ -130,7 +133,7 @@ void SpuCollisionTaskProcess::issueTask2()
// no error checking here... // no error checking here...
// but, currently, event queue can be no larger than NUM_WORKUNIT_TASKS. // but, currently, event queue can be no larger than NUM_WORKUNIT_TASKS.
taskDesc.inPtr = reinterpret_cast<uint64_t>(MIDPHASE_TASK_PTR(m_currentTask)); taskDesc.m_inPairPtr = reinterpret_cast<uint64_t>(MIDPHASE_TASK_PTR(m_currentTask));
taskDesc.taskId = m_currentTask; taskDesc.taskId = m_currentTask;
taskDesc.numPages = m_currentPage+1; taskDesc.numPages = m_currentPage+1;

View File

@@ -74,7 +74,7 @@ class btDispatcher;
///MidphaseWorkUnitInput stores individual primitive versus mesh collision detection input, to be processed by the SPU. ///MidphaseWorkUnitInput stores individual primitive versus mesh collision detection input, to be processed by the SPU.
struct SpuGatherAndProcessWorkUnitInput ATTRIBUTE_ALIGNED16(struct) SpuGatherAndProcessWorkUnitInput
{ {
uint64_t m_pairArrayPtr; uint64_t m_pairArrayPtr;
int m_startIndex; int m_startIndex;
@@ -151,6 +151,7 @@ public:
#define MIDPHASE_WORKUNIT_PAGE_SIZE (16) #define MIDPHASE_WORKUNIT_PAGE_SIZE (16)
//#define MIDPHASE_WORKUNIT_PAGE_SIZE (128)
#define MIDPHASE_NUM_WORKUNIT_PAGES 1 #define MIDPHASE_NUM_WORKUNIT_PAGES 1
#define MIDPHASE_WORKUNIT_TASK_SIZE (MIDPHASE_WORKUNIT_PAGE_SIZE*MIDPHASE_NUM_WORKUNIT_PAGES) #define MIDPHASE_WORKUNIT_TASK_SIZE (MIDPHASE_WORKUNIT_PAGE_SIZE*MIDPHASE_NUM_WORKUNIT_PAGES)

View File

@@ -61,7 +61,10 @@ DoubleBuffer<T,size>::backBufferDmaGet(uint64_t ea, unsigned int numBytes, unsig
{ {
m_dmaPending = true; m_dmaPending = true;
m_dmaTag = tag; m_dmaTag = tag;
m_backBuffer = (T*)cellDmaLargeGetReadOnly(m_backBuffer, ea, numBytes, tag, 0, 0); if (numBytes)
{
m_backBuffer = (T*)cellDmaLargeGetReadOnly(m_backBuffer, ea, numBytes, tag, 0, 0);
}
} }
template<class T, int size> template<class T, int size>

View File

@@ -22,6 +22,7 @@ subject to the following restrictions:
#include "SpuContactManifoldCollisionAlgorithm.h" #include "SpuContactManifoldCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionShapes/btCollisionShape.h" #include "BulletCollision/CollisionShapes/btCollisionShape.h"
#include "LinearMath/btQuickprof.h"
@@ -152,69 +153,81 @@ void SpuGatheringCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPai
{ {
m_maxNumOutstandingTasks = m_threadInterface->getNumTasks(); m_maxNumOutstandingTasks = m_threadInterface->getNumTasks();
if (!m_spuCollisionTaskProcess)
m_spuCollisionTaskProcess = new SpuCollisionTaskProcess(m_threadInterface,m_maxNumOutstandingTasks);
m_spuCollisionTaskProcess->setNumTasks(m_maxNumOutstandingTasks);
// printf("m_maxNumOutstandingTasks =%d\n",m_maxNumOutstandingTasks);
m_spuCollisionTaskProcess->initialize2(dispatchInfo.m_useEpa);
///modified version of btCollisionDispatcher::dispatchAllCollisionPairs:
{ {
btSpuCollisionPairCallback collisionCallback(dispatchInfo,this); BT_PROFILE("processAllOverlappingPairs");
pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher); if (!m_spuCollisionTaskProcess)
m_spuCollisionTaskProcess = new SpuCollisionTaskProcess(m_threadInterface,m_maxNumOutstandingTasks);
m_spuCollisionTaskProcess->setNumTasks(m_maxNumOutstandingTasks);
// printf("m_maxNumOutstandingTasks =%d\n",m_maxNumOutstandingTasks);
m_spuCollisionTaskProcess->initialize2(dispatchInfo.m_useEpa);
///modified version of btCollisionDispatcher::dispatchAllCollisionPairs:
{
btSpuCollisionPairCallback collisionCallback(dispatchInfo,this);
pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher);
}
} }
//send one big batch //send one big batch
int numTotalPairs = pairCache->getNumOverlappingPairs(); int numTotalPairs = pairCache->getNumOverlappingPairs();
btBroadphasePair* pairPtr = pairCache->getOverlappingPairArrayPtr(); btBroadphasePair* pairPtr = pairCache->getOverlappingPairArrayPtr();
int i; int i;
for (i=0;i<numTotalPairs;)
{ {
//Performance Hint: tweak this number during benchmarking BT_PROFILE("addWorkToTask");
static const int pairRange = SPU_BATCHSIZE_BROADPHASE_PAIRS; for (i=0;i<numTotalPairs;)
int endIndex = (i+pairRange) < numTotalPairs ? i+pairRange : numTotalPairs; {
m_spuCollisionTaskProcess->addWorkToTask(pairPtr,i,endIndex); //Performance Hint: tweak this number during benchmarking
i = endIndex; static const int pairRange = SPU_BATCHSIZE_BROADPHASE_PAIRS;
int endIndex = (i+pairRange) < numTotalPairs ? i+pairRange : numTotalPairs;
m_spuCollisionTaskProcess->addWorkToTask(pairPtr,i,endIndex);
i = endIndex;
}
} }
//handle PPU fallback pairs
for (i=0;i<numTotalPairs;i++)
{ {
btBroadphasePair& collisionPair = pairPtr[i]; BT_PROFILE("PPU fallback");
if (collisionPair.m_internalTmpValue == 3) //handle PPU fallback pairs
for (i=0;i<numTotalPairs;i++)
{ {
if (collisionPair.m_algorithm) btBroadphasePair& collisionPair = pairPtr[i];
if (collisionPair.m_internalTmpValue == 3)
{ {
btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject; if (collisionPair.m_algorithm)
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
if (dispatcher->needsCollision(colObj0,colObj1))
{ {
btManifoldResult contactPointResult(colObj0,colObj1); btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{
//discrete collision detection query
collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
} else
{
//continuous collision detection query, time of impact (toi)
btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
if (dispatchInfo.m_timeOfImpact > toi)
dispatchInfo.m_timeOfImpact = toi;
if (dispatcher->needsCollision(colObj0,colObj1))
{
btManifoldResult contactPointResult(colObj0,colObj1);
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{
//discrete collision detection query
collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
} else
{
//continuous collision detection query, time of impact (toi)
btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
if (dispatchInfo.m_timeOfImpact > toi)
dispatchInfo.m_timeOfImpact = toi;
}
} }
} }
} }
} }
} }
{
//make sure all SPU work is done BT_PROFILE("flush2");
m_spuCollisionTaskProcess->flush2(); //make sure all SPU work is done
m_spuCollisionTaskProcess->flush2();
}
} else } else
{ {

View File

@@ -23,8 +23,10 @@ subject to the following restrictions:
#endif #endif
#include <math.h> #include <math.h>
#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h"
//<vectormath_aos.h> //#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h"
#include <vectormath_aos.h>
using namespace Vectormath::Aos; using namespace Vectormath::Aos;

View File

@@ -34,22 +34,23 @@ subject to the following restrictions:
#define MAX_NUM_SPU_CONVEX_POINTS 128 #define MAX_NUM_SPU_CONVEX_POINTS 128
struct SpuConvexPolyhedronVertexData ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData
{ {
void* gSpuConvexShapePtr; void* gSpuConvexShapePtr;
btVector3* gConvexPoints; btVector3* gConvexPoints;
int gNumConvexPoints; int gNumConvexPoints;
int unused;
ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]); ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]);
}; };
#define MAX_SHAPE_SIZE 256 #define MAX_SHAPE_SIZE 256
struct CollisionShape_LocalStoreMemory ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory
{ {
ATTRIBUTE_ALIGNED16(char collisionShape[MAX_SHAPE_SIZE]); ATTRIBUTE_ALIGNED16(char collisionShape[MAX_SHAPE_SIZE]);
}; };
struct CompoundShape_LocalStoreMemory ATTRIBUTE_ALIGNED16(struct) CompoundShape_LocalStoreMemory
{ {
// Compound data // Compound data
#define MAX_SPU_COMPOUND_SUBSHAPES 16 #define MAX_SPU_COMPOUND_SUBSHAPES 16
@@ -57,7 +58,7 @@ struct CompoundShape_LocalStoreMemory
ATTRIBUTE_ALIGNED16(char gSubshapeShape[MAX_SPU_COMPOUND_SUBSHAPES][MAX_SHAPE_SIZE]); ATTRIBUTE_ALIGNED16(char gSubshapeShape[MAX_SPU_COMPOUND_SUBSHAPES][MAX_SHAPE_SIZE]);
}; };
struct bvhMeshShape_LocalStoreMemory ATTRIBUTE_ALIGNED16(struct) bvhMeshShape_LocalStoreMemory
{ {
//ATTRIBUTE_ALIGNED16(btOptimizedBvh gOptimizedBvh); //ATTRIBUTE_ALIGNED16(btOptimizedBvh gOptimizedBvh);
ATTRIBUTE_ALIGNED16(char gOptimizedBvh[sizeof(btOptimizedBvh)+16]); ATTRIBUTE_ALIGNED16(char gOptimizedBvh[sizeof(btOptimizedBvh)+16]);

View File

@@ -22,13 +22,13 @@ subject to the following restrictions:
class btStackAlloc; class btStackAlloc;
class btIDebugDraw; class btIDebugDraw;
class SpuVoronoiSimplexSolver; #include "BulletCollision/NarrowphaseCollision/btConvexPenetrationDepthSolver.h"
#include <LinearMath/btTransform.h> #include <LinearMath/btTransform.h>
///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation. ///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
class SpuConvexPenetrationDepthSolver class SpuConvexPenetrationDepthSolver : public btConvexPenetrationDepthSolver
{ {
public: public:

View File

@@ -273,11 +273,13 @@ SIMD_FORCE_INLINE void small_cache_read_triple( void* ls0, ppu_address_t ea0,
class spuNodeCallback : public btNodeOverlapCallback class spuNodeCallback : public btNodeOverlapCallback
{ {
SpuCollisionPairInput* m_wuInput; SpuCollisionPairInput* m_wuInput;
SpuContactResult& m_spuContacts; SpuContactResult& m_spuContacts;
CollisionTask_LocalStoreMemory* m_lsMemPtr; CollisionTask_LocalStoreMemory* m_lsMemPtr;
ATTRIBUTE_ALIGNED16(btTriangleShape) m_tmpTriangleShape;
ATTRIBUTE_ALIGNED16(btVector3 spuTriangleVertices[3]); ATTRIBUTE_ALIGNED16(btVector3 spuTriangleVertices[3]);
ATTRIBUTE_ALIGNED16(btScalar spuUnscaledVertex[4]); ATTRIBUTE_ALIGNED16(btScalar spuUnscaledVertex[4]);
@@ -345,8 +347,7 @@ public:
&spuUnscaledVertex[2],(ppu_address_t)&graphicsbasePtr[2], &spuUnscaledVertex[2],(ppu_address_t)&graphicsbasePtr[2],
sizeof(btScalar)); sizeof(btScalar));
spuTriangleVertices[j] = btVector3( m_tmpTriangleShape.getVertexPtr(j).setValue(spuUnscaledVertex[0]*meshScaling.getX(),
spuUnscaledVertex[0]*meshScaling.getX(),
spuUnscaledVertex[1]*meshScaling.getY(), spuUnscaledVertex[1]*meshScaling.getY(),
spuUnscaledVertex[2]*meshScaling.getZ()); spuUnscaledVertex[2]*meshScaling.getZ());
@@ -354,13 +355,9 @@ public:
} }
ATTRIBUTE_ALIGNED16(btTriangleShape) tmpTriangleShape(spuTriangleVertices[0],spuTriangleVertices[1],spuTriangleVertices[2]);
SpuCollisionPairInput triangleConcaveInput(*m_wuInput); SpuCollisionPairInput triangleConcaveInput(*m_wuInput);
// triangleConcaveInput.m_spuCollisionShapes[1] = &spuTriangleVertices[0]; // triangleConcaveInput.m_spuCollisionShapes[1] = &spuTriangleVertices[0];
triangleConcaveInput.m_spuCollisionShapes[1] = &tmpTriangleShape; triangleConcaveInput.m_spuCollisionShapes[1] = &m_tmpTriangleShape;
triangleConcaveInput.m_shapeType1 = TRIANGLE_SHAPE_PROXYTYPE; triangleConcaveInput.m_shapeType1 = TRIANGLE_SHAPE_PROXYTYPE;
m_spuContacts.setShapeIdentifiersB(subPart,triangleIndex); m_spuContacts.setShapeIdentifiersB(subPart,triangleIndex);
@@ -479,6 +476,9 @@ void ProcessConvexConcaveSpuCollision(SpuCollisionPairInput* wuInput, CollisionT
} }
int stats[11]={0,0,0,0,0,0,0,0,0,0,0};
int degenerateStats[11]={0,0,0,0,0,0,0,0,0,0,0};
//////////////////////// ////////////////////////
/// Convex versus Convex collision detection (handles collision between sphere, box, cylinder, triangle, cone, convex polyhedron etc) /// Convex versus Convex collision detection (handles collision between sphere, box, cylinder, triangle, cone, convex polyhedron etc)
@@ -507,22 +507,19 @@ void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTa
btVoronoiSimplexSolver simplexSolver; btVoronoiSimplexSolver simplexSolver;
btGjkEpaPenetrationDepthSolver epaPenetrationSolver2; btGjkEpaPenetrationDepthSolver epaPenetrationSolver2;
btConvexPenetrationDepthSolver* penetrationSolver = (btConvexPenetrationDepthSolver*)&epaPenetrationSolver2; btConvexPenetrationDepthSolver* penetrationSolver = &epaPenetrationSolver2;
#if 0 //SpuMinkowskiPenetrationDepthSolver minkowskiPenetrationSolver;
SpuVoronoiSimplexSolver vsSolver;
SpuMinkowskiPenetrationDepthSolver minkowskiPenetrationSolver;
#ifdef ENABLE_EPA #ifdef ENABLE_EPA
SpuEpaPenetrationDepthSolver epaPenetrationSolver;
if (gUseEpa) if (gUseEpa)
{ {
penetrationSolver = &epaPenetrationSolver; penetrationSolver = &epaPenetrationSolver2;
} else } else
#endif #endif
{ {
penetrationSolver = &minkowskiPenetrationSolver; //penetrationSolver = &minkowskiPenetrationSolver;
} }
#endif
///DMA in the vertices for convex shapes ///DMA in the vertices for convex shapes
ATTRIBUTE_ALIGNED16(char convexHullShape0[sizeof(btConvexHullShape)]); ATTRIBUTE_ALIGNED16(char convexHullShape0[sizeof(btConvexHullShape)]);
@@ -616,6 +613,10 @@ void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTa
{ {
btGjkPairDetector gjk(shape0Ptr,shape1Ptr,shapeType0,shapeType1,marginA,marginB,&simplexSolver,penetrationSolver);//&vsSolver,penetrationSolver); btGjkPairDetector gjk(shape0Ptr,shape1Ptr,shapeType0,shapeType1,marginA,marginB,&simplexSolver,penetrationSolver);//&vsSolver,penetrationSolver);
gjk.getClosestPoints(cpInput,spuContacts,0);//,debugDraw); gjk.getClosestPoints(cpInput,spuContacts,0);//,debugDraw);
stats[gjk.m_lastUsedMethod]++;
degenerateStats[gjk.m_degenerateSimplex]++;
#ifdef USE_SEPDISTANCE_UTIL #ifdef USE_SEPDISTANCE_UTIL
btScalar sepDist = gjk.getCachedSeparatingDistance()+spuManifold->getContactBreakingThreshold(); btScalar sepDist = gjk.getCachedSeparatingDistance()+spuManifold->getContactBreakingThreshold();
lsMemPtr->getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(gjk.getCachedSeparatingAxis(),sepDist,wuInput->m_worldTransform0,wuInput->m_worldTransform1); lsMemPtr->getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(gjk.getCachedSeparatingAxis(),sepDist,wuInput->m_worldTransform0,wuInput->m_worldTransform1);
@@ -880,7 +881,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
//////////////////// ////////////////////
ppu_address_t dmaInPtr = taskDesc.inPtr; ppu_address_t dmaInPtr = taskDesc.m_inPairPtr;
unsigned int numPages = taskDesc.numPages; unsigned int numPages = taskDesc.numPages;
unsigned int numOnLastPage = taskDesc.numOnLastPage; unsigned int numOnLastPage = taskDesc.numOnLastPage;
@@ -1036,7 +1037,6 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
btVector3 normalInB; btVector3 normalInB;
if (//!gUseEpa && if (//!gUseEpa &&
#ifdef USE_SEPDISTANCE_UTIL #ifdef USE_SEPDISTANCE_UTIL
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.getConservativeSeparatingDistance()<=0.f lsMem.getlocalCollisionAlgorithm()->m_sepDistance.getConservativeSeparatingDistance()<=0.f
@@ -1045,7 +1045,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
#endif #endif
) )
{ {
#define USE_PE_BOX_BOX 1 //#define USE_PE_BOX_BOX 1
#ifdef USE_PE_BOX_BOX #ifdef USE_PE_BOX_BOX
{ {
@@ -1163,9 +1163,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
#endif //USE_SEPDISTANCE_UTIL #endif //USE_SEPDISTANCE_UTIL
) )
{ {
handleCollisionPair(collisionPairInput, lsMem, spuContacts, handleCollisionPair(collisionPairInput, lsMem, spuContacts, (ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape, (ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
(ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape,
(ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
} else } else
{ {
//spu_printf("boxbox dist = %f\n",distance); //spu_printf("boxbox dist = %f\n",distance);

View File

@@ -23,7 +23,7 @@ subject to the following restrictions:
///Task Description for SPU collision detection ///Task Description for SPU collision detection
struct SpuGatherAndProcessPairsTaskDesc struct SpuGatherAndProcessPairsTaskDesc
{ {
ppu_address_t inPtr;//m_pairArrayPtr; ppu_address_t m_inPairPtr;//m_pairArrayPtr;
//mutex variable //mutex variable
uint32_t m_someMutexVariableInMainMemory; uint32_t m_someMutexVariableInMainMemory;

View File

@@ -67,16 +67,14 @@ btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654)) btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
}; };
bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& simplexSolver,
btConvexShape* convexA,btConvexShape* convexB,int shapeTypeA, int shapeTypeB, float marginA, float marginB,
btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc,
struct SpuConvexPolyhedronVertexData* convexVertexDataA,
struct SpuConvexPolyhedronVertexData* convexVertexDataB
) const
{
bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc)
{
#if 0
(void)stackAlloc; (void)stackAlloc;
(void)v; (void)v;
@@ -342,6 +340,8 @@ bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& s
//btAssert (false); //btAssert (false);
} }
return res.m_hasResult; return res.m_hasResult;
#endif
return false;
} }

View File

@@ -18,7 +18,7 @@ subject to the following restrictions:
#define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H #define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H
#include "SpuConvexPenetrationDepthSolver.h" #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
class btStackAlloc; class btStackAlloc;
class btIDebugDraw; class btIDebugDraw;
@@ -27,18 +27,18 @@ class btConvexShape;
///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation. ///MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation.
///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points. ///Implementation is based on sampling the depth using support mapping, and using GJK step to get the witness points.
class SpuMinkowskiPenetrationDepthSolver : public SpuConvexPenetrationDepthSolver class SpuMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver
{ {
public: public:
SpuMinkowskiPenetrationDepthSolver() {}
virtual ~SpuMinkowskiPenetrationDepthSolver() {};
virtual bool calcPenDepth( btVoronoiSimplexSolver& simplexSolver, virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
btConvexShape* convexA,btConvexShape* convexB,int shapeTypeA, int shapeTypeB, float marginA, float marginB, const btConvexShape* convexA,const btConvexShape* convexB,
btTransform& transA,const btTransform& transB, const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb, btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc, class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
struct SpuConvexPolyhedronVertexData* convexVertexDataA, );
struct SpuConvexPolyhedronVertexData* convexVertexDataB
) const;
}; };

View File

@@ -30,8 +30,9 @@
#ifndef AOS_VECTORMATH_BULLET_CONVERT_H #ifndef AOS_VECTORMATH_BULLET_CONVERT_H
#define AOS_VECTORMATH_BULLET_CONVERT_H #define AOS_VECTORMATH_BULLET_CONVERT_H
//#include <vectormath_aos.h> #include <vectormath_aos.h>
#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h" //#include "BulletMultiThreaded/vectormath/scalar/cpp/vectormath_aos.h"
#include "LinearMath/btVector3.h" #include "LinearMath/btVector3.h"
#include "LinearMath/btQuaternion.h" #include "LinearMath/btQuaternion.h"
#include "LinearMath/btMatrix3x3.h" #include "LinearMath/btMatrix3x3.h"