Add support for childshape index for btCompoundShape during ContactAddedCallback,
see example in Bullet/Demos/ConvexDecompositionDemo Removed some warnings
This commit is contained in:
@@ -66,7 +66,7 @@ int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size)
|
||||
|
||||
ATTRIBUTE_ALIGNED16(char tmpBuffer[32]);
|
||||
|
||||
char* mainMem = (char*)ea;
|
||||
|
||||
char* localStore = (char*)ls;
|
||||
uint32_t i;
|
||||
|
||||
@@ -126,8 +126,10 @@ int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size)
|
||||
#endif//FORCE_cellDmaUnalignedGet
|
||||
|
||||
#else
|
||||
char* mainMem = (char*)ea;
|
||||
//copy into final destination
|
||||
#ifdef USE_MEMCPY
|
||||
|
||||
memcpy(tmpTarget,mainMem,size);
|
||||
#else
|
||||
for ( i=0;i<size;i++)
|
||||
|
||||
@@ -77,7 +77,6 @@ struct bvhMeshShape_LocalStoreMemory
|
||||
};
|
||||
|
||||
|
||||
btVector3 localGetSupportingVertexWithoutMargin(int shapeType, void* shape, const btVector3& localDir,struct SpuConvexPolyhedronVertexData* convexVertexData);//, int *featureIndex)
|
||||
void computeAabb (btVector3& aabbMin, btVector3& aabbMax, btConvexInternalShape* convexShape, ppu_address_t convexShapePtr, int shapeType, const btTransform& xform);
|
||||
void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangleMeshShape* triMeshShape);
|
||||
void dmaBvhIndexedMesh (btIndexedMesh* IndexMesh, IndexedMeshArray& indexArray, int index, uint32_t dmaTag);
|
||||
|
||||
@@ -65,11 +65,16 @@ inline btScalar calculateCombinedRestitution(btScalar restitution0,btScalar rest
|
||||
m_isSwapped = isSwapped;
|
||||
}
|
||||
|
||||
void SpuContactResult::setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
void SpuContactResult::setShapeIdentifiersA(int partId0,int index0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SpuContactResult::setShapeIdentifiersB(int partId1,int index1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
///return true if it requires a dma transfer back
|
||||
@@ -84,7 +89,7 @@ bool ManifoldResultAddContactPoint(const btVector3& normalOnBInWorld,
|
||||
bool isSwapped)
|
||||
{
|
||||
|
||||
float contactTreshold = manifoldPtr->getContactBreakingThreshold();
|
||||
// float contactTreshold = manifoldPtr->getContactBreakingThreshold();
|
||||
|
||||
//spu_printf("SPU: add contactpoint, depth:%f, contactTreshold %f, manifoldPtr %llx\n",depth,contactTreshold,manifoldPtr);
|
||||
|
||||
@@ -174,7 +179,7 @@ void SpuContactResult::writeDoubleBufferedManifold(btPersistentManifold* lsManif
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpuContactResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
||||
void SpuContactResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||
{
|
||||
//spu_printf("*** SpuContactResult::addContactPoint: depth = %f\n",depth);
|
||||
|
||||
|
||||
@@ -87,14 +87,15 @@ class SpuContactResult : public btDiscreteCollisionDetectorInterface::Result
|
||||
return m_spuManifold;
|
||||
}
|
||||
|
||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1);
|
||||
virtual void setShapeIdentifiersA(int partId0,int index0);
|
||||
virtual void setShapeIdentifiersB(int partId1,int index1);
|
||||
|
||||
void setContactInfo(btPersistentManifold* spuManifold, ppu_address_t manifoldAddress,const btTransform& worldTrans0,const btTransform& worldTrans1, btScalar restitution0,btScalar restitution1, btScalar friction0,btScalar friction01, bool isSwapped);
|
||||
|
||||
|
||||
void writeDoubleBufferedManifold(btPersistentManifold* lsManifold, btPersistentManifold* mmManifold);
|
||||
|
||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);
|
||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
|
||||
|
||||
void flush();
|
||||
};
|
||||
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
triangleConcaveInput.m_spuCollisionShapes[1] = &tmpTriangleShape;
|
||||
triangleConcaveInput.m_shapeType1 = TRIANGLE_SHAPE_PROXYTYPE;
|
||||
|
||||
m_spuContacts.setShapeIdentifiers(-1,-1,subPart,triangleIndex);
|
||||
m_spuContacts.setShapeIdentifiersB(subPart,triangleIndex);
|
||||
|
||||
// m_spuContacts.flush();
|
||||
|
||||
@@ -1100,9 +1100,13 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
{
|
||||
SpuContactResult& m_spuContacts;
|
||||
|
||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
virtual void setShapeIdentifiersA(int partId0,int index0)
|
||||
{
|
||||
m_spuContacts.setShapeIdentifiers(partId0,index0,partId1,index1);
|
||||
m_spuContacts.setShapeIdentifiersA(partId0,index0);
|
||||
}
|
||||
virtual void setShapeIdentifiersB(int partId1,int index1)
|
||||
{
|
||||
m_spuContacts.setShapeIdentifiersB(partId1,index1);
|
||||
}
|
||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||
{
|
||||
|
||||
@@ -93,10 +93,14 @@ bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& s
|
||||
btScalar m_depth;
|
||||
bool m_hasResult;
|
||||
|
||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
virtual void setShapeIdentifiersA(int partId0,int index0)
|
||||
{
|
||||
(void)partId0;
|
||||
(void)index0;
|
||||
}
|
||||
|
||||
virtual void setShapeIdentifiersB(int partId1,int index1)
|
||||
{
|
||||
(void)partId1;
|
||||
(void)index1;
|
||||
}
|
||||
@@ -111,7 +115,7 @@ bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& s
|
||||
|
||||
//just take fixed number of orientation, and sample the penetration depth in that direction
|
||||
btScalar minProj = btScalar(BT_LARGE_FLOAT);
|
||||
btVector3 minNorm;
|
||||
btVector3 minNorm(0.f,0.f,0.f);
|
||||
btVector3 minVertex;
|
||||
btVector3 minA,minB;
|
||||
btVector3 seperatingAxisInA,seperatingAxisInB;
|
||||
@@ -240,8 +244,8 @@ bool SpuMinkowskiPenetrationDepthSolver::calcPenDepth( btVoronoiSimplexSolver& s
|
||||
seperatingAxisInA = (-norm)* transA.getBasis();
|
||||
seperatingAxisInB = norm* transB.getBasis();
|
||||
|
||||
pInA = localGetSupportingVertexWithoutMargin(shapeTypeA, convexA, seperatingAxisInA,convexVertexDataA);//, NULL);
|
||||
qInB = localGetSupportingVertexWithoutMargin(shapeTypeB, convexB, seperatingAxisInB,convexVertexDataB);//, NULL);
|
||||
pInA = convexA->localGetSupportVertexWithoutMarginNonVirtual( seperatingAxisInA);//, NULL);
|
||||
qInB = convexB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB);//, NULL);
|
||||
|
||||
// pInA = convexA->localGetSupportingVertexWithoutMargin(seperatingAxisInA);
|
||||
// qInB = convexB->localGetSupportingVertexWithoutMargin(seperatingAxisInB);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "../SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h"
|
||||
#include "SpuSubSimplexConvexCast.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
||||
|
||||
|
||||
/* Future optimization strategies:
|
||||
@@ -79,7 +80,7 @@ void GatherCollisionObjectAndShapeData (RaycastGatheredObjectData* gatheredObjec
|
||||
gatheredObjectData->m_collisionMargin = lsMemPtr->getCollisionObjectWrapper()->getCollisionMargin ();
|
||||
gatheredObjectData->m_shapeType = lsMemPtr->getCollisionObjectWrapper()->getShapeType ();
|
||||
gatheredObjectData->m_collisionShape = (ppu_address_t)lsMemPtr->getColObj()->getCollisionShape();
|
||||
gatheredObjectData->m_spuCollisionShape = (void*)&lsMemPtr->gCollisionShape.collisionShape;
|
||||
gatheredObjectData->m_spuCollisionShape = (btConvexShape*)&lsMemPtr->gCollisionShape.collisionShape;
|
||||
|
||||
/* DMA shape data */
|
||||
dmaCollisionShape (gatheredObjectData->m_spuCollisionShape, gatheredObjectData->m_collisionShape, 1, gatheredObjectData->m_shapeType);
|
||||
@@ -254,7 +255,8 @@ public:
|
||||
|
||||
RaycastGatheredObjectData triangleGatheredObjectData (*m_gatheredObjectData);
|
||||
triangleGatheredObjectData.m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
|
||||
triangleGatheredObjectData.m_spuCollisionShape = &spuTriangleVertices[0];
|
||||
btTriangleShape triangle(spuTriangleVertices[0],spuTriangleVertices[1],spuTriangleVertices[2]);
|
||||
triangleGatheredObjectData.m_spuCollisionShape = ▵
|
||||
|
||||
//printf("%f %f %f\n", spuTriangleVertices[0][0],spuTriangleVertices[0][1],spuTriangleVertices[0][2]);
|
||||
//printf("%f %f %f\n", spuTriangleVertices[1][0],spuTriangleVertices[1][1],spuTriangleVertices[1][2]);
|
||||
@@ -361,7 +363,8 @@ public:
|
||||
|
||||
RaycastGatheredObjectData triangleGatheredObjectData (*m_gatheredObjectData);
|
||||
triangleGatheredObjectData.m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
|
||||
triangleGatheredObjectData.m_spuCollisionShape = &spuTriangleVertices[0];
|
||||
btTriangleShape triangle(spuTriangleVertices[0],spuTriangleVertices[1],spuTriangleVertices[2]);
|
||||
triangleGatheredObjectData.m_spuCollisionShape = ▵
|
||||
|
||||
//printf("%f %f %f\n", spuTriangleVertices[0][0],spuTriangleVertices[0][1],spuTriangleVertices[0][2]);
|
||||
//printf("%f %f %f\n", spuTriangleVertices[1][0],spuTriangleVertices[1][1],spuTriangleVertices[1][2]);
|
||||
@@ -395,7 +398,7 @@ void spuWalkStacklessQuantizedTreeAgainstRays(RaycastTask_LocalStoreMemory* lsMe
|
||||
{
|
||||
int curIndex = startNodeIndex;
|
||||
int walkIterations = 0;
|
||||
int subTreeSize = endNodeIndex - startNodeIndex;
|
||||
//int subTreeSize = endNodeIndex - startNodeIndex;
|
||||
|
||||
int escapeIndex;
|
||||
|
||||
@@ -503,8 +506,8 @@ void spuWalkStacklessQuantizedTreeAgainstRays(RaycastTask_LocalStoreMemory* lsMe
|
||||
void performRaycastAgainstConcave (RaycastGatheredObjectData* gatheredObjectData, const SpuRaycastTaskWorkUnit* workUnits, SpuRaycastTaskWorkUnitOut* workUnitsOut, int numWorkUnits, RaycastTask_LocalStoreMemory* lsMemPtr)
|
||||
{
|
||||
//order: first collision shape is convex, second concave. m_isSwapped is true, if the original order was opposite
|
||||
register int dmaSize;
|
||||
register ppu_address_t dmaPpuAddress2;
|
||||
// register int dmaSize;
|
||||
// register ppu_address_t dmaPpuAddress2;
|
||||
|
||||
|
||||
btBvhTriangleMeshShape* trimeshShape = (btBvhTriangleMeshShape*)gatheredObjectData->m_spuCollisionShape;
|
||||
@@ -632,7 +635,7 @@ void performRaycastAgainstCompound (RaycastGatheredObjectData* gatheredObjectDat
|
||||
void
|
||||
performRaycastAgainstConvex (RaycastGatheredObjectData* gatheredObjectData, const SpuRaycastTaskWorkUnit& workUnit, SpuRaycastTaskWorkUnitOut* workUnitOut, RaycastTask_LocalStoreMemory* lsMemPtr)
|
||||
{
|
||||
SpuVoronoiSimplexSolver simplexSolver;
|
||||
btVoronoiSimplexSolver simplexSolver;
|
||||
|
||||
btTransform rayFromTrans, rayToTrans;
|
||||
rayFromTrans.setIdentity ();
|
||||
@@ -660,7 +663,7 @@ performRaycastAgainstConvex (RaycastGatheredObjectData* gatheredObjectData, cons
|
||||
}
|
||||
|
||||
/* performRaycast */
|
||||
SpuSubsimplexRayCast caster (gatheredObjectData->m_spuCollisionShape, &lsMemPtr->convexVertexData, gatheredObjectData->m_shapeType, gatheredObjectData->m_collisionMargin, &simplexSolver);
|
||||
SpuSubsimplexRayCast caster ((btConvexShape*)gatheredObjectData->m_spuCollisionShape, &lsMemPtr->convexVertexData, gatheredObjectData->m_shapeType, gatheredObjectData->m_collisionMargin, &simplexSolver);
|
||||
bool r = caster.calcTimeOfImpact (rayFromTrans, rayToTrans, gatheredObjectData->m_worldTransform, gatheredObjectData->m_worldTransform,result);
|
||||
|
||||
if (r)
|
||||
@@ -682,7 +685,7 @@ void processRaycastTask(void* userPtr, void* lsMemory)
|
||||
//spu_printf("in processRaycastTask %d\n", taskDesc.numSpuCollisionObjectWrappers);
|
||||
/* for each object */
|
||||
RaycastGatheredObjectData gatheredObjectData;
|
||||
for (int objectId = 0; objectId < taskDesc.numSpuCollisionObjectWrappers; objectId++)
|
||||
for (unsigned int objectId = 0; objectId < taskDesc.numSpuCollisionObjectWrappers; objectId++)
|
||||
{
|
||||
//spu_printf("%d / %d\n", objectId, taskDesc.numSpuCollisionObjectWrappers);
|
||||
|
||||
@@ -692,14 +695,15 @@ void processRaycastTask(void* userPtr, void* lsMemory)
|
||||
if (btBroadphaseProxy::isConcave (gatheredObjectData.m_shapeType))
|
||||
{
|
||||
SpuRaycastTaskWorkUnitOut tWorkUnitsOut[SPU_RAYCAST_WORK_UNITS_PER_TASK];
|
||||
for (int rayId = 0; rayId < taskDesc.numWorkUnits; rayId++)
|
||||
unsigned int rayId ;
|
||||
for (rayId = 0; rayId < taskDesc.numWorkUnits; rayId++)
|
||||
{
|
||||
tWorkUnitsOut[rayId].hitFraction = 1.0;
|
||||
}
|
||||
|
||||
performRaycastAgainstConcave (&gatheredObjectData, &taskDesc.workUnits[0], &tWorkUnitsOut[0], taskDesc.numWorkUnits, localMemory);
|
||||
|
||||
for (int rayId = 0; rayId < taskDesc.numWorkUnits; rayId++)
|
||||
for (rayId = 0; rayId < taskDesc.numWorkUnits; rayId++)
|
||||
{
|
||||
const SpuRaycastTaskWorkUnit& workUnit = taskDesc.workUnits[rayId];
|
||||
if (tWorkUnitsOut[rayId].hitFraction == 1.0)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
ATTRIBUTE_ALIGNED16(struct) RaycastGatheredObjectData
|
||||
{
|
||||
ppu_address_t m_collisionShape;
|
||||
void* m_spuCollisionShape;
|
||||
btCollisionShape* m_spuCollisionShape;
|
||||
btVector3 m_primitiveDimensions;
|
||||
int m_shapeType;
|
||||
float m_collisionMargin;
|
||||
|
||||
@@ -21,8 +21,8 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
|
||||
|
||||
|
||||
SpuSubsimplexRayCast::SpuSubsimplexRayCast (void* shapeB, SpuConvexPolyhedronVertexData* convexDataB, int shapeTypeB, float marginB,
|
||||
SpuVoronoiSimplexSolver* simplexSolver)
|
||||
SpuSubsimplexRayCast::SpuSubsimplexRayCast (btConvexShape* shapeB, SpuConvexPolyhedronVertexData* convexDataB, int shapeTypeB, float marginB,
|
||||
btVoronoiSimplexSolver* simplexSolver)
|
||||
:m_simplexSolver(simplexSolver), m_shapeB(shapeB), m_convexDataB(convexDataB), m_shapeTypeB(shapeTypeB), m_marginB(marginB)
|
||||
{
|
||||
}
|
||||
@@ -42,8 +42,7 @@ SpuSubsimplexRayCast::SpuSubsimplexRayCast (void* shapeB, SpuConvexPolyhedronVer
|
||||
void supportPoints (const btTransform& xformRay,
|
||||
const btTransform& xformB,
|
||||
const int shapeType,
|
||||
const void* shape,
|
||||
SpuConvexPolyhedronVertexData* convexVertexData,
|
||||
const btConvexShape* shape,
|
||||
const btScalar marginB,
|
||||
const btVector3& seperatingAxis,
|
||||
btVector3& w,
|
||||
@@ -54,7 +53,7 @@ void supportPoints (const btTransform& xformRay,
|
||||
saUnit.normalize();
|
||||
btVector3 SupportPellet = xformRay(0.0001 * -saUnit);
|
||||
btVector3 rotatedSeperatingAxis = seperatingAxis * xformB.getBasis();
|
||||
btVector3 SupportShape = xformB(localGetSupportingVertexWithoutMargin(shapeType, (void*)shape, rotatedSeperatingAxis, convexVertexData));
|
||||
btVector3 SupportShape = shape->localGetSupportVertexWithoutMarginNonVirtual(rotatedSeperatingAxis);
|
||||
SupportShape += saUnit * marginB;
|
||||
w = SupportPellet - SupportShape;
|
||||
supVertexRay = SupportPellet;
|
||||
@@ -82,7 +81,7 @@ bool SpuSubsimplexRayCast::calcTimeOfImpact(const btTransform& fromRay,
|
||||
btVector3 supVertexRay;
|
||||
btVector3 supVertexB;
|
||||
btVector3 v;
|
||||
supportPoints (fromRay, fromB, m_shapeTypeB, m_shapeB, m_convexDataB, m_marginB, r, v, supVertexRay, supVertexB);
|
||||
supportPoints (fromRay, fromB, m_shapeTypeB, m_shapeB, m_marginB, r, v, supVertexRay, supVertexB);
|
||||
|
||||
btVector3 n;
|
||||
n.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
|
||||
@@ -104,7 +103,7 @@ bool SpuSubsimplexRayCast::calcTimeOfImpact(const btTransform& fromRay,
|
||||
|
||||
while ( (dist2 > epsilon) && maxIter--)
|
||||
{
|
||||
supportPoints (interpolatedTransRay, interpolatedTransB, m_shapeTypeB, m_shapeB, m_convexDataB, m_marginB, v, w, supVertexRay, supVertexB);
|
||||
supportPoints (interpolatedTransRay, interpolatedTransB, m_shapeTypeB, m_shapeB, m_marginB, v, w, supVertexRay, supVertexB);
|
||||
|
||||
btScalar VdotW = v.dot(w);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
||||
#ifndef SPU_SUBSIMPLEX_RAY_CAST_H
|
||||
#define SPU_SUBSIMPLEX_RAY_CAST_H
|
||||
|
||||
#include "../SpuNarrowPhaseCollisionTask/SpuVoronoiSimplexSolver.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
|
||||
#include "../SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h"
|
||||
#include "SpuRaycastTask.h"
|
||||
|
||||
@@ -35,15 +35,15 @@ struct SpuCastResult
|
||||
/// Objects should not start in overlap, otherwise results are not defined.
|
||||
class SpuSubsimplexRayCast
|
||||
{
|
||||
SpuVoronoiSimplexSolver* m_simplexSolver;
|
||||
void* m_shapeB;
|
||||
btVoronoiSimplexSolver* m_simplexSolver;
|
||||
btConvexShape* m_shapeB;
|
||||
SpuConvexPolyhedronVertexData* m_convexDataB;
|
||||
int m_shapeTypeB;
|
||||
float m_marginB;
|
||||
|
||||
public:
|
||||
SpuSubsimplexRayCast (void* shapeB, SpuConvexPolyhedronVertexData* convexDataB, int shapeTypeB, float marginB,
|
||||
SpuVoronoiSimplexSolver* simplexSolver);
|
||||
SpuSubsimplexRayCast (btConvexShape* shapeB, SpuConvexPolyhedronVertexData* convexDataB, int shapeTypeB, float marginB,
|
||||
btVoronoiSimplexSolver* simplexSolver);
|
||||
|
||||
//virtual ~btSubsimplexConvexCast();
|
||||
|
||||
|
||||
@@ -714,7 +714,7 @@ static float computeJacobianInverse (const btRigidBody* rb0, const btRigidBody*
|
||||
|
||||
return 1.0f/jacobian;
|
||||
}
|
||||
|
||||
/*
|
||||
static float computeAngularJacobianInverse (const btRigidBody* rb0, const btRigidBody* rb1,
|
||||
const btVector3& normal)
|
||||
{
|
||||
@@ -724,7 +724,7 @@ static float computeAngularJacobianInverse (const btRigidBody* rb0, const btRigi
|
||||
return 1.0f/jacobian;
|
||||
}
|
||||
|
||||
/*static void setupLinearConstraintWorld (btSolverConstraint& constraint, const btRigidBody* rb0, const btRigidBody* rb1,
|
||||
static void setupLinearConstraintWorld (btSolverConstraint& constraint, const btRigidBody* rb0, const btRigidBody* rb1,
|
||||
const btVector3& anchorAinW, const btVector3& anchorBinW, const btContactSolverInfoData& solverInfo)
|
||||
{
|
||||
btVector3 relPos1 = anchorAinW - rb0->getCenterOfMassPosition();
|
||||
|
||||
Reference in New Issue
Block a user