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:
@@ -23,8 +23,10 @@ subject to the following restrictions:
|
||||
#endif
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
@@ -34,22 +34,23 @@ subject to the following restrictions:
|
||||
|
||||
#define MAX_NUM_SPU_CONVEX_POINTS 128
|
||||
|
||||
struct SpuConvexPolyhedronVertexData
|
||||
ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData
|
||||
{
|
||||
void* gSpuConvexShapePtr;
|
||||
btVector3* gConvexPoints;
|
||||
int gNumConvexPoints;
|
||||
int unused;
|
||||
ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]);
|
||||
};
|
||||
|
||||
#define MAX_SHAPE_SIZE 256
|
||||
|
||||
struct CollisionShape_LocalStoreMemory
|
||||
ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory
|
||||
{
|
||||
ATTRIBUTE_ALIGNED16(char collisionShape[MAX_SHAPE_SIZE]);
|
||||
};
|
||||
|
||||
struct CompoundShape_LocalStoreMemory
|
||||
ATTRIBUTE_ALIGNED16(struct) CompoundShape_LocalStoreMemory
|
||||
{
|
||||
// Compound data
|
||||
#define MAX_SPU_COMPOUND_SUBSHAPES 16
|
||||
@@ -57,7 +58,7 @@ struct CompoundShape_LocalStoreMemory
|
||||
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(char gOptimizedBvh[sizeof(btOptimizedBvh)+16]);
|
||||
|
||||
@@ -22,13 +22,13 @@ subject to the following restrictions:
|
||||
|
||||
class btStackAlloc;
|
||||
class btIDebugDraw;
|
||||
class SpuVoronoiSimplexSolver;
|
||||
#include "BulletCollision/NarrowphaseCollision/btConvexPenetrationDepthSolver.h"
|
||||
|
||||
#include <LinearMath/btTransform.h>
|
||||
|
||||
|
||||
///ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
|
||||
class SpuConvexPenetrationDepthSolver
|
||||
class SpuConvexPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -273,11 +273,13 @@ SIMD_FORCE_INLINE void small_cache_read_triple( void* ls0, ppu_address_t ea0,
|
||||
|
||||
|
||||
|
||||
|
||||
class spuNodeCallback : public btNodeOverlapCallback
|
||||
{
|
||||
SpuCollisionPairInput* m_wuInput;
|
||||
SpuContactResult& m_spuContacts;
|
||||
CollisionTask_LocalStoreMemory* m_lsMemPtr;
|
||||
ATTRIBUTE_ALIGNED16(btTriangleShape) m_tmpTriangleShape;
|
||||
|
||||
ATTRIBUTE_ALIGNED16(btVector3 spuTriangleVertices[3]);
|
||||
ATTRIBUTE_ALIGNED16(btScalar spuUnscaledVertex[4]);
|
||||
@@ -345,8 +347,7 @@ public:
|
||||
&spuUnscaledVertex[2],(ppu_address_t)&graphicsbasePtr[2],
|
||||
sizeof(btScalar));
|
||||
|
||||
spuTriangleVertices[j] = btVector3(
|
||||
spuUnscaledVertex[0]*meshScaling.getX(),
|
||||
m_tmpTriangleShape.getVertexPtr(j).setValue(spuUnscaledVertex[0]*meshScaling.getX(),
|
||||
spuUnscaledVertex[1]*meshScaling.getY(),
|
||||
spuUnscaledVertex[2]*meshScaling.getZ());
|
||||
|
||||
@@ -354,13 +355,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
ATTRIBUTE_ALIGNED16(btTriangleShape) tmpTriangleShape(spuTriangleVertices[0],spuTriangleVertices[1],spuTriangleVertices[2]);
|
||||
|
||||
|
||||
SpuCollisionPairInput triangleConcaveInput(*m_wuInput);
|
||||
// triangleConcaveInput.m_spuCollisionShapes[1] = &spuTriangleVertices[0];
|
||||
triangleConcaveInput.m_spuCollisionShapes[1] = &tmpTriangleShape;
|
||||
triangleConcaveInput.m_spuCollisionShapes[1] = &m_tmpTriangleShape;
|
||||
triangleConcaveInput.m_shapeType1 = TRIANGLE_SHAPE_PROXYTYPE;
|
||||
|
||||
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)
|
||||
@@ -507,22 +507,19 @@ void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTa
|
||||
btVoronoiSimplexSolver simplexSolver;
|
||||
btGjkEpaPenetrationDepthSolver epaPenetrationSolver2;
|
||||
|
||||
btConvexPenetrationDepthSolver* penetrationSolver = (btConvexPenetrationDepthSolver*)&epaPenetrationSolver2;
|
||||
|
||||
#if 0
|
||||
SpuVoronoiSimplexSolver vsSolver;
|
||||
SpuMinkowskiPenetrationDepthSolver minkowskiPenetrationSolver;
|
||||
btConvexPenetrationDepthSolver* penetrationSolver = &epaPenetrationSolver2;
|
||||
|
||||
//SpuMinkowskiPenetrationDepthSolver minkowskiPenetrationSolver;
|
||||
#ifdef ENABLE_EPA
|
||||
SpuEpaPenetrationDepthSolver epaPenetrationSolver;
|
||||
if (gUseEpa)
|
||||
{
|
||||
penetrationSolver = &epaPenetrationSolver;
|
||||
penetrationSolver = &epaPenetrationSolver2;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
penetrationSolver = &minkowskiPenetrationSolver;
|
||||
//penetrationSolver = &minkowskiPenetrationSolver;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
///DMA in the vertices for convex shapes
|
||||
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);
|
||||
gjk.getClosestPoints(cpInput,spuContacts,0);//,debugDraw);
|
||||
|
||||
stats[gjk.m_lastUsedMethod]++;
|
||||
degenerateStats[gjk.m_degenerateSimplex]++;
|
||||
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
btScalar sepDist = gjk.getCachedSeparatingDistance()+spuManifold->getContactBreakingThreshold();
|
||||
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 numOnLastPage = taskDesc.numOnLastPage;
|
||||
|
||||
@@ -1036,7 +1037,6 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
btVector3 normalInB;
|
||||
|
||||
|
||||
|
||||
if (//!gUseEpa &&
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.getConservativeSeparatingDistance()<=0.f
|
||||
@@ -1045,7 +1045,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#define USE_PE_BOX_BOX 1
|
||||
//#define USE_PE_BOX_BOX 1
|
||||
#ifdef USE_PE_BOX_BOX
|
||||
{
|
||||
|
||||
@@ -1163,9 +1163,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
#endif //USE_SEPDISTANCE_UTIL
|
||||
)
|
||||
{
|
||||
handleCollisionPair(collisionPairInput, lsMem, spuContacts,
|
||||
(ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape,
|
||||
(ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
|
||||
handleCollisionPair(collisionPairInput, lsMem, spuContacts, (ppu_address_t)lsMem.getColObj0()->getCollisionShape(), &lsMem.gCollisionShapes[0].collisionShape, (ppu_address_t)lsMem.getColObj1()->getCollisionShape(), &lsMem.gCollisionShapes[1].collisionShape);
|
||||
} else
|
||||
{
|
||||
//spu_printf("boxbox dist = %f\n",distance);
|
||||
|
||||
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
///Task Description for SPU collision detection
|
||||
struct SpuGatherAndProcessPairsTaskDesc
|
||||
{
|
||||
ppu_address_t inPtr;//m_pairArrayPtr;
|
||||
ppu_address_t m_inPairPtr;//m_pairArrayPtr;
|
||||
//mutex variable
|
||||
uint32_t m_someMutexVariableInMainMemory;
|
||||
|
||||
|
||||
@@ -67,16 +67,14 @@ btVector3(btScalar(-0.425323) , btScalar(0.309011),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)v;
|
||||
|
||||
@@ -342,6 +340,8 @@ bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& s
|
||||
//btAssert (false);
|
||||
}
|
||||
return res.m_hasResult;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
||||
#define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H
|
||||
|
||||
|
||||
#include "SpuConvexPenetrationDepthSolver.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
|
||||
|
||||
class btStackAlloc;
|
||||
class btIDebugDraw;
|
||||
@@ -27,18 +27,18 @@ class btConvexShape;
|
||||
|
||||
///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.
|
||||
class SpuMinkowskiPenetrationDepthSolver : public SpuConvexPenetrationDepthSolver
|
||||
class SpuMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
||||
{
|
||||
public:
|
||||
SpuMinkowskiPenetrationDepthSolver() {}
|
||||
virtual ~SpuMinkowskiPenetrationDepthSolver() {};
|
||||
|
||||
virtual bool 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;
|
||||
virtual bool 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
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user