bt -> b3 and BT -> B3 rename for content and filenames

This commit is contained in:
erwin coumans
2013-04-28 23:11:10 -07:00
parent 6bcb5b9d5f
commit 7366e262fd
178 changed files with 5218 additions and 5218 deletions

View File

@@ -1,8 +1,8 @@
#ifndef BT_COLLIDABLE_H
#define BT_COLLIDABLE_H
#ifndef B3_COLLIDABLE_H
#define B3_COLLIDABLE_H
enum btShapeTypes
enum b3ShapeTypes
{
SHAPE_HEIGHT_FIELD=1,
@@ -25,14 +25,14 @@ struct b3Collidable
int m_shapeIndex;
};
struct btCollidableNew
struct b3CollidableNew
{
short int m_shapeType;
short int m_numShapes;
int m_shapeIndex;
};
struct btGpuChildShape
struct b3GpuChildShape
{
float m_childPosition[4];
float m_childOrientation[4];
@@ -42,7 +42,7 @@ struct btGpuChildShape
int m_unused2;
};
struct btCompoundOverlappingPair
struct b3CompoundOverlappingPair
{
int m_bodyIndexA;
int m_bodyIndexB;
@@ -50,4 +50,4 @@ struct btCompoundOverlappingPair
int m_childShapeIndexA;
int m_childShapeIndexB;
};
#endif //BT_COLLIDABLE_H
#endif //B3_COLLIDABLE_H

View File

@@ -18,19 +18,19 @@ subject to the following restrictions:
///Separating axis rest based on work from Pierre Terdiman, see
///And contact clipping based on work from Simon Hobbs
//#define BT_DEBUG_SAT_FACE
//#define B3_DEBUG_SAT_FACE
#include "b3ConvexHullContact.h"
#include <string.h>//memcpy
#include "b3ConvexPolyhedronCL.h"
typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
typedef b3AlignedObjectArray<b3Vector3> b3VertexArray;
#include "Bullet3Common/b3Quickprof.h"
#include <float.h> //for FLT_MAX
#include "basic_initialize/b3OpenCLUtils.h"
#include "parallel_primitives/host/btLauncherCL.h"
#include "parallel_primitives/host/b3LauncherCL.h"
//#include "AdlQuaternion.h"
#include "../kernels/satKernels.h"
@@ -42,7 +42,7 @@ typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
#include "Bullet3Geometry/b3AabbUtil.h"
#define dot3F4 btDot
#define dot3F4 b3Dot
GpuSatCollision::GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_queue q )
:m_context(ctx),
@@ -65,22 +65,22 @@ m_totalContactsOut(m_context, m_queue)
//#endif
cl_program satProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,src,&errNum,flags,"opencl/gpu_narrowphase/kernels/sat.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_findSeparatingAxisKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findSeparatingAxisKernel",&errNum,satProg );
btAssert(m_findSeparatingAxisKernel);
btAssert(errNum==CL_SUCCESS);
b3Assert(m_findSeparatingAxisKernel);
b3Assert(errNum==CL_SUCCESS);
m_findConcaveSeparatingAxisKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findConcaveSeparatingAxisKernel",&errNum,satProg );
btAssert(m_findConcaveSeparatingAxisKernel);
btAssert(errNum==CL_SUCCESS);
b3Assert(m_findConcaveSeparatingAxisKernel);
b3Assert(errNum==CL_SUCCESS);
m_findCompoundPairsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findCompoundPairsKernel",&errNum,satProg );
btAssert(m_findCompoundPairsKernel);
btAssert(errNum==CL_SUCCESS);
b3Assert(m_findCompoundPairsKernel);
b3Assert(errNum==CL_SUCCESS);
m_processCompoundPairsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "processCompoundPairsKernel",&errNum,satProg );
btAssert(m_processCompoundPairsKernel);
btAssert(errNum==CL_SUCCESS);
b3Assert(m_processCompoundPairsKernel);
b3Assert(errNum==CL_SUCCESS);
}
if (1)
@@ -93,30 +93,30 @@ m_totalContactsOut(m_context, m_queue)
//#endif
cl_program satClipContactsProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,srcClip,&errNum,flags,"opencl/gpu_narrowphase/kernels/satClipHullContacts.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_clipHullHullKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipHullHullKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_clipCompoundsHullHullKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipCompoundsHullHullKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_findClippingFacesKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "findClippingFacesKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_clipFacesAndContactReductionKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipFacesAndContactReductionKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_clipHullHullConcaveConvexKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipHullHullConcaveConvexKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_extractManifoldAndAddContactKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "extractManifoldAndAddContactKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_newContactReductionKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip,
"newContactReductionKernel",&errNum,satClipContactsProg);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
}
else
{
@@ -133,28 +133,28 @@ m_totalContactsOut(m_context, m_queue)
{
const char* srcBvh = bvhTraversalKernelCL;
cl_program bvhTraversalProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,srcBvh,&errNum,"","opencl/gpu_narrowphase/kernels/bvhTraversal.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_bvhTraversalKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcBvh, "bvhTraversalKernel",&errNum,bvhTraversalProg,"");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
}
{
const char* primitiveContactsSrc = primitiveContactsKernelsCL;
cl_program primitiveContactsProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,primitiveContactsSrc,&errNum,"","opencl/gpu_narrowphase/kernels/primitiveContacts.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_primitiveContactsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "primitiveContactsKernel",&errNum,primitiveContactsProg,"");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_findConcaveSphereContactsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "findConcaveSphereContactsKernel",&errNum,primitiveContactsProg );
btAssert(errNum==CL_SUCCESS);
btAssert(m_findConcaveSphereContactsKernel);
b3Assert(errNum==CL_SUCCESS);
b3Assert(m_findConcaveSphereContactsKernel);
m_processCompoundPairsPrimitivesKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "processCompoundPairsPrimitivesKernel",&errNum,primitiveContactsProg,"");
btAssert(errNum==CL_SUCCESS);
btAssert(m_processCompoundPairsPrimitivesKernel);
b3Assert(errNum==CL_SUCCESS);
b3Assert(m_processCompoundPairsPrimitivesKernel);
}
@@ -207,7 +207,7 @@ GpuSatCollision::~GpuSatCollision()
}
struct MyTriangleCallback : public btNodeOverlapCallback
struct MyTriangleCallback : public b3NodeOverlapCallback
{
int m_bodyIndexA;
int m_bodyIndexB;
@@ -221,7 +221,7 @@ struct MyTriangleCallback : public btNodeOverlapCallback
#define float4 b3Vector3
#define make_float4(x,y,z,w) btVector4(x,y,z,w)
#define make_float4(x,y,z,w) b3Vector4(x,y,z,w)
float signedDistanceFromPointToPlane(const float4& point, const float4& planeEqn, float4* closestPointOnFace)
{
@@ -248,7 +248,7 @@ b3Vector3 transform(b3Vector3* v, const b3Vector3* pos, const b3Vector3* orn)
inline bool IsPointInPolygon(const float4& p,
const btGpuFace* face,
const b3GpuFace* face,
const float4* baseVertex,
const int* convexIndices,
float4* out)
@@ -277,10 +277,10 @@ inline bool IsPointInPolygon(const float4& p,
ap = p-a;
v = cross3(ab,plane);
if (btDot(ap, v) > 0.f)
if (b3Dot(ap, v) > 0.f)
{
float ab_m2 = btDot(ab, ab);
float rt = ab_m2 != 0.f ? btDot(ab, ap) / ab_m2 : 0.f;
float ab_m2 = b3Dot(ab, ab);
float rt = ab_m2 != 0.f ? b3Dot(ab, ap) / ab_m2 : 0.f;
if (rt <= 0.f)
{
*out = a;
@@ -305,7 +305,7 @@ inline bool IsPointInPolygon(const float4& p,
#define normalize3(a) (a.normalize())
int extractManifoldSequentialGlobal( const float4* p, int nPoints, const float4& nearNormal, btInt4* contactIdx)
int extractManifoldSequentialGlobal( const float4* p, int nPoints, const float4& nearNormal, b3Int4* contactIdx)
{
if( nPoints == 0 )
return 0;
@@ -414,7 +414,7 @@ void computeContactPlaneConvex(int pairIndex,
const b3ConvexPolyhedronCL* convexShapes,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
const b3GpuFace* faces,
b3Contact4* globalContactsOut,
int& nGlobalContactsOut,
int maxContactCapacity)
@@ -459,7 +459,7 @@ void computeContactPlaneConvex(int pairIndex,
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
int numPoints = 0;
btInt4 contactIdx;
b3Int4 contactIdx;
contactIdx.s[0] = 0;
contactIdx.s[1] = 1;
contactIdx.s[2] = 2;
@@ -547,14 +547,14 @@ void computeContactPlaneCompound(int pairIndex,
const b3ConvexPolyhedronCL* convexShapes,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
const b3GpuFace* faces,
b3Contact4* globalContactsOut,
int& nGlobalContactsOut,
int maxContactCapacity)
{
int shapeTypeB = collidables[collidableIndexB].m_shapeType;
btAssert(shapeTypeB == SHAPE_COMPOUND_OF_CONVEX_HULLS);
b3Assert(shapeTypeB == SHAPE_COMPOUND_OF_CONVEX_HULLS);
@@ -597,7 +597,7 @@ void computeContactPlaneCompound(int pairIndex,
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
int numPoints = 0;
btInt4 contactIdx;
b3Int4 contactIdx;
contactIdx.s[0] = 0;
contactIdx.s[1] = 1;
contactIdx.s[2] = 2;
@@ -686,7 +686,7 @@ void computeContactSphereConvex(int pairIndex,
const b3ConvexPolyhedronCL* convexShapes,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
const b3GpuFace* faces,
b3Contact4* globalContactsOut,
int& nGlobalContactsOut,
int maxContactCapacity)
@@ -722,7 +722,7 @@ void computeContactSphereConvex(int pairIndex,
float4 localHitNormal;
for ( int f = 0; f < numFaces; f++ )
{
btGpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];
b3GpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];
float4 planeEqn;
float4 localPlaneNormal = make_float4(face.m_plane.getX(),face.m_plane.getY(),face.m_plane.getZ(),0.f);
float4 n1 = localPlaneNormal;//quatRotate(quat,localPlaneNormal);
@@ -763,7 +763,7 @@ void computeContactSphereConvex(int pairIndex,
b3Scalar l2 = tmp.length2();
if (l2<radius*radius)
{
dist = btSqrt(l2);
dist = b3Sqrt(l2);
if (dist>minDist)
{
minDist = dist;
@@ -833,32 +833,32 @@ void computeContactSphereConvex(int pairIndex,
}
void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btInt2>* pairs, int nPairs,
const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
void GpuSatCollision::computeConvexConvexContactsGPUSAT( const b3OpenCLArray<b3Int2>* pairs, int nPairs,
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
int maxContactCapacity,
const btOpenCLArray<b3ConvexPolyhedronCL>& convexData,
const btOpenCLArray<b3Vector3>& gpuVertices,
const btOpenCLArray<b3Vector3>& gpuUniqueEdges,
const btOpenCLArray<btGpuFace>& gpuFaces,
const btOpenCLArray<int>& gpuIndices,
const btOpenCLArray<b3Collidable>& gpuCollidables,
const btOpenCLArray<btGpuChildShape>& gpuChildShapes,
const b3OpenCLArray<b3ConvexPolyhedronCL>& convexData,
const b3OpenCLArray<b3Vector3>& gpuVertices,
const b3OpenCLArray<b3Vector3>& gpuUniqueEdges,
const b3OpenCLArray<b3GpuFace>& gpuFaces,
const b3OpenCLArray<int>& gpuIndices,
const b3OpenCLArray<b3Collidable>& gpuCollidables,
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
const btOpenCLArray<btYetAnotherAabb>& clAabbsWS,
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
btOpenCLArray<btInt4>& clippingFacesOutGPU,
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
const b3OpenCLArray<b3YetAnotherAabb>& clAabbsWS,
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
btOpenCLArray<b3BvhInfo>* bvhInfo,
b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
b3OpenCLArray<b3BvhInfo>* bvhInfo,
int numObjects,
int maxTriConvexPairCapacity,
btOpenCLArray<btInt4>& triangleConvexPairsOut,
b3OpenCLArray<b3Int4>& triangleConvexPairsOut,
int& numTriConvexPairsOut
)
{
@@ -868,9 +868,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
//#define CHECK_ON_HOST
#ifdef CHECK_ON_HOST
b3AlignedObjectArray<btYetAnotherAabb> hostAabbs;
b3AlignedObjectArray<b3YetAnotherAabb> hostAabbs;
clAabbsWS.copyToHost(hostAabbs);
b3AlignedObjectArray<btInt2> hostPairs;
b3AlignedObjectArray<b3Int2> hostPairs;
pairs->copyToHost(hostPairs);
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
@@ -886,18 +886,18 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
b3AlignedObjectArray<b3Vector3> hostUniqueEdges;
gpuUniqueEdges.copyToHost(hostUniqueEdges);
b3AlignedObjectArray<btGpuFace> hostFaces;
b3AlignedObjectArray<b3GpuFace> hostFaces;
gpuFaces.copyToHost(hostFaces);
b3AlignedObjectArray<int> hostIndices;
gpuIndices.copyToHost(hostIndices);
b3AlignedObjectArray<b3Collidable> hostCollidables;
gpuCollidables.copyToHost(hostCollidables);
b3AlignedObjectArray<btGpuChildShape> cpuChildShapes;
b3AlignedObjectArray<b3GpuChildShape> cpuChildShapes;
gpuChildShapes.copyToHost(cpuChildShapes);
b3AlignedObjectArray<btInt4> hostTriangleConvexPairs;
b3AlignedObjectArray<b3Int4> hostTriangleConvexPairs;
b3AlignedObjectArray<b3Contact4> hostContacts;
if (nContacts)
@@ -984,22 +984,22 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
{
m_totalContactsOut.copyFromHostPointer(&nContacts,1,0,true);
BT_PROFILE("primitiveContactsKernel");
btBufferInfoCL bInfo[] = {
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
B3_PROFILE("primitiveContactsKernel");
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_primitiveContactsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_primitiveContactsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( nPairs );
launcher.setConst(maxContactCapacity);
int num = nPairs;
@@ -1013,33 +1013,33 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
#endif//CHECK_ON_HOST
BT_PROFILE("computeConvexConvexContactsGPUSAT");
B3_PROFILE("computeConvexConvexContactsGPUSAT");
// printf("nContacts = %d\n",nContacts);
btOpenCLArray<b3Vector3> sepNormals(m_context,m_queue);
b3OpenCLArray<b3Vector3> sepNormals(m_context,m_queue);
sepNormals.resize(nPairs);
btOpenCLArray<int> hasSeparatingNormals(m_context,m_queue);
b3OpenCLArray<int> hasSeparatingNormals(m_context,m_queue);
hasSeparatingNormals.resize(nPairs);
int concaveCapacity=maxTriConvexPairCapacity;
btOpenCLArray<b3Vector3> concaveSepNormals(m_context,m_queue);
b3OpenCLArray<b3Vector3> concaveSepNormals(m_context,m_queue);
concaveSepNormals.resize(concaveCapacity);
btOpenCLArray<int> numConcavePairsOut(m_context,m_queue);
b3OpenCLArray<int> numConcavePairsOut(m_context,m_queue);
numConcavePairsOut.push_back(0);
int compoundPairCapacity=65536*10;
btOpenCLArray<btCompoundOverlappingPair> gpuCompoundPairs(m_context,m_queue);
b3OpenCLArray<b3CompoundOverlappingPair> gpuCompoundPairs(m_context,m_queue);
gpuCompoundPairs.resize(compoundPairCapacity);
btOpenCLArray<b3Vector3> gpuCompoundSepNormals(m_context,m_queue);
b3OpenCLArray<b3Vector3> gpuCompoundSepNormals(m_context,m_queue);
gpuCompoundSepNormals.resize(compoundPairCapacity);
btOpenCLArray<int> gpuHasCompoundSepNormals(m_context,m_queue);
b3OpenCLArray<int> gpuHasCompoundSepNormals(m_context,m_queue);
gpuHasCompoundSepNormals.resize(compoundPairCapacity);
btOpenCLArray<int> numCompoundPairsOut(m_context,m_queue);
b3OpenCLArray<int> numCompoundPairsOut(m_context,m_queue);
numCompoundPairsOut.push_back(0);
int numCompoundPairs = 0;
@@ -1053,23 +1053,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
{
{
BT_PROFILE("findSeparatingAxisKernel");
btBufferInfoCL bInfo[] = {
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( sepNormals.getBufferCL()),
btBufferInfoCL( hasSeparatingNormals.getBufferCL())
B3_PROFILE("findSeparatingAxisKernel");
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( sepNormals.getBufferCL()),
b3BufferInfoCL( hasSeparatingNormals.getBufferCL())
};
btLauncherCL launcher(m_queue, m_findSeparatingAxisKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_findSeparatingAxisKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( nPairs );
int num = nPairs;
@@ -1086,9 +1086,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (treeNodesGPU->size() && treeNodesGPU->size())
{
BT_PROFILE("m_bvhTraversalKernel");
B3_PROFILE("m_bvhTraversalKernel");
numConcavePairs = numConcavePairsOut.at(0);
btLauncherCL launcher(m_queue, m_bvhTraversalKernel);
b3LauncherCL launcher(m_queue, m_bvhTraversalKernel);
launcher.setBuffer( pairs->getBufferCL());
launcher.setBuffer( bodyBuf->getBufferCL());
launcher.setBuffer( gpuCollidables.getBufferCL());
@@ -1117,23 +1117,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (numConcavePairs)
{
//now perform a SAT test for each triangle-convex element (stored in triangleConvexPairsOut)
BT_PROFILE("findConcaveSeparatingAxisKernel");
btBufferInfoCL bInfo[] = {
btBufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( concaveSepNormals.getBufferCL())
B3_PROFILE("findConcaveSeparatingAxisKernel");
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( concaveSepNormals.getBufferCL())
};
btLauncherCL launcher(m_queue, m_findConcaveSeparatingAxisKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_findConcaveSeparatingAxisKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numConcavePairs );
@@ -1143,7 +1143,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
// b3AlignedObjectArray<b3Vector3> cpuCompoundSepNormals;
// concaveSepNormals.copyToHost(cpuCompoundSepNormals);
// b3AlignedObjectArray<btInt4> cpuConcavePairs;
// b3AlignedObjectArray<b3Int4> cpuConcavePairs;
// triangleConvexPairsOut.copyToHost(cpuConcavePairs);
@@ -1156,25 +1156,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (1)
{
BT_PROFILE("findCompoundPairsKernel");
btBufferInfoCL bInfo[] =
B3_PROFILE("findCompoundPairsKernel");
b3BufferInfoCL bInfo[] =
{
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( gpuCompoundPairs.getBufferCL()),
btBufferInfoCL( numCompoundPairsOut.getBufferCL())
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( gpuCompoundPairs.getBufferCL()),
b3BufferInfoCL( numCompoundPairsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_findCompoundPairsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_findCompoundPairsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( nPairs );
launcher.setConst( compoundPairCapacity);
@@ -1197,25 +1197,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (numCompoundPairs)
{
#ifndef CHECK_ON_HOST
BT_PROFILE("processCompoundPairsPrimitivesKernel");
btBufferInfoCL bInfo[] =
B3_PROFILE("processCompoundPairsPrimitivesKernel");
b3BufferInfoCL bInfo[] =
{
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_processCompoundPairsPrimitivesKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_processCompoundPairsPrimitivesKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numCompoundPairs );
launcher.setConst(maxContactCapacity);
@@ -1230,25 +1230,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (numCompoundPairs)
{
BT_PROFILE("processCompoundPairsKernel");
btBufferInfoCL bInfo[] =
B3_PROFILE("processCompoundPairsKernel");
b3BufferInfoCL bInfo[] =
{
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( gpuCompoundSepNormals.getBufferCL()),
btBufferInfoCL( gpuHasCompoundSepNormals.getBufferCL())
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( gpuCompoundSepNormals.getBufferCL()),
b3BufferInfoCL( gpuHasCompoundSepNormals.getBufferCL())
};
btLauncherCL launcher(m_queue, m_processCompoundPairsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_processCompoundPairsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numCompoundPairs );
int num = numCompoundPairs;
@@ -1277,24 +1277,24 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
{
if (numConcavePairs)
{
BT_PROFILE("findConcaveSphereContactsKernel");
B3_PROFILE("findConcaveSphereContactsKernel");
nContacts = m_totalContactsOut.at(0);
btBufferInfoCL bInfo[] = {
btBufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_findConcaveSphereContactsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_findConcaveSphereContactsKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numConcavePairs );
launcher.setConst(maxContactCapacity);
@@ -1317,7 +1317,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (contactClippingOnGpu)
{
//BT_PROFILE("clipHullHullKernel");
//B3_PROFILE("clipHullHullKernel");
m_totalContactsOut.copyFromHostPointer(&nContacts,1,0,true);
@@ -1330,24 +1330,24 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
// nContacts = m_totalContactsOut.at(0);
// printf("nContacts before = %d\n", nContacts);
BT_PROFILE("clipHullHullConcaveConvexKernel");
B3_PROFILE("clipHullHullConcaveConvexKernel");
nContacts = m_totalContactsOut.at(0);
btBufferInfoCL bInfo[] = {
btBufferInfoCL( triangleConvexPairsOut.getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( concaveSepNormals.getBufferCL()),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( concaveSepNormals.getBufferCL()),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_clipHullHullConcaveConvexKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_clipHullHullConcaveConvexKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numConcavePairs );
int num = numConcavePairs;
launcher.launch1D( num);
@@ -1364,7 +1364,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
//convex-convex contact clipping
if (1)
{
BT_PROFILE("clipHullHullKernel");
B3_PROFILE("clipHullHullKernel");
bool breakupKernel = false;
#ifdef __APPLE__
@@ -1396,26 +1396,26 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
{
BT_PROFILE("findClippingFacesKernel");
btBufferInfoCL bInfo[] = {
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( sepNormals.getBufferCL()),
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
btBufferInfoCL( worldVertsA1GPU.getBufferCL()),
btBufferInfoCL( worldNormalsAGPU.getBufferCL()),
btBufferInfoCL( worldVertsB1GPU.getBufferCL())
B3_PROFILE("findClippingFacesKernel");
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( sepNormals.getBufferCL()),
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
b3BufferInfoCL( worldVertsA1GPU.getBufferCL()),
b3BufferInfoCL( worldNormalsAGPU.getBufferCL()),
b3BufferInfoCL( worldVertsB1GPU.getBufferCL())
};
btLauncherCL launcher(m_queue, m_findClippingFacesKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_findClippingFacesKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( vertexFaceCapacity);
launcher.setConst( nPairs );
int num = nPairs;
@@ -1431,26 +1431,26 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
///clip face B against face A, reduce contacts and append them to a global contact array
if (1)
{
BT_PROFILE("clipFacesAndContactReductionKernel");
B3_PROFILE("clipFacesAndContactReductionKernel");
//nContacts = m_totalContactsOut.at(0);
//int h = hasSeparatingNormals.at(0);
//int4 p = clippingFacesOutGPU.at(0);
btBufferInfoCL bInfo[] = {
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( sepNormals.getBufferCL()),
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
btBufferInfoCL( worldVertsA1GPU.getBufferCL()),
btBufferInfoCL( worldNormalsAGPU.getBufferCL()),
btBufferInfoCL( worldVertsB1GPU.getBufferCL()),
btBufferInfoCL( worldVertsB2GPU.getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( sepNormals.getBufferCL()),
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
b3BufferInfoCL( worldVertsA1GPU.getBufferCL()),
b3BufferInfoCL( worldNormalsAGPU.getBufferCL()),
b3BufferInfoCL( worldVertsB1GPU.getBufferCL()),
b3BufferInfoCL( worldVertsB2GPU.getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_clipFacesAndContactReductionKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_clipFacesAndContactReductionKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst(vertexFaceCapacity);
launcher.setConst( nPairs );
@@ -1479,21 +1479,21 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
contactOut->reserve(nContacts+nPairs);
{
BT_PROFILE("newContactReductionKernel");
btBufferInfoCL bInfo[] =
B3_PROFILE("newContactReductionKernel");
b3BufferInfoCL bInfo[] =
{
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( sepNormals.getBufferCL()),
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
btBufferInfoCL( worldVertsB2GPU.getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( sepNormals.getBufferCL()),
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
b3BufferInfoCL( worldVertsB2GPU.getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_newContactReductionKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_newContactReductionKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst(vertexFaceCapacity);
launcher.setConst( nPairs );
int num = nPairs;
@@ -1514,22 +1514,22 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (nPairs)
{
btBufferInfoCL bInfo[] = {
btBufferInfoCL( pairs->getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( sepNormals.getBufferCL()),
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( sepNormals.getBufferCL()),
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_clipHullHullKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_clipHullHullKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( nPairs );
int num = nPairs;
launcher.launch1D( num);
@@ -1543,23 +1543,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (nCompoundsPairs)
{
btBufferInfoCL bInfo[] = {
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
btBufferInfoCL( bodyBuf->getBufferCL(),true),
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
btBufferInfoCL( convexData.getBufferCL(),true),
btBufferInfoCL( gpuVertices.getBufferCL(),true),
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
btBufferInfoCL( gpuFaces.getBufferCL(),true),
btBufferInfoCL( gpuIndices.getBufferCL(),true),
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
btBufferInfoCL( gpuCompoundSepNormals.getBufferCL(),true),
btBufferInfoCL( gpuHasCompoundSepNormals.getBufferCL(),true),
btBufferInfoCL( contactOut->getBufferCL()),
btBufferInfoCL( m_totalContactsOut.getBufferCL())
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
b3BufferInfoCL( gpuCompoundSepNormals.getBufferCL(),true),
b3BufferInfoCL( gpuHasCompoundSepNormals.getBufferCL(),true),
b3BufferInfoCL( contactOut->getBufferCL()),
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
};
btLauncherCL launcher(m_queue, m_clipCompoundsHullHullKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher(m_queue, m_clipCompoundsHullHullKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( nCompoundsPairs );
launcher.setConst(maxContactCapacity);

View File

@@ -2,22 +2,22 @@
#ifndef _CONVEX_HULL_CONTACT_H
#define _CONVEX_HULL_CONTACT_H
#include "parallel_primitives/host/btOpenCLArray.h"
#include "parallel_primitives/host/b3OpenCLArray.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "b3ConvexUtility.h"
#include "b3ConvexPolyhedronCL.h"
#include "b3Collidable.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
#include "parallel_primitives/host/btInt2.h"
#include "parallel_primitives/host/btInt4.h"
#include "parallel_primitives/host/b3Int2.h"
#include "parallel_primitives/host/b3Int4.h"
#include "b3OptimizedBvh.h"
#include "b3BvhInfo.h"
//#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
struct btYetAnotherAabb
struct b3YetAnotherAabb
{
union
{
@@ -59,37 +59,37 @@ struct GpuSatCollision
cl_kernel m_processCompoundPairsPrimitivesKernel;
btOpenCLArray<int> m_totalContactsOut;
b3OpenCLArray<int> m_totalContactsOut;
GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_queue q );
virtual ~GpuSatCollision();
void computeConvexConvexContactsGPUSAT( const btOpenCLArray<btInt2>* pairs, int nPairs,
const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
void computeConvexConvexContactsGPUSAT( const b3OpenCLArray<b3Int2>* pairs, int nPairs,
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
int maxContactCapacity,
const btOpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
const btOpenCLArray<b3Vector3>& vertices,
const btOpenCLArray<b3Vector3>& uniqueEdges,
const btOpenCLArray<btGpuFace>& faces,
const btOpenCLArray<int>& indices,
const btOpenCLArray<b3Collidable>& gpuCollidables,
const btOpenCLArray<btGpuChildShape>& gpuChildShapes,
const b3OpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
const b3OpenCLArray<b3Vector3>& vertices,
const b3OpenCLArray<b3Vector3>& uniqueEdges,
const b3OpenCLArray<b3GpuFace>& faces,
const b3OpenCLArray<int>& indices,
const b3OpenCLArray<b3Collidable>& gpuCollidables,
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
const btOpenCLArray<btYetAnotherAabb>& clAabbs,
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
btOpenCLArray<btInt4>& clippingFacesOutGPU,
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
const b3OpenCLArray<b3YetAnotherAabb>& clAabbs,
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
btOpenCLArray<b3BvhInfo>* bvhInfo,
b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
b3OpenCLArray<b3BvhInfo>* bvhInfo,
int numObjects,
int maxTriConvexPairCapacity,
btOpenCLArray<btInt4>& triangleConvexPairs,
b3OpenCLArray<b3Int4>& triangleConvexPairs,
int& numTriConvexPairsOut
);

View File

@@ -3,9 +3,9 @@
#include "Bullet3Common/b3Transform.h"
struct btGpuFace
struct b3GpuFace
{
btVector4 m_plane;
b3Vector4 m_plane;
int m_indexOffset;
int m_numIndices;
};
@@ -45,7 +45,7 @@ ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
//b3Scalar dp = pt.dot(dir);
b3Scalar dp = vertices[m_vertexOffset+i].dot(localDir);
//btAssert(dp==dpL);
//b3Assert(dp==dpL);
if(dp < min) min = dp;
if(dp > max) max = dp;
}

View File

@@ -42,7 +42,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
b3ConvexHullComputer* convexUtil = &conv;
b3AlignedObjectArray<btMyFace> tmpFaces;
b3AlignedObjectArray<b3MyFace> tmpFaces;
tmpFaces.resize(numFaces);
int numVertices = convexUtil->vertices.size();
@@ -96,7 +96,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
}
else
{
btAssert(0);//degenerate?
b3Assert(0);//degenerate?
faceNormals[i].setZero();
}
@@ -124,14 +124,14 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
int refFace = todoFaces[todoFaces.size()-1];
coplanarFaceGroup.push_back(refFace);
btMyFace& faceA = tmpFaces[refFace];
b3MyFace& faceA = tmpFaces[refFace];
todoFaces.pop_back();
b3Vector3 faceNormalA(faceA.m_plane[0],faceA.m_plane[1],faceA.m_plane[2]);
for (int j=todoFaces.size()-1;j>=0;j--)
{
int i = todoFaces[j];
btMyFace& faceB = tmpFaces[i];
b3MyFace& faceB = tmpFaces[i];
b3Vector3 faceNormalB(faceB.m_plane[0],faceB.m_plane[1],faceB.m_plane[2]);
if (faceNormalA.dot(faceNormalB)>faceWeldThreshold)
{
@@ -153,7 +153,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
{
// m_polyhedron->m_faces.push_back(tmpFaces[coplanarFaceGroup[i]]);
btMyFace& face = tmpFaces[coplanarFaceGroup[i]];
b3MyFace& face = tmpFaces[coplanarFaceGroup[i]];
b3Vector3 faceNormal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
averageFaceNormal+=faceNormal;
for (int f=0;f<face.m_indices.size();f++)
@@ -179,7 +179,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
btMyFace combinedFace;
b3MyFace combinedFace;
for (int i=0;i<4;i++)
combinedFace.m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
@@ -212,7 +212,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
// this vertex is rejected -- is anybody else using this vertex?
for(int j = 0; j < tmpFaces.size(); j++) {
btMyFace& face = tmpFaces[j];
b3MyFace& face = tmpFaces[j];
// is this a face of the current coplanar group?
bool is_in_current_group = false;
for(int k = 0; k < coplanarFaceGroup.size(); k++) {
@@ -249,7 +249,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
{
for (int i=0;i<coplanarFaceGroup.size();i++)
{
btMyFace face = tmpFaces[coplanarFaceGroup[i]];
b3MyFace face = tmpFaces[coplanarFaceGroup[i]];
m_faces.push_back(face);
}
@@ -275,14 +275,14 @@ inline bool IsAlmostZero(const b3Vector3& v)
return true;
}
struct btInternalVertexPair
struct b3InternalVertexPair
{
btInternalVertexPair(short int v0,short int v1)
b3InternalVertexPair(short int v0,short int v1)
:m_v0(v0),
m_v1(v1)
{
if (m_v1>m_v0)
btSwap(m_v0,m_v1);
b3Swap(m_v0,m_v1);
}
short int m_v0;
short int m_v1;
@@ -290,15 +290,15 @@ struct btInternalVertexPair
{
return m_v0+(m_v1<<16);
}
bool equals(const btInternalVertexPair& other) const
bool equals(const b3InternalVertexPair& other) const
{
return m_v0==other.m_v0 && m_v1==other.m_v1;
}
};
struct btInternalEdge
struct b3InternalEdge
{
btInternalEdge()
b3InternalEdge()
:m_face0(-1),
m_face1(-1)
{
@@ -339,7 +339,7 @@ bool b3ConvexUtility::testContainment() const
void b3ConvexUtility::initialize()
{
b3HashMap<btInternalVertexPair,btInternalEdge> edges;
b3HashMap<b3InternalVertexPair,b3InternalEdge> edges;
b3Scalar TotalArea = 0.0f;
@@ -351,8 +351,8 @@ void b3ConvexUtility::initialize()
for(int j=0;j<NbTris;j++)
{
int k = (j+1)%numVertices;
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
btInternalEdge* edptr = edges.find(vp);
b3InternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
b3InternalEdge* edptr = edges.find(vp);
b3Vector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
edge.normalize();
@@ -383,12 +383,12 @@ void b3ConvexUtility::initialize()
if (edptr)
{
//TBD: figure out why I added this assert
// btAssert(edptr->m_face0>=0);
// btAssert(edptr->m_face1<0);
// b3Assert(edptr->m_face0>=0);
// b3Assert(edptr->m_face1<0);
edptr->m_face1 = i;
} else
{
btInternalEdge ed;
b3InternalEdge ed;
ed.m_face0 = i;
edges.insert(vp,ed);
}
@@ -404,11 +404,11 @@ void b3ConvexUtility::initialize()
for(int j=0;j<numVertices;j++)
{
int k = (j+1)%numVertices;
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
btInternalEdge* edptr = edges.find(vp);
btAssert(edptr);
btAssert(edptr->m_face0>=0);
btAssert(edptr->m_face1>=0);
b3InternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
b3InternalEdge* edptr = edges.find(vp);
b3Assert(edptr);
b3Assert(edptr->m_face0>=0);
b3Assert(edptr->m_face1>=0);
int connectedFace = (edptr->m_face0==i)?edptr->m_face1:edptr->m_face0;
m_faces[i].m_connectedFaces[j] = connectedFace;
@@ -445,7 +445,7 @@ void b3ConvexUtility::initialize()
for(int i=0;i<m_faces.size();i++)
{
const b3Vector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
const b3Scalar dist = btFabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
const b3Scalar dist = b3Fabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
if(dist<m_radius)
m_radius = dist;
}

View File

@@ -23,7 +23,7 @@ subject to the following restrictions:
#include "b3ConvexPolyhedronCL.h"
struct btMyFace
struct b3MyFace
{
b3AlignedObjectArray<int> m_indices;
b3Scalar m_plane[4];
@@ -32,7 +32,7 @@ struct btMyFace
ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
{
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
b3Vector3 m_localCenter;
b3Vector3 m_extents;
@@ -41,7 +41,7 @@ ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
b3Scalar m_radius;
b3AlignedObjectArray<b3Vector3> m_vertices;
b3AlignedObjectArray<btMyFace> m_faces;
b3AlignedObjectArray<b3MyFace> m_faces;
b3AlignedObjectArray<b3Vector3> m_uniqueEdges;

View File

@@ -35,7 +35,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
// NodeArray triangleNodes;
struct NodeTriangleCallback : public btInternalTriangleIndexCallback
struct NodeTriangleCallback : public b3InternalTriangleIndexCallback
{
NodeArray& m_triangleNodes;
@@ -53,10 +53,10 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
{
btOptimizedBvhNode node;
b3OptimizedBvhNode node;
b3Vector3 aabbMin,aabbMax;
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
aabbMin.setMin(triangle[0]);
aabbMax.setMax(triangle[0]);
aabbMin.setMin(triangle[1]);
@@ -76,7 +76,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
m_triangleNodes.push_back(node);
}
};
struct QuantizedNodeTriangleCallback : public btInternalTriangleIndexCallback
struct QuantizedNodeTriangleCallback : public b3InternalTriangleIndexCallback
{
QuantizedNodeArray& m_triangleNodes;
const b3QuantizedBvh* m_optimizedTree; // for quantization
@@ -96,15 +96,15 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
{
// The partId and triangle index must fit in the same (positive) integer
btAssert(partId < (1<<MAX_NUM_PARTS_IN_BITS));
btAssert(triangleIndex < (1<<(31-MAX_NUM_PARTS_IN_BITS)));
b3Assert(partId < (1<<MAX_NUM_PARTS_IN_BITS));
b3Assert(triangleIndex < (1<<(31-MAX_NUM_PARTS_IN_BITS)));
//negative indices are reserved for escapeIndex
btAssert(triangleIndex>=0);
b3Assert(triangleIndex>=0);
btQuantizedBvhNode node;
b3QuantizedBvhNode node;
b3Vector3 aabbMin,aabbMax;
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
aabbMin.setMin(triangle[0]);
aabbMax.setMax(triangle[0]);
aabbMin.setMin(triangle[1]);
@@ -167,8 +167,8 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
{
NodeTriangleCallback callback(m_leafNodes);
b3Vector3 aabbMin(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
b3Vector3 aabbMax(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
b3Vector3 aabbMin(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
b3Vector3 aabbMax(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
@@ -185,7 +185,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
///if the entire tree is small then subtree size, we need to create a header info for the tree
if(m_useQuantization && !m_SubtreeHeaders.size())
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
subtree.m_rootNodeIndex = 0;
subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
@@ -216,7 +216,7 @@ void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const b3Vector
int i;
for (i=0;i<m_SubtreeHeaders.size();i++)
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[subtree.m_rootNodeIndex]);
}
@@ -232,15 +232,15 @@ void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const b3Vector
void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
{
//incrementally initialize quantization values
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
btAssert(aabbMin.getX() > m_bvhAabbMin.getX());
btAssert(aabbMin.getY() > m_bvhAabbMin.getY());
btAssert(aabbMin.getZ() > m_bvhAabbMin.getZ());
b3Assert(aabbMin.getX() > m_bvhAabbMin.getX());
b3Assert(aabbMin.getY() > m_bvhAabbMin.getY());
b3Assert(aabbMin.getZ() > m_bvhAabbMin.getZ());
btAssert(aabbMax.getX() < m_bvhAabbMax.getX());
btAssert(aabbMax.getY() < m_bvhAabbMax.getY());
btAssert(aabbMax.getZ() < m_bvhAabbMax.getZ());
b3Assert(aabbMax.getX() < m_bvhAabbMax.getX());
b3Assert(aabbMax.getY() < m_bvhAabbMax.getY());
b3Assert(aabbMax.getZ() < m_bvhAabbMax.getZ());
///we should update all quantization values, using updateBvhNodes(meshInterface);
///but we only update chunks that overlap the given aabb
@@ -254,7 +254,7 @@ void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b
int i;
for (i=0;i<this->m_SubtreeHeaders.size();i++)
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
//PCK: unsigned instead of bool
unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
@@ -272,7 +272,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
{
(void)index;
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
int curNodeSubPart=-1;
@@ -295,7 +295,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
{
btQuantizedBvhNode& curNode = m_quantizedContiguousNodes[i];
b3QuantizedBvhNode& curNode = m_quantizedContiguousNodes[i];
if (curNode.isLeafNode())
{
//recalc aabb from triangle data
@@ -308,7 +308,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts, type,stride,&indexbase,indexstride,numfaces,indicestype,nodeSubPart);
curNodeSubPart = nodeSubPart;
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
b3Assert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
}
//triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts,
@@ -336,8 +336,8 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
aabbMin.setMin(triangleVerts[0]);
aabbMax.setMax(triangleVerts[0]);
aabbMin.setMin(triangleVerts[1]);
@@ -352,9 +352,9 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
{
//combine aabb from both children
btQuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1];
b3QuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1];
btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] :
b3QuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] :
&m_quantizedContiguousNodes[i+1+leftChildNode->getEscapeIndex()];

View File

@@ -15,8 +15,8 @@ subject to the following restrictions:
///Contains contributions from Disney Studio's
#ifndef BT_OPTIMIZED_BVH_H
#define BT_OPTIMIZED_BVH_H
#ifndef B3_OPTIMIZED_BVH_H
#define B3_OPTIMIZED_BVH_H
#include "b3QuantizedBvh.h"
@@ -28,7 +28,7 @@ ATTRIBUTE_ALIGNED16(class) b3OptimizedBvh : public b3QuantizedBvh
{
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
protected:
@@ -60,6 +60,6 @@ public:
};
#endif //BT_OPTIMIZED_BVH_H
#endif //B3_OPTIMIZED_BVH_H

View File

@@ -21,7 +21,7 @@ subject to the following restrictions:
#define RAYAABB2
b3QuantizedBvh::b3QuantizedBvh() :
m_bulletVersion(BT_BULLET_VERSION),
m_bulletVersion(B3_BULLET_VERSION),
m_useQuantization(false),
m_traversalMode(TRAVERSAL_STACKLESS_CACHE_FRIENDLY)
//m_traversalMode(TRAVERSAL_STACKLESS)
@@ -58,7 +58,7 @@ void b3QuantizedBvh::buildInternal()
///if the entire tree is small then subtree size, we need to create a header info for the tree
if(m_useQuantization && !m_SubtreeHeaders.size())
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
subtree.m_rootNodeIndex = 0;
subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
@@ -123,7 +123,7 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
int numIndices =endIndex-startIndex;
int curIndex = m_curNodeIndex;
btAssert(numIndices>0);
b3Assert(numIndices>0);
if (numIndices==1)
{
@@ -178,7 +178,7 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
if (m_useQuantization)
{
//escapeIndex is the number of nodes of this subtree
const int sizeQuantizedNode =sizeof(btQuantizedBvhNode);
const int sizeQuantizedNode =sizeof(b3QuantizedBvhNode);
const int treeSizeInBytes = escapeIndex * sizeQuantizedNode;
if (treeSizeInBytes > MAX_SUBTREE_SIZE_IN_BYTES)
{
@@ -195,19 +195,19 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
void b3QuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex)
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
btQuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex];
b3QuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex];
int leftSubTreeSize = leftChildNode.isLeafNode() ? 1 : leftChildNode.getEscapeIndex();
int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast<int>(sizeof(btQuantizedBvhNode));
int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast<int>(sizeof(b3QuantizedBvhNode));
btQuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex];
b3QuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex];
int rightSubTreeSize = rightChildNode.isLeafNode() ? 1 : rightChildNode.getEscapeIndex();
int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast<int>(sizeof(btQuantizedBvhNode));
int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast<int>(sizeof(b3QuantizedBvhNode));
if(leftSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
subtree.setAabbFromQuantizeNode(leftChildNode);
subtree.m_rootNodeIndex = leftChildNodexIndex;
subtree.m_subtreeSize = leftSubTreeSize;
@@ -215,7 +215,7 @@ void b3QuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChild
if(rightSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
{
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
subtree.setAabbFromQuantizeNode(rightChildNode);
subtree.m_rootNodeIndex = rightChildNodexIndex;
subtree.m_subtreeSize = rightSubTreeSize;
@@ -274,7 +274,7 @@ int b3QuantizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int sp
bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
(void)unbal;
btAssert(!unbal);
b3Assert(!unbal);
return splitIndex;
}
@@ -309,7 +309,7 @@ int b3QuantizedBvh::calcSplittingAxis(int startIndex,int endIndex)
void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
void b3QuantizedBvh::reportAabbOverlappingNodex(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
@@ -331,13 +331,13 @@ void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
break;
case TRAVERSAL_RECURSIVE:
{
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[0];
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[0];
walkRecursiveQuantizedTreeAgainstQueryAabb(rootNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
}
break;
default:
//unsupported
btAssert(0);
b3Assert(0);
}
} else
{
@@ -349,11 +349,11 @@ void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
int maxIterations = 0;
void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
void b3QuantizedBvh::walkStacklessTree(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
btAssert(!m_useQuantization);
b3Assert(!m_useQuantization);
const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0];
const b3OptimizedBvhNode* rootNode = &m_contiguousNodes[0];
int escapeIndex, curIndex = 0;
int walkIterations = 0;
bool isLeafNode;
@@ -363,7 +363,7 @@ void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const
while (curIndex < m_curNodeIndex)
{
//catch bugs in tree data
btAssert (walkIterations < m_curNodeIndex);
b3Assert (walkIterations < m_curNodeIndex);
walkIterations++;
aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg);
@@ -394,7 +394,7 @@ void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const
/*
///this was the original recursive traversal, before we optimized towards stackless traversal
void b3QuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
void b3QuantizedBvh::walkTree(b3OptimizedBvhNode* rootNode,b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
if (aabbOverlap)
@@ -413,9 +413,9 @@ void b3QuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback
}
*/
void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const b3QuantizedBvhNode* currentNode,b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
bool isLeafNode;
//PCK: unsigned instead of bool
@@ -434,10 +434,10 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantize
} else
{
//process left and right children
const btQuantizedBvhNode* leftChildNode = currentNode+1;
const b3QuantizedBvhNode* leftChildNode = currentNode+1;
walkRecursiveQuantizedTreeAgainstQueryAabb(leftChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
const btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex();
const b3QuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex();
walkRecursiveQuantizedTreeAgainstQueryAabb(rightChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
}
}
@@ -445,11 +445,11 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantize
void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
void b3QuantizedBvh::walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
{
btAssert(!m_useQuantization);
b3Assert(!m_useQuantization);
const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0];
const b3OptimizedBvhNode* rootNode = &m_contiguousNodes[0];
int escapeIndex, curIndex = 0;
int walkIterations = 0;
bool isLeafNode;
@@ -474,9 +474,9 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
lambda_max = rayDir.dot(rayTarget-raySource);
///what about division by zero? --> just set rayDirection[i] to 1.0
b3Vector3 rayDirectionInverse;
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
unsigned int sign[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0};
#endif
@@ -486,7 +486,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
{
b3Scalar param = 1.0;
//catch bugs in tree data
btAssert (walkIterations < m_curNodeIndex);
b3Assert (walkIterations < m_curNodeIndex);
walkIterations++;
@@ -503,11 +503,11 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
///careful with this check: need to check division by zero (above) and fix the unQuantize method
///thanks Joerg/hiker for the reproduction case!
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
rayBoxOverlap = aabbOverlap ? btRayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
rayBoxOverlap = aabbOverlap ? b3RayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
#else
b3Vector3 normal;
rayBoxOverlap = btRayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal);
rayBoxOverlap = b3RayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal);
#endif
isLeafNode = rootNode->m_escapeIndex == -1;
@@ -537,16 +537,16 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
int curIndex = startNodeIndex;
int walkIterations = 0;
int subTreeSize = endNodeIndex - startNodeIndex;
(void)subTreeSize;
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
int escapeIndex;
bool isLeafNode;
@@ -561,9 +561,9 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
rayDirection.normalize ();
lambda_max = rayDirection.dot(rayTarget-raySource);
///what about division by zero? --> just set rayDirection[i] to 1.0
rayDirection[0] = rayDirection[0] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[0];
rayDirection[1] = rayDirection[1] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[1];
rayDirection[2] = rayDirection[2] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[2];
rayDirection[0] = rayDirection[0] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[0];
rayDirection[1] = rayDirection[1] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[1];
rayDirection[2] = rayDirection[2] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[2];
unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0};
#endif
@@ -590,7 +590,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
//some code snippet to debugDraw aabb, to visually analyze bvh structure
static int drawPatch = 0;
//need some global access to a debugDrawer
extern btIDebugDraw* debugDrawerPtr;
extern b3IDebugDraw* debugDrawerPtr;
if (curIndex==drawPatch)
{
b3Vector3 aabbMin,aabbMax;
@@ -602,7 +602,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
#endif//VISUALLY_ANALYZE_BVH
//catch bugs in tree data
btAssert (walkIterations < subTreeSize);
b3Assert (walkIterations < subTreeSize);
walkIterations++;
//PCK: unsigned instead of bool
@@ -621,8 +621,8 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
bounds[1] -= aabbMin;
b3Vector3 normal;
#if 0
bool ra2 = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
bool ra = btRayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal);
bool ra2 = b3RayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
bool ra = b3RayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal);
if (ra2 != ra)
{
printf("functions don't match\n");
@@ -633,11 +633,11 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
///thanks Joerg/hiker for the reproduction case!
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
//BT_PROFILE("btRayAabb2");
rayBoxOverlap = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
//B3_PROFILE("b3RayAabb2");
rayBoxOverlap = b3RayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
#else
rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
rayBoxOverlap = true;//b3RayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
#endif
}
@@ -663,16 +663,16 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
}
void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const
void b3QuantizedBvh::walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
int curIndex = startNodeIndex;
int walkIterations = 0;
int subTreeSize = endNodeIndex - startNodeIndex;
(void)subTreeSize;
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
int escapeIndex;
bool isLeafNode;
@@ -687,7 +687,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
//some code snippet to debugDraw aabb, to visually analyze bvh structure
static int drawPatch = 0;
//need some global access to a debugDrawer
extern btIDebugDraw* debugDrawerPtr;
extern b3IDebugDraw* debugDrawerPtr;
if (curIndex==drawPatch)
{
b3Vector3 aabbMin,aabbMax;
@@ -699,7 +699,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
#endif//VISUALLY_ANALYZE_BVH
//catch bugs in tree data
btAssert (walkIterations < subTreeSize);
b3Assert (walkIterations < subTreeSize);
walkIterations++;
//PCK: unsigned instead of bool
@@ -729,16 +729,16 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
}
//This traversal can be called from Playstation 3 SPU
void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
int i;
for (i=0;i<this->m_SubtreeHeaders.size();i++)
{
const btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
const b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
//PCK: unsigned instead of bool
unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
@@ -752,13 +752,13 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallba
}
void b3QuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const
void b3QuantizedBvh::reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const
{
reportBoxCastOverlappingNodex(nodeCallback,raySource,rayTarget,b3Vector3(0,0,0),b3Vector3(0,0,0));
}
void b3QuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
void b3QuantizedBvh::reportBoxCastOverlappingNodex(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
//always use stackless
@@ -790,12 +790,12 @@ void b3QuantizedBvh::swapLeafNodes(int i,int splitIndex)
{
if (m_useQuantization)
{
btQuantizedBvhNode tmp = m_quantizedLeafNodes[i];
b3QuantizedBvhNode tmp = m_quantizedLeafNodes[i];
m_quantizedLeafNodes[i] = m_quantizedLeafNodes[splitIndex];
m_quantizedLeafNodes[splitIndex] = tmp;
} else
{
btOptimizedBvhNode tmp = m_leafNodes[i];
b3OptimizedBvhNode tmp = m_leafNodes[i];
m_leafNodes[i] = m_leafNodes[splitIndex];
m_leafNodes[splitIndex] = tmp;
}
@@ -833,23 +833,23 @@ unsigned int b3QuantizedBvh::getAlignmentSerializationPadding()
unsigned b3QuantizedBvh::calculateSerializeBufferSize() const
{
unsigned baseSize = sizeof(b3QuantizedBvh) + getAlignmentSerializationPadding();
baseSize += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
baseSize += sizeof(b3BvhSubtreeInfo) * m_subtreeHeaderCount;
if (m_useQuantization)
{
return baseSize + m_curNodeIndex * sizeof(btQuantizedBvhNode);
return baseSize + m_curNodeIndex * sizeof(b3QuantizedBvhNode);
}
return baseSize + m_curNodeIndex * sizeof(btOptimizedBvhNode);
return baseSize + m_curNodeIndex * sizeof(b3OptimizedBvhNode);
}
bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian) const
{
btAssert(m_subtreeHeaderCount == m_SubtreeHeaders.size());
b3Assert(m_subtreeHeaderCount == m_SubtreeHeaders.size());
m_subtreeHeaderCount = m_SubtreeHeaders.size();
/* if (i_dataBufferSize < calculateSerializeBufferSize() || o_alignedDataBuffer == NULL || (((unsigned)o_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0))
{
///check alignedment for buffer?
btAssert(0);
b3Assert(0);
return false;
}
*/
@@ -862,15 +862,15 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
if (i_swapEndian)
{
targetBvh->m_curNodeIndex = static_cast<int>(btSwapEndian(m_curNodeIndex));
targetBvh->m_curNodeIndex = static_cast<int>(b3SwapEndian(m_curNodeIndex));
btSwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin);
btSwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax);
btSwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization);
b3SwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin);
b3SwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax);
b3SwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization);
targetBvh->m_traversalMode = (btTraversalMode)btSwapEndian(m_traversalMode);
targetBvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(m_subtreeHeaderCount));
targetBvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(m_traversalMode);
targetBvh->m_subtreeHeaderCount = static_cast<int>(b3SwapEndian(m_subtreeHeaderCount));
}
else
{
@@ -900,15 +900,15 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
{
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
}
}
else
@@ -929,7 +929,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
}
}
nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
nodeData += sizeof(b3QuantizedBvhNode) * nodeCount;
// this clears the pointer in the member variable it doesn't really do anything to the data
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
@@ -944,12 +944,12 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
{
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
b3SwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
b3SwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex));
targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_subPart));
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex));
targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex));
targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_subPart));
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex));
}
}
else
@@ -964,7 +964,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = m_contiguousNodes[nodeIndex].m_triangleIndex;
}
}
nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
nodeData += sizeof(b3OptimizedBvhNode) * nodeCount;
// this clears the pointer in the member variable it doesn't really do anything to the data
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
@@ -981,16 +981,16 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
{
for (int i = 0; i < m_subtreeHeaderCount; i++)
{
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex));
targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_subtreeSize));
targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(b3SwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex));
targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(b3SwapEndian(m_SubtreeHeaders[i].m_subtreeSize));
}
}
else
@@ -1014,7 +1014,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
targetBvh->m_SubtreeHeaders[i].m_padding[2] = 0;
}
}
nodeData += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
nodeData += sizeof(b3BvhSubtreeInfo) * m_subtreeHeaderCount;
// this clears the pointer in the member variable it doesn't really do anything to the data
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
@@ -1038,18 +1038,18 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
if (i_swapEndian)
{
bvh->m_curNodeIndex = static_cast<int>(btSwapEndian(bvh->m_curNodeIndex));
bvh->m_curNodeIndex = static_cast<int>(b3SwapEndian(bvh->m_curNodeIndex));
btUnSwapVector3Endian(bvh->m_bvhAabbMin);
btUnSwapVector3Endian(bvh->m_bvhAabbMax);
btUnSwapVector3Endian(bvh->m_bvhQuantization);
b3UnSwapVector3Endian(bvh->m_bvhAabbMin);
b3UnSwapVector3Endian(bvh->m_bvhAabbMax);
b3UnSwapVector3Endian(bvh->m_bvhQuantization);
bvh->m_traversalMode = (btTraversalMode)btSwapEndian(bvh->m_traversalMode);
bvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(bvh->m_subtreeHeaderCount));
bvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(bvh->m_traversalMode);
bvh->m_subtreeHeaderCount = static_cast<int>(b3SwapEndian(bvh->m_subtreeHeaderCount));
}
unsigned int calculatedBufSize = bvh->calculateSerializeBufferSize();
btAssert(calculatedBufSize <= i_dataBufferSize);
b3Assert(calculatedBufSize <= i_dataBufferSize);
if (calculatedBufSize > i_dataBufferSize)
{
@@ -1076,18 +1076,18 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
{
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
}
}
nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
nodeData += sizeof(b3QuantizedBvhNode) * nodeCount;
}
else
{
@@ -1097,15 +1097,15 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
{
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
b3UnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
b3UnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex));
bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart));
bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex));
bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex));
bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart));
bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex));
}
}
nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
nodeData += sizeof(b3OptimizedBvhNode) * nodeCount;
}
sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
@@ -1117,16 +1117,16 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
{
for (int i = 0; i < bvh->m_subtreeHeaderCount; i++)
{
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex));
bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize));
bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(b3SwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex));
bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(b3SwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize));
}
}
@@ -1138,12 +1138,12 @@ b3QuantizedBvh::b3QuantizedBvh(b3QuantizedBvh &self, bool /* ownsMemory */) :
m_bvhAabbMin(self.m_bvhAabbMin),
m_bvhAabbMax(self.m_bvhAabbMax),
m_bvhQuantization(self.m_bvhQuantization),
m_bulletVersion(BT_BULLET_VERSION)
m_bulletVersion(B3_BULLET_VERSION)
{
}
void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData)
void b3QuantizedBvh::deSerializeFloat(struct b3QuantizedBvhFloatData& quantizedBvhFloatData)
{
m_bvhAabbMax.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMax);
m_bvhAabbMin.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMin);
@@ -1158,7 +1158,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
if (numElem)
{
btOptimizedBvhNodeFloatData* memPtr = quantizedBvhFloatData.m_contiguousNodesPtr;
b3OptimizedBvhNodeFloatData* memPtr = quantizedBvhFloatData.m_contiguousNodesPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
@@ -1177,7 +1177,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
if (numElem)
{
btQuantizedBvhNodeData* memPtr = quantizedBvhFloatData.m_quantizedContiguousNodesPtr;
b3QuantizedBvhNodeData* memPtr = quantizedBvhFloatData.m_quantizedContiguousNodesPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex;
@@ -1191,14 +1191,14 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
}
}
m_traversalMode = btTraversalMode(quantizedBvhFloatData.m_traversalMode);
m_traversalMode = b3TraversalMode(quantizedBvhFloatData.m_traversalMode);
{
int numElem = quantizedBvhFloatData.m_numSubtreeHeaders;
m_SubtreeHeaders.resize(numElem);
if (numElem)
{
btBvhSubtreeInfoData* memPtr = quantizedBvhFloatData.m_subTreeInfoPtr;
b3BvhSubtreeInfoData* memPtr = quantizedBvhFloatData.m_subTreeInfoPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ;
@@ -1214,7 +1214,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
}
}
void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData)
void b3QuantizedBvh::deSerializeDouble(struct b3QuantizedBvhDoubleData& quantizedBvhDoubleData)
{
m_bvhAabbMax.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMax);
m_bvhAabbMin.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMin);
@@ -1229,7 +1229,7 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
if (numElem)
{
btOptimizedBvhNodeDoubleData* memPtr = quantizedBvhDoubleData.m_contiguousNodesPtr;
b3OptimizedBvhNodeDoubleData* memPtr = quantizedBvhDoubleData.m_contiguousNodesPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
@@ -1248,7 +1248,7 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
if (numElem)
{
btQuantizedBvhNodeData* memPtr = quantizedBvhDoubleData.m_quantizedContiguousNodesPtr;
b3QuantizedBvhNodeData* memPtr = quantizedBvhDoubleData.m_quantizedContiguousNodesPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex;
@@ -1262,14 +1262,14 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
}
}
m_traversalMode = btTraversalMode(quantizedBvhDoubleData.m_traversalMode);
m_traversalMode = b3TraversalMode(quantizedBvhDoubleData.m_traversalMode);
{
int numElem = quantizedBvhDoubleData.m_numSubtreeHeaders;
m_SubtreeHeaders.resize(numElem);
if (numElem)
{
btBvhSubtreeInfoData* memPtr = quantizedBvhDoubleData.m_subTreeInfoPtr;
b3BvhSubtreeInfoData* memPtr = quantizedBvhDoubleData.m_subTreeInfoPtr;
for (int i=0;i<numElem;i++,memPtr++)
{
m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ;
@@ -1289,9 +1289,9 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
///fills the dataBuffer and returns the struct name (and 0 on failure)
const char* b3QuantizedBvh::serialize(void* dataBuffer, btSerializer* serializer) const
const char* b3QuantizedBvh::serialize(void* dataBuffer, b3Serializer* serializer) const
{
btAssert(0);
b3Assert(0);
return 0;
}

View File

@@ -13,10 +13,10 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_QUANTIZED_BVH_H
#define BT_QUANTIZED_BVH_H
#ifndef B3_QUANTIZED_BVH_H
#define B3_QUANTIZED_BVH_H
class btSerializer;
class b3Serializer;
//#define DEBUG_CHECK_DEQUANTIZATION 1
#ifdef DEBUG_CHECK_DEQUANTIZATION
@@ -31,14 +31,14 @@ class btSerializer;
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3AlignedAllocator.h"
#ifdef BT_USE_DOUBLE_PRECISION
#define btQuantizedBvhData btQuantizedBvhDoubleData
#define btOptimizedBvhNodeData btOptimizedBvhNodeDoubleData
#define btQuantizedBvhDataName "btQuantizedBvhDoubleData"
#ifdef B3_USE_DOUBLE_PRECISION
#define b3QuantizedBvhData b3QuantizedBvhDoubleData
#define b3OptimizedBvhNodeData b3OptimizedBvhNodeDoubleData
#define b3QuantizedBvhDataName "b3QuantizedBvhDoubleData"
#else
#define btQuantizedBvhData btQuantizedBvhFloatData
#define btOptimizedBvhNodeData btOptimizedBvhNodeFloatData
#define btQuantizedBvhDataName "btQuantizedBvhFloatData"
#define b3QuantizedBvhData b3QuantizedBvhFloatData
#define b3OptimizedBvhNodeData b3OptimizedBvhNodeFloatData
#define b3QuantizedBvhDataName "b3QuantizedBvhFloatData"
#endif
@@ -53,11 +53,11 @@ class btSerializer;
// actually) triangles each (since the sign bit is reserved
#define MAX_NUM_PARTS_IN_BITS 10
///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.
///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode
{
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
//12 bytes
unsigned short int m_quantizedAabbMin[3];
@@ -72,12 +72,12 @@ ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
}
int getEscapeIndex() const
{
btAssert(!isLeafNode());
b3Assert(!isLeafNode());
return -m_escapeIndexOrTriangleIndex;
}
int getTriangleIndex() const
{
btAssert(isLeafNode());
b3Assert(isLeafNode());
unsigned int x=0;
unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
// Get only the lower bits where the triangle index is stored
@@ -85,18 +85,18 @@ ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
}
int getPartId() const
{
btAssert(isLeafNode());
b3Assert(isLeafNode());
// Get only the highest bits where the part index is stored
return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
}
}
;
/// btOptimizedBvhNode contains both internal and leaf node information.
/// b3OptimizedBvhNode contains both internal and leaf node information.
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode
{
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
//32 bytes
b3Vector3 m_aabbMinOrg;
@@ -115,11 +115,11 @@ ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
};
///btBvhSubtreeInfo provides info to gather a subtree of limited size
ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
///b3BvhSubtreeInfo provides info to gather a subtree of limited size
ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo
{
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
//12 bytes
unsigned short int m_quantizedAabbMin[3];
@@ -130,13 +130,13 @@ public:
int m_subtreeSize;
int m_padding[3];
btBvhSubtreeInfo()
b3BvhSubtreeInfo()
{
//memset(&m_padding[0], 0, sizeof(m_padding));
}
void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
void setAabbFromQuantizeNode(const b3QuantizedBvhNode& quantizedNode)
{
m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
@@ -149,10 +149,10 @@ public:
;
class btNodeOverlapCallback
class b3NodeOverlapCallback
{
public:
virtual ~btNodeOverlapCallback() {};
virtual ~b3NodeOverlapCallback() {};
virtual void processNode(int subPart, int triangleIndex) = 0;
};
@@ -163,18 +163,18 @@ public:
///for code readability:
typedef b3AlignedObjectArray<btOptimizedBvhNode> NodeArray;
typedef b3AlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
typedef b3AlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
typedef b3AlignedObjectArray<b3OptimizedBvhNode> NodeArray;
typedef b3AlignedObjectArray<b3QuantizedBvhNode> QuantizedNodeArray;
typedef b3AlignedObjectArray<b3BvhSubtreeInfo> BvhSubtreeInfoArray;
///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase.
///It is used by the b3BvhTriangleMeshShape as midphase, and by the b3MultiSapBroadphase.
///It is recommended to use quantization for better performance and lower memory requirements.
ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh
{
public:
enum btTraversalMode
enum b3TraversalMode
{
TRAVERSAL_STACKLESS = 0,
TRAVERSAL_STACKLESS_CACHE_FRIENDLY,
@@ -202,7 +202,7 @@ protected:
QuantizedNodeArray m_quantizedLeafNodes;
QuantizedNodeArray m_quantizedContiguousNodes;
btTraversalMode m_traversalMode;
b3TraversalMode m_traversalMode;
BvhSubtreeInfoArray m_SubtreeHeaders;
//This is only used for serialization so we don't have to add serialization directly to b3AlignedObjectArray
@@ -310,20 +310,20 @@ protected:
int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void walkStacklessTree(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
void walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
void walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
void walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
void walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
void walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
///tree traversal designed for small-memory processors like PS3 SPU
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
void walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
void walkRecursiveQuantizedTreeAgainstQueryAabb(const b3QuantizedBvhNode* currentNode,b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA,const btQuantizedBvhNode* treeNodeB,btNodeOverlapCallback* nodeCallback) const;
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const b3QuantizedBvhNode* treeNodeA,const b3QuantizedBvhNode* treeNodeB,b3NodeOverlapCallback* nodeCallback) const;
@@ -332,7 +332,7 @@ protected:
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
b3QuantizedBvh();
@@ -346,22 +346,22 @@ public:
void buildInternal();
///***************************************** expert/internal use only *************************
void reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const;
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void reportAabbOverlappingNodex(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const;
void reportBoxCastOverlappingNodex(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
SIMD_FORCE_INLINE void quantize(unsigned short* out, const b3Vector3& point,int isMax) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
btAssert(point.getX() <= m_bvhAabbMax.getX());
btAssert(point.getY() <= m_bvhAabbMax.getY());
btAssert(point.getZ() <= m_bvhAabbMax.getZ());
b3Assert(point.getX() <= m_bvhAabbMax.getX());
b3Assert(point.getY() <= m_bvhAabbMax.getY());
b3Assert(point.getZ() <= m_bvhAabbMax.getZ());
btAssert(point.getX() >= m_bvhAabbMin.getX());
btAssert(point.getY() >= m_bvhAabbMin.getY());
btAssert(point.getZ() >= m_bvhAabbMin.getZ());
b3Assert(point.getX() >= m_bvhAabbMin.getX());
b3Assert(point.getY() >= m_bvhAabbMin.getY());
b3Assert(point.getZ() >= m_bvhAabbMin.getZ());
b3Vector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative
@@ -420,7 +420,7 @@ public:
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const b3Vector3& point2,int isMax) const
{
btAssert(m_useQuantization);
b3Assert(m_useQuantization);
b3Vector3 clampedPoint(point2);
clampedPoint.setMax(m_bvhAabbMin);
@@ -442,7 +442,7 @@ public:
}
///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
void setTraversalMode(btTraversalMode traversalMode)
void setTraversalMode(b3TraversalMode traversalMode)
{
m_traversalMode = traversalMode;
}
@@ -477,11 +477,11 @@ public:
virtual int calculateSerializeBufferSizeNew() const;
///fills the dataBuffer and returns the struct name (and 0 on failure)
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
virtual void deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData);
virtual void deSerializeFloat(struct b3QuantizedBvhFloatData& quantizedBvhFloatData);
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData);
virtual void deSerializeDouble(struct b3QuantizedBvhDoubleData& quantizedBvhDoubleData);
////////////////////////////////////////////////////////////////////
@@ -501,7 +501,7 @@ private:
;
struct btBvhSubtreeInfoData
struct b3BvhSubtreeInfoData
{
int m_rootNodeIndex;
int m_subtreeSize;
@@ -509,20 +509,20 @@ struct btBvhSubtreeInfoData
unsigned short m_quantizedAabbMax[3];
};
struct btOptimizedBvhNodeFloatData
struct b3OptimizedBvhNodeFloatData
{
btVector3FloatData m_aabbMinOrg;
btVector3FloatData m_aabbMaxOrg;
b3Vector3FloatData m_aabbMinOrg;
b3Vector3FloatData m_aabbMaxOrg;
int m_escapeIndex;
int m_subPart;
int m_triangleIndex;
char m_pad[4];
};
struct btOptimizedBvhNodeDoubleData
struct b3OptimizedBvhNodeDoubleData
{
btVector3DoubleData m_aabbMinOrg;
btVector3DoubleData m_aabbMaxOrg;
b3Vector3DoubleData m_aabbMinOrg;
b3Vector3DoubleData m_aabbMaxOrg;
int m_escapeIndex;
int m_subPart;
int m_triangleIndex;
@@ -530,53 +530,53 @@ struct btOptimizedBvhNodeDoubleData
};
struct btQuantizedBvhNodeData
struct b3QuantizedBvhNodeData
{
unsigned short m_quantizedAabbMin[3];
unsigned short m_quantizedAabbMax[3];
int m_escapeIndexOrTriangleIndex;
};
struct btQuantizedBvhFloatData
struct b3QuantizedBvhFloatData
{
btVector3FloatData m_bvhAabbMin;
btVector3FloatData m_bvhAabbMax;
btVector3FloatData m_bvhQuantization;
b3Vector3FloatData m_bvhAabbMin;
b3Vector3FloatData m_bvhAabbMax;
b3Vector3FloatData m_bvhQuantization;
int m_curNodeIndex;
int m_useQuantization;
int m_numContiguousLeafNodes;
int m_numQuantizedContiguousNodes;
btOptimizedBvhNodeFloatData *m_contiguousNodesPtr;
btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
btBvhSubtreeInfoData *m_subTreeInfoPtr;
b3OptimizedBvhNodeFloatData *m_contiguousNodesPtr;
b3QuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
b3BvhSubtreeInfoData *m_subTreeInfoPtr;
int m_traversalMode;
int m_numSubtreeHeaders;
};
struct btQuantizedBvhDoubleData
struct b3QuantizedBvhDoubleData
{
btVector3DoubleData m_bvhAabbMin;
btVector3DoubleData m_bvhAabbMax;
btVector3DoubleData m_bvhQuantization;
b3Vector3DoubleData m_bvhAabbMin;
b3Vector3DoubleData m_bvhAabbMax;
b3Vector3DoubleData m_bvhQuantization;
int m_curNodeIndex;
int m_useQuantization;
int m_numContiguousLeafNodes;
int m_numQuantizedContiguousNodes;
btOptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
b3OptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
b3QuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
int m_traversalMode;
int m_numSubtreeHeaders;
btBvhSubtreeInfoData *m_subTreeInfoPtr;
b3BvhSubtreeInfoData *m_subTreeInfoPtr;
};
SIMD_FORCE_INLINE int b3QuantizedBvh::calculateSerializeBufferSizeNew() const
{
return sizeof(btQuantizedBvhData);
return sizeof(b3QuantizedBvhData);
}
#endif //BT_QUANTIZED_BVH_H
#endif //B3_QUANTIZED_BVH_H

View File

@@ -22,7 +22,7 @@ b3StridingMeshInterface::~b3StridingMeshInterface()
}
void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
void b3StridingMeshInterface::InternalProcessAllTriangles(b3InternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
(void)aabbMin;
(void)aabbMax;
@@ -104,7 +104,7 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
break;
}
default:
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
b3Assert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
}
break;
}
@@ -161,12 +161,12 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
break;
}
default:
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
b3Assert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
}
break;
}
default:
btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
b3Assert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
}
unLockReadOnlyVertexBase(part);
@@ -176,15 +176,15 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
void b3StridingMeshInterface::calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax)
{
struct AabbCalculationCallback : public btInternalTriangleIndexCallback
struct AabbCalculationCallback : public b3InternalTriangleIndexCallback
{
b3Vector3 m_aabbMin;
b3Vector3 m_aabbMax;
AabbCalculationCallback()
{
m_aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
m_aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
m_aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
m_aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
}
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
@@ -203,8 +203,8 @@ void b3StridingMeshInterface::calculateAabbBruteForce(b3Vector3& aabbMin,b3Vecto
//first calculate the total aabb for all triangles
AabbCalculationCallback aabbCallback;
aabbMin.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
aabbMin.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
aabbMax.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);
aabbMin = aabbCallback.m_aabbMin;

View File

@@ -13,12 +13,12 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_STRIDING_MESHINTERFACE_H
#define BT_STRIDING_MESHINTERFACE_H
#ifndef B3_STRIDING_MESHINTERFACE_H
#define B3_STRIDING_MESHINTERFACE_H
#include "Bullet3Common/b3Vector3.h"
#include "b3TriangleCallback.h"
//#include "btConcaveShape.h"
//#include "b3ConcaveShape.h"
enum PHY_ScalarType {
@@ -27,7 +27,7 @@ enum PHY_ScalarType {
};
/// The b3StridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
/// The b3StridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with b3BvhTriangleMeshShape and some other collision shapes.
/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
@@ -37,7 +37,7 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
b3Vector3 m_scaling;
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
b3StridingMeshInterface() :m_scaling(b3Scalar(1.),b3Scalar(1.),b3Scalar(1.))
{
@@ -48,7 +48,7 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
virtual void InternalProcessAllTriangles(b3InternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
///brute force method to calculate aabb
void calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax);
@@ -99,29 +99,29 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
virtual int calculateSerializeBufferSize() const;
///fills the dataBuffer and returns the struct name (and 0 on failure)
//virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
//virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
};
struct btIntIndexData
struct b3IntIndexData
{
int m_value;
};
struct btShortIntIndexData
struct b3ShortIntIndexData
{
short m_value;
char m_pad[2];
};
struct btShortIntIndexTripletData
struct b3ShortIntIndexTripletData
{
short m_values[3];
char m_pad[2];
};
struct btCharIndexTripletData
struct b3CharIndexTripletData
{
unsigned char m_values[3];
char m_pad;
@@ -129,16 +129,16 @@ struct btCharIndexTripletData
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btMeshPartData
struct b3MeshPartData
{
btVector3FloatData *m_vertices3f;
btVector3DoubleData *m_vertices3d;
b3Vector3FloatData *m_vertices3f;
b3Vector3DoubleData *m_vertices3d;
btIntIndexData *m_indices32;
btShortIntIndexTripletData *m_3indices16;
btCharIndexTripletData *m_3indices8;
b3IntIndexData *m_indices32;
b3ShortIntIndexTripletData *m_3indices16;
b3CharIndexTripletData *m_3indices8;
btShortIntIndexData *m_indices16;//backwards compatibility
b3ShortIntIndexData *m_indices16;//backwards compatibility
int m_numTriangles;//length of m_indices = m_numTriangles
int m_numVertices;
@@ -146,10 +146,10 @@ struct btMeshPartData
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btStridingMeshInterfaceData
struct b3StridingMeshInterfaceData
{
btMeshPartData *m_meshPartsPtr;
btVector3FloatData m_scaling;
b3MeshPartData *m_meshPartsPtr;
b3Vector3FloatData m_scaling;
int m_numMeshParts;
char m_padding[4];
};
@@ -159,9 +159,9 @@ struct btStridingMeshInterfaceData
SIMD_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const
{
return sizeof(btStridingMeshInterfaceData);
return sizeof(b3StridingMeshInterfaceData);
}
#endif //BT_STRIDING_MESHINTERFACE_H
#endif //B3_STRIDING_MESHINTERFACE_H

View File

@@ -21,7 +21,7 @@ b3TriangleCallback::~b3TriangleCallback()
}
btInternalTriangleIndexCallback::~btInternalTriangleIndexCallback()
b3InternalTriangleIndexCallback::~b3InternalTriangleIndexCallback()
{
}

View File

@@ -13,14 +13,14 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_TRIANGLE_CALLBACK_H
#define BT_TRIANGLE_CALLBACK_H
#ifndef B3_TRIANGLE_CALLBACK_H
#define B3_TRIANGLE_CALLBACK_H
#include "Bullet3Common/b3Vector3.h"
///The b3TriangleCallback provides a callback for each overlapping triangle when calling processAllTriangles.
///This callback is called by processAllTriangles for all btConcaveShape derived class, such as btBvhTriangleMeshShape, btStaticPlaneShape and btHeightfieldTerrainShape.
///This callback is called by processAllTriangles for all b3ConcaveShape derived class, such as b3BvhTriangleMeshShape, b3StaticPlaneShape and b3HeightfieldTerrainShape.
class b3TriangleCallback
{
public:
@@ -29,14 +29,14 @@ public:
virtual void processTriangle(b3Vector3* triangle, int partId, int triangleIndex) = 0;
};
class btInternalTriangleIndexCallback
class b3InternalTriangleIndexCallback
{
public:
virtual ~btInternalTriangleIndexCallback();
virtual ~b3InternalTriangleIndexCallback();
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex) = 0;
};
#endif //BT_TRIANGLE_CALLBACK_H
#endif //B3_TRIANGLE_CALLBACK_H

View File

@@ -18,7 +18,7 @@ subject to the following restrictions:
b3TriangleIndexVertexArray::b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride)
: m_hasAabb(0)
{
btIndexedMesh mesh;
b3IndexedMesh mesh;
mesh.m_numTriangles = numTriangles;
mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
@@ -38,9 +38,9 @@ b3TriangleIndexVertexArray::~b3TriangleIndexVertexArray()
void b3TriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
{
btAssert(subpart< getNumSubParts() );
b3Assert(subpart< getNumSubParts() );
btIndexedMesh& mesh = m_indexedMeshes[subpart];
b3IndexedMesh& mesh = m_indexedMeshes[subpart];
numverts = mesh.m_numVertices;
(*vertexbase) = (unsigned char *) mesh.m_vertexBase;
@@ -58,7 +58,7 @@ void b3TriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertex
void b3TriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const
{
const btIndexedMesh& mesh = m_indexedMeshes[subpart];
const b3IndexedMesh& mesh = m_indexedMeshes[subpart];
numverts = mesh.m_numVertices;
(*vertexbase) = (const unsigned char *)mesh.m_vertexBase;

View File

@@ -13,19 +13,19 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
#define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
#ifndef B3_TRIANGLE_INDEX_VERTEX_ARRAY_H
#define B3_TRIANGLE_INDEX_VERTEX_ARRAY_H
#include "b3StridingMeshInterface.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "Bullet3Common/b3Scalar.h"
///The btIndexedMesh indexes a single vertex and index array. Multiple btIndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh.
///The b3IndexedMesh indexes a single vertex and index array. Multiple b3IndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh.
///Instead of the number of indices, we pass the number of triangles.
ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
ATTRIBUTE_ALIGNED16( struct) b3IndexedMesh
{
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
int m_numTriangles;
const unsigned char * m_triangleIndexBase;
@@ -46,20 +46,20 @@ ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
PHY_ScalarType m_vertexType;
btIndexedMesh()
b3IndexedMesh()
:m_indexType(PHY_INTEGER),
#ifdef BT_USE_DOUBLE_PRECISION
#ifdef B3_USE_DOUBLE_PRECISION
m_vertexType(PHY_DOUBLE)
#else // BT_USE_DOUBLE_PRECISION
#else // B3_USE_DOUBLE_PRECISION
m_vertexType(PHY_FLOAT)
#endif // BT_USE_DOUBLE_PRECISION
#endif // B3_USE_DOUBLE_PRECISION
{
}
}
;
typedef b3AlignedObjectArray<btIndexedMesh> IndexedMeshArray;
typedef b3AlignedObjectArray<b3IndexedMesh> IndexedMeshArray;
///The b3TriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing triangle/index arrays.
///Additional meshes can be added using addIndexedMesh
@@ -76,7 +76,7 @@ protected:
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
b3TriangleIndexVertexArray() : m_hasAabb(0)
{
@@ -87,7 +87,7 @@ public:
//just to be backwards compatible
b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride);
void addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
void addIndexedMesh(const b3IndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
{
m_indexedMeshes.push_back(mesh);
m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType;
@@ -130,4 +130,4 @@ public:
}
;
#endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
#endif //B3_TRIANGLE_INDEX_VERTEX_ARRAY_H

View File

@@ -1,6 +1,6 @@
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
static const char* bvhTraversalKernelCL= \
"//keep this enum in sync with the CPU version (in btCollidable.h)\n"
"//keep this enum in sync with the CPU version (in b3Collidable.h)\n"
"//written by Erwin Coumans\n"
"\n"
"#define SHAPE_CONVEX_HULL 3\n"
@@ -13,7 +13,7 @@ static const char* bvhTraversalKernelCL= \
"\n"
"#define MAX_NUM_PARTS_IN_BITS 10\n"
"\n"
"///btQuantizedBvhNode is a compressed aabb node, 16 bytes.\n"
"///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.\n"
"///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).\n"
"typedef struct\n"
"{\n"
@@ -22,7 +22,7 @@ static const char* bvhTraversalKernelCL= \
" unsigned short int m_quantizedAabbMax[3];\n"
" //4 bytes\n"
" int m_escapeIndexOrTriangleIndex;\n"
"} btQuantizedBvhNode;\n"
"} b3QuantizedBvhNode;\n"
"\n"
"typedef struct\n"
"{\n"
@@ -44,12 +44,12 @@ static const char* bvhTraversalKernelCL= \
" }\n"
" int getEscapeIndex() const\n"
" {\n"
" btAssert(!isLeafNode());\n"
" b3Assert(!isLeafNode());\n"
" return -m_escapeIndexOrTriangleIndex;\n"
" }\n"
" int getTriangleIndex() const\n"
" {\n"
" btAssert(isLeafNode());\n"
" b3Assert(isLeafNode());\n"
" unsigned int x=0;\n"
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
" // Get only the lower bits where the triangle index is stored\n"
@@ -57,13 +57,13 @@ static const char* bvhTraversalKernelCL= \
" }\n"
" int getPartId() const\n"
" {\n"
" btAssert(isLeafNode());\n"
" b3Assert(isLeafNode());\n"
" // Get only the highest bits where the part index is stored\n"
" return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));\n"
" }\n"
"*/\n"
"\n"
"int getTriangleIndex(const btQuantizedBvhNode* rootNode)\n"
"int getTriangleIndex(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" unsigned int x=0;\n"
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
@@ -71,13 +71,13 @@ static const char* bvhTraversalKernelCL= \
" return (rootNode->m_escapeIndexOrTriangleIndex&~(y));\n"
"}\n"
"\n"
"int isLeaf(const btQuantizedBvhNode* rootNode)\n"
"int isLeaf(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" //skipindex is negative (internal node), triangleindex >=0 (leafnode)\n"
" return (rootNode->m_escapeIndexOrTriangleIndex >= 0)? 1 : 0;\n"
"}\n"
" \n"
"int getEscapeIndex(const btQuantizedBvhNode* rootNode)\n"
"int getEscapeIndex(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" return -rootNode->m_escapeIndexOrTriangleIndex;\n"
"}\n"
@@ -92,9 +92,9 @@ static const char* bvhTraversalKernelCL= \
" //4 bytes\n"
" int m_subtreeSize;\n"
" int m_padding[3];\n"
"} btBvhSubtreeInfo;\n"
"} b3BvhSubtreeInfo;\n"
"\n"
"///keep this in sync with btCollidable.h\n"
"///keep this in sync with b3Collidable.h\n"
"typedef struct\n"
"{\n"
" int m_numChildShapes;\n"
@@ -102,7 +102,7 @@ static const char* bvhTraversalKernelCL= \
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" \n"
"} btCollidableGpu;\n"
"} b3CollidableGpu;\n"
"\n"
"typedef struct\n"
"{\n"
@@ -112,7 +112,7 @@ static const char* bvhTraversalKernelCL= \
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
"} btGpuChildShape;\n"
"} b3GpuChildShape;\n"
"\n"
"\n"
"typedef struct\n"
@@ -142,7 +142,7 @@ static const char* bvhTraversalKernelCL= \
" float m_maxElems[4];\n"
" int m_maxIndices[4];\n"
" };\n"
"} btAabbCL;\n"
"} b3AabbCL;\n"
"\n"
"\n"
"int testQuantizedAabbAgainstQuantizedAabb(\n"
@@ -196,12 +196,12 @@ static const char* bvhTraversalKernelCL= \
"// work-in-progress\n"
"__kernel void bvhTraversalKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global btAabbCL* aabbs,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global b3AabbCL* aabbs,\n"
" __global int4* concavePairsOut,\n"
" __global volatile int* numConcavePairsOut,\n"
" __global const btBvhSubtreeInfo* subtreeHeadersRoot,\n"
" __global const btQuantizedBvhNode* quantizedNodesRoot,\n"
" __global const b3BvhSubtreeInfo* subtreeHeadersRoot,\n"
" __global const b3QuantizedBvhNode* quantizedNodesRoot,\n"
" __global const b3BvhInfo* bvhInfos,\n"
" int numPairs,\n"
" int maxNumConcavePairsCapacity)\n"
@@ -238,8 +238,8 @@ static const char* bvhTraversalKernelCL= \
" float4 bvhAabbMax = bvhInfo.m_aabbMax;\n"
" float4 bvhQuantization = bvhInfo.m_quantization;\n"
" int numSubtreeHeaders = bvhInfo.m_numSubTrees;\n"
" __global const btBvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];\n"
" __global const btQuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];\n"
" __global const b3BvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];\n"
" __global const b3QuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];\n"
" \n"
"\n"
" unsigned short int quantizedQueryAabbMin[3];\n"
@@ -249,7 +249,7 @@ static const char* bvhTraversalKernelCL= \
" \n"
" for (int i=0;i<numSubtreeHeaders;i++)\n"
" {\n"
" btBvhSubtreeInfo subtree = subtreeHeaders[i];\n"
" b3BvhSubtreeInfo subtree = subtreeHeaders[i];\n"
" \n"
" int overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);\n"
" if (overlap != 0)\n"
@@ -262,7 +262,7 @@ static const char* bvhTraversalKernelCL= \
" int aabbOverlap;\n"
" while (curIndex < endNodeIndex)\n"
" {\n"
" btQuantizedBvhNode rootNode = quantizedNodes[curIndex];\n"
" b3QuantizedBvhNode rootNode = quantizedNodes[curIndex];\n"
" aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode.m_quantizedAabbMin,rootNode.m_quantizedAabbMax);\n"
" isLeafNode = isLeaf(&rootNode);\n"
" if (aabbOverlap)\n"

View File

@@ -67,9 +67,9 @@ static const char* primitiveContactsKernelsCL= \
" float m_maxElems[4];\n"
" int m_maxIndices[4];\n"
" };\n"
"} btAabbCL;\n"
"} b3AabbCL;\n"
"\n"
"///keep this in sync with btCollidable.h\n"
"///keep this in sync with b3Collidable.h\n"
"typedef struct\n"
"{\n"
" int m_numChildShapes;\n"
@@ -77,7 +77,7 @@ static const char* primitiveContactsKernelsCL= \
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" \n"
"} btCollidableGpu;\n"
"} b3CollidableGpu;\n"
"\n"
"typedef struct\n"
"{\n"
@@ -87,7 +87,7 @@ static const char* primitiveContactsKernelsCL= \
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
"} btGpuChildShape;\n"
"} b3GpuChildShape;\n"
"\n"
"#define GET_NPOINTS(x) (x).m_worldNormal.w\n"
"\n"
@@ -129,7 +129,7 @@ static const char* primitiveContactsKernelsCL= \
" float4 m_plane;\n"
" int m_indexOffset;\n"
" int m_numIndices;\n"
"} btGpuFace;\n"
"} b3GpuFace;\n"
"\n"
"#define SELECT_UINT4( b, a, condition ) select( b,a,condition )\n"
"\n"
@@ -290,7 +290,7 @@ static const char* primitiveContactsKernelsCL= \
"\n"
"\n"
"inline bool IsPointInPolygon(float4 p, \n"
" const btGpuFace* face,\n"
" const b3GpuFace* face,\n"
" __global const float4* baseVertex,\n"
" __global const int* convexIndices,\n"
" float4* out)\n"
@@ -352,11 +352,11 @@ static const char* primitiveContactsKernelsCL= \
" int bodyIndexA, int bodyIndexB, \n"
" int collidableIndexA, int collidableIndexB, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes,\n"
" __global const float4* convexVertices,\n"
" __global const int* convexIndices,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
" int maxContactCapacity,\n"
@@ -383,7 +383,7 @@ static const char* primitiveContactsKernelsCL= \
"\n"
" for ( int f = 0; f < numFaces; f++ )\n"
" {\n"
" btGpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];\n"
" b3GpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];\n"
"\n"
" // set up a plane equation \n"
" float4 planeEqn;\n"
@@ -594,11 +594,11 @@ static const char* primitiveContactsKernelsCL= \
" int bodyIndexA, int bodyIndexB, \n"
" int collidableIndexA, int collidableIndexB, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu*collidables,\n"
" __global const b3CollidableGpu*collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes,\n"
" __global const float4* convexVertices,\n"
" __global const int* convexIndices,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
" int maxContactCapacity,\n"
@@ -733,8 +733,8 @@ static const char* primitiveContactsKernelsCL= \
" int bodyIndexA, int bodyIndexB, \n"
" int collidableIndexA, int collidableIndexB, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const btGpuFace* faces,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const b3GpuFace* faces,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
" int maxContactCapacity)\n"
@@ -793,11 +793,11 @@ static const char* primitiveContactsKernelsCL= \
"\n"
"__kernel void primitiveContactsKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
@@ -972,14 +972,14 @@ static const char* primitiveContactsKernelsCL= \
"// work-in-progress\n"
"__kernel void processCompoundPairsPrimitivesKernel( __global const int4* gpuCompoundPairs,\n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global b3AabbCL* aabbs,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
" int numCompoundPairs, int maxContactCapacity\n"
@@ -1157,7 +1157,7 @@ static const char* primitiveContactsKernelsCL= \
" int bodyIndexA, int bodyIndexB,\n"
" int collidableIndexA, int collidableIndexB, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" const float4* triangleVertices,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
@@ -1299,13 +1299,13 @@ static const char* primitiveContactsKernelsCL= \
"// work-in-progress\n"
"__kernel void findConcaveSphereContactsKernel( __global int4* concavePairs,\n"
" __global const BodyData* rigidBodies,\n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global b3AabbCL* aabbs,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
" int numConcavePairs, int maxContactCapacity\n"
@@ -1329,7 +1329,7 @@ static const char* primitiveContactsKernelsCL= \
" if (collidables[collidableIndexB].m_shapeType==SHAPE_SPHERE)\n"
" {\n"
" int f = concavePairs[i].z;\n"
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" \n"
" float4 verticesA[3];\n"
" for (int i=0;i<3;i++)\n"

View File

@@ -55,7 +55,7 @@ static const char* satClipKernelsCL= \
"} Contact4;\n"
"\n"
"\n"
"///keep this in sync with btCollidable.h\n"
"///keep this in sync with b3Collidable.h\n"
"typedef struct\n"
"{\n"
" int m_numChildShapes;\n"
@@ -63,7 +63,7 @@ static const char* satClipKernelsCL= \
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" \n"
"} btCollidableGpu;\n"
"} b3CollidableGpu;\n"
"\n"
"typedef struct\n"
"{\n"
@@ -73,7 +73,7 @@ static const char* satClipKernelsCL= \
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
"} btGpuChildShape;\n"
"} b3GpuChildShape;\n"
"\n"
"#define GET_NPOINTS(x) (x).m_worldNormal.w\n"
"\n"
@@ -115,7 +115,7 @@ static const char* satClipKernelsCL= \
" float4 m_plane;\n"
" int m_indexOffset;\n"
" int m_numIndices;\n"
"} btGpuFace;\n"
"} b3GpuFace;\n"
"\n"
"#define SELECT_UINT4( b, a, condition ) select( b,a,condition )\n"
"\n"
@@ -357,7 +357,7 @@ static const char* satClipKernelsCL= \
" float4* worldVertsB2, int capacityWorldVertsB2,\n"
" const float minDist, float maxDist,\n"
" __global const float4* vertices,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" float4* contactsOut,\n"
" int contactCapacity)\n"
@@ -392,7 +392,7 @@ static const char* satClipKernelsCL= \
" if (closestFaceA<0)\n"
" return numContactsOut;\n"
"\n"
" btGpuFace polyA = faces[hullA->m_faceOffset+closestFaceA];\n"
" b3GpuFace polyA = faces[hullA->m_faceOffset+closestFaceA];\n"
"\n"
" // clip polygon to back of planes of all faces of hull A that are adjacent to witness face\n"
" int numVerticesA = polyA.m_numIndices;\n"
@@ -416,7 +416,7 @@ static const char* satClipKernelsCL= \
" //clipFace(*pVtxIn, *pVtxOut,planeNormalWS,planeEqWS);\n"
" numVertsOut = clipFace(pVtxIn, numVertsIn, planeNormalWS,planeEqWS, pVtxOut);\n"
"\n"
" //btSwap(pVtxIn,pVtxOut);\n"
" //b3Swap(pVtxIn,pVtxOut);\n"
" float4* tmp = pVtxOut;\n"
" pVtxOut = pVtxIn;\n"
" pVtxIn = tmp;\n"
@@ -458,10 +458,10 @@ static const char* satClipKernelsCL= \
" float4* worldVertsB2, int capacityWorldVertsB2,\n"
" const float minDist, float maxDist,\n"
" const float4* verticesA,\n"
" const btGpuFace* facesA,\n"
" const b3GpuFace* facesA,\n"
" const int* indicesA,\n"
" __global const float4* verticesB,\n"
" __global const btGpuFace* facesB,\n"
" __global const b3GpuFace* facesB,\n"
" __global const int* indicesB,\n"
" float4* contactsOut,\n"
" int contactCapacity)\n"
@@ -496,7 +496,7 @@ static const char* satClipKernelsCL= \
" if (closestFaceA<0)\n"
" return numContactsOut;\n"
"\n"
" btGpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];\n"
" b3GpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];\n"
"\n"
" // clip polygon to back of planes of all faces of hull A that are adjacent to witness face\n"
" int numVerticesA = polyA.m_numIndices;\n"
@@ -520,7 +520,7 @@ static const char* satClipKernelsCL= \
" //clipFace(*pVtxIn, *pVtxOut,planeNormalWS,planeEqWS);\n"
" numVertsOut = clipFace(pVtxIn, numVertsIn, planeNormalWS,planeEqWS, pVtxOut);\n"
"\n"
" //btSwap(pVtxIn,pVtxOut);\n"
" //b3Swap(pVtxIn,pVtxOut);\n"
" float4* tmp = pVtxOut;\n"
" pVtxOut = pVtxIn;\n"
" pVtxIn = tmp;\n"
@@ -561,7 +561,7 @@ static const char* satClipKernelsCL= \
" float4* worldVertsB1, float4* worldVertsB2, int capacityWorldVerts,\n"
" const float minDist, float maxDist,\n"
" __global const float4* vertices,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" float4* localContactsOut,\n"
" int localContactCapacity)\n"
@@ -589,7 +589,7 @@ static const char* satClipKernelsCL= \
" }\n"
"\n"
" {\n"
" const btGpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
" const b3GpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
" const int numVertices = polyB.m_numIndices;\n"
" for(int e0=0;e0<numVertices;e0++)\n"
" {\n"
@@ -617,10 +617,10 @@ static const char* satClipKernelsCL= \
" float4* worldVertsB1, float4* worldVertsB2, int capacityWorldVerts,\n"
" const float minDist, float maxDist,\n"
" const float4* verticesA,\n"
" const btGpuFace* facesA,\n"
" const b3GpuFace* facesA,\n"
" const int* indicesA,\n"
" __global const float4* verticesB,\n"
" __global const btGpuFace* facesB,\n"
" __global const b3GpuFace* facesB,\n"
" __global const int* indicesB,\n"
" float4* localContactsOut,\n"
" int localContactCapacity)\n"
@@ -648,7 +648,7 @@ static const char* satClipKernelsCL= \
" }\n"
"\n"
" {\n"
" const btGpuFace polyB = facesB[hullB->m_faceOffset+closestFaceB];\n"
" const b3GpuFace polyB = facesB[hullB->m_faceOffset+closestFaceB];\n"
" const int numVertices = polyB.m_numIndices;\n"
" for(int e0=0;e0<numVertices;e0++)\n"
" {\n"
@@ -956,11 +956,11 @@ static const char* satClipKernelsCL= \
"\n"
"__kernel void clipHullHullKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global const float4* separatingNormals,\n"
" __global const int* hasSeparatingAxis,\n"
@@ -1053,13 +1053,13 @@ static const char* satClipKernelsCL= \
"\n"
"__kernel void clipCompoundsHullHullKernel( __global const int4* gpuCompoundPairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global const float4* gpuCompoundSepNormalsOut,\n"
" __global const int* gpuHasCompoundSepNormalsOut,\n"
" __global Contact4* restrict globalContactsOut,\n"
@@ -1185,7 +1185,7 @@ static const char* satClipKernelsCL= \
"\n"
"__kernel void sphereSphereCollisionKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const float4* separatingNormals,\n"
" __global const int* hasSeparatingAxis,\n"
" __global Contact4* restrict globalContactsOut,\n"
@@ -1252,13 +1252,13 @@ static const char* satClipKernelsCL= \
"\n"
"__kernel void clipHullHullConcaveConvexKernel( __global int4* concavePairsIn,\n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global const float4* separatingNormals,\n"
" __global Contact4* restrict globalContactsOut,\n"
" counter32_t nGlobalContactsOut,\n"
@@ -1306,7 +1306,7 @@ static const char* satClipKernelsCL= \
" convexPolyhedronA.m_vertexOffset = 0;\n"
" float4 localCenter = make_float4(0.f,0.f,0.f,0.f);\n"
"\n"
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" \n"
" float4 verticesA[3];\n"
" for (int i=0;i<3;i++)\n"
@@ -1335,7 +1335,7 @@ static const char* satClipKernelsCL= \
" \n"
" float4 normal = make_float4(face.m_plane.x,face.m_plane.y,face.m_plane.z,0.f);\n"
" \n"
" btGpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
" b3GpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
" int indicesA[3+3+2+2+2];\n"
" int curUsedIndices=0;\n"
" int fidx=0;\n"
@@ -1496,7 +1496,7 @@ static const char* satClipKernelsCL= \
" int capacityWorldVerts,\n"
" const float minDist, float maxDist,\n"
" __global const float4* vertices,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global int4* clippingFaces, int pairIndex)\n"
"{\n"
@@ -1523,7 +1523,7 @@ static const char* satClipKernelsCL= \
" }\n"
" \n"
" {\n"
" const btGpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
" const b3GpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
" const int numVertices = polyB.m_numIndices;\n"
" for(int e0=0;e0<numVertices;e0++)\n"
" {\n"
@@ -1664,11 +1664,11 @@ static const char* satClipKernelsCL= \
"\n"
"__kernel void findClippingFacesKernel( __global const int2* pairs,\n"
" __global const BodyData* rigidBodies,\n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes,\n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global const float4* separatingNormals,\n"
" __global const int* hasSeparatingAxis,\n"

View File

@@ -1,6 +1,6 @@
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
static const char* satKernelsCL= \
"//keep this enum in sync with the CPU version (in btCollidable.h)\n"
"//keep this enum in sync with the CPU version (in b3Collidable.h)\n"
"//written by Erwin Coumans\n"
"\n"
"\n"
@@ -13,7 +13,7 @@ static const char* satKernelsCL= \
"\n"
"typedef unsigned int u32;\n"
"\n"
"///keep this in sync with btCollidable.h\n"
"///keep this in sync with b3Collidable.h\n"
"typedef struct\n"
"{\n"
" int m_numChildShapes;\n"
@@ -21,7 +21,7 @@ static const char* satKernelsCL= \
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" \n"
"} btCollidableGpu;\n"
"} b3CollidableGpu;\n"
"\n"
"typedef struct\n"
"{\n"
@@ -31,7 +31,7 @@ static const char* satKernelsCL= \
" int m_unused0;\n"
" int m_unused1;\n"
" int m_unused2;\n"
"} btGpuChildShape;\n"
"} b3GpuChildShape;\n"
"\n"
"\n"
"typedef struct\n"
@@ -80,14 +80,14 @@ static const char* satKernelsCL= \
" float m_maxElems[4];\n"
" int m_maxIndices[4];\n"
" };\n"
"} btAabbCL;\n"
"} b3AabbCL;\n"
"\n"
"typedef struct\n"
"{\n"
" float4 m_plane;\n"
" int m_indexOffset;\n"
" int m_numIndices;\n"
"} btGpuFace;\n"
"} b3GpuFace;\n"
"\n"
"#define make_float4 (float4)\n"
"\n"
@@ -296,12 +296,12 @@ static const char* satKernelsCL= \
" \n"
" const float4* verticesA, \n"
" const float4* uniqueEdgesA, \n"
" const btGpuFace* facesA,\n"
" const b3GpuFace* facesA,\n"
" const int* indicesA,\n"
"\n"
" __global const float4* verticesB, \n"
" __global const float4* uniqueEdgesB, \n"
" __global const btGpuFace* facesB,\n"
" __global const b3GpuFace* facesB,\n"
" __global const int* indicesB,\n"
" float4* sep,\n"
" float* dmin)\n"
@@ -348,11 +348,11 @@ static const char* satKernelsCL= \
" const float4 DeltaC2,\n"
" __global const float4* verticesA, \n"
" __global const float4* uniqueEdgesA, \n"
" __global const btGpuFace* facesA,\n"
" __global const b3GpuFace* facesA,\n"
" __global const int* indicesA,\n"
" const float4* verticesB,\n"
" const float4* uniqueEdgesB, \n"
" const btGpuFace* facesB,\n"
" const b3GpuFace* facesB,\n"
" const int* indicesB,\n"
" float4* sep,\n"
" float* dmin)\n"
@@ -401,11 +401,11 @@ static const char* satKernelsCL= \
" const float4 DeltaC2,\n"
" const float4* verticesA, \n"
" const float4* uniqueEdgesA, \n"
" const btGpuFace* facesA,\n"
" const b3GpuFace* facesA,\n"
" const int* indicesA,\n"
" __global const float4* verticesB, \n"
" __global const float4* uniqueEdgesB, \n"
" __global const btGpuFace* facesB,\n"
" __global const b3GpuFace* facesB,\n"
" __global const int* indicesB,\n"
" float4* sep,\n"
" float* dmin)\n"
@@ -507,7 +507,7 @@ static const char* satKernelsCL= \
" const float4 DeltaC2,\n"
" __global const float4* vertices, \n"
" __global const float4* uniqueEdges, \n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" float4* sep,\n"
" float* dmin)\n"
@@ -566,7 +566,7 @@ static const char* satKernelsCL= \
" const float4 DeltaC2,\n"
" __global const float4* vertices, \n"
" __global const float4* uniqueEdges, \n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" float4* sep,\n"
" float* dmin)\n"
@@ -643,14 +643,14 @@ static const char* satKernelsCL= \
"// work-in-progress\n"
"__kernel void processCompoundPairsKernel( __global const int4* gpuCompoundPairs,\n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global b3AabbCL* aabbs,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global volatile float4* gpuCompoundSepNormalsOut,\n"
" __global volatile int* gpuHasCompoundSepNormalsOut,\n"
" int numCompoundPairs\n"
@@ -760,14 +760,14 @@ static const char* satKernelsCL= \
"// work-in-progress\n"
"__kernel void findCompoundPairsKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global b3AabbCL* aabbs,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global volatile int4* gpuCompoundPairsOut,\n"
" __global volatile int* numCompoundPairsOut,\n"
" int numPairs,\n"
@@ -942,13 +942,13 @@ static const char* satKernelsCL= \
"// work-in-progress\n"
"__kernel void findSeparatingAxisKernel( __global const int2* pairs, \n"
" __global const BodyData* rigidBodies, \n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global b3AabbCL* aabbs,\n"
" __global volatile float4* separatingNormals,\n"
" __global volatile int* hasSeparatingAxis,\n"
" int numPairs\n"
@@ -1056,14 +1056,14 @@ static const char* satKernelsCL= \
"// work-in-progress\n"
"__kernel void findConcaveSeparatingAxisKernel( __global int4* concavePairs,\n"
" __global const BodyData* rigidBodies,\n"
" __global const btCollidableGpu* collidables,\n"
" __global const b3CollidableGpu* collidables,\n"
" __global const ConvexPolyhedronCL* convexShapes, \n"
" __global const float4* vertices,\n"
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const b3GpuFace* faces,\n"
" __global const int* indices,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global btAabbCL* aabbs,\n"
" __global const b3GpuChildShape* gpuChildShapes,\n"
" __global b3AabbCL* aabbs,\n"
" __global float4* concaveSeparatingNormalsOut,\n"
" int numConcavePairs\n"
" )\n"
@@ -1106,9 +1106,9 @@ static const char* satKernelsCL= \
" convexPolyhedronA.m_vertexOffset = 0;\n"
" float4 localCenter = make_float4(0.f,0.f,0.f,0.f);\n"
"\n"
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
" float4 triMinAabb, triMaxAabb;\n"
" btAabbCL triAabb;\n"
" b3AabbCL triAabb;\n"
" triAabb.m_min = make_float4(1e30f,1e30f,1e30f,0.f);\n"
" triAabb.m_max = make_float4(-1e30f,-1e30f,-1e30f,0.f);\n"
" \n"
@@ -1153,7 +1153,7 @@ static const char* satKernelsCL= \
" \n"
" float4 normal = make_float4(face.m_plane.x,face.m_plane.y,face.m_plane.z,0.f);\n"
" \n"
" btGpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
" b3GpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
" int indicesA[3+3+2+2+2];\n"
" int curUsedIndices=0;\n"
" int fidx=0;\n"

View File

@@ -18,10 +18,10 @@ subject to the following restrictions:
#include "../host/b3ConvexHullContact.h"
#include "Bullet3Common/b3Vector3.h"
#include "parallel_primitives/host/btFillCL.h"
#include "parallel_primitives/host/btBoundSearchCL.h"
#include "parallel_primitives/host/btRadixSort32CL.h"
#include "parallel_primitives/host/btPrefixScanCL.h"
#include "parallel_primitives/host/b3FillCL.h"
#include "parallel_primitives/host/b3BoundSearchCL.h"
#include "parallel_primitives/host/b3RadixSort32CL.h"
#include "parallel_primitives/host/b3PrefixScanCL.h"
#include "Bullet3Common/b3CommandLineArgs.h"
#include "../host/b3ConvexHullContact.h"
@@ -54,7 +54,7 @@ void initCL(int preferredDeviceIndex, int preferredPlatformIndex)
int numDev = b3OpenCLUtils::getNumDevices(g_context);
if (numDev>0)
{
btOpenCLDeviceInfo info;
b3OpenCLDeviceInfo info;
g_device= b3OpenCLUtils::getDevice(g_context,0);
g_queue = clCreateCommandQueue(g_context, g_device, 0, &ciErrNum);
oclCHECKERROR(ciErrNum, CL_SUCCESS);