more bt* to b3*

This commit is contained in:
erwin coumans
2013-04-16 17:08:59 -07:00
parent faabffc23d
commit e646754228
116 changed files with 2466 additions and 3034 deletions

View File

@@ -1,14 +1,14 @@
#include "b3GpuSapBroadphase.h"
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
#include "parallel_primitives/host/btLauncherCL.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
#include "basic_initialize/b3OpenCLUtils.h"
#include "../kernels/sapKernels.h"
#include "../kernels/sapFastKernels.h"
#include "BulletCommon/btMinMax.h"
#include "BulletCommon/b3MinMax.h"
b3GpuSapBroadphase::b3GpuSapBroadphase(cl_context ctx,cl_device_id device, cl_command_queue q )
@@ -77,8 +77,8 @@ b3GpuSapBroadphase::~b3GpuSapBroadphase()
}
/// conservative test for overlap between two aabbs
static bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1,
const btVector3 &aabbMin2, const btVector3 &aabbMax2)
static bool TestAabbAgainstAabb2(const b3Vector3 &aabbMin1, const b3Vector3 &aabbMax1,
const b3Vector3 &aabbMin2, const b3Vector3 &aabbMax2)
{
bool overlap = true;
overlap = (aabbMin1.getX() > aabbMax2.getX() || aabbMax1.getX() < aabbMin2.getX()) ? false : overlap;
@@ -192,7 +192,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
}
}
btAlignedObjectArray<btInt2> hostPairs;
b3AlignedObjectArray<btInt2> hostPairs;
{
int numSmallAabbs = m_smallAabbsCPU.size();
@@ -202,8 +202,8 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
for (int j=i+1;j<numSmallAabbs;j++)
{
if (TestAabbAgainstAabb2((btVector3&)m_smallAabbsCPU[i].m_min, (btVector3&)m_smallAabbsCPU[i].m_max,
(btVector3&)m_smallAabbsCPU[j].m_min,(btVector3&)m_smallAabbsCPU[j].m_max))
if (TestAabbAgainstAabb2((b3Vector3&)m_smallAabbsCPU[i].m_min, (b3Vector3&)m_smallAabbsCPU[i].m_max,
(b3Vector3&)m_smallAabbsCPU[j].m_min,(b3Vector3&)m_smallAabbsCPU[j].m_max))
{
btInt2 pair;
pair.x = m_smallAabbsCPU[i].m_minIndices[3];//store the original index in the unsorted aabb array
@@ -224,8 +224,8 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
for (int j=0;j<numLargeAabbs;j++)
{
if (TestAabbAgainstAabb2((btVector3&)m_smallAabbsCPU[i].m_min, (btVector3&)m_smallAabbsCPU[i].m_max,
(btVector3&)m_largeAabbsCPU[j].m_min,(btVector3&)m_largeAabbsCPU[j].m_max))
if (TestAabbAgainstAabb2((b3Vector3&)m_smallAabbsCPU[i].m_min, (b3Vector3&)m_smallAabbsCPU[i].m_max,
(b3Vector3&)m_largeAabbsCPU[j].m_min,(b3Vector3&)m_largeAabbsCPU[j].m_max))
{
btInt2 pair;
pair.x = m_largeAabbsCPU[j].m_minIndices[3];
@@ -485,7 +485,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
pairCount.setFromOpenCLBuffer(launcher.m_arrays[2]->getBufferCL(),numElements);
numPairs = pairCount.at(0);
//printf("overlapping pairs = %d\n",numPairs);
btAlignedObjectArray<btInt2> hostOoverlappingPairs;
b3AlignedObjectArray<btInt2> hostOoverlappingPairs;
btOpenCLArray<btInt2> tmpGpuPairs(m_context,m_queue);
tmpGpuPairs.setFromOpenCLBuffer(launcher.m_arrays[1]->getBufferCL(),numPairs );
@@ -520,7 +520,7 @@ void b3GpuSapBroadphase::writeAabbsToGpu()
}
void b3GpuSapBroadphase::createLargeProxy(const btVector3& aabbMin, const btVector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
void b3GpuSapBroadphase::createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
{
int index = userPtr;
b3SapAabb aabb;
@@ -535,7 +535,7 @@ void b3GpuSapBroadphase::createLargeProxy(const btVector3& aabbMin, const btVec
m_allAabbsCPU.push_back(aabb);
}
void b3GpuSapBroadphase::createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
void b3GpuSapBroadphase::createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
{
int index = userPtr;
b3SapAabb aabb;

View File

@@ -3,7 +3,7 @@
#include "parallel_primitives/host/btOpenCLArray.h"
#include "parallel_primitives/host/btFillCL.h" //btInt2
class btVector3;
class b3Vector3;
#include "parallel_primitives/host/btRadixSort32CL.h"
#include "b3SapAabb.h"
@@ -25,19 +25,19 @@ class b3GpuSapBroadphase
class btRadixSort32CL* m_sorter;
///test for 3d SAP
btAlignedObjectArray<btSortData> m_sortedAxisCPU[3][2];
b3AlignedObjectArray<btSortData> m_sortedAxisCPU[3][2];
int m_currentBuffer;
public:
btOpenCLArray<b3SapAabb> m_allAabbsGPU;
btAlignedObjectArray<b3SapAabb> m_allAabbsCPU;
b3AlignedObjectArray<b3SapAabb> m_allAabbsCPU;
btOpenCLArray<b3SapAabb> m_smallAabbsGPU;
btAlignedObjectArray<b3SapAabb> m_smallAabbsCPU;
b3AlignedObjectArray<b3SapAabb> m_smallAabbsCPU;
btOpenCLArray<b3SapAabb> m_largeAabbsGPU;
btAlignedObjectArray<b3SapAabb> m_largeAabbsCPU;
b3AlignedObjectArray<b3SapAabb> m_largeAabbsCPU;
btOpenCLArray<btInt2> m_overlappingPairs;
@@ -55,8 +55,8 @@ class b3GpuSapBroadphase
void init3dSap();
void calculateOverlappingPairsHostIncremental3Sap();
void createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
void createLargeProxy(const btVector3& aabbMin, const btVector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
//call writeAabbsToGpu after done making all changes (createProxy etc)
void writeAabbsToGpu();

View File

@@ -16,13 +16,13 @@ subject to the following restrictions:
#include <stdio.h>
#include "../basic_initialize/b3OpenCLUtils.h"
#include "../host/b3GpuSapBroadphase.h"
#include "BulletCommon/btVector3.h"
#include "BulletCommon/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 "BulletCommon/CommandLineArgs.h"
#include "BulletCommon/btMinMax.h"
#include "BulletCommon/b3CommandLineArgs.h"
#include "BulletCommon/b3MinMax.h"
int g_nPassed = 0;
int g_nFailed = 0;
@@ -76,8 +76,8 @@ inline void broadphaseTest()
b3GpuSapBroadphase* sap = new b3GpuSapBroadphase(g_context,g_device,g_queue);
int group=1;
int mask=1;
btVector3 aabbMin(0,0,0);
btVector3 aabbMax(1,1,1);
b3Vector3 aabbMin(0,0,0);
b3Vector3 aabbMax(1,1,1);
int usrPtr = 1;
sap->createProxy(aabbMin,aabbMax,usrPtr,group,mask);
@@ -105,7 +105,7 @@ int main(int argc, char** argv)
int preferredDeviceIndex = -1;
int preferredPlatformIndex = -1;
CommandLineArgs args(argc, argv);
b3CommandLineArgs args(argc, argv);
args.GetCmdLineArgument("deviceId", preferredDeviceIndex);
args.GetCmdLineArgument("platformId", preferredPlatformIndex);

View File

@@ -29,11 +29,11 @@ function createProject(vendor)
"../../parallel_primitives/host/btPrefixScanCL.h",
"../../parallel_primitives/host/btRadixSort32CL.cpp",
"../../parallel_primitives/host/btRadixSort32CL.h",
"../../../src/BulletCommon/btAlignedAllocator.cpp",
"../../../src/BulletCommon/btAlignedAllocator.h",
"../../../src/BulletCommon/btAlignedObjectArray.h",
"../../../src/BulletCommon/btQuickprof.cpp",
"../../../src/BulletCommon/btQuickprof.h",
"../../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../../src/BulletCommon/b3AlignedAllocator.h",
"../../../src/BulletCommon/b3AlignedObjectArray.h",
"../../../src/BulletCommon/b3Quickprof.cpp",
"../../../src/BulletCommon/b3Quickprof.h",
}

View File

@@ -1,15 +1,15 @@
#ifndef BT_CONTACT4_H
#define BT_CONTACT4_H
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
ATTRIBUTE_ALIGNED16(struct) b3Contact4
{
BT_DECLARE_ALIGNED_ALLOCATOR();
btVector3 m_worldPos[4];
btVector3 m_worldNormal;
b3Vector3 m_worldPos[4];
b3Vector3 m_worldNormal;
// float m_restituitionCoeff;
// float m_frictionCoeff;
unsigned short m_restituitionCoeffCmp;

View File

@@ -25,8 +25,8 @@ subject to the following restrictions:
#include "b3ConvexPolyhedronCL.h"
typedef btAlignedObjectArray<btVector3> btVertexArray;
#include "BulletCommon/btQuickprof.h"
typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
#include "BulletCommon/b3Quickprof.h"
#include <float.h> //for FLT_MAX
#include "basic_initialize/b3OpenCLUtils.h"
@@ -219,7 +219,7 @@ struct MyTriangleCallback : public btNodeOverlapCallback
};
#define float4 btVector3
#define float4 b3Vector3
#define make_float4(x,y,z,w) btVector4(x,y,z,w)
float signedDistanceFromPointToPlane(const float4& point, const float4& planeEqn, float4* closestPointOnFace)
@@ -234,14 +234,14 @@ float signedDistanceFromPointToPlane(const float4& point, const float4& planeEqn
#define cross3(a,b) (a.cross(b))
btVector3 transform(btVector3* v, const btVector3* pos, const btVector3* orn)
b3Vector3 transform(b3Vector3* v, const b3Vector3* pos, const b3Vector3* orn)
{
btTransform tr;
b3Transform tr;
tr.setIdentity();
tr.setOrigin(*pos);
btQuaternion* o = (btQuaternion*) orn;
b3Quaternion* o = (b3Quaternion*) orn;
tr.setRotation(*o);
btVector3 res = tr(*v);
b3Vector3 res = tr(*v);
return res;
}
@@ -411,7 +411,7 @@ void computeContactPlaneConvex(int pairIndex,
const b3RigidBodyCL* rigidBodies,
const b3Collidable* collidables,
const b3ConvexPolyhedronCL* convexShapes,
const btVector3* convexVertices,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
b3Contact4* globalContactsOut,
@@ -422,40 +422,40 @@ void computeContactPlaneConvex(int pairIndex,
int shapeIndex = collidables[collidableIndexB].m_shapeIndex;
const b3ConvexPolyhedronCL* hullB = &convexShapes[shapeIndex];
btVector3 posB = rigidBodies[bodyIndexB].m_pos;
btQuaternion ornB = rigidBodies[bodyIndexB].m_quat;
btVector3 posA = rigidBodies[bodyIndexA].m_pos;
btQuaternion ornA = rigidBodies[bodyIndexA].m_quat;
b3Vector3 posB = rigidBodies[bodyIndexB].m_pos;
b3Quaternion ornB = rigidBodies[bodyIndexB].m_quat;
b3Vector3 posA = rigidBodies[bodyIndexA].m_pos;
b3Quaternion ornA = rigidBodies[bodyIndexA].m_quat;
int numContactsOut = 0;
int numWorldVertsB1= 0;
btVector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
btVector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
btVector3 planeNormalWorld = quatRotate(ornA,planeNormal);
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal);
float planeConstant = planeEq.w;
btTransform convexWorldTransform;
b3Transform convexWorldTransform;
convexWorldTransform.setIdentity();
convexWorldTransform.setOrigin(posB);
convexWorldTransform.setRotation(ornB);
btTransform planeTransform;
b3Transform planeTransform;
planeTransform.setIdentity();
planeTransform.setOrigin(posA);
planeTransform.setRotation(ornA);
btTransform planeInConvex;
b3Transform planeInConvex;
planeInConvex= convexWorldTransform.inverse() * planeTransform;
btTransform convexInPlane;
b3Transform convexInPlane;
convexInPlane = planeTransform.inverse() * convexWorldTransform;
btVector3 planeNormalInConvex = planeInConvex.getBasis()*-planeNormal;
b3Vector3 planeNormalInConvex = planeInConvex.getBasis()*-planeNormal;
float maxDot = -1e30;
int hitVertex=-1;
btVector3 hitVtx;
b3Vector3 hitVtx;
#define MAX_PLANE_CONVEX_POINTS 64
btVector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
int numPoints = 0;
btInt4 contactIdx;
@@ -466,7 +466,7 @@ void computeContactPlaneConvex(int pairIndex,
for (int i=0;i<hullB->m_numVertices;i++)
{
btVector3 vtx = convexVertices[hullB->m_vertexOffset+i];
b3Vector3 vtx = convexVertices[hullB->m_vertexOffset+i];
float curDot = vtx.dot(planeNormalInConvex);
@@ -482,8 +482,8 @@ void computeContactPlaneConvex(int pairIndex,
if (numPoints<MAX_PLANE_CONVEX_POINTS)
{
btVector3 vtxWorld = convexWorldTransform*vtx;
btVector3 vtxInPlane = planeTransform.inverse()*vtxWorld;
b3Vector3 vtxWorld = convexWorldTransform*vtx;
b3Vector3 vtxInPlane = planeTransform.inverse()*vtxWorld;
float dist = planeNormal.dot(vtxInPlane)-planeConstant;
if (dist<0.f)
{
@@ -523,7 +523,7 @@ void computeContactPlaneConvex(int pairIndex,
c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;
for (int i=0;i<numReducedPoints;i++)
{
btVector3 pOnB1 = contactPoints[contactIdx.s[i]];
b3Vector3 pOnB1 = contactPoints[contactIdx.s[i]];
c->m_worldPos[i] = pOnB1;
}
c->m_worldNormal[3] = numReducedPoints;
@@ -544,7 +544,7 @@ void computeContactPlaneCompound(int pairIndex,
const b3RigidBodyCL* rigidBodies,
const b3Collidable* collidables,
const b3ConvexPolyhedronCL* convexShapes,
const btVector3* convexVertices,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
b3Contact4* globalContactsOut,
@@ -560,40 +560,40 @@ void computeContactPlaneCompound(int pairIndex,
int shapeIndex = collidables[collidableIndexB].m_shapeIndex;
const b3ConvexPolyhedronCL* hullB = &convexShapes[shapeIndex];
btVector3 posB = rigidBodies[bodyIndexB].m_pos;
btQuaternion ornB = rigidBodies[bodyIndexB].m_quat;
btVector3 posA = rigidBodies[bodyIndexA].m_pos;
btQuaternion ornA = rigidBodies[bodyIndexA].m_quat;
b3Vector3 posB = rigidBodies[bodyIndexB].m_pos;
b3Quaternion ornB = rigidBodies[bodyIndexB].m_quat;
b3Vector3 posA = rigidBodies[bodyIndexA].m_pos;
b3Quaternion ornA = rigidBodies[bodyIndexA].m_quat;
int numContactsOut = 0;
int numWorldVertsB1= 0;
btVector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
btVector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
btVector3 planeNormalWorld = quatRotate(ornA,planeNormal);
b3Vector3 planeEq = faces[collidables[collidableIndexA].m_shapeIndex].m_plane;
b3Vector3 planeNormal(planeEq.x,planeEq.y,planeEq.z);
b3Vector3 planeNormalWorld = quatRotate(ornA,planeNormal);
float planeConstant = planeEq.w;
btTransform convexWorldTransform;
b3Transform convexWorldTransform;
convexWorldTransform.setIdentity();
convexWorldTransform.setOrigin(posB);
convexWorldTransform.setRotation(ornB);
btTransform planeTransform;
b3Transform planeTransform;
planeTransform.setIdentity();
planeTransform.setOrigin(posA);
planeTransform.setRotation(ornA);
btTransform planeInConvex;
b3Transform planeInConvex;
planeInConvex= convexWorldTransform.inverse() * planeTransform;
btTransform convexInPlane;
b3Transform convexInPlane;
convexInPlane = planeTransform.inverse() * convexWorldTransform;
btVector3 planeNormalInConvex = planeInConvex.getBasis()*-planeNormal;
b3Vector3 planeNormalInConvex = planeInConvex.getBasis()*-planeNormal;
float maxDot = -1e30;
int hitVertex=-1;
btVector3 hitVtx;
b3Vector3 hitVtx;
#define MAX_PLANE_CONVEX_POINTS 64
btVector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
int numPoints = 0;
btInt4 contactIdx;
@@ -604,7 +604,7 @@ void computeContactPlaneCompound(int pairIndex,
for (int i=0;i<hullB->m_numVertices;i++)
{
btVector3 vtx = convexVertices[hullB->m_vertexOffset+i];
b3Vector3 vtx = convexVertices[hullB->m_vertexOffset+i];
float curDot = vtx.dot(planeNormalInConvex);
@@ -620,8 +620,8 @@ void computeContactPlaneCompound(int pairIndex,
if (numPoints<MAX_PLANE_CONVEX_POINTS)
{
btVector3 vtxWorld = convexWorldTransform*vtx;
btVector3 vtxInPlane = planeTransform.inverse()*vtxWorld;
b3Vector3 vtxWorld = convexWorldTransform*vtx;
b3Vector3 vtxInPlane = planeTransform.inverse()*vtxWorld;
float dist = planeNormal.dot(vtxInPlane)-planeConstant;
if (dist<0.f)
{
@@ -661,7 +661,7 @@ void computeContactPlaneCompound(int pairIndex,
c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;
for (int i=0;i<numReducedPoints;i++)
{
btVector3 pOnB1 = contactPoints[contactIdx.s[i]];
b3Vector3 pOnB1 = contactPoints[contactIdx.s[i]];
c->m_worldPos[i] = pOnB1;
}
c->m_worldNormal[3] = numReducedPoints;
@@ -683,7 +683,7 @@ void computeContactSphereConvex(int pairIndex,
const b3RigidBodyCL* rigidBodies,
const b3Collidable* collidables,
const b3ConvexPolyhedronCL* convexShapes,
const btVector3* convexVertices,
const b3Vector3* convexVertices,
const int* convexIndices,
const btGpuFace* faces,
b3Contact4* globalContactsOut,
@@ -693,20 +693,20 @@ void computeContactSphereConvex(int pairIndex,
float radius = collidables[collidableIndexA].m_radius;
float4 spherePos1 = rigidBodies[bodyIndexA].m_pos;
btQuaternion sphereOrn = rigidBodies[bodyIndexA].m_quat;
b3Quaternion sphereOrn = rigidBodies[bodyIndexA].m_quat;
float4 pos = rigidBodies[bodyIndexB].m_pos;
btQuaternion quat = rigidBodies[bodyIndexB].m_quat;
b3Quaternion quat = rigidBodies[bodyIndexB].m_quat;
btTransform tr;
b3Transform tr;
tr.setIdentity();
tr.setOrigin(pos);
tr.setRotation(quat);
btTransform trInv = tr.inverse();
b3Transform trInv = tr.inverse();
float4 spherePos = trInv(spherePos1);
@@ -740,7 +740,7 @@ void computeContactSphereConvex(int pairIndex,
if ( dist > 0 )
{
//might hit an edge or vertex
btVector3 out;
b3Vector3 out;
bool isInPoly = IsPointInPolygon(spherePos,
&face,
@@ -758,8 +758,8 @@ void computeContactSphereConvex(int pairIndex,
}
} else
{
btVector3 tmp = spherePos-out;
btScalar l2 = tmp.length2();
b3Vector3 tmp = spherePos-out;
b3Scalar l2 = tmp.length2();
if (l2<radius*radius)
{
dist = btSqrt(l2);
@@ -837,20 +837,20 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
int maxContactCapacity,
const btOpenCLArray<b3ConvexPolyhedronCL>& convexData,
const btOpenCLArray<btVector3>& gpuVertices,
const btOpenCLArray<btVector3>& gpuUniqueEdges,
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 btOpenCLArray<btYetAnotherAabb>& clAabbsWS,
btOpenCLArray<btVector3>& worldVertsB1GPU,
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
btOpenCLArray<btInt4>& clippingFacesOutGPU,
btOpenCLArray<btVector3>& worldNormalsAGPU,
btOpenCLArray<btVector3>& worldVertsA1GPU,
btOpenCLArray<btVector3>& worldVertsB2GPU,
btAlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
int numObjects,
@@ -865,38 +865,38 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
//#define CHECK_ON_HOST
#ifdef CHECK_ON_HOST
btAlignedObjectArray<btYetAnotherAabb> hostAabbs;
b3AlignedObjectArray<btYetAnotherAabb> hostAabbs;
clAabbsWS.copyToHost(hostAabbs);
btAlignedObjectArray<btInt2> hostPairs;
b3AlignedObjectArray<btInt2> hostPairs;
pairs->copyToHost(hostPairs);
btAlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
bodyBuf->copyToHost(hostBodyBuf);
btAlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
convexData.copyToHost(hostConvexData);
btAlignedObjectArray<btVector3> hostVertices;
b3AlignedObjectArray<b3Vector3> hostVertices;
gpuVertices.copyToHost(hostVertices);
btAlignedObjectArray<btVector3> hostUniqueEdges;
b3AlignedObjectArray<b3Vector3> hostUniqueEdges;
gpuUniqueEdges.copyToHost(hostUniqueEdges);
btAlignedObjectArray<btGpuFace> hostFaces;
b3AlignedObjectArray<btGpuFace> hostFaces;
gpuFaces.copyToHost(hostFaces);
btAlignedObjectArray<int> hostIndices;
b3AlignedObjectArray<int> hostIndices;
gpuIndices.copyToHost(hostIndices);
btAlignedObjectArray<b3Collidable> hostCollidables;
b3AlignedObjectArray<b3Collidable> hostCollidables;
gpuCollidables.copyToHost(hostCollidables);
btAlignedObjectArray<btGpuChildShape> cpuChildShapes;
b3AlignedObjectArray<btGpuChildShape> cpuChildShapes;
gpuChildShapes.copyToHost(cpuChildShapes);
btAlignedObjectArray<btInt4> hostTriangleConvexPairs;
b3AlignedObjectArray<btInt4> hostTriangleConvexPairs;
btAlignedObjectArray<b3Contact4> hostContacts;
b3AlignedObjectArray<b3Contact4> hostContacts;
if (nContacts)
{
contactOut->copyToHost(hostContacts);
@@ -1013,13 +1013,13 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
BT_PROFILE("computeConvexConvexContactsGPUSAT");
// printf("nContacts = %d\n",nContacts);
btOpenCLArray<btVector3> sepNormals(m_context,m_queue);
btOpenCLArray<b3Vector3> sepNormals(m_context,m_queue);
sepNormals.resize(nPairs);
btOpenCLArray<int> hasSeparatingNormals(m_context,m_queue);
hasSeparatingNormals.resize(nPairs);
int concaveCapacity=maxTriConvexPairCapacity;
btOpenCLArray<btVector3> concaveSepNormals(m_context,m_queue);
btOpenCLArray<b3Vector3> concaveSepNormals(m_context,m_queue);
concaveSepNormals.resize(concaveCapacity);
btOpenCLArray<int> numConcavePairsOut(m_context,m_queue);
@@ -1029,7 +1029,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
btOpenCLArray<btCompoundOverlappingPair> gpuCompoundPairs(m_context,m_queue);
gpuCompoundPairs.resize(compoundPairCapacity);
btOpenCLArray<btVector3> gpuCompoundSepNormals(m_context,m_queue);
btOpenCLArray<b3Vector3> gpuCompoundSepNormals(m_context,m_queue);
gpuCompoundSepNormals.resize(compoundPairCapacity);
@@ -1081,9 +1081,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
if (numNodes)
{
int numSubTrees = subTreesGPU->size();
btVector3 bvhAabbMin = bvhData[0]->m_bvhAabbMin;
btVector3 bvhAabbMax = bvhData[0]->m_bvhAabbMax;
btVector3 bvhQuantization = bvhData[0]->m_bvhQuantization;
b3Vector3 bvhAabbMin = bvhData[0]->m_bvhAabbMin;
b3Vector3 bvhAabbMax = bvhData[0]->m_bvhAabbMax;
b3Vector3 bvhQuantization = bvhData[0]->m_bvhQuantization;
{
BT_PROFILE("m_bvhTraversalKernel");
numConcavePairs = numConcavePairsOut.at(0);
@@ -1142,9 +1142,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
launcher.launch1D( num);
clFinish(m_queue);
// btAlignedObjectArray<btVector3> cpuCompoundSepNormals;
// b3AlignedObjectArray<b3Vector3> cpuCompoundSepNormals;
// concaveSepNormals.copyToHost(cpuCompoundSepNormals);
// btAlignedObjectArray<btInt4> cpuConcavePairs;
// b3AlignedObjectArray<btInt4> cpuConcavePairs;
// triangleConvexPairsOut.copyToHost(cpuConcavePairs);
@@ -1355,7 +1355,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
clFinish(m_queue);
nContacts = m_totalContactsOut.at(0);
contactOut->resize(nContacts);
btAlignedObjectArray<b3Contact4> cpuContacts;
b3AlignedObjectArray<b3Contact4> cpuContacts;
contactOut->copyToHost(cpuContacts);
// printf("nContacts after = %d\n", nContacts);
}

View File

@@ -4,7 +4,7 @@
#include "parallel_primitives/host/btOpenCLArray.h"
#include "b3RigidBodyCL.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "b3ConvexUtility.h"
#include "b3ConvexPolyhedronCL.h"
#include "b3Collidable.h"
@@ -69,20 +69,20 @@ struct GpuSatCollision
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
int maxContactCapacity,
const btOpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
const btOpenCLArray<btVector3>& vertices,
const btOpenCLArray<btVector3>& uniqueEdges,
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 btOpenCLArray<btYetAnotherAabb>& clAabbs,
btOpenCLArray<btVector3>& worldVertsB1GPU,
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
btOpenCLArray<btInt4>& clippingFacesOutGPU,
btOpenCLArray<btVector3>& worldNormalsAGPU,
btOpenCLArray<btVector3>& worldVertsA1GPU,
btOpenCLArray<btVector3>& worldVertsB2GPU,
btAlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
int numObjects,

View File

@@ -1,7 +1,7 @@
#ifndef CONVEX_POLYHEDRON_CL
#define CONVEX_POLYHEDRON_CL
#include "BulletCommon/btTransform.h"
#include "BulletCommon/b3Transform.h"
struct btGpuFace
{
@@ -12,12 +12,12 @@ struct btGpuFace
ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
{
btVector3 m_localCenter;
btVector3 m_extents;
btVector3 mC;
btVector3 mE;
b3Vector3 m_localCenter;
b3Vector3 m_extents;
b3Vector3 mC;
b3Vector3 mE;
btScalar m_radius;
b3Scalar m_radius;
int m_faceOffset;
int m_numFaces;
int m_numVertices;
@@ -29,29 +29,29 @@ ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
inline void project(const btTransform& trans, const btVector3& dir, const btAlignedObjectArray<btVector3>& vertices, btScalar& min, btScalar& max) const
inline void project(const b3Transform& trans, const b3Vector3& dir, const b3AlignedObjectArray<b3Vector3>& vertices, b3Scalar& min, b3Scalar& max) const
{
min = FLT_MAX;
max = -FLT_MAX;
int numVerts = m_numVertices;
const btVector3 localDir = trans.getBasis().transpose()*dir;
const btVector3 localDi2 = quatRotate(trans.getRotation().inverse(),dir);
const b3Vector3 localDir = trans.getBasis().transpose()*dir;
const b3Vector3 localDi2 = quatRotate(trans.getRotation().inverse(),dir);
btScalar offset = trans.getOrigin().dot(dir);
b3Scalar offset = trans.getOrigin().dot(dir);
for(int i=0;i<numVerts;i++)
{
//btVector3 pt = trans * vertices[m_vertexOffset+i];
//btScalar dp = pt.dot(dir);
btScalar dp = vertices[m_vertexOffset+i].dot(localDir);
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
//b3Scalar dp = pt.dot(dir);
b3Scalar dp = vertices[m_vertexOffset+i].dot(localDir);
//btAssert(dp==dpL);
if(dp < min) min = dp;
if(dp > max) max = dp;
}
if(min>max)
{
btScalar tmp = min;
b3Scalar tmp = min;
min = max;
max = tmp;
}

View File

@@ -17,8 +17,8 @@ subject to the following restrictions:
#include "b3ConvexUtility.h"
#include "BulletGeometry/btConvexHullComputer.h"
#include "BulletGeometry/btGrahamScan2dConvexHull.h"
#include "BulletCommon/btQuaternion.h"
#include "BulletCommon/btHashMap.h"
#include "BulletCommon/b3Quaternion.h"
#include "BulletCommon/b3HashMap.h"
#include "b3ConvexPolyhedronCL.h"
@@ -28,21 +28,21 @@ b3ConvexUtility::~b3ConvexUtility()
{
}
bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices, int numPoints, bool mergeCoplanarTriangles)
bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices, int numPoints, bool mergeCoplanarTriangles)
{
btConvexHullComputer conv;
conv.compute(&orgVertices[0].getX(), sizeof(btVector3),numPoints,0.f,0.f);
conv.compute(&orgVertices[0].getX(), sizeof(b3Vector3),numPoints,0.f,0.f);
btAlignedObjectArray<btVector3> faceNormals;
b3AlignedObjectArray<b3Vector3> faceNormals;
int numFaces = conv.faces.size();
faceNormals.resize(numFaces);
btConvexHullComputer* convexUtil = &conv;
btAlignedObjectArray<btMyFace> tmpFaces;
b3AlignedObjectArray<btMyFace> tmpFaces;
tmpFaces.resize(numFaces);
int numVertices = convexUtil->vertices.size();
@@ -60,7 +60,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
const btConvexHullComputer::Edge* firstEdge = &convexUtil->edges[face];
const btConvexHullComputer::Edge* edge = firstEdge;
btVector3 edges[3];
b3Vector3 edges[3];
int numEdges = 0;
//compute face normals
@@ -70,10 +70,10 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
int src = edge->getSourceVertex();
tmpFaces[i].m_indices.push_back(src);
int targ = edge->getTargetVertex();
btVector3 wa = convexUtil->vertices[src];
b3Vector3 wa = convexUtil->vertices[src];
btVector3 wb = convexUtil->vertices[targ];
btVector3 newEdge = wb-wa;
b3Vector3 wb = convexUtil->vertices[targ];
b3Vector3 newEdge = wb-wa;
newEdge.normalize();
if (numEdges<2)
edges[numEdges++] = newEdge;
@@ -81,7 +81,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
edge = edge->getNextEdgeOfFace();
} while (edge!=firstEdge);
btScalar planeEq = 1e30f;
b3Scalar planeEq = 1e30f;
if (numEdges==2)
@@ -102,7 +102,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
for (int v=0;v<tmpFaces[i].m_indices.size();v++)
{
btScalar eq = m_vertices[tmpFaces[i].m_indices[v]].dot(faceNormals[i]);
b3Scalar eq = m_vertices[tmpFaces[i].m_indices[v]].dot(faceNormals[i]);
if (planeEq>eq)
{
planeEq=eq;
@@ -113,26 +113,26 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
//merge coplanar faces and copy them to m_polyhedron
btScalar faceWeldThreshold= 0.999f;
btAlignedObjectArray<int> todoFaces;
b3Scalar faceWeldThreshold= 0.999f;
b3AlignedObjectArray<int> todoFaces;
for (int i=0;i<tmpFaces.size();i++)
todoFaces.push_back(i);
while (todoFaces.size())
{
btAlignedObjectArray<int> coplanarFaceGroup;
b3AlignedObjectArray<int> coplanarFaceGroup;
int refFace = todoFaces[todoFaces.size()-1];
coplanarFaceGroup.push_back(refFace);
btMyFace& faceA = tmpFaces[refFace];
todoFaces.pop_back();
btVector3 faceNormalA(faceA.m_plane[0],faceA.m_plane[1],faceA.m_plane[2]);
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];
btVector3 faceNormalB(faceB.m_plane[0],faceB.m_plane[1],faceB.m_plane[2]);
b3Vector3 faceNormalB(faceB.m_plane[0],faceB.m_plane[1],faceB.m_plane[2]);
if (faceNormalA.dot(faceNormalB)>faceWeldThreshold)
{
coplanarFaceGroup.push_back(i);
@@ -146,20 +146,20 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
{
//do the merge: use Graham Scan 2d convex hull
btAlignedObjectArray<GrahamVector3> orgpoints;
btVector3 averageFaceNormal(0,0,0);
b3AlignedObjectArray<GrahamVector3> orgpoints;
b3Vector3 averageFaceNormal(0,0,0);
for (int i=0;i<coplanarFaceGroup.size();i++)
{
// m_polyhedron->m_faces.push_back(tmpFaces[coplanarFaceGroup[i]]);
btMyFace& face = tmpFaces[coplanarFaceGroup[i]];
btVector3 faceNormal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
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++)
{
int orgIndex = face.m_indices[f];
btVector3 pt = m_vertices[orgIndex];
b3Vector3 pt = m_vertices[orgIndex];
bool found = false;
@@ -183,7 +183,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
for (int i=0;i<4;i++)
combinedFace.m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
btAlignedObjectArray<GrahamVector3> hull;
b3AlignedObjectArray<GrahamVector3> hull;
averageFaceNormal.normalize();
GrahamScanConvexHull2D(orgpoints,hull,averageFaceNormal);
@@ -269,7 +269,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const btVector3* orgVertices,
inline bool IsAlmostZero(const btVector3& v)
inline bool IsAlmostZero(const b3Vector3& v)
{
if(fabsf(v.getX())>1e-6 || fabsf(v.getY())>1e-6 || fabsf(v.getZ())>1e-6) return false;
return true;
@@ -314,20 +314,20 @@ bool b3ConvexUtility::testContainment() const
{
for(int p=0;p<8;p++)
{
btVector3 LocalPt;
if(p==0) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], m_extents[2]);
else if(p==1) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], -m_extents[2]);
else if(p==2) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], m_extents[2]);
else if(p==3) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], -m_extents[2]);
else if(p==4) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], m_extents[2]);
else if(p==5) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], -m_extents[2]);
else if(p==6) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], m_extents[2]);
else if(p==7) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], -m_extents[2]);
b3Vector3 LocalPt;
if(p==0) LocalPt = m_localCenter + b3Vector3(m_extents[0], m_extents[1], m_extents[2]);
else if(p==1) LocalPt = m_localCenter + b3Vector3(m_extents[0], m_extents[1], -m_extents[2]);
else if(p==2) LocalPt = m_localCenter + b3Vector3(m_extents[0], -m_extents[1], m_extents[2]);
else if(p==3) LocalPt = m_localCenter + b3Vector3(m_extents[0], -m_extents[1], -m_extents[2]);
else if(p==4) LocalPt = m_localCenter + b3Vector3(-m_extents[0], m_extents[1], m_extents[2]);
else if(p==5) LocalPt = m_localCenter + b3Vector3(-m_extents[0], m_extents[1], -m_extents[2]);
else if(p==6) LocalPt = m_localCenter + b3Vector3(-m_extents[0], -m_extents[1], m_extents[2]);
else if(p==7) LocalPt = m_localCenter + b3Vector3(-m_extents[0], -m_extents[1], -m_extents[2]);
for(int i=0;i<m_faces.size();i++)
{
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
const btScalar d = LocalPt.dot(Normal) + m_faces[i].m_plane[3];
const b3Vector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
const b3Scalar d = LocalPt.dot(Normal) + m_faces[i].m_plane[3];
if(d>0.0f)
return false;
}
@@ -339,9 +339,9 @@ bool b3ConvexUtility::testContainment() const
void b3ConvexUtility::initialize()
{
btHashMap<btInternalVertexPair,btInternalEdge> edges;
b3HashMap<btInternalVertexPair,btInternalEdge> edges;
btScalar TotalArea = 0.0f;
b3Scalar TotalArea = 0.0f;
m_localCenter.setValue(0, 0, 0);
for(int i=0;i<m_faces.size();i++)
@@ -353,11 +353,11 @@ void b3ConvexUtility::initialize()
int k = (j+1)%numVertices;
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
btInternalEdge* edptr = edges.find(vp);
btVector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
b3Vector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
edge.normalize();
bool found = false;
btVector3 diff,diff2;
b3Vector3 diff,diff2;
for (int p=0;p<m_uniqueEdges.size();p++)
{
@@ -421,14 +421,14 @@ void b3ConvexUtility::initialize()
int numVertices = m_faces[i].m_indices.size();
int NbTris = numVertices-2;
const btVector3& p0 = m_vertices[m_faces[i].m_indices[0]];
const b3Vector3& p0 = m_vertices[m_faces[i].m_indices[0]];
for(int j=1;j<=NbTris;j++)
{
int k = (j+1)%numVertices;
const btVector3& p1 = m_vertices[m_faces[i].m_indices[j]];
const btVector3& p2 = m_vertices[m_faces[i].m_indices[k]];
btScalar Area = ((p0 - p1).cross(p0 - p2)).length() * 0.5f;
btVector3 Center = (p0+p1+p2)/3.0f;
const b3Vector3& p1 = m_vertices[m_faces[i].m_indices[j]];
const b3Vector3& p2 = m_vertices[m_faces[i].m_indices[k]];
b3Scalar Area = ((p0 - p1).cross(p0 - p2)).length() * 0.5f;
b3Vector3 Center = (p0+p1+p2)/3.0f;
m_localCenter += Area * Center;
TotalArea += Area;
}
@@ -444,22 +444,22 @@ void b3ConvexUtility::initialize()
m_radius = FLT_MAX;
for(int i=0;i<m_faces.size();i++)
{
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
const btScalar dist = btFabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
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]);
if(dist<m_radius)
m_radius = dist;
}
btScalar MinX = FLT_MAX;
btScalar MinY = FLT_MAX;
btScalar MinZ = FLT_MAX;
btScalar MaxX = -FLT_MAX;
btScalar MaxY = -FLT_MAX;
btScalar MaxZ = -FLT_MAX;
b3Scalar MinX = FLT_MAX;
b3Scalar MinY = FLT_MAX;
b3Scalar MinZ = FLT_MAX;
b3Scalar MaxX = -FLT_MAX;
b3Scalar MaxY = -FLT_MAX;
b3Scalar MaxZ = -FLT_MAX;
for(int i=0; i<m_vertices.size(); i++)
{
const btVector3& pt = m_vertices[i];
const b3Vector3& pt = m_vertices[i];
if(pt.getX()<MinX) MinX = pt.getX();
if(pt.getX()>MaxX) MaxX = pt.getX();
if(pt.getY()<MinY) MinY = pt.getY();
@@ -472,10 +472,10 @@ void b3ConvexUtility::initialize()
// const btScalar r = m_radius / sqrtf(2.0f);
const btScalar r = m_radius / sqrtf(3.0f);
// const b3Scalar r = m_radius / sqrtf(2.0f);
const b3Scalar r = m_radius / sqrtf(3.0f);
const int LargestExtent = mE.maxAxis();
const btScalar Step = (mE[LargestExtent]*0.5f - r)/1024.0f;
const b3Scalar Step = (mE[LargestExtent]*0.5f - r)/1024.0f;
m_extents[0] = m_extents[1] = m_extents[2] = r;
m_extents[LargestExtent] = mE[LargestExtent]*0.5f;
bool FoundBox = false;
@@ -496,14 +496,14 @@ void b3ConvexUtility::initialize()
else
{
// Refine the box
const btScalar Step = (m_radius - r)/1024.0f;
const b3Scalar Step = (m_radius - r)/1024.0f;
const int e0 = (1<<LargestExtent) & 3;
const int e1 = (1<<e0) & 3;
for(int j=0;j<1024;j++)
{
const btScalar Saved0 = m_extents[e0];
const btScalar Saved1 = m_extents[e1];
const b3Scalar Saved0 = m_extents[e0];
const b3Scalar Saved1 = m_extents[e1];
m_extents[e0] += Step;
m_extents[e1] += Step;

View File

@@ -17,16 +17,16 @@ subject to the following restrictions:
#ifndef _BT_CONVEX_UTILITY_H
#define _BT_CONVEX_UTILITY_H
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/btTransform.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "BulletCommon/b3Transform.h"
#include "b3ConvexPolyhedronCL.h"
struct btMyFace
{
btAlignedObjectArray<int> m_indices;
btScalar m_plane[4];
b3AlignedObjectArray<int> m_indices;
b3Scalar m_plane[4];
};
ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
@@ -34,15 +34,15 @@ ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
btVector3 m_localCenter;
btVector3 m_extents;
btVector3 mC;
btVector3 mE;
btScalar m_radius;
b3Vector3 m_localCenter;
b3Vector3 m_extents;
b3Vector3 mC;
b3Vector3 mE;
b3Scalar m_radius;
btAlignedObjectArray<btVector3> m_vertices;
btAlignedObjectArray<btMyFace> m_faces;
btAlignedObjectArray<btVector3> m_uniqueEdges;
b3AlignedObjectArray<b3Vector3> m_vertices;
b3AlignedObjectArray<btMyFace> m_faces;
b3AlignedObjectArray<b3Vector3> m_uniqueEdges;
b3ConvexUtility()
@@ -50,7 +50,7 @@ ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
}
virtual ~b3ConvexUtility();
bool initializePolyhedralFeatures(const btVector3* orgVertices, int numVertices, bool mergeCoplanarTriangles=true);
bool initializePolyhedralFeatures(const b3Vector3* orgVertices, int numVertices, bool mergeCoplanarTriangles=true);
void initialize();
bool testContainment() const;

View File

@@ -17,7 +17,6 @@ subject to the following restrictions:
#include "b3OptimizedBvh.h"
#include "b3StridingMeshInterface.h"
#include "BulletGeometry/btAabbUtil2.h"
#include "BulletCommon/btIDebugDraw.h"
b3OptimizedBvh::b3OptimizedBvh()
@@ -29,7 +28,7 @@ b3OptimizedBvh::~b3OptimizedBvh()
}
void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax)
void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantizedAabbCompression, const b3Vector3& bvhAabbMin, const b3Vector3& bvhAabbMax)
{
m_useQuantization = useQuantizedAabbCompression;
@@ -52,12 +51,12 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
{
}
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
{
btOptimizedBvhNode node;
btVector3 aabbMin,aabbMax;
aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
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.setMin(triangle[0]);
aabbMax.setMax(triangle[0]);
aabbMin.setMin(triangle[1]);
@@ -94,7 +93,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
{
}
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
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));
@@ -103,9 +102,9 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
btAssert(triangleIndex>=0);
btQuantizedBvhNode node;
btVector3 aabbMin,aabbMax;
aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
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.setMin(triangle[0]);
aabbMax.setMax(triangle[0]);
aabbMin.setMin(triangle[1]);
@@ -114,8 +113,8 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
aabbMax.setMax(triangle[2]);
//PCK: add these checks for zero dimensions of aabb
const btScalar MIN_AABB_DIMENSION = btScalar(0.002);
const btScalar MIN_AABB_HALF_DIMENSION = btScalar(0.001);
const b3Scalar MIN_AABB_DIMENSION = b3Scalar(0.002);
const b3Scalar MIN_AABB_HALF_DIMENSION = b3Scalar(0.001);
if (aabbMax.getX() - aabbMin.getX() < MIN_AABB_DIMENSION)
{
aabbMax.setX(aabbMax.getX() + MIN_AABB_HALF_DIMENSION);
@@ -168,8 +167,8 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
{
NodeTriangleCallback callback(m_leafNodes);
btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
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));
triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
@@ -203,7 +202,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax)
void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
{
if (m_useQuantization)
{
@@ -230,7 +229,7 @@ void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const btVector
void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax)
void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
{
//incrementally initialize quantization values
btAssert(m_useQuantization);
@@ -287,9 +286,9 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
int numfaces = 0;
PHY_ScalarType indicestype = PHY_INTEGER;
btVector3 triangleVerts[3];
btVector3 aabbMin,aabbMax;
const btVector3& meshScaling = meshInterface->getScaling();
b3Vector3 triangleVerts[3];
b3Vector3 aabbMin,aabbMax;
const b3Vector3& meshScaling = meshInterface->getScaling();
int i;
for (i=endNode-1;i>=firstNode;i--)
@@ -323,7 +322,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
if (type == PHY_FLOAT)
{
float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
triangleVerts[j] = btVector3(
triangleVerts[j] = b3Vector3(
graphicsbase[0]*meshScaling.getX(),
graphicsbase[1]*meshScaling.getY(),
graphicsbase[2]*meshScaling.getZ());
@@ -331,14 +330,14 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
else
{
double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
triangleVerts[j] = btVector3( btScalar(graphicsbase[0]*meshScaling.getX()), btScalar(graphicsbase[1]*meshScaling.getY()), btScalar(graphicsbase[2]*meshScaling.getZ()));
triangleVerts[j] = b3Vector3( b3Scalar(graphicsbase[0]*meshScaling.getX()), b3Scalar(graphicsbase[1]*meshScaling.getY()), b3Scalar(graphicsbase[2]*meshScaling.getZ()));
}
}
aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
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.setMin(triangleVerts[0]);
aabbMax.setMax(triangleVerts[0]);
aabbMin.setMin(triangleVerts[1]);

View File

@@ -38,11 +38,11 @@ public:
virtual ~b3OptimizedBvh();
void build(b3StridingMeshInterface* triangles,bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax);
void build(b3StridingMeshInterface* triangles,bool useQuantizedAabbCompression, const b3Vector3& bvhAabbMin, const b3Vector3& bvhAabbMax);
void refit(b3StridingMeshInterface* triangles,const btVector3& aabbMin,const btVector3& aabbMax);
void refit(b3StridingMeshInterface* triangles,const b3Vector3& aabbMin,const b3Vector3& aabbMax);
void refitPartial(b3StridingMeshInterface* triangles,const btVector3& aabbMin, const btVector3& aabbMax);
void refitPartial(b3StridingMeshInterface* triangles,const b3Vector3& aabbMin, const b3Vector3& aabbMax);
void updateBvhNodes(b3StridingMeshInterface* meshInterface,int firstNode,int endNode,int index);

View File

@@ -16,7 +16,6 @@ subject to the following restrictions:
#include "b3QuantizedBvh.h"
#include "BulletGeometry/btAabbUtil2.h"
#include "BulletCommon/btIDebugDraw.h"
#define RAYAABB2
@@ -77,25 +76,25 @@ void b3QuantizedBvh::buildInternal()
///just for debugging, to visualize the individual patches/subtrees
#ifdef DEBUG_PATCH_COLORS
btVector3 color[4]=
b3Vector3 color[4]=
{
btVector3(1,0,0),
btVector3(0,1,0),
btVector3(0,0,1),
btVector3(0,1,1)
b3Vector3(1,0,0),
b3Vector3(0,1,0),
b3Vector3(0,0,1),
b3Vector3(0,1,1)
};
#endif //DEBUG_PATCH_COLORS
void b3QuantizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin)
void b3QuantizedBvh::setQuantizationValues(const b3Vector3& bvhAabbMin,const b3Vector3& bvhAabbMax,b3Scalar quantizationMargin)
{
//enlarge the AABB to avoid division by zero when initializing the quantization values
btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
b3Vector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
m_bvhAabbMin = bvhAabbMin - clampValue;
m_bvhAabbMax = bvhAabbMax + clampValue;
btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
m_bvhQuantization = btVector3(btScalar(65533.0),btScalar(65533.0),btScalar(65533.0)) / aabbSize;
b3Vector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
m_bvhQuantization = b3Vector3(b3Scalar(65533.0),b3Scalar(65533.0),b3Scalar(65533.0)) / aabbSize;
m_useQuantization = true;
}
@@ -147,8 +146,8 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
//set the min aabb to 'inf' or a max value, and set the max aabb to a -inf/minimum value.
//the aabb will be expanded during buildTree/mergeInternalNodeAabb with actual node values
setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);//can't use btVector3(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY)) because of quantization
setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);//can't use btVector3(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY)) because of quantization
setInternalNodeAabbMin(m_curNodeIndex,m_bvhAabbMax);//can't use b3Vector3(SIMD_INFINITY,SIMD_INFINITY,SIMD_INFINITY)) because of quantization
setInternalNodeAabbMax(m_curNodeIndex,m_bvhAabbMin);//can't use b3Vector3(-SIMD_INFINITY,-SIMD_INFINITY,-SIMD_INFINITY)) because of quantization
for (i=startIndex;i<endIndex;i++)
@@ -232,22 +231,22 @@ int b3QuantizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int sp
int i;
int splitIndex =startIndex;
int numIndices = endIndex - startIndex;
btScalar splitValue;
b3Scalar splitValue;
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
b3Vector3 means(b3Scalar(0.),b3Scalar(0.),b3Scalar(0.));
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
b3Vector3 center = b3Scalar(0.5)*(getAabbMax(i)+getAabbMin(i));
means+=center;
}
means *= (btScalar(1.)/(btScalar)numIndices);
means *= (b3Scalar(1.)/(b3Scalar)numIndices);
splitValue = means[splitAxis];
//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
b3Vector3 center = b3Scalar(0.5)*(getAabbMax(i)+getAabbMin(i));
if (center[splitAxis] > splitValue)
{
//swap
@@ -285,32 +284,32 @@ int b3QuantizedBvh::calcSplittingAxis(int startIndex,int endIndex)
{
int i;
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
b3Vector3 means(b3Scalar(0.),b3Scalar(0.),b3Scalar(0.));
b3Vector3 variance(b3Scalar(0.),b3Scalar(0.),b3Scalar(0.));
int numIndices = endIndex-startIndex;
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
b3Vector3 center = b3Scalar(0.5)*(getAabbMax(i)+getAabbMin(i));
means+=center;
}
means *= (btScalar(1.)/(btScalar)numIndices);
means *= (b3Scalar(1.)/(b3Scalar)numIndices);
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
btVector3 diff2 = center-means;
b3Vector3 center = b3Scalar(0.5)*(getAabbMax(i)+getAabbMin(i));
b3Vector3 diff2 = center-means;
diff2 = diff2 * diff2;
variance += diff2;
}
variance *= (btScalar(1.)/ ((btScalar)numIndices-1) );
variance *= (b3Scalar(1.)/ ((b3Scalar)numIndices-1) );
return variance.maxAxis();
}
void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
@@ -350,7 +349,7 @@ void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
int maxIterations = 0;
void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
btAssert(!m_useQuantization);
@@ -395,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 btVector3& aabbMin,const btVector3& aabbMax) const
void b3QuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
if (aabbOverlap)
@@ -446,7 +445,7 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantize
void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const
void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
{
btAssert(!m_useQuantization);
@@ -457,11 +456,11 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
//PCK: unsigned instead of bool
unsigned aabbOverlap=0;
unsigned rayBoxOverlap=0;
btScalar lambda_max = 1.0;
b3Scalar lambda_max = 1.0;
/* Quick pruning by quantized box */
btVector3 rayAabbMin = raySource;
btVector3 rayAabbMax = raySource;
b3Vector3 rayAabbMin = raySource;
b3Vector3 rayAabbMax = raySource;
rayAabbMin.setMin(rayTarget);
rayAabbMax.setMax(rayTarget);
@@ -470,22 +469,22 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
rayAabbMax += aabbMax;
#ifdef RAYAABB2
btVector3 rayDir = (rayTarget-raySource);
b3Vector3 rayDir = (rayTarget-raySource);
rayDir.normalize ();
lambda_max = rayDir.dot(rayTarget-raySource);
///what about division by zero? --> just set rayDirection[i] to 1.0
btVector3 rayDirectionInverse;
rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0];
rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1];
rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2];
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];
unsigned int sign[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0};
#endif
btVector3 bounds[2];
b3Vector3 bounds[2];
while (curIndex < m_curNodeIndex)
{
btScalar param = 1.0;
b3Scalar param = 1.0;
//catch bugs in tree data
btAssert (walkIterations < m_curNodeIndex);
@@ -507,7 +506,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
rayBoxOverlap = aabbOverlap ? btRayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
#else
btVector3 normal;
b3Vector3 normal;
rayBoxOverlap = btRayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal);
#endif
@@ -538,7 +537,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
{
btAssert(m_useQuantization);
@@ -555,22 +554,22 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
unsigned boxBoxOverlap = 0;
unsigned rayBoxOverlap = 0;
btScalar lambda_max = 1.0;
b3Scalar lambda_max = 1.0;
#ifdef RAYAABB2
btVector3 rayDirection = (rayTarget-raySource);
b3Vector3 rayDirection = (rayTarget-raySource);
rayDirection.normalize ();
lambda_max = rayDirection.dot(rayTarget-raySource);
///what about division by zero? --> just set rayDirection[i] to 1.0
rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[0];
rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[1];
rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[2];
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];
unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0};
#endif
/* Quick pruning by quantized box */
btVector3 rayAabbMin = raySource;
btVector3 rayAabbMax = raySource;
b3Vector3 rayAabbMin = raySource;
b3Vector3 rayAabbMax = raySource;
rayAabbMin.setMin(rayTarget);
rayAabbMax.setMax(rayTarget);
@@ -594,10 +593,10 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
extern btIDebugDraw* debugDrawerPtr;
if (curIndex==drawPatch)
{
btVector3 aabbMin,aabbMax;
b3Vector3 aabbMin,aabbMax;
aabbMin = unQuantize(rootNode->m_quantizedAabbMin);
aabbMax = unQuantize(rootNode->m_quantizedAabbMax);
btVector3 color(1,0,0);
b3Vector3 color(1,0,0);
debugDrawerPtr->drawAabb(aabbMin,aabbMax,color);
}
#endif//VISUALLY_ANALYZE_BVH
@@ -608,19 +607,19 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
walkIterations++;
//PCK: unsigned instead of bool
// only interested if this is closer than any previous hit
btScalar param = 1.0;
b3Scalar param = 1.0;
rayBoxOverlap = 0;
boxBoxOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax);
isLeafNode = rootNode->isLeafNode();
if (boxBoxOverlap)
{
btVector3 bounds[2];
b3Vector3 bounds[2];
bounds[0] = unQuantize(rootNode->m_quantizedAabbMin);
bounds[1] = unQuantize(rootNode->m_quantizedAabbMax);
/* Add box cast extents */
bounds[0] -= aabbMax;
bounds[1] -= aabbMin;
btVector3 normal;
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);
@@ -691,10 +690,10 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
extern btIDebugDraw* debugDrawerPtr;
if (curIndex==drawPatch)
{
btVector3 aabbMin,aabbMax;
b3Vector3 aabbMin,aabbMax;
aabbMin = unQuantize(rootNode->m_quantizedAabbMin);
aabbMax = unQuantize(rootNode->m_quantizedAabbMax);
btVector3 color(1,0,0);
b3Vector3 color(1,0,0);
debugDrawerPtr->drawAabb(aabbMin,aabbMax,color);
}
#endif//VISUALLY_ANALYZE_BVH
@@ -753,13 +752,13 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallba
}
void b3QuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const
void b3QuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const
{
reportBoxCastOverlappingNodex(nodeCallback,raySource,rayTarget,btVector3(0,0,0),btVector3(0,0,0));
reportBoxCastOverlappingNodex(nodeCallback,raySource,rayTarget,b3Vector3(0,0,0),b3Vector3(0,0,0));
}
void b3QuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const
void b3QuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
//always use stackless
@@ -774,8 +773,8 @@ void b3QuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCa
/*
{
//recursive traversal
btVector3 qaabbMin = raySource;
btVector3 qaabbMax = raySource;
b3Vector3 qaabbMin = raySource;
b3Vector3 qaabbMax = raySource;
qaabbMin.setMin(rayTarget);
qaabbMax.setMax(rayTarget);
qaabbMin += aabbMin;
@@ -1134,7 +1133,7 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
return bvh;
}
// Constructor that prevents btVector3's default constructor from being called
// Constructor that prevents b3Vector3's default constructor from being called
b3QuantizedBvh::b3QuantizedBvh(b3QuantizedBvh &self, bool /* ownsMemory */) :
m_bvhAabbMin(self.m_bvhAabbMin),
m_bvhAabbMax(self.m_bvhAabbMax),

View File

@@ -28,8 +28,8 @@ class btSerializer;
#include <stdlib.h>
#endif //DEBUG_CHECK_DEQUANTIZATION
#include "BulletCommon/btVector3.h"
#include "BulletCommon/btAlignedAllocator.h"
#include "BulletCommon/b3Vector3.h"
#include "BulletCommon/b3AlignedAllocator.h"
#ifdef BT_USE_DOUBLE_PRECISION
#define btQuantizedBvhData btQuantizedBvhDoubleData
@@ -99,8 +99,8 @@ ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
BT_DECLARE_ALIGNED_ALLOCATOR();
//32 bytes
btVector3 m_aabbMinOrg;
btVector3 m_aabbMaxOrg;
b3Vector3 m_aabbMinOrg;
b3Vector3 m_aabbMaxOrg;
//4
int m_escapeIndex;
@@ -157,15 +157,15 @@ public:
virtual void processNode(int subPart, int triangleIndex) = 0;
};
#include "BulletCommon/btAlignedAllocator.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/b3AlignedAllocator.h"
#include "BulletCommon/b3AlignedObjectArray.h"
///for code readability:
typedef btAlignedObjectArray<btOptimizedBvhNode> NodeArray;
typedef btAlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
typedef b3AlignedObjectArray<btOptimizedBvhNode> NodeArray;
typedef b3AlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
typedef b3AlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
@@ -184,9 +184,9 @@ public:
btVector3 m_bvhAabbMin;
btVector3 m_bvhAabbMax;
btVector3 m_bvhQuantization;
b3Vector3 m_bvhAabbMin;
b3Vector3 m_bvhAabbMax;
b3Vector3 m_bvhQuantization;
protected:
int m_bulletVersion; //for serialization versioning. It could also be used to detect endianess.
@@ -205,7 +205,7 @@ protected:
btTraversalMode m_traversalMode;
BvhSubtreeInfoArray m_SubtreeHeaders;
//This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray
//This is only used for serialization so we don't have to add serialization directly to b3AlignedObjectArray
mutable int m_subtreeHeaderCount;
@@ -214,7 +214,7 @@ protected:
///two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!)
///this might be refactored into a virtual, it is usually not calculated at run-time
void setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin)
void setInternalNodeAabbMin(int nodeIndex, const b3Vector3& aabbMin)
{
if (m_useQuantization)
{
@@ -225,7 +225,7 @@ protected:
}
}
void setInternalNodeAabbMax(int nodeIndex,const btVector3& aabbMax)
void setInternalNodeAabbMax(int nodeIndex,const b3Vector3& aabbMax)
{
if (m_useQuantization)
{
@@ -236,7 +236,7 @@ protected:
}
}
btVector3 getAabbMin(int nodeIndex) const
b3Vector3 getAabbMin(int nodeIndex) const
{
if (m_useQuantization)
{
@@ -246,7 +246,7 @@ protected:
return m_leafNodes[nodeIndex].m_aabbMinOrg;
}
btVector3 getAabbMax(int nodeIndex) const
b3Vector3 getAabbMax(int nodeIndex) const
{
if (m_useQuantization)
{
@@ -271,7 +271,7 @@ protected:
}
void mergeInternalNodeAabb(int nodeIndex,const btVector3& newAabbMin,const btVector3& newAabbMax)
void mergeInternalNodeAabb(int nodeIndex,const b3Vector3& newAabbMin,const b3Vector3& newAabbMax)
{
if (m_useQuantization)
{
@@ -310,11 +310,11 @@ protected:
int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) 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 btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, 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;
///tree traversal designed for small-memory processors like PS3 SPU
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
@@ -340,17 +340,17 @@ public:
///***************************************** expert/internal use only *************************
void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0));
void setQuantizationValues(const b3Vector3& bvhAabbMin,const b3Vector3& bvhAabbMax,b3Scalar quantizationMargin=b3Scalar(1.0));
QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; }
///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized
void buildInternal();
///***************************************** expert/internal use only *************************
void reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const;
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;
SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point,int isMax) const
SIMD_FORCE_INLINE void quantize(unsigned short* out, const b3Vector3& point,int isMax) const
{
btAssert(m_useQuantization);
@@ -363,15 +363,15 @@ public:
btAssert(point.getY() >= m_bvhAabbMin.getY());
btAssert(point.getZ() >= m_bvhAabbMin.getZ());
btVector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
b3Vector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative
///end-points always set the first bit, so that they are sorted properly (so that neighbouring AABBs overlap properly)
///@todo: double-check this
if (isMax)
{
out[0] = (unsigned short) (((unsigned short)(v.getX()+btScalar(1.)) | 1));
out[1] = (unsigned short) (((unsigned short)(v.getY()+btScalar(1.)) | 1));
out[2] = (unsigned short) (((unsigned short)(v.getZ()+btScalar(1.)) | 1));
out[0] = (unsigned short) (((unsigned short)(v.getX()+b3Scalar(1.)) | 1));
out[1] = (unsigned short) (((unsigned short)(v.getY()+b3Scalar(1.)) | 1));
out[2] = (unsigned short) (((unsigned short)(v.getZ()+b3Scalar(1.)) | 1));
} else
{
out[0] = (unsigned short) (((unsigned short)(v.getX()) & 0xfffe));
@@ -381,7 +381,7 @@ public:
#ifdef DEBUG_CHECK_DEQUANTIZATION
btVector3 newPoint = unQuantize(out);
b3Vector3 newPoint = unQuantize(out);
if (isMax)
{
if (newPoint.getX() < point.getX())
@@ -417,12 +417,12 @@ public:
}
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2,int isMax) const
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const b3Vector3& point2,int isMax) const
{
btAssert(m_useQuantization);
btVector3 clampedPoint(point2);
b3Vector3 clampedPoint(point2);
clampedPoint.setMax(m_bvhAabbMin);
clampedPoint.setMin(m_bvhAabbMax);
@@ -430,13 +430,13 @@ public:
}
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
SIMD_FORCE_INLINE b3Vector3 unQuantize(const unsigned short* vecIn) const
{
btVector3 vecOut;
b3Vector3 vecOut;
vecOut.setValue(
(btScalar)(vecIn[0]) / (m_bvhQuantization.getX()),
(btScalar)(vecIn[1]) / (m_bvhQuantization.getY()),
(btScalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
(b3Scalar)(vecIn[0]) / (m_bvhQuantization.getX()),
(b3Scalar)(vecIn[1]) / (m_bvhQuantization.getY()),
(b3Scalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
vecOut += m_bvhAabbMin;
return vecOut;
}
@@ -493,7 +493,7 @@ public:
private:
// Special "copy" constructor that allows for in-place deserialization
// Prevents btVector3's default constructor from being called, but doesn't inialize much else
// Prevents b3Vector3's default constructor from being called, but doesn't inialize much else
// ownsMemory should most likely be false if deserializing, and if you are not, don't call this (it also changes the function signature, which we need)
b3QuantizedBvh(b3QuantizedBvh &other, bool ownsMemory);

View File

@@ -1,17 +1,17 @@
#ifndef BT_RIGID_BODY_CL
#define BT_RIGID_BODY_CL
#include "BulletCommon/btScalar.h"
#include "BulletCommon/btMatrix3x3.h"
#include "BulletCommon/b3Scalar.h"
#include "BulletCommon/b3Matrix3x3.h"
ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
{
BT_DECLARE_ALIGNED_ALLOCATOR();
btVector3 m_pos;
btQuaternion m_quat;
btVector3 m_linVel;
btVector3 m_angVel;
b3Vector3 m_pos;
b3Quaternion m_quat;
b3Vector3 m_linVel;
b3Vector3 m_angVel;
int m_collidableIdx;
float m_invMass;
@@ -27,8 +27,8 @@ ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
struct btInertiaCL
{
btMatrix3x3 m_invInertiaWorld;
btMatrix3x3 m_initInvInertia;
b3Matrix3x3 m_invInertiaWorld;
b3Matrix3x3 m_initInvInertia;
};

View File

@@ -22,7 +22,7 @@ b3StridingMeshInterface::~b3StridingMeshInterface()
}
void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
{
(void)aabbMin;
(void)aabbMax;
@@ -35,9 +35,9 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
PHY_ScalarType gfxindextype;
int stride,numverts,numtriangles;
int gfxindex;
btVector3 triangle[3];
b3Vector3 triangle[3];
btVector3 meshScaling = getScaling();
b3Vector3 meshScaling = getScaling();
///if the number of parts is big, the performance might drop due to the innerloop switch on indextype
for (part=0;part<graphicssubparts ;part++)
@@ -121,11 +121,11 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
{
unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[0].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(),(b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[1].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[2].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
}
break;
@@ -136,11 +136,11 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
{
unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[0].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(),(b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[1].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[2].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
}
break;
@@ -151,11 +151,11 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
{
unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[0].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(),(b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[1].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ());
triangle[2].setValue((b3Scalar)graphicsbase[0]*meshScaling.getX(),(b3Scalar)graphicsbase[1]*meshScaling.getY(), (b3Scalar)graphicsbase[2]*meshScaling.getZ());
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
}
break;
@@ -173,21 +173,21 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
}
}
void b3StridingMeshInterface::calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax)
void b3StridingMeshInterface::calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax)
{
struct AabbCalculationCallback : public btInternalTriangleIndexCallback
{
btVector3 m_aabbMin;
btVector3 m_aabbMax;
b3Vector3 m_aabbMin;
b3Vector3 m_aabbMax;
AabbCalculationCallback()
{
m_aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
m_aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
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));
}
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
{
(void)partId;
(void)triangleIndex;
@@ -203,8 +203,8 @@ void b3StridingMeshInterface::calculateAabbBruteForce(btVector3& aabbMin,btVecto
//first calculate the total aabb for all triangles
AabbCalculationCallback aabbCallback;
aabbMin.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
aabbMax.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
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));
InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);
aabbMin = aabbCallback.m_aabbMin;

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef BT_STRIDING_MESHINTERFACE_H
#define BT_STRIDING_MESHINTERFACE_H
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
#include "b3TriangleCallback.h"
//#include "btConcaveShape.h"
@@ -34,12 +34,12 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
{
protected:
btVector3 m_scaling;
b3Vector3 m_scaling;
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
b3StridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
b3StridingMeshInterface() :m_scaling(b3Scalar(1.),b3Scalar(1.),b3Scalar(1.))
{
}
@@ -48,10 +48,10 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
///brute force method to calculate aabb
void calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
void calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax);
/// get read and write access to a subpart of a triangle mesh
/// this subpart has a continuous array of vertices and indices
@@ -77,21 +77,21 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
virtual void preallocateIndices(int numindices)=0;
virtual bool hasPremadeAabb() const { return false; }
virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
virtual void setPremadeAabb(const b3Vector3& aabbMin, const b3Vector3& aabbMax ) const
{
(void) aabbMin;
(void) aabbMax;
}
virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
virtual void getPremadeAabb(b3Vector3* aabbMin, b3Vector3* aabbMax ) const
{
(void) aabbMin;
(void) aabbMax;
}
const btVector3& getScaling() const {
const b3Vector3& getScaling() const {
return m_scaling;
}
void setScaling(const btVector3& scaling)
void setScaling(const b3Vector3& scaling)
{
m_scaling = scaling;
}

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#ifndef BT_TRIANGLE_CALLBACK_H
#define BT_TRIANGLE_CALLBACK_H
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
///The b3TriangleCallback provides a callback for each overlapping triangle when calling processAllTriangles.
@@ -26,7 +26,7 @@ class b3TriangleCallback
public:
virtual ~b3TriangleCallback();
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex) = 0;
virtual void processTriangle(b3Vector3* triangle, int partId, int triangleIndex) = 0;
};
class btInternalTriangleIndexCallback
@@ -34,7 +34,7 @@ class btInternalTriangleIndexCallback
public:
virtual ~btInternalTriangleIndexCallback();
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) = 0;
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex) = 0;
};

View File

@@ -15,7 +15,7 @@ subject to the following restrictions:
#include "b3TriangleIndexVertexArray.h"
b3TriangleIndexVertexArray::b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
b3TriangleIndexVertexArray::b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride)
: m_hasAabb(0)
{
btIndexedMesh mesh;
@@ -79,14 +79,14 @@ bool b3TriangleIndexVertexArray::hasPremadeAabb() const
}
void b3TriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
void b3TriangleIndexVertexArray::setPremadeAabb(const b3Vector3& aabbMin, const b3Vector3& aabbMax ) const
{
m_aabbMin = aabbMin;
m_aabbMax = aabbMax;
m_hasAabb = 1; // this is intentionally an int see notes in header
}
void b3TriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
void b3TriangleIndexVertexArray::getPremadeAabb(b3Vector3* aabbMin, b3Vector3* aabbMax ) const
{
*aabbMin = m_aabbMin;
*aabbMax = m_aabbMax;

View File

@@ -17,8 +17,8 @@ subject to the following restrictions:
#define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
#include "b3StridingMeshInterface.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/btScalar.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "BulletCommon/b3Scalar.h"
///The btIndexedMesh indexes a single vertex and index array. Multiple btIndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh.
@@ -59,7 +59,7 @@ ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
;
typedef btAlignedObjectArray<btIndexedMesh> IndexedMeshArray;
typedef b3AlignedObjectArray<btIndexedMesh> IndexedMeshArray;
///The b3TriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing triangle/index arrays.
///Additional meshes can be added using addIndexedMesh
@@ -71,8 +71,8 @@ protected:
IndexedMeshArray m_indexedMeshes;
int m_pad[2];
mutable int m_hasAabb; // using int instead of bool to maintain alignment
mutable btVector3 m_aabbMin;
mutable btVector3 m_aabbMax;
mutable b3Vector3 m_aabbMin;
mutable b3Vector3 m_aabbMax;
public:
@@ -85,7 +85,7 @@ public:
virtual ~b3TriangleIndexVertexArray();
//just to be backwards compatible
b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride);
b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride);
void addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
{
@@ -124,8 +124,8 @@ public:
virtual void preallocateIndices(int numindices){(void) numindices;}
virtual bool hasPremadeAabb() const;
virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
virtual void setPremadeAabb(const b3Vector3& aabbMin, const b3Vector3& aabbMax ) const;
virtual void getPremadeAabb(b3Vector3* aabbMin, b3Vector3* aabbMax ) const;
}
;

View File

@@ -17,15 +17,15 @@ subject to the following restrictions:
#include "../basic_initialize/b3OpenCLUtils.h"
#include "../host/b3ConvexHullContact.h"
#include "BulletCommon/btVector3.h"
#include "BulletCommon/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 "BulletCommon/CommandLineArgs.h"
#include "BulletCommon/b3CommandLineArgs.h"
#include "../host/b3ConvexHullContact.h"
#include "BulletCommon/btMinMax.h"
#include "BulletCommon/b3MinMax.h"
int g_nPassed = 0;
int g_nFailed = 0;
bool g_testFailed = 0;
@@ -88,7 +88,7 @@ int main(int argc, char** argv)
{
int preferredDeviceIndex = -1; int preferredPlatformIndex = -1;
CommandLineArgs args(argc, argv);
b3CommandLineArgs args(argc, argv);
args.GetCmdLineArgument("deviceId", preferredDeviceIndex);
args.GetCmdLineArgument("platformId", preferredPlatformIndex);

View File

@@ -29,11 +29,11 @@ function createProject(vendor)
"../../parallel_primitives/host/btPrefixScanCL.h",
"../../parallel_primitives/host/btRadixSort32CL.cpp",
"../../parallel_primitives/host/btRadixSort32CL.h",
"../../../src/BulletCommon/btAlignedAllocator.cpp",
"../../../src/BulletCommon/btAlignedAllocator.h",
"../../../src/BulletCommon/btAlignedObjectArray.h",
"../../../src/BulletCommon/btQuickprof.cpp",
"../../../src/BulletCommon/btQuickprof.h",
"../../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../../src/BulletCommon/b3AlignedAllocator.h",
"../../../src/BulletCommon/b3AlignedObjectArray.h",
"../../../src/BulletCommon/b3Quickprof.cpp",
"../../../src/BulletCommon/b3Quickprof.h",
"../../../src/BulletGeometry/**.cpp",
"../../../src/BulletGeometry/**.h",

View File

@@ -2,7 +2,7 @@
#include "b3GpuBatchingPgsSolver.h"
#include "../../parallel_primitives/host/btRadixSort32CL.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
#include "../../parallel_primitives/host/btLauncherCL.h"
#include "../../parallel_primitives/host/btBoundSearchCL.h"
#include "../../parallel_primitives/host/btPrefixScanCL.h"
@@ -76,9 +76,9 @@ struct btGpuBatchingPgsSolverInternalData
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
btAlignedObjectArray<unsigned int> m_idxBuffer;
btAlignedObjectArray<btSortData> m_sortData;
btAlignedObjectArray<b3Contact4> m_old;
b3AlignedObjectArray<unsigned int> m_idxBuffer;
b3AlignedObjectArray<btSortData> m_sortData;
b3AlignedObjectArray<b3Contact4> m_old;
};
@@ -519,7 +519,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
btOpenCLArray<btSortData>& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer);
this->m_data->m_solverGPU->m_sort32->execute(keyValuesInOut);
/*btAlignedObjectArray<btSortData> hostValues;
/*b3AlignedObjectArray<btSortData> hostValues;
keyValuesInOut.copyToHost(hostValues);
printf("hostValues.size=%d\n",hostValues.size());
*/
@@ -596,15 +596,15 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
} else
{
BT_PROFILE("cpu batchContacts");
btAlignedObjectArray<b3Contact4> cpuContacts;
b3AlignedObjectArray<b3Contact4> cpuContacts;
btOpenCLArray<b3Contact4>* contactsIn = m_data->m_solverGPU->m_contactBuffer2;
contactsIn->copyToHost(cpuContacts);
btOpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
btOpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
btAlignedObjectArray<unsigned int> nNativeHost;
btAlignedObjectArray<unsigned int> offsetsNativeHost;
b3AlignedObjectArray<unsigned int> nNativeHost;
b3AlignedObjectArray<unsigned int> offsetsNativeHost;
{
BT_PROFILE("countsNative/offsetsNative copyToHost");
@@ -641,7 +641,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
}
{
BT_PROFILE("m_contactBuffer->copyFromHost");
m_data->m_solverGPU->m_contactBuffer2->copyFromHost((btAlignedObjectArray<b3Contact4>&)cpuContacts);
m_data->m_solverGPU->m_contactBuffer2->copyFromHost((b3AlignedObjectArray<b3Contact4>&)cpuContacts);
}
}
@@ -724,19 +724,19 @@ static bool sortfnc(const btSortData& a,const btSortData& b)
btAlignedObjectArray<int> bodyUsed;
b3AlignedObjectArray<int> bodyUsed;
btAlignedObjectArray<unsigned int> idxBuffer;
btAlignedObjectArray<btSortData> sortData;
btAlignedObjectArray<b3Contact4> old;
b3AlignedObjectArray<unsigned int> idxBuffer;
b3AlignedObjectArray<btSortData> sortData;
b3AlignedObjectArray<b3Contact4> old;
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies)
{
btAlignedObjectArray<int> bodyUsed;
b3AlignedObjectArray<int> bodyUsed;
bodyUsed.resize(numBodies);
for (int q=0;q<numBodies;q++)
bodyUsed[q]=0;

View File

@@ -1,15 +1,15 @@
#ifndef BT_CONSTRAINT4_h
#define BT_CONSTRAINT4_h
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
{
BT_DECLARE_ALIGNED_ALLOCATOR();
btVector3 m_linear;//normal?
btVector3 m_worldPos[4];
btVector3 m_center; // friction
b3Vector3 m_linear;//normal?
b3Vector3 m_worldPos[4];
b3Vector3 m_center; // friction
float m_jacCoeffInv[4];
float m_b[4];
float m_appliedRambdaDt[4];

View File

@@ -13,57 +13,57 @@
struct btGpuNarrowPhaseInternalData
{
btAlignedObjectArray<b3ConvexUtility*>* m_convexData;
b3AlignedObjectArray<b3ConvexUtility*>* m_convexData;
btAlignedObjectArray<b3ConvexPolyhedronCL> m_convexPolyhedra;
btAlignedObjectArray<btVector3> m_uniqueEdges;
btAlignedObjectArray<btVector3> m_convexVertices;
btAlignedObjectArray<int> m_convexIndices;
b3AlignedObjectArray<b3ConvexPolyhedronCL> m_convexPolyhedra;
b3AlignedObjectArray<b3Vector3> m_uniqueEdges;
b3AlignedObjectArray<b3Vector3> m_convexVertices;
b3AlignedObjectArray<int> m_convexIndices;
btOpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
btOpenCLArray<btVector3>* m_uniqueEdgesGPU;
btOpenCLArray<btVector3>* m_convexVerticesGPU;
btOpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
btOpenCLArray<b3Vector3>* m_convexVerticesGPU;
btOpenCLArray<int>* m_convexIndicesGPU;
btOpenCLArray<btVector3>* m_worldVertsB1GPU;
btOpenCLArray<b3Vector3>* m_worldVertsB1GPU;
btOpenCLArray<btInt4>* m_clippingFacesOutGPU;
btOpenCLArray<btVector3>* m_worldNormalsAGPU;
btOpenCLArray<btVector3>* m_worldVertsA1GPU;
btOpenCLArray<btVector3>* m_worldVertsB2GPU;
btOpenCLArray<b3Vector3>* m_worldNormalsAGPU;
btOpenCLArray<b3Vector3>* m_worldVertsA1GPU;
btOpenCLArray<b3Vector3>* m_worldVertsB2GPU;
btAlignedObjectArray<btGpuChildShape> m_cpuChildShapes;
b3AlignedObjectArray<btGpuChildShape> m_cpuChildShapes;
btOpenCLArray<btGpuChildShape>* m_gpuChildShapes;
btAlignedObjectArray<btGpuFace> m_convexFaces;
b3AlignedObjectArray<btGpuFace> m_convexFaces;
btOpenCLArray<btGpuFace>* m_convexFacesGPU;
GpuSatCollision* m_gpuSatCollision;
btAlignedObjectArray<btInt2>* m_pBufPairsCPU;
b3AlignedObjectArray<btInt2>* m_pBufPairsCPU;
btOpenCLArray<btInt2>* m_convexPairsOutGPU;
btOpenCLArray<btInt2>* m_planePairs;
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
btAlignedObjectArray<b3Contact4>* m_pBufContactOutCPU;
b3AlignedObjectArray<b3Contact4>* m_pBufContactOutCPU;
btAlignedObjectArray<b3RigidBodyCL>* m_bodyBufferCPU;
b3AlignedObjectArray<b3RigidBodyCL>* m_bodyBufferCPU;
btOpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
btAlignedObjectArray<btInertiaCL>* m_inertiaBufferCPU;
b3AlignedObjectArray<btInertiaCL>* m_inertiaBufferCPU;
btOpenCLArray<btInertiaCL>* m_inertiaBufferGPU;
int m_numAcceleratedShapes;
int m_numAcceleratedRigidBodies;
btAlignedObjectArray<b3Collidable> m_collidablesCPU;
b3AlignedObjectArray<b3Collidable> m_collidablesCPU;
btOpenCLArray<b3Collidable>* m_collidablesGPU;
btOpenCLArray<b3SapAabb>* m_localShapeAABBGPU;
btAlignedObjectArray<b3SapAabb>* m_localShapeAABBCPU;
b3AlignedObjectArray<b3SapAabb>* m_localShapeAABBCPU;
btAlignedObjectArray<class b3OptimizedBvh*> m_bvhData;
b3AlignedObjectArray<class b3OptimizedBvh*> m_bvhData;
btOpenCLArray<btQuantizedBvhNode>* m_treeNodesGPU;
btOpenCLArray<btBvhSubtreeInfo>* m_subTreesGPU;
@@ -89,18 +89,18 @@ m_queue(queue)
m_data->m_config = config;
m_data->m_gpuSatCollision = new GpuSatCollision(ctx,device,queue);
m_data->m_pBufPairsCPU = new btAlignedObjectArray<btInt2>;
m_data->m_pBufPairsCPU = new b3AlignedObjectArray<btInt2>;
m_data->m_pBufPairsCPU->resize(config.m_maxBroadphasePairs);
m_data->m_convexPairsOutGPU = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_planePairs = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_pBufContactOutCPU = new btAlignedObjectArray<b3Contact4>();
m_data->m_pBufContactOutCPU = new b3AlignedObjectArray<b3Contact4>();
m_data->m_pBufContactOutCPU->resize(config.m_maxBroadphasePairs);
m_data->m_bodyBufferCPU = new btAlignedObjectArray<b3RigidBodyCL>();
m_data->m_bodyBufferCPU = new b3AlignedObjectArray<b3RigidBodyCL>();
m_data->m_bodyBufferCPU->resize(config.m_maxConvexBodies);
m_data->m_inertiaBufferCPU = new btAlignedObjectArray<btInertiaCL>();
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<btInertiaCL>();
m_data->m_inertiaBufferCPU->resize(config.m_maxConvexBodies);
m_data->m_pBufContactOutGPU = new btOpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
@@ -108,7 +108,7 @@ m_queue(queue)
m_data->m_inertiaBufferGPU = new btOpenCLArray<btInertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
m_data->m_collidablesGPU = new btOpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
m_data->m_localShapeAABBCPU = new btAlignedObjectArray<b3SapAabb>;
m_data->m_localShapeAABBCPU = new b3AlignedObjectArray<b3SapAabb>;
m_data->m_localShapeAABBGPU = new btOpenCLArray<b3SapAabb>(ctx,queue,config.m_maxConvexShapes);
@@ -119,20 +119,20 @@ m_queue(queue)
m_data->m_gpuChildShapes = new btOpenCLArray<btGpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
m_data->m_convexPolyhedraGPU = new btOpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
m_data->m_uniqueEdgesGPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
m_data->m_convexVerticesGPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexVertices,true);
m_data->m_uniqueEdgesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
m_data->m_convexVerticesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexVertices,true);
m_data->m_convexIndicesGPU = new btOpenCLArray<int>(ctx,queue,config.m_maxConvexIndices,true);
m_data->m_worldVertsB1GPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_clippingFacesOutGPU = new btOpenCLArray<btInt4>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldNormalsAGPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldVertsA1GPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB2GPU = new btOpenCLArray<btVector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldNormalsAGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldVertsA1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB2GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_convexData = new btAlignedObjectArray<b3ConvexUtility* >();
m_data->m_convexData = new b3AlignedObjectArray<b3ConvexUtility* >();
m_data->m_convexData->resize(config.m_maxConvexShapes);
@@ -209,8 +209,8 @@ int b3GpuNarrowPhase::registerSphereShape(float radius)
if (col.m_shapeIndex>=0)
{
b3SapAabb aabb;
btVector3 myAabbMin(-radius,-radius,-radius);
btVector3 myAabbMax(radius,radius,radius);
b3Vector3 myAabbMin(-radius,-radius,-radius);
b3Vector3 myAabbMax(radius,radius,radius);
aabb.m_min[0] = myAabbMin[0];//s_convexHeightField->m_aabb.m_min.x;
aabb.m_min[1] = myAabbMin[1];//s_convexHeightField->m_aabb.m_min.y;
@@ -231,7 +231,7 @@ int b3GpuNarrowPhase::registerSphereShape(float radius)
}
int b3GpuNarrowPhase::registerFace(const btVector3& faceNormal, float faceConstant)
int b3GpuNarrowPhase::registerFace(const b3Vector3& faceNormal, float faceConstant)
{
int faceOffset = m_data->m_convexFaces.size();
btGpuFace& face = m_data->m_convexFaces.expand();
@@ -243,7 +243,7 @@ int b3GpuNarrowPhase::registerFace(const btVector3& faceNormal, float faceConsta
return faceOffset;
}
int b3GpuNarrowPhase::registerPlaneShape(const btVector3& planeNormal, float planeConstant)
int b3GpuNarrowPhase::registerPlaneShape(const b3Vector3& planeNormal, float planeConstant)
{
int collidableIndex = allocateCollidable();
@@ -346,13 +346,13 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* convexPtr,b3Colli
int b3GpuNarrowPhase::registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling)
{
btAlignedObjectArray<btVector3> verts;
b3AlignedObjectArray<b3Vector3> verts;
unsigned char* vts = (unsigned char*) vertices;
for (int i=0;i<numVertices;i++)
{
float* vertex = (float*) &vts[i*strideInBytes];
verts.push_back(btVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
}
b3ConvexUtility* utilPtr = new b3ConvexUtility();
@@ -375,7 +375,7 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* utilPtr)
{
btVector3 localCenter(0,0,0);
b3Vector3 localCenter(0,0,0);
for (int i=0;i<utilPtr->m_vertices.size();i++)
localCenter+=utilPtr->m_vertices[i];
localCenter*= (1.f/utilPtr->m_vertices.size());
@@ -388,8 +388,8 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* utilPtr)
{
b3SapAabb aabb;
btVector3 myAabbMin(1e30f,1e30f,1e30f);
btVector3 myAabbMax(-1e30f,-1e30f,-1e30f);
b3Vector3 myAabbMin(1e30f,1e30f,1e30f);
b3Vector3 myAabbMax(-1e30f,-1e30f,-1e30f);
for (int i=0;i<utilPtr->m_vertices.size();i++)
{
@@ -414,7 +414,7 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* utilPtr)
}
int b3GpuNarrowPhase::registerCompoundShape(btAlignedObjectArray<btGpuChildShape>* childShapes)
int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes)
{
int collidableIndex = allocateCollidable();
@@ -438,8 +438,8 @@ int b3GpuNarrowPhase::registerCompoundShape(btAlignedObjectArray<btGpuChildShap
b3SapAabb aabbWS;
btVector3 myAabbMin(1e30f,1e30f,1e30f);
btVector3 myAabbMax(-1e30f,-1e30f,-1e30f);
b3Vector3 myAabbMin(1e30f,1e30f,1e30f);
b3Vector3 myAabbMax(-1e30f,-1e30f,-1e30f);
//compute local AABB of the compound of all children
for (int i=0;i<childShapes->size();i++)
@@ -448,17 +448,17 @@ int b3GpuNarrowPhase::registerCompoundShape(btAlignedObjectArray<btGpuChildShap
b3Collidable& childCol = getCollidableCpu(childColIndex);
b3SapAabb aabbLoc =m_data->m_localShapeAABBCPU->at(childColIndex);
btVector3 childLocalAabbMin(aabbLoc.m_min[0],aabbLoc.m_min[1],aabbLoc.m_min[2]);
btVector3 childLocalAabbMax(aabbLoc.m_max[0],aabbLoc.m_max[1],aabbLoc.m_max[2]);
btVector3 aMin,aMax;
btScalar margin(0.f);
btTransform childTr;
b3Vector3 childLocalAabbMin(aabbLoc.m_min[0],aabbLoc.m_min[1],aabbLoc.m_min[2]);
b3Vector3 childLocalAabbMax(aabbLoc.m_max[0],aabbLoc.m_max[1],aabbLoc.m_max[2]);
b3Vector3 aMin,aMax;
b3Scalar margin(0.f);
b3Transform childTr;
childTr.setIdentity();
childTr.setOrigin(btVector3(childShapes->at(i).m_childPosition[0],
childTr.setOrigin(b3Vector3(childShapes->at(i).m_childPosition[0],
childShapes->at(i).m_childPosition[1],
childShapes->at(i).m_childPosition[2]));
childTr.setRotation(btQuaternion(childShapes->at(i).m_childOrientation[0],
childTr.setRotation(b3Quaternion(childShapes->at(i).m_childOrientation[0],
childShapes->at(i).m_childOrientation[1],
childShapes->at(i).m_childOrientation[2],
childShapes->at(i).m_childOrientation[3]));
@@ -485,7 +485,7 @@ int b3GpuNarrowPhase::registerCompoundShape(btAlignedObjectArray<btGpuChildShap
}
int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices,const float* scaling1)
int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,const float* scaling1)
{
//right now we only support one single mesh, it is on the todo to merge all mesh data etc
btAssert(m_data->m_treeNodesGPU ==0);
@@ -496,7 +496,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vert
exit (0);
}
btVector3 scaling(scaling1[0],scaling1[1],scaling1[2]);
b3Vector3 scaling(scaling1[0],scaling1[1],scaling1[2]);
int collidableIndex = allocateCollidable();
b3Collidable& col = getCollidableCpu(collidableIndex);
@@ -507,12 +507,12 @@ int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vert
b3SapAabb aabb;
btVector3 myAabbMin(1e30f,1e30f,1e30f);
btVector3 myAabbMax(-1e30f,-1e30f,-1e30f);
b3Vector3 myAabbMin(1e30f,1e30f,1e30f);
b3Vector3 myAabbMax(-1e30f,-1e30f,-1e30f);
for (int i=0;i<vertices->size();i++)
{
btVector3 vtx(vertices->at(i)*scaling);
b3Vector3 vtx(vertices->at(i)*scaling);
myAabbMin.setMin(vtx);
myAabbMax.setMax(vtx);
}
@@ -530,7 +530,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vert
m_data->m_localShapeAABBGPU->push_back(aabb);
b3OptimizedBvh* bvh = new b3OptimizedBvh();
//void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax)
//void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantizedAabbCompression, const b3Vector3& bvhAabbMin, const b3Vector3& bvhAabbMax)
bool useQuantizedAabbCompression = true;
b3TriangleIndexVertexArray* meshInterface=new b3TriangleIndexVertexArray();
@@ -538,12 +538,12 @@ int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vert
mesh.m_numTriangles = indices->size()/3;
mesh.m_numVertices = vertices->size();
mesh.m_vertexBase = (const unsigned char *)&vertices->at(0).getX();
mesh.m_vertexStride = sizeof(btVector3);
mesh.m_vertexStride = sizeof(b3Vector3);
mesh.m_triangleIndexStride = 3 * sizeof(int);// or sizeof(int)
mesh.m_triangleIndexBase = (const unsigned char *)&indices->at(0);
meshInterface->addIndexedMesh(mesh);
bvh->build(meshInterface, useQuantizedAabbCompression, (btVector3&)aabb.m_min, (btVector3&)aabb.m_max);
bvh->build(meshInterface, useQuantizedAabbCompression, (b3Vector3&)aabb.m_min, (b3Vector3&)aabb.m_max);
m_data->m_bvhData.push_back(bvh);
int numNodes = bvh->getQuantizedNodeArray().size();
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU = new btOpenCLArray<btQuantizedBvhNode>(this->m_context,this->m_queue,numNodes);
@@ -560,21 +560,21 @@ int b3GpuNarrowPhase::registerConcaveMesh(btAlignedObjectArray<btVector3>* vert
return collidableIndex;
}
int b3GpuNarrowPhase::registerConcaveMeshShape(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices,b3Collidable& col, const float* scaling1)
int b3GpuNarrowPhase::registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,b3Collidable& col, const float* scaling1)
{
btVector3 scaling(scaling1[0],scaling1[1],scaling1[2]);
b3Vector3 scaling(scaling1[0],scaling1[1],scaling1[2]);
m_data->m_convexData->resize(m_data->m_numAcceleratedShapes+1);
m_data->m_convexPolyhedra.resize(m_data->m_numAcceleratedShapes+1);
b3ConvexPolyhedronCL& convex = m_data->m_convexPolyhedra.at(m_data->m_convexPolyhedra.size()-1);
convex.mC = btVector3(0,0,0);
convex.mE = btVector3(0,0,0);
convex.m_extents= btVector3(0,0,0);
convex.m_localCenter = btVector3(0,0,0);
convex.mC = b3Vector3(0,0,0);
convex.mE = b3Vector3(0,0,0);
convex.m_extents= b3Vector3(0,0,0);
convex.m_localCenter = b3Vector3(0,0,0);
convex.m_radius = 0.f;
convex.m_numUniqueEdges = 0;
@@ -593,12 +593,12 @@ int b3GpuNarrowPhase::registerConcaveMeshShape(btAlignedObjectArray<btVector3>*
{
//printf("i=%d out of %d", i,convex.m_numFaces);
}
btVector3 vert0(vertices->at(indices->at(i*3))*scaling);
btVector3 vert1(vertices->at(indices->at(i*3+1))*scaling);
btVector3 vert2(vertices->at(indices->at(i*3+2))*scaling);
b3Vector3 vert0(vertices->at(indices->at(i*3))*scaling);
b3Vector3 vert1(vertices->at(indices->at(i*3+1))*scaling);
b3Vector3 vert2(vertices->at(indices->at(i*3+2))*scaling);
btVector3 normal = ((vert1-vert0).cross(vert2-vert0)).normalize();
btScalar c = -(normal.dot(vert0));
b3Vector3 normal = ((vert1-vert0).cross(vert2-vert0)).normalize();
b3Scalar c = -(normal.dot(vert0));
m_data->m_convexFaces[convex.m_faceOffset+i].m_plane[0] = normal.getX();
m_data->m_convexFaces[convex.m_faceOffset+i].m_plane[1] = normal.getY();
@@ -753,8 +753,8 @@ const b3SapAabb& b3GpuNarrowPhase::getLocalSpaceAabb(int collidableIndex) const
int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const float* position, const float* orientation , const float* aabbMinPtr, const float* aabbMaxPtr,bool writeToGpu)
{
btVector3 aabbMin(aabbMinPtr[0],aabbMinPtr[1],aabbMinPtr[2]);
btVector3 aabbMax (aabbMaxPtr[0],aabbMaxPtr[1],aabbMaxPtr[2]);
b3Vector3 aabbMin(aabbMinPtr[0],aabbMinPtr[1],aabbMinPtr[2]);
b3Vector3 aabbMax (aabbMaxPtr[0],aabbMaxPtr[1],aabbMaxPtr[2]);
btAssert(m_data->m_numAcceleratedRigidBodies< (m_data->m_config.m_maxConvexBodies-1));
@@ -807,9 +807,9 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
//approximate using the aabb of the shape
//Aabb aabb = (*m_data->m_shapePointers)[shapeIndex]->m_aabb;
btVector3 halfExtents = (aabbMax-aabbMin);//*0.5f;//fake larger inertia makes demos more stable ;-)
b3Vector3 halfExtents = (aabbMax-aabbMin);//*0.5f;//fake larger inertia makes demos more stable ;-)
btVector3 localInertia;
b3Vector3 localInertia;
float lx=2.f*halfExtents[0];
float ly=2.f*halfExtents[1];
@@ -819,7 +819,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
(mass/12.0f) * (lx*lx + lz*lz),
(mass/12.0f) * (lx*lx + ly*ly));
btVector3 invLocalInertia;
b3Vector3 invLocalInertia;
invLocalInertia[0] = 1.f/localInertia[0];
invLocalInertia[1] = 1.f/localInertia[1];
invLocalInertia[2] = 1.f/localInertia[2];
@@ -830,7 +830,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
0, invLocalInertia[1], 0,
0, 0, invLocalInertia[2]);
btMatrix3x3 m (body.m_quat);
b3Matrix3x3 m (body.m_quat);
shapeInfo.m_invInertiaWorld = m.scaled(invLocalInertia) * m.transpose();

View File

@@ -3,8 +3,8 @@
#include "../../gpu_narrowphase/host/b3Collidable.h"
#include "basic_initialize/b3OpenCLInclude.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "BulletCommon/b3Vector3.h"
class b3GpuNarrowPhase
{
@@ -20,7 +20,7 @@ protected:
cl_command_queue m_queue;
int registerConvexHullShape(class b3ConvexUtility* convexPtr, b3Collidable& col);
int registerConcaveMeshShape(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
public:
@@ -32,12 +32,12 @@ public:
virtual ~b3GpuNarrowPhase(void);
int registerSphereShape(float radius);
int registerPlaneShape(const btVector3& planeNormal, float planeConstant);
int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
int registerCompoundShape(btAlignedObjectArray<btGpuChildShape>* childShapes);
int registerFace(const btVector3& faceNormal, float faceConstant);
int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
int registerFace(const b3Vector3& faceNormal, float faceConstant);
int registerConcaveMesh(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices,const float* scaling);
int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,const float* scaling);
//do they need to be merged?

View File

@@ -20,7 +20,7 @@
#include "b3GpuBatchingPgsSolver.h"
#include "b3Solver.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
#include "b3Config.h"
b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id device, cl_command_queue q,class b3GpuNarrowPhase* narrowphase, class b3GpuSapBroadphase* broadphaseSap )
@@ -133,9 +133,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
bool forceHost = false;
if (forceHost)
{
btAlignedObjectArray<b3RigidBodyCL> hostBodies;
btAlignedObjectArray<btInertiaCL> hostInertias;
btAlignedObjectArray<b3Contact4> hostContacts;
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
b3AlignedObjectArray<btInertiaCL> hostInertias;
b3AlignedObjectArray<b3Contact4> hostContacts;
{
BT_PROFILE("copyToHost");
@@ -161,11 +161,11 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
}
} else
{
btAlignedObjectArray<b3RigidBodyCL> hostBodies;
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
gpuBodies.copyToHost(hostBodies);
btAlignedObjectArray<btInertiaCL> hostInertias;
b3AlignedObjectArray<btInertiaCL> hostInertias;
gpuInertias.copyToHost(hostInertias);
btAlignedObjectArray<b3Contact4> hostContacts;
b3AlignedObjectArray<b3Contact4> hostContacts;
gpuContacts.copyToHost(hostContacts);
{
m_data->m_solver->solveContacts(m_data->m_narrowphase->getNumBodiesGpu(),&hostBodies[0],&hostInertias[0],numContacts,&hostContacts[0]);
@@ -207,7 +207,7 @@ void b3GpuRigidBodyPipeline::integrate(float timeStep)
float angularDamp = 0.99f;
launcher.setConst(angularDamp);
btVector3 gravity(0.f,-9.8f,0.f);
b3Vector3 gravity(0.f,-9.8f,0.f);
launcher.setConst(gravity);
launcher.launch1D(numBodies);
@@ -256,18 +256,18 @@ int b3GpuRigidBodyPipeline::getNumBodies() const
int b3GpuRigidBodyPipeline::registerPhysicsInstance(float mass, const float* position, const float* orientation, int collidableIndex, int userIndex)
{
btVector3 aabbMin(0,0,0),aabbMax(0,0,0);
b3Vector3 aabbMin(0,0,0),aabbMax(0,0,0);
if (collidableIndex>=0)
{
b3SapAabb localAabb = m_data->m_narrowphase->getLocalSpaceAabb(collidableIndex);
btVector3 localAabbMin(localAabb.m_min[0],localAabb.m_min[1],localAabb.m_min[2]);
btVector3 localAabbMax(localAabb.m_max[0],localAabb.m_max[1],localAabb.m_max[2]);
b3Vector3 localAabbMin(localAabb.m_min[0],localAabb.m_min[1],localAabb.m_min[2]);
b3Vector3 localAabbMax(localAabb.m_max[0],localAabb.m_max[1],localAabb.m_max[2]);
btScalar margin = 0.01f;
btTransform t;
b3Scalar margin = 0.01f;
b3Transform t;
t.setIdentity();
t.setOrigin(btVector3(position[0],position[1],position[2]));
t.setRotation(btQuaternion(orientation[0],orientation[1],orientation[2],orientation[3]));
t.setOrigin(b3Vector3(position[0],position[1],position[2]));
t.setRotation(b3Quaternion(orientation[0],orientation[1],orientation[2],orientation[3]));
btTransformAabb(localAabbMin,localAabbMax, margin,t,aabbMin,aabbMax);
if (mass)
{

View File

@@ -23,10 +23,10 @@ public:
//int registerConvexPolyhedron(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
//int registerSphereShape(float radius);
//int registerPlaneShape(const btVector3& planeNormal, float planeConstant);
//int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
//int registerConcaveMesh(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices, const float* scaling);
//int registerCompoundShape(btAlignedObjectArray<btGpuChildShape>* childShapes);
//int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
//int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
int registerPhysicsInstance(float mass, const float* position, const float* orientation, int collisionShapeIndex, int userData);

View File

@@ -2,7 +2,7 @@
#define BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#include "../../basic_initialize/b3OpenCLInclude.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "../../parallel_primitives/host/btOpenCLArray.h"
#include "../../gpu_narrowphase/host/b3Collidable.h"

View File

@@ -39,9 +39,9 @@ bool useNewBatchingKernel = false;
#include "../kernels/batchingKernelsNew.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
#include "../../parallel_primitives/host/btLauncherCL.h"
#include "BulletCommon/btVector3.h"
#include "BulletCommon/b3Vector3.h"
struct SolverDebugInfo
{
@@ -282,8 +282,8 @@ b3Solver::~b3Solver()
static
inline
float calcRelVel(const btVector3& l0, const btVector3& l1, const btVector3& a0, const btVector3& a1,
const btVector3& linVel0, const btVector3& angVel0, const btVector3& linVel1, const btVector3& angVel1)
float calcRelVel(const b3Vector3& l0, const b3Vector3& l1, const b3Vector3& a0, const b3Vector3& a1,
const b3Vector3& linVel0, const b3Vector3& angVel0, const b3Vector3& linVel1, const b3Vector3& angVel1)
{
return btDot(l0, linVel0) + btDot(a0, angVel0) + btDot(l1, linVel1) + btDot(a1, angVel1);
}
@@ -291,8 +291,8 @@ b3Solver::~b3Solver()
static
inline
void setLinearAndAngular(const btVector3& n, const btVector3& r0, const btVector3& r1,
btVector3& linear, btVector3& angular0, btVector3& angular1)
void setLinearAndAngular(const b3Vector3& n, const b3Vector3& r0, const b3Vector3& r1,
b3Vector3& linear, b3Vector3& angular0, b3Vector3& angular1)
{
linear = -n;
angular0 = -btCross(r0, n);
@@ -304,15 +304,15 @@ template<bool JACOBI>
static
__inline
void solveContact(b3GpuConstraint4& cs,
const btVector3& posA, btVector3& linVelA, btVector3& angVelA, float invMassA, const btMatrix3x3& invInertiaA,
const btVector3& posB, btVector3& linVelB, btVector3& angVelB, float invMassB, const btMatrix3x3& invInertiaB,
const b3Vector3& posA, b3Vector3& linVelA, b3Vector3& angVelA, float invMassA, const b3Matrix3x3& invInertiaA,
const b3Vector3& posB, b3Vector3& linVelB, b3Vector3& angVelB, float invMassB, const b3Matrix3x3& invInertiaB,
float maxRambdaDt[4], float minRambdaDt[4])
{
btVector3 dLinVelA; dLinVelA.setZero();
btVector3 dAngVelA; dAngVelA.setZero();
btVector3 dLinVelB; dLinVelB.setZero();
btVector3 dAngVelB; dAngVelB.setZero();
b3Vector3 dLinVelA; dLinVelA.setZero();
b3Vector3 dAngVelA; dAngVelA.setZero();
b3Vector3 dLinVelB; dLinVelB.setZero();
b3Vector3 dAngVelB; dAngVelB.setZero();
for(int ic=0; ic<4; ic++)
{
@@ -320,12 +320,12 @@ void solveContact(b3GpuConstraint4& cs,
if( cs.m_jacCoeffInv[ic] == 0.f ) continue;
{
btVector3 angular0, angular1, linear;
btVector3 r0 = cs.m_worldPos[ic] - (btVector3&)posA;
btVector3 r1 = cs.m_worldPos[ic] - (btVector3&)posB;
setLinearAndAngular( (const btVector3 &)-cs.m_linear, (const btVector3 &)r0, (const btVector3 &)r1, linear, angular0, angular1 );
b3Vector3 angular0, angular1, linear;
b3Vector3 r0 = cs.m_worldPos[ic] - (b3Vector3&)posA;
b3Vector3 r1 = cs.m_worldPos[ic] - (b3Vector3&)posB;
setLinearAndAngular( (const b3Vector3 &)-cs.m_linear, (const b3Vector3 &)r0, (const b3Vector3 &)r1, linear, angular0, angular1 );
float rambdaDt = calcRelVel((const btVector3 &)cs.m_linear,(const btVector3 &) -cs.m_linear, angular0, angular1,
float rambdaDt = calcRelVel((const b3Vector3 &)cs.m_linear,(const b3Vector3 &) -cs.m_linear, angular0, angular1,
linVelA, angVelA, linVelB, angVelB ) + cs.m_b[ic];
rambdaDt *= cs.m_jacCoeffInv[ic];
@@ -339,10 +339,10 @@ void solveContact(b3GpuConstraint4& cs,
cs.m_appliedRambdaDt[ic] = updated;
}
btVector3 linImp0 = invMassA*linear*rambdaDt;
btVector3 linImp1 = invMassB*(-linear)*rambdaDt;
btVector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
btVector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
b3Vector3 linImp0 = invMassA*linear*rambdaDt;
b3Vector3 linImp1 = invMassB*(-linear)*rambdaDt;
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
#ifdef _WIN32
btAssert(_finite(linImp0.getX()));
btAssert(_finite(linImp1.getX()));
@@ -381,30 +381,30 @@ void solveContact(b3GpuConstraint4& cs,
static
__inline
void solveFriction(b3GpuConstraint4& cs,
const btVector3& posA, btVector3& linVelA, btVector3& angVelA, float invMassA, const btMatrix3x3& invInertiaA,
const btVector3& posB, btVector3& linVelB, btVector3& angVelB, float invMassB, const btMatrix3x3& invInertiaB,
const b3Vector3& posA, b3Vector3& linVelA, b3Vector3& angVelA, float invMassA, const b3Matrix3x3& invInertiaA,
const b3Vector3& posB, b3Vector3& linVelB, b3Vector3& angVelB, float invMassB, const b3Matrix3x3& invInertiaB,
float maxRambdaDt[4], float minRambdaDt[4])
{
if( cs.m_fJacCoeffInv[0] == 0 && cs.m_fJacCoeffInv[0] == 0 ) return;
const btVector3& center = (const btVector3&)cs.m_center;
const b3Vector3& center = (const b3Vector3&)cs.m_center;
btVector3 n = -(const btVector3&)cs.m_linear;
b3Vector3 n = -(const b3Vector3&)cs.m_linear;
btVector3 tangent[2];
b3Vector3 tangent[2];
#if 1
btPlaneSpace1 (n, tangent[0],tangent[1]);
#else
btVector3 r = cs.m_worldPos[0]-center;
b3Vector3 r = cs.m_worldPos[0]-center;
tangent[0] = cross3( n, r );
tangent[1] = cross3( tangent[0], n );
tangent[0] = normalize3( tangent[0] );
tangent[1] = normalize3( tangent[1] );
#endif
btVector3 angular0, angular1, linear;
btVector3 r0 = center - posA;
btVector3 r1 = center - posB;
b3Vector3 angular0, angular1, linear;
b3Vector3 r0 = center - posA;
b3Vector3 r1 = center - posB;
for(int i=0; i<2; i++)
{
setLinearAndAngular( tangent[i], r0, r1, linear, angular0, angular1 );
@@ -422,10 +422,10 @@ void solveContact(b3GpuConstraint4& cs,
cs.m_fAppliedRambdaDt[i] = updated;
}
btVector3 linImp0 = invMassA*linear*rambdaDt;
btVector3 linImp1 = invMassB*(-linear)*rambdaDt;
btVector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
btVector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
b3Vector3 linImp0 = invMassA*linear*rambdaDt;
b3Vector3 linImp1 = invMassB*(-linear)*rambdaDt;
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
#ifdef _WIN32
btAssert(_finite(linImp0.getX()));
btAssert(_finite(linImp1.getX()));
@@ -437,8 +437,8 @@ void solveContact(b3GpuConstraint4& cs,
}
{ // angular damping for point constraint
btVector3 ab = ( posB - posA ).normalized();
btVector3 ac = ( center - posA ).normalized();
b3Vector3 ab = ( posB - posA ).normalized();
b3Vector3 ac = ( center - posA ).normalized();
if( btDot( ab, ac ) > 0.95f || (invMassA == 0.f || invMassB == 0.f))
{
float angNA = btDot( n, angVelA );
@@ -454,7 +454,7 @@ void solveContact(b3GpuConstraint4& cs,
struct SolveTask// : public ThreadPool::Task
{
SolveTask(btAlignedObjectArray<b3RigidBodyCL>& bodies, btAlignedObjectArray<btInertiaCL>& shapes, btAlignedObjectArray<b3GpuConstraint4>& constraints,
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<btInertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
int start, int nConstraints)
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
m_solveFriction( true ){}
@@ -480,8 +480,8 @@ struct SolveTask// : public ThreadPool::Task
float maxRambdaDt[4] = {FLT_MAX,FLT_MAX,FLT_MAX,FLT_MAX};
float minRambdaDt[4] = {0.f,0.f,0.f,0.f};
solveContact<false>( m_constraints[i], (btVector3&)bodyA.m_pos, (btVector3&)bodyA.m_linVel, (btVector3&)bodyA.m_angVel, bodyA.m_invMass, (const btMatrix3x3 &)m_shapes[aIdx].m_invInertiaWorld,
(btVector3&)bodyB.m_pos, (btVector3&)bodyB.m_linVel, (btVector3&)bodyB.m_angVel, bodyB.m_invMass, (const btMatrix3x3 &)m_shapes[bIdx].m_invInertiaWorld,
solveContact<false>( m_constraints[i], (b3Vector3&)bodyA.m_pos, (b3Vector3&)bodyA.m_linVel, (b3Vector3&)bodyA.m_angVel, bodyA.m_invMass, (const b3Matrix3x3 &)m_shapes[aIdx].m_invInertiaWorld,
(b3Vector3&)bodyB.m_pos, (b3Vector3&)bodyB.m_linVel, (b3Vector3&)bodyB.m_angVel, bodyB.m_invMass, (const b3Matrix3x3 &)m_shapes[bIdx].m_invInertiaWorld,
maxRambdaDt, minRambdaDt );
}
@@ -502,8 +502,8 @@ struct SolveTask// : public ThreadPool::Task
minRambdaDt[j] = -maxRambdaDt[j];
}
solveFriction( m_constraints[i], (btVector3&)bodyA.m_pos, (btVector3&)bodyA.m_linVel, (btVector3&)bodyA.m_angVel, bodyA.m_invMass,(const btMatrix3x3 &) m_shapes[aIdx].m_invInertiaWorld,
(btVector3&)bodyB.m_pos, (btVector3&)bodyB.m_linVel, (btVector3&)bodyB.m_angVel, bodyB.m_invMass,(const btMatrix3x3 &) m_shapes[bIdx].m_invInertiaWorld,
solveFriction( m_constraints[i], (b3Vector3&)bodyA.m_pos, (b3Vector3&)bodyA.m_linVel, (b3Vector3&)bodyA.m_angVel, bodyA.m_invMass,(const b3Matrix3x3 &) m_shapes[aIdx].m_invInertiaWorld,
(b3Vector3&)bodyB.m_pos, (b3Vector3&)bodyB.m_linVel, (b3Vector3&)bodyB.m_angVel, bodyB.m_invMass,(const b3Matrix3x3 &) m_shapes[bIdx].m_invInertiaWorld,
maxRambdaDt, minRambdaDt );
}
@@ -512,9 +512,9 @@ struct SolveTask// : public ThreadPool::Task
}
btAlignedObjectArray<b3RigidBodyCL>& m_bodies;
btAlignedObjectArray<btInertiaCL>& m_shapes;
btAlignedObjectArray<b3GpuConstraint4>& m_constraints;
b3AlignedObjectArray<b3RigidBodyCL>& m_bodies;
b3AlignedObjectArray<btInertiaCL>& m_shapes;
b3AlignedObjectArray<b3GpuConstraint4>& m_constraints;
int m_start;
int m_nConstraints;
bool m_solveFriction;
@@ -525,11 +525,11 @@ void b3Solver::solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBu
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
{
btAlignedObjectArray<b3RigidBodyCL> bodyNative;
b3AlignedObjectArray<b3RigidBodyCL> bodyNative;
bodyBuf->copyToHost(bodyNative);
btAlignedObjectArray<btInertiaCL> shapeNative;
b3AlignedObjectArray<btInertiaCL> shapeNative;
shapeBuf->copyToHost(shapeNative);
btAlignedObjectArray<b3GpuConstraint4> constraintNative;
b3AlignedObjectArray<b3GpuConstraint4> constraintNative;
constraint->copyToHost(constraintNative);
for(int iter=0; iter<m_nIterations; iter++)

View File

@@ -19,9 +19,9 @@
#include "b3OpenCLUtils.h"
#include "../parallel_primitives/host/btOpenCLArray.h"
#include "../parallel_primitives/host/btLauncherCL.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
#include "../parallel_primitives/host/btFillCL.h"
#include "BulletCommon/CommandLineArgs.h"
#include "BulletCommon/b3CommandLineArgs.h"
#include <string.h>
#include <stdio.h>
@@ -86,7 +86,7 @@ char* loadProgSource(const char* cFilename, const char* cPreamble, size_t* szFin
int main(int argc, char **argv)
{
printf("Use --deviceId=<id> or --platformId=<id> to override OpenCL device\n");
CommandLineArgs args(argc,argv);
b3CommandLineArgs args(argc,argv);
const int nx = 1024;
const int ny = 1024;

View File

@@ -27,11 +27,11 @@ function createProject (vendor)
"main.cpp",
"../basic_initialize/b3OpenCLUtils.cpp",
"../basic_initialize/b3OpenCLUtils.h",
"../../src/BulletCommon/btAlignedAllocator.cpp",
"../../src/BulletCommon/btAlignedAllocator.h",
"../../src/BulletCommon/btAlignedObjectArray.h",
"../../src/BulletCommon/btQuickprof.cpp",
"../../src/BulletCommon/btQuickprof.h",
"../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../src/BulletCommon/b3AlignedAllocator.h",
"../../src/BulletCommon/b3AlignedObjectArray.h",
"../../src/BulletCommon/b3Quickprof.cpp",
"../../src/BulletCommon/b3Quickprof.h",
}
end

View File

@@ -24,11 +24,11 @@ function createProject(vendor)
"../host/btFillCL.cpp",
"../host/btPrefixScanCL.cpp",
"../host/btRadixSort32CL.cpp",
"../../../src/BulletCommon/btAlignedAllocator.cpp",
"../../../src/BulletCommon/btAlignedAllocator.h",
"../../../src/BulletCommon/btAlignedObjectArray.h",
"../../../src/BulletCommon/btQuickprof.cpp",
"../../../src/BulletCommon/btQuickprof.h",
"../../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../../src/BulletCommon/b3AlignedAllocator.h",
"../../../src/BulletCommon/b3AlignedObjectArray.h",
"../../../src/BulletCommon/b3Quickprof.cpp",
"../../../src/BulletCommon/b3Quickprof.h",
}
end

View File

@@ -66,7 +66,7 @@
#include "../host/btRadixSort32CL.h"
#include "../../basic_initialize/b3OpenCLUtils.h"
#include "BulletCommon/btQuickprof.h"
#include "BulletCommon/b3Quickprof.h"
cl_context g_cxMainContext;
cl_device_id g_device;
@@ -112,7 +112,7 @@ void TimedSort(
printf("Keys only, %d iterations, %d elements\n", iterations, num_elements);
int max_elements = num_elements;
btAlignedObjectArray<unsigned int> hostData;
b3AlignedObjectArray<unsigned int> hostData;
hostData.resize(num_elements);
for (int i=0;i<num_elements;i++)
{
@@ -126,7 +126,7 @@ void TimedSort(
//sorter.executeHost(gpuData);
sorter.execute(gpuData);
btAlignedObjectArray<unsigned int> hostDataSorted;
b3AlignedObjectArray<unsigned int> hostDataSorted;
gpuData.copyToHost(hostDataSorted);
clFinish(g_cqCommandQueue);
@@ -218,7 +218,7 @@ void TimedSort(
printf("Key-values, %d iterations, %d elements\n", iterations, num_elements);
int max_elements = num_elements;
btAlignedObjectArray<btSortData> hostData;
b3AlignedObjectArray<btSortData> hostData;
hostData.resize(num_elements);
for (int i=0;i<num_elements;i++)
{
@@ -233,7 +233,7 @@ void TimedSort(
//sorter.executeHost(gpuData);
sorter.execute(gpuData);
btAlignedObjectArray<btSortData> hostDataSorted;
b3AlignedObjectArray<btSortData> hostDataSorted;
gpuData.copyToHost(hostDataSorted);
#if 0
for (int i=0;i<num_elements;i++)
@@ -549,7 +549,7 @@ void Usage()
#include <algorithm>
#include <string>
class CommandLineArgs
class b3CommandLineArgs
{
protected:
@@ -558,7 +558,7 @@ protected:
public:
// Constructor
CommandLineArgs(int argc, char **argv)
b3CommandLineArgs(int argc, char **argv)
{
using namespace std;
@@ -603,7 +603,7 @@ public:
};
template <typename T>
void CommandLineArgs::GetCmdLineArgument(const char *arg_name, T &val)
void b3CommandLineArgs::GetCmdLineArgument(const char *arg_name, T &val)
{
using namespace std;
map<string, string>::iterator itr;
@@ -614,7 +614,7 @@ void CommandLineArgs::GetCmdLineArgument(const char *arg_name, T &val)
}
template <>
void CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, char* &val)
void b3CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, char* &val)
{
using namespace std;
map<string, string>::iterator itr;
@@ -644,7 +644,7 @@ int main( int argc, char** argv)
gDebugSkipLoadingBinary = true;
cl_int ciErrNum;
CommandLineArgs args(argc,argv);
b3CommandLineArgs args(argc,argv);
args.GetCmdLineArgument("deviceId", gPreferredDeviceId);
args.GetCmdLineArgument("platformId", gPreferredPlatformId);

View File

@@ -138,8 +138,8 @@ void btBoundSearchCL::execute(btOpenCLArray<btSortData>& src, int nSrc, btOpenCL
}
void btBoundSearchCL::executeHost( btAlignedObjectArray<btSortData>& src, int nSrc,
btAlignedObjectArray<unsigned int>& dst, int nDst, Option option )
void btBoundSearchCL::executeHost( b3AlignedObjectArray<btSortData>& src, int nSrc,
b3AlignedObjectArray<unsigned int>& dst, int nDst, Option option )
{
@@ -188,9 +188,9 @@ void btBoundSearchCL::executeHost( btAlignedObjectArray<btSortData>& src, int nS
}
else if( option == COUNT )
{
btAlignedObjectArray<unsigned int> lower;
b3AlignedObjectArray<unsigned int> lower;
lower.resize(nDst );
btAlignedObjectArray<unsigned int> upper;
b3AlignedObjectArray<unsigned int> upper;
upper.resize(nDst );
for(int i=0; i<nDst; i++)

View File

@@ -60,7 +60,7 @@ class btBoundSearchCL
// src has to be src[i].m_key <= src[i+1].m_key
void execute( btOpenCLArray<btSortData>& src, int nSrc, btOpenCLArray<unsigned int>& dst, int nDst, Option option = BOUND_LOWER );
void executeHost( btAlignedObjectArray<btSortData>& src, int nSrc, btAlignedObjectArray<unsigned int>& dst, int nDst, Option option = BOUND_LOWER);
void executeHost( b3AlignedObjectArray<btSortData>& src, int nSrc, b3AlignedObjectArray<unsigned int>& dst, int nDst, Option option = BOUND_LOWER);
};

View File

@@ -90,7 +90,7 @@ void btFillCL::execute(btOpenCLArray<unsigned int>& src, const unsigned int valu
}
}
void btFillCL::executeHost(btAlignedObjectArray<btInt2> &src, const btInt2 &value, int n, int offset)
void btFillCL::executeHost(b3AlignedObjectArray<btInt2> &src, const btInt2 &value, int n, int offset)
{
for (int i=0;i<n;i++)
{
@@ -98,7 +98,7 @@ void btFillCL::executeHost(btAlignedObjectArray<btInt2> &src, const btInt2 &valu
}
}
void btFillCL::executeHost(btAlignedObjectArray<int> &src, const int value, int n, int offset)
void btFillCL::executeHost(b3AlignedObjectArray<int> &src, const int value, int n, int offset)
{
for (int i=0;i<n;i++)
{

View File

@@ -2,7 +2,7 @@
#define BT_FILL_CL_H
#include "btOpenCLArray.h"
#include "BulletCommon/btScalar.h"
#include "BulletCommon/b3Scalar.h"
#include "btInt2.h"
#include "btInt4.h"
@@ -48,9 +48,9 @@ public:
void execute(btOpenCLArray<btInt2>& src, const btInt2& value, int n, int offset = 0);
void executeHost(btAlignedObjectArray<btInt2> &src, const btInt2 &value, int n, int offset);
void executeHost(b3AlignedObjectArray<btInt2> &src, const btInt2 &value, int n, int offset);
void executeHost(btAlignedObjectArray<int> &src, const int value, int n, int offset);
void executeHost(b3AlignedObjectArray<int> &src, const int value, int n, int offset);
// void execute(btOpenCLArray<btInt4>& src, const btInt4& value, int n, int offset = 0);

View File

@@ -1,7 +1,7 @@
#ifndef BT_INT4_H
#define BT_INT4_H
#include "BulletCommon/btScalar.h"
#include "BulletCommon/b3Scalar.h"
ATTRIBUTE_ALIGNED16(struct) btUnsignedInt4
{

View File

@@ -3,7 +3,7 @@
#define BT_LAUNCHER_CL_H
#include "btBufferInfoCL.h"
#include "BulletCommon/btMinMax.h"
#include "BulletCommon/b3MinMax.h"
#include "btOpenCLArray.h"
#include <stdio.h>
@@ -31,14 +31,14 @@ class btLauncherCL
cl_kernel m_kernel;
int m_idx;
btAlignedObjectArray<btKernelArgData> m_kernelArguments;
b3AlignedObjectArray<btKernelArgData> m_kernelArguments;
int m_serializationSizeInBytes;
public:
btAlignedObjectArray<btOpenCLArray<unsigned char>* > m_arrays;
b3AlignedObjectArray<btOpenCLArray<unsigned char>* > m_arrays;
btLauncherCL(cl_command_queue queue, cl_kernel kernel)
:m_commandQueue(queue),

View File

@@ -1,7 +1,7 @@
#ifndef BT_OPENCL_ARRAY_H
#define BT_OPENCL_ARRAY_H
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/b3AlignedObjectArray.h"
#include "../../basic_initialize/b3OpenCLInclude.h"
template <typename T>
@@ -61,7 +61,7 @@ public:
}
// we could enable this assignment, but need to make sure to avoid accidental deep copies
// btOpenCLArray<T>& operator=(const btAlignedObjectArray<T>& src)
// btOpenCLArray<T>& operator=(const b3AlignedObjectArray<T>& src)
// {
// copyFromArray(src);
// return *this;
@@ -212,7 +212,7 @@ public:
btAssert( status == CL_SUCCESS );
}
void copyFromHost(const btAlignedObjectArray<T>& srcArray, bool waitForCompletion=true)
void copyFromHost(const b3AlignedObjectArray<T>& srcArray, bool waitForCompletion=true)
{
int newSize = srcArray.size();
@@ -238,7 +238,7 @@ public:
}
void copyToHost(btAlignedObjectArray<T>& destArray, bool waitForCompletion=true) const
void copyToHost(b3AlignedObjectArray<T>& destArray, bool waitForCompletion=true) const
{
destArray.resize(this->size());
if (size())

View File

@@ -98,7 +98,7 @@ void btPrefixScanCL::execute(btOpenCLArray<unsigned int>& src, btOpenCLArray<uns
}
void btPrefixScanCL::executeHost(btAlignedObjectArray<unsigned int>& src, btAlignedObjectArray<unsigned int>& dst, int n, unsigned int* sum)
void btPrefixScanCL::executeHost(b3AlignedObjectArray<unsigned int>& src, b3AlignedObjectArray<unsigned int>& dst, int n, unsigned int* sum)
{
unsigned int s = 0;
//if( data->m_option == EXCLUSIVE )

View File

@@ -4,7 +4,7 @@
#include "btOpenCLArray.h"
#include "btBufferInfoCL.h"
#include "BulletCommon/btAlignedObjectArray.h"
#include "BulletCommon/b3AlignedObjectArray.h"
class btPrefixScanCL
{
@@ -31,7 +31,7 @@ class btPrefixScanCL
virtual ~btPrefixScanCL();
void execute(btOpenCLArray<unsigned int>& src, btOpenCLArray<unsigned int>& dst, int n, unsigned int* sum = 0);
void executeHost(btAlignedObjectArray<unsigned int>& src, btAlignedObjectArray<unsigned int>& dst, int n, unsigned int* sum);
void executeHost(b3AlignedObjectArray<unsigned int>& src, b3AlignedObjectArray<unsigned int>& dst, int n, unsigned int* sum);
};
#endif //BT_PREFIX_SCAN_CL_H

View File

@@ -93,7 +93,7 @@ btRadixSort32CL::~btRadixSort32CL()
clReleaseKernel(m_prefixScanKernel);
}
void btRadixSort32CL::executeHost(btAlignedObjectArray<btSortData>& inout, int sortBits /* = 32 */)
void btRadixSort32CL::executeHost(b3AlignedObjectArray<btSortData>& inout, int sortBits /* = 32 */)
{
int n = inout.size();
const int BITS_PER_PASS = 8;
@@ -104,7 +104,7 @@ void btRadixSort32CL::executeHost(btAlignedObjectArray<btSortData>& inout, int s
int counter[NUM_TABLES];
btSortData* src = &inout[0];
btAlignedObjectArray<btSortData> workbuffer;
b3AlignedObjectArray<btSortData> workbuffer;
workbuffer.resize(inout.size());
btSortData* dst = &workbuffer[0];
@@ -166,7 +166,7 @@ void btRadixSort32CL::executeHost(btAlignedObjectArray<btSortData>& inout, int s
void btRadixSort32CL::executeHost(btOpenCLArray<btSortData>& keyValuesInOut, int sortBits /* = 32 */)
{
btAlignedObjectArray<btSortData> inout;
b3AlignedObjectArray<btSortData> inout;
keyValuesInOut.copyToHost(inout);
executeHost(inout,sortBits);
@@ -194,7 +194,7 @@ void btRadixSort32CL::execute(btOpenCLArray<btSortData>& keyValuesInOut, int sor
int dataAlignment = DATA_ALIGNMENT;
#ifdef DEBUG_RADIXSORT2
btAlignedObjectArray<btSortData> test2;
b3AlignedObjectArray<btSortData> test2;
keyValuesInOut.copyToHost(test2);
printf("numElem = %d\n",test2.size());
for (int i=0;i<test2.size();i++)
@@ -307,7 +307,7 @@ void btRadixSort32CL::execute(btOpenCLArray<btSortData>& keyValuesInOut, int sor
#ifdef DEBUG_RADIXSORT
btAlignedObjectArray<unsigned int> testHist;
b3AlignedObjectArray<unsigned int> testHist;
srcHisto->copyToHost(testHist);
printf("ib = %d, testHist size = %d, non zero elements:\n",ib, testHist.size());
for (int i=0;i<testHist.size();i++)
@@ -379,8 +379,8 @@ void btRadixSort32CL::execute(btOpenCLArray<btSortData>& keyValuesInOut, int sor
int startBit = ib;
destHisto->copyToHost(testHist);
btAlignedObjectArray<btSortData> srcHost;
btAlignedObjectArray<btSortData> dstHost;
b3AlignedObjectArray<btSortData> srcHost;
b3AlignedObjectArray<btSortData> dstHost;
dstHost.resize(src->size());
src->copyToHost(srcHost);
@@ -405,11 +405,11 @@ void btRadixSort32CL::execute(btOpenCLArray<btSortData>& keyValuesInOut, int sor
int counter2[NUM_TABLES]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int tables[NUM_TABLES];
btAlignedObjectArray<btSortData> dstHostOK;
b3AlignedObjectArray<btSortData> dstHostOK;
dstHostOK.resize(src->size());
destHisto->copyToHost(testHist);
btAlignedObjectArray<btSortData> srcHost;
b3AlignedObjectArray<btSortData> srcHost;
src->copyToHost(srcHost);
int blockSize = 256;
@@ -435,7 +435,7 @@ void btRadixSort32CL::execute(btOpenCLArray<btSortData>& keyValuesInOut, int sor
}
btAlignedObjectArray<btSortData> dstHost;
b3AlignedObjectArray<btSortData> dstHost;
dstHost.resize(src->size());

View File

@@ -78,7 +78,7 @@ public:
void execute(btOpenCLArray<btSortData>& keyValuesInOut, int sortBits = 32 );
void executeHost(btOpenCLArray<btSortData>& keyValuesInOut, int sortBits = 32);
void executeHost(btAlignedObjectArray<btSortData>& keyValuesInOut, int sortBits = 32);
void executeHost(b3AlignedObjectArray<btSortData>& keyValuesInOut, int sortBits = 32);
};
#endif //BT_RADIXSORT32_H

View File

@@ -19,8 +19,8 @@ subject to the following restrictions:
#include "../host/btBoundSearchCL.h"
#include "../host/btRadixSort32CL.h"
#include "../host/btPrefixScanCL.h"
#include "BulletCommon/CommandLineArgs.h"
#include "BulletCommon/btMinMax.h"
#include "BulletCommon/b3CommandLineArgs.h"
#include "BulletCommon/b3MinMax.h"
int g_nPassed = 0;
int g_nFailed = 0;
@@ -89,11 +89,11 @@ inline void fillIntTest()
int offset=0;
fillCL->execute(intBuffer,value,size,offset);
btAlignedObjectArray<int> hostBuf2;
b3AlignedObjectArray<int> hostBuf2;
hostBuf2.resize(size);
fillCL->executeHost(hostBuf2,value,size,offset);
btAlignedObjectArray<int> hostBuf;
b3AlignedObjectArray<int> hostBuf;
intBuffer.copyToHost(hostBuf);
for(int i=0; i<size; i++)
@@ -146,11 +146,11 @@ void boundSearchTest( )
btOpenCLArray<unsigned int> upperCL(g_context,g_queue,maxSize);
btOpenCLArray<unsigned int> lowerCL(g_context,g_queue,maxSize);
btAlignedObjectArray<btSortData> srcHost;
btAlignedObjectArray<unsigned int> upperHost;
btAlignedObjectArray<unsigned int> lowerHost;
btAlignedObjectArray<unsigned int> upperHostCompare;
btAlignedObjectArray<unsigned int> lowerHostCompare;
b3AlignedObjectArray<btSortData> srcHost;
b3AlignedObjectArray<unsigned int> upperHost;
b3AlignedObjectArray<unsigned int> lowerHost;
b3AlignedObjectArray<unsigned int> upperHostCompare;
b3AlignedObjectArray<unsigned int> lowerHostCompare;
btBoundSearchCL* search = new btBoundSearchCL(g_context,g_device,g_queue, maxSize);
@@ -260,8 +260,8 @@ void prefixScanTest()
int maxSize = 1024*256;
btAlignedObjectArray<unsigned int> buf0Host;
btAlignedObjectArray<unsigned int> buf1Host;
b3AlignedObjectArray<unsigned int> buf0Host;
b3AlignedObjectArray<unsigned int> buf1Host;
btOpenCLArray<unsigned int> buf2CL(g_context,g_queue,maxSize);
btOpenCLArray<unsigned int> buf3CL(g_context,g_queue,maxSize);
@@ -305,9 +305,9 @@ bool radixSortTest()
int maxSize = 1024*256;
btAlignedObjectArray<btSortData> buf0Host;
b3AlignedObjectArray<btSortData> buf0Host;
buf0Host.resize(maxSize);
btAlignedObjectArray<btSortData> buf1Host;
b3AlignedObjectArray<btSortData> buf1Host;
buf1Host.resize(maxSize );
btOpenCLArray<btSortData> buf2CL(g_context,g_queue,maxSize);
@@ -356,7 +356,7 @@ int main(int argc, char** argv)
int preferredDeviceIndex = -1;
int preferredPlatformIndex = -1;
CommandLineArgs args(argc, argv);
b3CommandLineArgs args(argc, argv);
args.GetCmdLineArgument("deviceId", preferredDeviceIndex);
args.GetCmdLineArgument("platformId", preferredPlatformIndex);

View File

@@ -27,9 +27,9 @@ function createProject(vendor)
"../host/btPrefixScanCL.h",
"../host/btRadixSort32CL.cpp",
"../host/btRadixSort32CL.h",
"../../../src/BulletCommon/btAlignedAllocator.cpp",
"../../../src/BulletCommon/btAlignedAllocator.h",
"../../../src/BulletCommon/btAlignedObjectArray.h",
"../../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../../src/BulletCommon/b3AlignedAllocator.h",
"../../../src/BulletCommon/b3AlignedObjectArray.h",
}
end

View File

@@ -60,8 +60,8 @@ int main(int argc, char* argv[])
int numElements = 1024*1024;
btOpenCLArray<int> a(ctx,queue);
btOpenCLArray<int> b(ctx,queue);
btAlignedObjectArray<int> hostA;
btAlignedObjectArray<int> hostB;
b3AlignedObjectArray<int> hostA;
b3AlignedObjectArray<int> hostB;
for (int i=0;i<numElements;i++)
{

View File

@@ -27,9 +27,9 @@ function createProject (vendor)
"main.cpp",
"../basic_initialize/b3OpenCLUtils.cpp",
"../basic_initialize/b3OpenCLUtils.h",
"../../src/BulletCommon/btAlignedAllocator.cpp",
"../../src/BulletCommon/btAlignedAllocator.h",
"../../src/BulletCommon/btAlignedObjectArray.h",
"../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../src/BulletCommon/b3AlignedAllocator.h",
"../../src/BulletCommon/b3AlignedObjectArray.h",
}
end

View File

@@ -27,9 +27,9 @@ function createProject (vendor)
"main.cpp",
"../basic_initialize/b3OpenCLUtils.cpp",
"../basic_initialize/b3OpenCLUtils.h",
"../../src/BulletCommon/btAlignedAllocator.cpp",
"../../src/BulletCommon/btAlignedAllocator.h",
"../../src/BulletCommon/btAlignedObjectArray.h",
"../../src/BulletCommon/b3AlignedAllocator.cpp",
"../../src/BulletCommon/b3AlignedAllocator.h",
"../../src/BulletCommon/b3AlignedObjectArray.h",
}
end