Minor changes to SpuBatchRaycaster

Add DISABLE_CELL_DMA_GET_READ_ONLY define to SpuCollisionShapes
This commit is contained in:
john.mccutchan
2008-03-28 19:10:46 +00:00
parent ce0075c96f
commit 1464097327
3 changed files with 56 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ subject to the following restrictions:
*/ */
#include <new> #include <new>
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
#include "LinearMath/btAlignedAllocator.h" #include "LinearMath/btAlignedAllocator.h"
#include "SpuBatchRaycaster.h" #include "SpuBatchRaycaster.h"
@@ -55,10 +56,57 @@ SpuBatchRaycaster::setCollisionObjects (btCollisionObjectArray& castUponObjects,
} }
void void
SpuBatchRaycaster::addRay (const btVector3& rayFrom, const btVector3& rayTo) SpuBatchRaycaster::setCollisionObjectsSkipPE (btCollisionObjectArray& castUponObjects, int numCastUponObjects)
{
if (castUponObjectWrappers)
{
btAlignedFree (castUponObjectWrappers);
castUponObjectWrappers = NULL;
}
int numNonPEShapes = 0;
for (int i = 0; i < numCastUponObjects; i++)
{
const btCollisionShape* shape = castUponObjects[i]->getCollisionShape();
if (shape->getShapeType () == BOX_SHAPE_PROXYTYPE ||
shape->getShapeType () == SPHERE_SHAPE_PROXYTYPE ||
shape->getShapeType () == CAPSULE_SHAPE_PROXYTYPE)
{
continue;
}
numNonPEShapes++;
}
castUponObjectWrappers = (SpuCollisionObjectWrapper*)btAlignedAlloc (sizeof(SpuCollisionObjectWrapper) * numNonPEShapes,16);
numCastUponObjectWrappers = numNonPEShapes;
int index = 0;
for (int i = 0; i < numCastUponObjects; i++)
{
const btCollisionShape* shape = castUponObjects[i]->getCollisionShape();
if (shape->getShapeType () == BOX_SHAPE_PROXYTYPE ||
shape->getShapeType () == SPHERE_SHAPE_PROXYTYPE ||
shape->getShapeType () == CAPSULE_SHAPE_PROXYTYPE)
{
continue;
}
castUponObjectWrappers[index] = SpuCollisionObjectWrapper(castUponObjects[i]);
index++;
}
printf("Number of shapes bullet is casting against: %d\n", numNonPEShapes);
btAssert (index == numNonPEShapes);
}
void
SpuBatchRaycaster::addRay (const btVector3& rayFrom, const btVector3& rayTo, const btScalar hitFraction)
{ {
SpuRaycastTaskWorkUnitOut workUnitOut; SpuRaycastTaskWorkUnitOut workUnitOut;
workUnitOut.hitFraction = 1.0; workUnitOut.hitFraction = hitFraction;
workUnitOut.hitNormal = btVector3(0.0, 1.0, 0.0); workUnitOut.hitNormal = btVector3(0.0, 1.0, 0.0);
rayBatchOutput.push_back (workUnitOut); rayBatchOutput.push_back (workUnitOut);

View File

@@ -38,8 +38,8 @@ public:
SpuBatchRaycaster (class btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks); SpuBatchRaycaster (class btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks);
~SpuBatchRaycaster (); ~SpuBatchRaycaster ();
void setCollisionObjects (btCollisionObjectArray& castUponObjects, int numCastUponObjects); void setCollisionObjects (btCollisionObjectArray& castUponObjects, int numCastUponObjects);
void setCollisionObjectsSkipPE (btCollisionObjectArray& castUponObjects, int numCastUponObjects);
void addRay (const btVector3& rayFrom, const btVector3& rayTo); void addRay (const btVector3& rayFrom, const btVector3& rayTo, const btScalar hitFraction = 1.0);
void clearRays (); void clearRays ();
void performBatchRaycast (); void performBatchRaycast ();
const SpuRaycastTaskWorkUnitOut& operator [] (int i) const; const SpuRaycastTaskWorkUnitOut& operator [] (int i) const;

View File

@@ -298,7 +298,11 @@ void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangle
dmaSize = sizeof(btTriangleIndexVertexArray); dmaSize = sizeof(btTriangleIndexVertexArray);
dmaPpuAddress2 = reinterpret_cast<ppu_address_t>(triMeshShape->getMeshInterface()); dmaPpuAddress2 = reinterpret_cast<ppu_address_t>(triMeshShape->getMeshInterface());
// spu_printf("trimeshShape->getMeshInterface() == %llx\n",dmaPpuAddress2); // spu_printf("trimeshShape->getMeshInterface() == %llx\n",dmaPpuAddress2);
#ifdef DISABLE_CELL_DMA_GET_READ_ONLY // needed for PE ray caster
cellDmaGet(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
#else
bvhMeshShape->gTriangleMeshInterfacePtr = (btTriangleIndexVertexArray*)cellDmaGetReadOnly(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0); bvhMeshShape->gTriangleMeshInterfacePtr = (btTriangleIndexVertexArray*)cellDmaGetReadOnly(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
#endif
//cellDmaWaitTagStatusAll(DMA_MASK(1)); //cellDmaWaitTagStatusAll(DMA_MASK(1));
///now DMA over the BVH ///now DMA over the BVH