Minor changes to SpuBatchRaycaster
Add DISABLE_CELL_DMA_GET_READ_ONLY define to SpuCollisionShapes
This commit is contained in:
@@ -14,6 +14,7 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||
#include "LinearMath/btAlignedAllocator.h"
|
||||
#include "SpuBatchRaycaster.h"
|
||||
|
||||
@@ -55,10 +56,57 @@ SpuBatchRaycaster::setCollisionObjects (btCollisionObjectArray& castUponObjects,
|
||||
}
|
||||
|
||||
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;
|
||||
workUnitOut.hitFraction = 1.0;
|
||||
workUnitOut.hitFraction = hitFraction;
|
||||
workUnitOut.hitNormal = btVector3(0.0, 1.0, 0.0);
|
||||
|
||||
rayBatchOutput.push_back (workUnitOut);
|
||||
|
||||
@@ -38,8 +38,8 @@ public:
|
||||
SpuBatchRaycaster (class btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks);
|
||||
~SpuBatchRaycaster ();
|
||||
void setCollisionObjects (btCollisionObjectArray& castUponObjects, int numCastUponObjects);
|
||||
|
||||
void addRay (const btVector3& rayFrom, const btVector3& rayTo);
|
||||
void setCollisionObjectsSkipPE (btCollisionObjectArray& castUponObjects, int numCastUponObjects);
|
||||
void addRay (const btVector3& rayFrom, const btVector3& rayTo, const btScalar hitFraction = 1.0);
|
||||
void clearRays ();
|
||||
void performBatchRaycast ();
|
||||
const SpuRaycastTaskWorkUnitOut& operator [] (int i) const;
|
||||
|
||||
@@ -298,7 +298,11 @@ void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangle
|
||||
dmaSize = sizeof(btTriangleIndexVertexArray);
|
||||
dmaPpuAddress2 = reinterpret_cast<ppu_address_t>(triMeshShape->getMeshInterface());
|
||||
// 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);
|
||||
#endif
|
||||
//cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||
|
||||
///now DMA over the BVH
|
||||
|
||||
Reference in New Issue
Block a user