Ported Minkowski Portal Refinement mpr.c from libccd to OpenCL, for bettwe edge-edge performance (and additional contact point for degenerate/high detailed convex shapes)
Removed b3RigidBodyCL, replace by b3RigidBodyData and b3RigidBodyData_t shared between C++ host and OpenCL, Same for b3InertiaCL -> b3InertiaData
This commit is contained in:
@@ -597,7 +597,7 @@ cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
|
||||
if (disableBinaryCaching)
|
||||
{
|
||||
kernelSourceOrg = 0;
|
||||
//kernelSourceOrg = 0;
|
||||
}
|
||||
|
||||
cl_program m_cpProgram=0;
|
||||
|
||||
@@ -16,6 +16,7 @@ subject to the following restrictions:
|
||||
bool findSeparatingAxisOnGpu = true;
|
||||
bool splitSearchSepAxisConcave = false;
|
||||
bool splitSearchSepAxisConvex = true;
|
||||
bool useMprGpu = false;//use mpr for edge-edge (+contact point) or sat. Needs testing on main OpenCL platforms, before enabling...
|
||||
bool bvhTraversalKernelGPU = true;
|
||||
bool findConcaveSeparatingAxisKernelGPU = true;
|
||||
bool clipConcaveFacesAndFindContactsCPU = false;//false;//true;
|
||||
@@ -23,6 +24,11 @@ bool clipConvexFacesAndFindContactsCPU = false;//false;//true;
|
||||
bool reduceConcaveContactsOnGPU = true;//false;
|
||||
bool reduceConvexContactsOnGPU = true;//false;
|
||||
bool findConvexClippingFacesGPU = true;
|
||||
bool useGjk = true;///option for CPU/host testing, when findSeparatingAxisOnGpu = false
|
||||
bool useGjkContacts = true;//////option for CPU/host testing when findSeparatingAxisOnGpu = false
|
||||
|
||||
|
||||
static int myframecount=0;///for testing
|
||||
|
||||
///This file was written by Erwin Coumans
|
||||
///Separating axis rest based on work from Pierre Terdiman, see
|
||||
@@ -40,7 +46,9 @@ int b3g_actualSATPairTests=0;
|
||||
|
||||
#include "b3ConvexHullContact.h"
|
||||
#include <string.h>//memcpy
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h"
|
||||
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ContactCache.h"
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
|
||||
@@ -53,6 +61,8 @@ typedef b3AlignedObjectArray<b3Vector3> b3VertexArray;
|
||||
//#include "AdlQuaternion.h"
|
||||
|
||||
#include "kernels/satKernels.h"
|
||||
#include "kernels/mprKernels.h"
|
||||
|
||||
#include "kernels/satConcaveKernels.h"
|
||||
|
||||
#include "kernels/satClipHullContacts.h"
|
||||
@@ -65,6 +75,7 @@ typedef b3AlignedObjectArray<b3Vector3> b3VertexArray;
|
||||
#define BT_NARROWPHASE_SAT_PATH "src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl"
|
||||
#define BT_NARROWPHASE_SAT_CONCAVE_PATH "src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl"
|
||||
|
||||
#define BT_NARROWPHASE_MPR_PATH "src/Bullet3OpenCL/NarrowphaseCollision/kernels/mpr.cl"
|
||||
|
||||
|
||||
#define BT_NARROWPHASE_CLIPHULL_PATH "src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.cl"
|
||||
@@ -115,12 +126,25 @@ m_dmins(m_context,m_queue)
|
||||
|
||||
if (1)
|
||||
{
|
||||
const char* mprSrc = mprKernelsCL;
|
||||
const char* src = satKernelsCL;
|
||||
const char* srcConcave = satConcaveKernelsCL;
|
||||
char flags[1024]={0};
|
||||
//#ifdef CL_PLATFORM_INTEL
|
||||
// sprintf(flags,"-g -s \"%s\"","C:/develop/bullet3_experiments2/opencl/gpu_narrowphase/kernels/sat.cl");
|
||||
//#endif
|
||||
m_mprPenetrationKernel = 0;
|
||||
|
||||
if (useMprGpu)
|
||||
{
|
||||
cl_program mprProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,mprSrc,&errNum,flags,BT_NARROWPHASE_MPR_PATH);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_mprPenetrationKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,mprSrc, "mprPenetrationKernel",&errNum,mprProg );
|
||||
b3Assert(m_mprPenetrationKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
cl_program satProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,src,&errNum,flags,BT_NARROWPHASE_SAT_PATH);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
@@ -251,6 +275,9 @@ GpuSatCollision::~GpuSatCollision()
|
||||
clReleaseKernel(m_findSeparatingAxisEdgeEdgeKernel);
|
||||
|
||||
|
||||
if (m_mprPenetrationKernel)
|
||||
clReleaseKernel(m_mprPenetrationKernel);
|
||||
|
||||
if (m_findSeparatingAxisKernel)
|
||||
clReleaseKernel(m_findSeparatingAxisKernel);
|
||||
|
||||
@@ -1158,12 +1185,12 @@ int clipHullHullSingle(
|
||||
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
|
||||
const b3AlignedObjectArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3AlignedObjectArray<b3RigidBodyData>* bodyBuf,
|
||||
b3AlignedObjectArray<b3Contact4>* globalContactOut,
|
||||
int& nContacts,
|
||||
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronCL>& hostConvexDataA,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronCL>& hostConvexDataB,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronData>& hostConvexDataA,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronData>& hostConvexDataB,
|
||||
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& uniqueEdgesA,
|
||||
@@ -1181,7 +1208,7 @@ int clipHullHullSingle(
|
||||
int maxContactCapacity )
|
||||
{
|
||||
int contactIndex = -1;
|
||||
b3ConvexPolyhedronCL hullA, hullB;
|
||||
b3ConvexPolyhedronData hullA, hullB;
|
||||
|
||||
b3Collidable colA = hostCollidablesA[collidableIndexA];
|
||||
hullA = hostConvexDataA[colA.m_shapeIndex];
|
||||
@@ -1303,9 +1330,9 @@ int clipHullHullSingle(
|
||||
void computeContactPlaneConvex(int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3RigidBodyCL* rigidBodies,
|
||||
const b3RigidBodyData* rigidBodies,
|
||||
const b3Collidable* collidables,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3ConvexPolyhedronData* convexShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
const b3GpuFace* faces,
|
||||
@@ -1315,7 +1342,7 @@ void computeContactPlaneConvex(int pairIndex,
|
||||
{
|
||||
|
||||
int shapeIndex = collidables[collidableIndexB].m_shapeIndex;
|
||||
const b3ConvexPolyhedronCL* hullB = &convexShapes[shapeIndex];
|
||||
const b3ConvexPolyhedronData* hullB = &convexShapes[shapeIndex];
|
||||
|
||||
b3Vector3 posB = rigidBodies[bodyIndexB].m_pos;
|
||||
b3Quaternion ornB = rigidBodies[bodyIndexB].m_quat;
|
||||
@@ -2085,7 +2112,7 @@ __kernel void clipCompoundsHullHullKernel( __global const b3Int4* gpuCompoundP
|
||||
void computeContactCompoundCompound(int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3RigidBodyCL* rigidBodies,
|
||||
const b3RigidBodyData* rigidBodies,
|
||||
const b3Collidable* collidables,
|
||||
const b3ConvexPolyhedronData* convexShapes,
|
||||
const b3GpuChildShape* cpuChildShapes,
|
||||
@@ -2238,7 +2265,7 @@ void computeContactCompoundCompound(int pairIndex,
|
||||
|
||||
int shapeIndexB = collidables[childColIndexB].m_shapeIndex;
|
||||
|
||||
const b3ConvexPolyhedronCL* hullB = &convexShapes[shapeIndexB];
|
||||
const b3ConvexPolyhedronData* hullB = &convexShapes[shapeIndexB];
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -2248,9 +2275,9 @@ void computeContactCompoundCompound(int pairIndex,
|
||||
void computeContactPlaneCompound(int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3RigidBodyCL* rigidBodies,
|
||||
const b3RigidBodyData* rigidBodies,
|
||||
const b3Collidable* collidables,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3ConvexPolyhedronData* convexShapes,
|
||||
const b3GpuChildShape* cpuChildShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
@@ -2280,7 +2307,7 @@ void computeContactPlaneCompound(int pairIndex,
|
||||
|
||||
int shapeIndexB = collidables[childColIndexB].m_shapeIndex;
|
||||
|
||||
const b3ConvexPolyhedronCL* hullB = &convexShapes[shapeIndexB];
|
||||
const b3ConvexPolyhedronData* hullB = &convexShapes[shapeIndexB];
|
||||
|
||||
|
||||
b3Vector3 posA = rigidBodies[bodyIndexA].m_pos;
|
||||
@@ -2401,9 +2428,9 @@ void computeContactPlaneCompound(int pairIndex,
|
||||
void computeContactSphereConvex(int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3RigidBodyCL* rigidBodies,
|
||||
const b3RigidBodyData* rigidBodies,
|
||||
const b3Collidable* collidables,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3ConvexPolyhedronData* convexShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
const b3GpuFace* faces,
|
||||
@@ -2562,9 +2589,9 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3AlignedObjectArray<b3RigidBodyCL>& rigidBodies,
|
||||
const b3AlignedObjectArray<b3RigidBodyData>& rigidBodies,
|
||||
const b3AlignedObjectArray<b3Collidable>& collidables,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronCL>& convexShapes,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronData>& convexShapes,
|
||||
const b3AlignedObjectArray<b3Vector3>& convexVertices,
|
||||
const b3AlignedObjectArray<b3Vector3>& uniqueEdges,
|
||||
const b3AlignedObjectArray<int>& convexIndices,
|
||||
@@ -2572,7 +2599,11 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
b3AlignedObjectArray<b3Contact4>& globalContactsOut,
|
||||
int& nGlobalContactsOut,
|
||||
int maxContactCapacity,
|
||||
const b3AlignedObjectArray<b3Contact4>& oldContacts
|
||||
b3AlignedObjectArray<int>&hostHasSepAxis,
|
||||
b3AlignedObjectArray<b3Vector3>&hostSepAxis
|
||||
|
||||
|
||||
//,const b3AlignedObjectArray<b3Contact4>& oldContacts
|
||||
)
|
||||
{
|
||||
int contactIndex = -1;
|
||||
@@ -2629,10 +2660,10 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
//printf("add existing points?\n");
|
||||
//refresh
|
||||
|
||||
int numOldPoints = oldContacts[pairs[pairIndex].z].getNPoints();
|
||||
int numOldPoints = 0;//oldContacts[pairs[pairIndex].z].getNPoints();
|
||||
if (numOldPoints)
|
||||
{
|
||||
newContact = oldContacts[pairs[pairIndex].z];
|
||||
//newContact = oldContacts[pairs[pairIndex].z];
|
||||
#ifdef PERSISTENT_CONTACTS_HOST
|
||||
b3ContactCache::refreshContactPoints(transA,transB,newContact);
|
||||
#endif //PERSISTENT_CONTACTS_HOST
|
||||
@@ -2670,7 +2701,12 @@ int computeContactConvexConvex( b3AlignedObjectArray<b3Int4>& pairs,
|
||||
newContact.m_localPosA[p] = transA.inverse()*resultPointOnAWorld;
|
||||
newContact.m_localPosB[p] = transB.inverse()*resultPointOnBWorld;
|
||||
#endif
|
||||
newContact.m_worldNormalOnB = sepAxis2;
|
||||
newContact.m_worldNormalOnB = sepAxis2;
|
||||
|
||||
|
||||
hostHasSepAxis[pairIndex] = 1;
|
||||
hostSepAxis[pairIndex] =sepAxis2;
|
||||
//printf("sepAxis[%d]=%f,%f,%f,%f\n",pairIndex,sepAxis2.x,sepAxis2.y,sepAxis2.z,sepAxis2.w);
|
||||
}
|
||||
//printf("bodyIndexA %d,bodyIndexB %d,normal=%f,%f,%f numPoints %d\n",bodyIndexA,bodyIndexB,normalOnSurfaceB.x,normalOnSurfaceB.y,normalOnSurfaceB.z,numPoints);
|
||||
newContact.m_worldNormalOnB.w = (b3Scalar)numPoints;
|
||||
@@ -2690,9 +2726,9 @@ int computeContactConvexConvex2(
|
||||
int pairIndex,
|
||||
int bodyIndexA, int bodyIndexB,
|
||||
int collidableIndexA, int collidableIndexB,
|
||||
const b3AlignedObjectArray<b3RigidBodyCL>& rigidBodies,
|
||||
const b3AlignedObjectArray<b3RigidBodyData>& rigidBodies,
|
||||
const b3AlignedObjectArray<b3Collidable>& collidables,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronCL>& convexShapes,
|
||||
const b3AlignedObjectArray<b3ConvexPolyhedronData>& convexShapes,
|
||||
const b3AlignedObjectArray<b3Vector3>& convexVertices,
|
||||
const b3AlignedObjectArray<b3Vector3>& uniqueEdges,
|
||||
const b3AlignedObjectArray<int>& convexIndices,
|
||||
@@ -2710,7 +2746,7 @@ int computeContactConvexConvex2(
|
||||
b3Quaternion ornB = rigidBodies[bodyIndexB].m_quat;
|
||||
|
||||
|
||||
b3ConvexPolyhedronCL hullA, hullB;
|
||||
b3ConvexPolyhedronData hullA, hullB;
|
||||
|
||||
b3Vector3 sepNormalWorldSpace;
|
||||
|
||||
@@ -2787,15 +2823,17 @@ int computeContactConvexConvex2(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>* pairs, int nPairs,
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
const b3OpenCLArray<b3Contact4>* oldContacts,
|
||||
int maxContactCapacity,
|
||||
int compoundPairCapacity,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronCL>& convexData,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronData>& convexData,
|
||||
const b3OpenCLArray<b3Vector3>& gpuVertices,
|
||||
const b3OpenCLArray<b3Vector3>& gpuUniqueEdges,
|
||||
const b3OpenCLArray<b3GpuFace>& gpuFaces,
|
||||
@@ -2822,6 +2860,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
int& numTriConvexPairsOut
|
||||
)
|
||||
{
|
||||
myframecount++;
|
||||
|
||||
if (!nPairs)
|
||||
return;
|
||||
|
||||
@@ -2846,12 +2886,12 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> hostConvexData;
|
||||
convexData.copyToHost(hostConvexData);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostVertices;
|
||||
@@ -2962,8 +3002,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
hostCollidables[collidableIndexB].m_shapeType == SHAPE_CONVEX_HULL)
|
||||
{
|
||||
//printf("hostPairs[i].z=%d\n",hostPairs[i].z);
|
||||
int contactIndex = computeContactConvexConvex2(i,bodyIndexA,bodyIndexB,collidableIndexA,collidableIndexB,hostBodyBuf, hostCollidables,hostConvexData,hostVertices,hostUniqueEdges,hostIndices,hostFaces,hostContacts,nContacts,maxContactCapacity,oldHostContacts);
|
||||
//int contactIndex = computeContactConvexConvex(hostPairs,i,bodyIndexA,bodyIndexB,collidableIndexA,collidableIndexB,hostBodyBuf,hostCollidables,hostConvexData,hostVertices,hostUniqueEdges,hostIndices,hostFaces,hostContacts,nContacts,maxContactCapacity,oldHostContacts);
|
||||
//int contactIndex = computeContactConvexConvex2(i,bodyIndexA,bodyIndexB,collidableIndexA,collidableIndexB,hostBodyBuf, hostCollidables,hostConvexData,hostVertices,hostUniqueEdges,hostIndices,hostFaces,hostContacts,nContacts,maxContactCapacity,oldHostContacts);
|
||||
int contactIndex = computeContactConvexConvex(hostPairs,i,bodyIndexA,bodyIndexB,collidableIndexA,collidableIndexB,hostBodyBuf,hostCollidables,hostConvexData,hostVertices,hostUniqueEdges,hostIndices,hostFaces,hostContacts,nContacts,maxContactCapacity,oldHostContacts);
|
||||
|
||||
|
||||
if (contactIndex>=0)
|
||||
@@ -3068,56 +3108,109 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
m_dmins.resize(nPairs);
|
||||
if (splitSearchSepAxisConvex)
|
||||
{
|
||||
|
||||
{
|
||||
B3_PROFILE("findSeparatingAxisVertexFaceKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWorldSpace.getBufferCL(),true),
|
||||
b3BufferInfoCL( m_sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_dmins.getBufferCL())
|
||||
};
|
||||
B3_PROFILE("findSeparatingAxisVertexFaceKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWorldSpace.getBufferCL(),true),
|
||||
b3BufferInfoCL( m_sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_dmins.getBufferCL())
|
||||
};
|
||||
|
||||
b3LauncherCL launcher(m_queue, m_findSeparatingAxisVertexFaceKernel,"findSeparatingAxisVertexFaceKernel");
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
b3LauncherCL launcher(m_queue, m_findSeparatingAxisVertexFaceKernel,"findSeparatingAxisVertexFaceKernel");
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (useMprGpu)
|
||||
{
|
||||
B3_PROFILE("findSeparatingAxisEdgeEdgeKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWorldSpace.getBufferCL(),true),
|
||||
b3BufferInfoCL( m_sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_dmins.getBufferCL())
|
||||
};
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
{
|
||||
B3_PROFILE("mprPenetrationKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( m_sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
b3LauncherCL launcher(m_queue, m_findSeparatingAxisEdgeEdgeKernel,"findSeparatingAxisEdgeEdgeKernel");
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
b3LauncherCL launcher(m_queue, m_mprPenetrationKernel,"mprPenetrationKernel");
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
|
||||
launcher.setConst(maxContactCapacity);
|
||||
launcher.setConst( nPairs );
|
||||
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
/*
|
||||
b3AlignedObjectArray<int>hostHasSepAxis;
|
||||
m_hasSeparatingNormals.copyToHost(hostHasSepAxis);
|
||||
b3AlignedObjectArray<b3Vector3>hostSepAxis;
|
||||
m_sepNormals.copyToHost(hostSepAxis);
|
||||
*/
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
contactOut->resize(nContacts);
|
||||
//printf("nContacts (after processCompoundPairsPrimitivesKernel) = %d\n",nContacts);
|
||||
if (nContacts>maxContactCapacity)
|
||||
{
|
||||
|
||||
b3Error("Error: contacts exceeds capacity (%d/%d)\n", nContacts, maxContactCapacity);
|
||||
nContacts = maxContactCapacity;
|
||||
}
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
||||
{
|
||||
B3_PROFILE("findSeparatingAxisEdgeEdgeKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWorldSpace.getBufferCL(),true),
|
||||
b3BufferInfoCL( m_sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( m_dmins.getBufferCL())
|
||||
};
|
||||
|
||||
b3LauncherCL launcher(m_queue, m_findSeparatingAxisEdgeEdgeKernel,"findSeparatingAxisEdgeEdgeKernel");
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
@@ -3150,11 +3243,12 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
else
|
||||
{
|
||||
|
||||
B3_PROFILE("findSeparatingAxisKernel CPU");
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
|
||||
b3AlignedObjectArray<b3Collidable> hostCollidables;
|
||||
@@ -3163,7 +3257,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3GpuChildShape> cpuChildShapes;
|
||||
gpuChildShapes.copyToHost(cpuChildShapes);
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexShapeData;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> hostConvexShapeData;
|
||||
convexData.copyToHost(hostConvexShapeData);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostVertices;
|
||||
@@ -3181,6 +3275,15 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
b3AlignedObjectArray<int> hostIndices;
|
||||
gpuIndices.copyToHost(hostIndices);
|
||||
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
if (nContacts)
|
||||
{
|
||||
contactOut->copyToHost(hostContacts);
|
||||
}
|
||||
hostContacts.resize(maxContactCapacity);
|
||||
int nGlobalContactsOut = nContacts;
|
||||
|
||||
|
||||
for (int i=0;i<nPairs;i++)
|
||||
{
|
||||
@@ -3215,41 +3318,237 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3Vector3 posB = hostBodyBuf[bodyIndexB].m_pos;
|
||||
b3Quaternion ornA =hostBodyBuf[bodyIndexA].m_quat;
|
||||
b3Quaternion ornB =hostBodyBuf[bodyIndexB].m_quat;
|
||||
|
||||
|
||||
if (useGjk)
|
||||
{
|
||||
|
||||
//first approximate the separating axis, to 'fail-proof' GJK+EPA or MPR
|
||||
{
|
||||
b3Vector3 c0local = hostConvexShapeData[shapeIndexA].m_localCenter;
|
||||
b3Vector3 c0 = b3TransformPoint(c0local, posA, ornA);
|
||||
b3Vector3 c1local = hostConvexShapeData[shapeIndexB].m_localCenter;
|
||||
b3Vector3 c1 = b3TransformPoint(c1local,posB,ornB);
|
||||
b3Vector3 DeltaC2 = c0 - c1;
|
||||
|
||||
b3Vector3 c0local = hostConvexShapeData[shapeIndexA].m_localCenter;
|
||||
b3Vector3 c0 = b3TransformPoint(c0local, posA, ornA);
|
||||
b3Vector3 c1local = hostConvexShapeData[shapeIndexB].m_localCenter;
|
||||
b3Vector3 c1 = b3TransformPoint(c1local,posB,ornB);
|
||||
b3Vector3 DeltaC2 = c0 - c1;
|
||||
b3Vector3 sepAxis;
|
||||
|
||||
b3Vector3 sepAxis;
|
||||
bool hasSepAxisA = b3FindSeparatingAxis(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
|
||||
bool hasSepAxisA = b3FindSeparatingAxis(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
if (hasSepAxisA)
|
||||
{
|
||||
bool hasSepAxisB = b3FindSeparatingAxis(convexShapeB, convexShapeA, posB, ornB, posA, ornA, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
if (hasSepAxisB)
|
||||
{
|
||||
bool hasEdgeEdge =b3FindSeparatingAxisEdgeEdge(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin,false);
|
||||
|
||||
if (hasEdgeEdge)
|
||||
{
|
||||
hostHasSepAxis[i] = 1;
|
||||
hostSepAxis[i] = sepAxis;
|
||||
hostSepAxis[i].w = dmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hostHasSepAxis[i])
|
||||
{
|
||||
int pairIndex = i;
|
||||
|
||||
bool useMpr = true;
|
||||
if (useMpr)
|
||||
{
|
||||
int res=0;
|
||||
float depth = 0.f;
|
||||
b3Vector3 sepAxis2 = b3MakeVector3(1,0,0);
|
||||
b3Vector3 resultPointOnBWorld = b3MakeVector3(0,0,0);
|
||||
|
||||
float depthOut;
|
||||
b3Vector3 dirOut;
|
||||
b3Vector3 posOut;
|
||||
|
||||
|
||||
//res = b3MprPenetration(bodyIndexA,bodyIndexB,hostBodyBuf,hostConvexShapeData,hostCollidables,hostVertices,&mprConfig,&depthOut,&dirOut,&posOut);
|
||||
res = b3MprPenetration(pairIndex,bodyIndexA,bodyIndexB,&hostBodyBuf[0],&hostConvexShapeData[0],&hostCollidables[0],&hostVertices[0],&hostSepAxis[0],&hostHasSepAxis[0],&depthOut,&dirOut,&posOut);
|
||||
depth = depthOut;
|
||||
sepAxis2 = b3MakeVector3(-dirOut.x,-dirOut.y,-dirOut.z);
|
||||
resultPointOnBWorld = posOut;
|
||||
//hostHasSepAxis[i] = 0;
|
||||
|
||||
|
||||
if (res==0)
|
||||
{
|
||||
//add point?
|
||||
//printf("depth = %f\n",depth);
|
||||
//printf("normal = %f,%f,%f\n",dir.v[0],dir.v[1],dir.v[2]);
|
||||
//qprintf("pos = %f,%f,%f\n",pos.v[0],pos.v[1],pos.v[2]);
|
||||
|
||||
|
||||
|
||||
float dist=0.f;
|
||||
|
||||
const b3ConvexPolyhedronData& hullA = hostConvexShapeData[hostCollidables[hostBodyBuf[bodyIndexA].m_collidableIdx].m_shapeIndex];
|
||||
const b3ConvexPolyhedronData& hullB = hostConvexShapeData[hostCollidables[hostBodyBuf[bodyIndexB].m_collidableIdx].m_shapeIndex];
|
||||
|
||||
if(b3TestSepAxis( &hullA, &hullB, posA,ornA,posB,ornB,&sepAxis2, &hostVertices[0], &hostVertices[0],&dist))
|
||||
{
|
||||
if (depth > dist)
|
||||
{
|
||||
float diff = depth - dist;
|
||||
|
||||
static float maxdiff = 0.f;
|
||||
if (maxdiff < diff)
|
||||
{
|
||||
maxdiff = diff;
|
||||
printf("maxdiff = %20.10f\n",maxdiff);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (depth > dmin)
|
||||
{
|
||||
b3Vector3 oldAxis = hostSepAxis[i];
|
||||
depth = dmin;
|
||||
sepAxis2 = oldAxis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(b3TestSepAxis( &hullA, &hullB, posA,ornA,posB,ornB,&sepAxis2, &hostVertices[0], &hostVertices[0],&dist))
|
||||
{
|
||||
if (depth > dist)
|
||||
{
|
||||
float diff = depth - dist;
|
||||
//printf("?diff = %f\n",diff );
|
||||
static float maxdiff = 0.f;
|
||||
if (maxdiff < diff)
|
||||
{
|
||||
maxdiff = diff;
|
||||
printf("maxdiff = %20.10f\n",maxdiff);
|
||||
}
|
||||
}
|
||||
//this is used for SAT
|
||||
//hostHasSepAxis[i] = 1;
|
||||
//hostSepAxis[i] = sepAxis2;
|
||||
|
||||
//add contact point
|
||||
|
||||
int contactIndex = nGlobalContactsOut;
|
||||
b3Contact4& newContact = hostContacts.at(nGlobalContactsOut);
|
||||
nGlobalContactsOut++;
|
||||
newContact.m_batchIdx = 0;//i;
|
||||
newContact.m_bodyAPtrAndSignBit = (hostBodyBuf.at(bodyIndexA).m_invMass==0)? -bodyIndexA:bodyIndexA;
|
||||
newContact.m_bodyBPtrAndSignBit = (hostBodyBuf.at(bodyIndexB).m_invMass==0)? -bodyIndexB:bodyIndexB;
|
||||
|
||||
newContact.m_frictionCoeffCmp = 45874;
|
||||
newContact.m_restituitionCoeffCmp = 0;
|
||||
|
||||
|
||||
static float maxDepth = 0.f;
|
||||
|
||||
if (depth > maxDepth)
|
||||
{
|
||||
maxDepth = depth;
|
||||
printf("MPR maxdepth = %f\n",maxDepth );
|
||||
|
||||
}
|
||||
|
||||
|
||||
resultPointOnBWorld.w = -depth;
|
||||
newContact.m_worldPosB[0] = resultPointOnBWorld;
|
||||
b3Vector3 resultPointOnAWorld = resultPointOnBWorld+depth*sepAxis2;
|
||||
newContact.m_worldNormalOnB = sepAxis2;
|
||||
newContact.m_worldNormalOnB.w = (b3Scalar)1;
|
||||
} else
|
||||
{
|
||||
printf("rejected\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
int result = computeContactConvexConvex( hostPairs,
|
||||
pairIndex,
|
||||
bodyIndexA, bodyIndexB,
|
||||
collidableIndexA, collidableIndexB,
|
||||
hostBodyBuf,
|
||||
hostCollidables,
|
||||
hostConvexShapeData,
|
||||
hostVertices,
|
||||
hostUniqueEdges,
|
||||
hostIndices,
|
||||
hostFaces,
|
||||
hostContacts,
|
||||
nGlobalContactsOut,
|
||||
maxContactCapacity,
|
||||
hostHasSepAxis,
|
||||
hostSepAxis
|
||||
|
||||
);
|
||||
}//mpr
|
||||
}//hostHasSepAxis[i] = 1;
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
b3Vector3 c0local = hostConvexShapeData[shapeIndexA].m_localCenter;
|
||||
b3Vector3 c0 = b3TransformPoint(c0local, posA, ornA);
|
||||
b3Vector3 c1local = hostConvexShapeData[shapeIndexB].m_localCenter;
|
||||
b3Vector3 c1 = b3TransformPoint(c1local,posB,ornB);
|
||||
b3Vector3 DeltaC2 = c0 - c1;
|
||||
|
||||
if (hasSepAxisA)
|
||||
{
|
||||
bool hasSepAxisB = b3FindSeparatingAxis(convexShapeB, convexShapeA, posB, ornB, posA, ornA, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
if (hasSepAxisB)
|
||||
{
|
||||
bool hasEdgeEdge = b3FindSeparatingAxisEdgeEdge(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
if (hasEdgeEdge)
|
||||
{
|
||||
hostHasSepAxis[i] = 1;
|
||||
hostSepAxis[i] = sepAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
b3Vector3 sepAxis;
|
||||
|
||||
bool hasSepAxisA = b3FindSeparatingAxis(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
|
||||
if (hasSepAxisA)
|
||||
{
|
||||
bool hasSepAxisB = b3FindSeparatingAxis(convexShapeB, convexShapeA, posB, ornB, posA, ornA, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin);
|
||||
if (hasSepAxisB)
|
||||
{
|
||||
bool hasEdgeEdge =b3FindSeparatingAxisEdgeEdge(convexShapeA, convexShapeB, posA, ornA, posB, ornB, DeltaC2,
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&hostVertices.at(0), &hostUniqueEdges.at(0), &hostFaces.at(0), &hostIndices.at(0),
|
||||
&sepAxis, &dmin,true);
|
||||
|
||||
if (hasEdgeEdge)
|
||||
{
|
||||
hostHasSepAxis[i] = 1;
|
||||
hostSepAxis[i] = sepAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useGjkContacts)//nGlobalContactsOut>0)
|
||||
{
|
||||
//printf("nGlobalContactsOut=%d\n",nGlobalContactsOut);
|
||||
nContacts = nGlobalContactsOut;
|
||||
contactOut->copyFromHost(hostContacts);
|
||||
|
||||
m_totalContactsOut.copyFromHostPointer(&nContacts,1,0,true);
|
||||
}
|
||||
|
||||
m_hasSeparatingNormals.copyFromHost(hostHasSepAxis);
|
||||
m_sepNormals.copyFromHost(hostSepAxis);
|
||||
@@ -3337,7 +3636,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
|
||||
|
||||
@@ -3350,7 +3649,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3GpuChildShape> cpuChildShapes;
|
||||
gpuChildShapes.copyToHost(cpuChildShapes);
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> hostConvexData;
|
||||
convexData.copyToHost(hostConvexData);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostVertices;
|
||||
@@ -3537,7 +3836,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
{
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
b3AlignedObjectArray<b3Collidable> hostCollidables;
|
||||
gpuCollidables.copyToHost(hostCollidables);
|
||||
@@ -3750,14 +4049,14 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
b3AlignedObjectArray<b3Int4> triangleConvexPairsOutHost;
|
||||
triangleConvexPairsOut.copyToHost(triangleConvexPairsOutHost);
|
||||
//triangleConvexPairsOutHost.resize(maxTriConvexPairCapacity);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
b3AlignedObjectArray<b3Collidable> hostCollidables;
|
||||
gpuCollidables.copyToHost(hostCollidables);
|
||||
b3AlignedObjectArray<b3Aabb> hostAabbsWorldSpace;
|
||||
clAabbsWorldSpace.copyToHost(hostAabbsWorldSpace);
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> hostConvexData;
|
||||
convexData.copyToHost(hostConvexData);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostVertices;
|
||||
@@ -3887,7 +4186,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
//B3_PROFILE("clipHullHullKernel");
|
||||
|
||||
bool breakupConcaveConvexKernel = false;
|
||||
bool breakupConcaveConvexKernel = true;
|
||||
|
||||
#ifdef __APPLE__
|
||||
//actually, some Apple OpenCL platform/device combinations work fine...
|
||||
@@ -4025,7 +4324,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
volatile int nGlobalContactsOut = nContacts;
|
||||
b3AlignedObjectArray<b3Int4> triangleConvexPairsOutHost;
|
||||
triangleConvexPairsOut.copyToHost(triangleConvexPairsOutHost);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
|
||||
b3AlignedObjectArray<int>concaveHasSeparatingNormalsCPU;
|
||||
@@ -4123,7 +4422,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
//convex-convex contact clipping
|
||||
B3_PROFILE("clipHullHullKernel");
|
||||
bool breakupKernel = false;
|
||||
bool breakupKernel = true;
|
||||
|
||||
#ifdef __APPLE__
|
||||
breakupKernel = true;
|
||||
@@ -4182,7 +4481,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
float minDist = -1e30f;
|
||||
float maxDist = 0.02f;
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> hostConvexData;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> hostConvexData;
|
||||
convexData.copyToHost(hostConvexData);
|
||||
b3AlignedObjectArray<b3Collidable> hostCollidables;
|
||||
gpuCollidables.copyToHost(hostCollidables);
|
||||
@@ -4194,7 +4493,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
|
||||
|
||||
@@ -4267,6 +4566,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
if (clipConvexFacesAndFindContactsCPU)
|
||||
{
|
||||
|
||||
//b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
//pairs->copyToHost(hostPairs);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostSepNormals;
|
||||
m_sepNormals.copyToHost(hostSepNormals);
|
||||
b3AlignedObjectArray<int> hostHasSepAxis;
|
||||
@@ -4343,8 +4645,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
}
|
||||
|
||||
{
|
||||
// nContacts = m_totalContactsOut.at(0);
|
||||
// printf("nContacts = %d\n",nContacts);
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
//printf("nContacts = %d\n",nContacts);
|
||||
|
||||
int newContactCapacity = nContacts+nPairs;
|
||||
contactOut->reserve(newContactCapacity);
|
||||
@@ -4382,7 +4684,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
|
||||
volatile int nGlobalContactsOut = nContacts;
|
||||
b3AlignedObjectArray<b3Int4> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodyBuf;
|
||||
bodyBuf->copyToHost(hostBodyBuf);
|
||||
b3AlignedObjectArray<b3Vector3> hostSepNormals;
|
||||
m_sepNormals.copyToHost(hostSepNormals);
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#define _CONVEX_HULL_CONTACT_H
|
||||
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "Bullet3Common/shared/b3Int2.h"
|
||||
@@ -26,6 +26,7 @@ struct GpuSatCollision
|
||||
cl_device_id m_device;
|
||||
cl_command_queue m_queue;
|
||||
cl_kernel m_findSeparatingAxisKernel;
|
||||
cl_kernel m_mprPenetrationKernel;
|
||||
|
||||
cl_kernel m_findSeparatingAxisVertexFaceKernel;
|
||||
cl_kernel m_findSeparatingAxisEdgeEdgeKernel;
|
||||
@@ -77,12 +78,12 @@ struct GpuSatCollision
|
||||
|
||||
|
||||
void computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>* pairs, int nPairs,
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
const b3OpenCLArray<b3Contact4>* oldContacts,
|
||||
int maxContactCapacity,
|
||||
int compoundPairCapacity,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronData>& hostConvexData,
|
||||
const b3OpenCLArray<b3Vector3>& vertices,
|
||||
const b3OpenCLArray<b3Vector3>& uniqueEdges,
|
||||
const b3OpenCLArray<b3GpuFace>& faces,
|
||||
|
||||
@@ -6,39 +6,4 @@
|
||||
|
||||
|
||||
|
||||
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL : public b3ConvexPolyhedronData
|
||||
{
|
||||
|
||||
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 b3Vector3 localDir = trans.getBasis().transpose()*dir;
|
||||
const b3Vector3 localDi2 = b3QuatRotate(trans.getRotation().inverse(),dir);
|
||||
|
||||
b3Scalar offset = trans.getOrigin().dot(dir);
|
||||
|
||||
for(int i=0;i<numVerts;i++)
|
||||
{
|
||||
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
|
||||
//b3Scalar dp = pt.dot(dir);
|
||||
b3Scalar dp = vertices[m_vertexOffset+i].dot(localDir);
|
||||
//b3Assert(dp==dpL);
|
||||
if(dp < min) min = dp;
|
||||
if(dp > max) max = dp;
|
||||
}
|
||||
if(min>max)
|
||||
{
|
||||
b3Scalar tmp = min;
|
||||
min = max;
|
||||
max = tmp;
|
||||
}
|
||||
min += offset;
|
||||
max += offset;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //CONVEX_POLYHEDRON_CL
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace gjkepa2_impl
|
||||
{
|
||||
|
||||
|
||||
const b3ConvexPolyhedronCL* m_shapes[2];
|
||||
const b3ConvexPolyhedronData* m_shapes[2];
|
||||
|
||||
|
||||
b3Matrix3x3 m_toshape1;
|
||||
@@ -631,7 +631,10 @@ namespace gjkepa2_impl
|
||||
append(m_stock,best);
|
||||
best=findbest();
|
||||
outer=*best;
|
||||
} else { m_status=eStatus::InvalidHull;break; }
|
||||
} else {
|
||||
m_status=eStatus::Failed;
|
||||
//m_status=eStatus::InvalidHull;
|
||||
break; }
|
||||
} else { m_status=eStatus::AccuraryReached;break; }
|
||||
} else { m_status=eStatus::OutOfVertices;break; }
|
||||
}
|
||||
@@ -804,7 +807,7 @@ namespace gjkepa2_impl
|
||||
|
||||
//
|
||||
static void Initialize(const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL* hullA, const b3ConvexPolyhedronCL* hullB,
|
||||
const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
b3GjkEpaSolver2::sResults& results,
|
||||
@@ -839,7 +842,7 @@ int b3GjkEpaSolver2::StackSizeRequirement()
|
||||
|
||||
//
|
||||
bool b3GjkEpaSolver2::Distance( const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL* hullA, const b3ConvexPolyhedronCL* hullB,
|
||||
const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
const b3Vector3& guess,
|
||||
@@ -877,7 +880,7 @@ bool b3GjkEpaSolver2::Distance( const b3Transform& transA, const b3Transform& t
|
||||
|
||||
//
|
||||
bool b3GjkEpaSolver2::Penetration( const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL* hullA, const b3ConvexPolyhedronCL* hullB,
|
||||
const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
const b3Vector3& guess,
|
||||
@@ -927,7 +930,7 @@ bool b3GjkEpaSolver2::Penetration( const b3Transform& transA, const b3Transform&
|
||||
b3Scalar b3GjkEpaSolver2::SignedDistance(const b3Vector3& position,
|
||||
b3Scalar margin,
|
||||
const b3Transform& transA,
|
||||
const b3ConvexPolyhedronCL& hullA,
|
||||
const b3ConvexPolyhedronData& hullA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
sResults& results)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,8 @@ GJK-EPA collision solver by Nathanael Presson, 2008
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
|
||||
|
||||
///btGjkEpaSolver contributed under zlib by Nathanael Presson
|
||||
struct b3GjkEpaSolver2
|
||||
@@ -49,14 +50,14 @@ struct sResults
|
||||
static int StackSizeRequirement();
|
||||
|
||||
static bool Distance( const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL* hullA, const b3ConvexPolyhedronCL* hullB,
|
||||
const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
const b3Vector3& guess,
|
||||
sResults& results);
|
||||
|
||||
static bool Penetration( const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL* hullA, const b3ConvexPolyhedronCL* hullB,
|
||||
const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
const b3Vector3& guess,
|
||||
@@ -65,19 +66,15 @@ static bool Penetration( const b3Transform& transA, const b3Transform& transB,
|
||||
#if 0
|
||||
static b3Scalar SignedDistance( const b3Vector3& position,
|
||||
b3Scalar margin,
|
||||
const b3Transform& transA,
|
||||
const b3ConvexPolyhedronCL& hullA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
|
||||
const btConvexShape* shape,
|
||||
const btTransform& wtrs,
|
||||
sResults& results);
|
||||
|
||||
static bool SignedDistance( const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhedronCL& hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
static bool SignedDistance( const btConvexShape* shape0,const btTransform& wtrs0,
|
||||
const btConvexShape* shape1,const btTransform& wtrs1,
|
||||
const b3Vector3& guess,
|
||||
sResults& results);
|
||||
#endif //0
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
||||
#include "b3GjkPairDetector.h"
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
#include "b3VoronoiSimplexSolver.h"
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
#include "b3VectorFloat4.h"
|
||||
#include "b3GjkEpa.h"
|
||||
#include "b3SupportMappings.h"
|
||||
@@ -48,7 +48,7 @@ m_fixContactNormalDirection(1)
|
||||
|
||||
bool calcPenDepth( b3VoronoiSimplexSolver& simplexSolver,
|
||||
const b3Transform& transformA, const b3Transform& transformB,
|
||||
const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhedronCL& hullB,
|
||||
const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
b3Vector3& v, b3Vector3& wWitnessOnA, b3Vector3& wWitnessOnB)
|
||||
@@ -83,7 +83,7 @@ bool calcPenDepth( b3VoronoiSimplexSolver& simplexSolver,
|
||||
}
|
||||
#define dot3F4 b3Dot
|
||||
|
||||
inline void project(const b3ConvexPolyhedronCL& hull, const float4& pos, const b3Quaternion& orn, const float4& dir, const b3AlignedObjectArray<b3Vector3>& vertices, b3Scalar& min, b3Scalar& max)
|
||||
inline void project(const b3ConvexPolyhedronData& hull, const float4& pos, const b3Quaternion& orn, const float4& dir, const b3AlignedObjectArray<b3Vector3>& vertices, b3Scalar& min, b3Scalar& max)
|
||||
{
|
||||
min = FLT_MAX;
|
||||
max = -FLT_MAX;
|
||||
@@ -114,7 +114,7 @@ inline void project(const b3ConvexPolyhedronCL& hull, const float4& pos, const
|
||||
}
|
||||
|
||||
|
||||
static bool TestSepAxis(const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhedronCL& hullB,
|
||||
static bool TestSepAxis(const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
const float4& posA,const b3Quaternion& ornA,
|
||||
const float4& posB,const b3Quaternion& ornB,
|
||||
float4& sep_axis, const b3AlignedObjectArray<b3Vector3>& verticesA,const b3AlignedObjectArray<b3Vector3>& verticesB,b3Scalar& depth)
|
||||
@@ -146,7 +146,7 @@ static bool TestSepAxis(const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhed
|
||||
|
||||
|
||||
bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhedronCL& hullB,
|
||||
const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
b3Scalar maximumDistanceSquared,
|
||||
@@ -203,9 +203,7 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
b3Scalar margin = marginA + marginB;
|
||||
b3Scalar bestDeltaN = -1e30f;
|
||||
b3Vector3 bestSepAxis= b3MakeVector3(0,0,0);
|
||||
b3Vector3 bestPointOnA;
|
||||
b3Vector3 bestPointOnB;
|
||||
|
||||
|
||||
|
||||
|
||||
gjkDetector->m_simplexSolver->reset();
|
||||
@@ -224,33 +222,10 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
b3Vector3 pWorld = localTransA(pInA);
|
||||
b3Vector3 qWorld = localTransB(qInB);
|
||||
|
||||
{
|
||||
b3Scalar l2 = gjkDetector->m_cachedSeparatingAxis.length2();
|
||||
if (l2>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
|
||||
b3Vector3 testAxis = gjkDetector->m_cachedSeparatingAxis*(1.f/b3Sqrt(l2));
|
||||
float computedDepth=1e30f;
|
||||
if (!TestSepAxis(hullA,hullB,transA.getOrigin(),transA.getRotation(),
|
||||
transB.getOrigin(),transB.getRotation(),testAxis,verticesA,verticesB,computedDepth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(computedDepth<resultSepDistance)
|
||||
{
|
||||
if (testAxis.length2()>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
resultSepDistance = computedDepth;
|
||||
resultSepNormal = testAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_SPU_COLLISION_DETECTION
|
||||
spu_printf("got local supporting vertices\n");
|
||||
#endif
|
||||
|
||||
if (check2d)
|
||||
{
|
||||
@@ -260,26 +235,7 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
|
||||
b3Vector3 w = pWorld - qWorld;
|
||||
delta = gjkDetector->m_cachedSeparatingAxis.dot(w);
|
||||
if (delta>0)
|
||||
return false;
|
||||
b3Scalar deltaN = gjkDetector->m_cachedSeparatingAxis.normalized().dot(w.normalized());
|
||||
|
||||
|
||||
if (deltaN < bestDeltaN)
|
||||
{
|
||||
bestDeltaN = deltaN;
|
||||
//printf("new solution?\n");
|
||||
bestSepAxis = gjkDetector->m_cachedSeparatingAxis;
|
||||
gjkDetector->m_simplexSolver->compute_points(bestPointOnA, bestPointOnB);
|
||||
}
|
||||
prevDelta = delta;
|
||||
b3Scalar dist = 0;
|
||||
if (delta<0)
|
||||
dist = -b3Sqrt(b3Fabs(delta));
|
||||
else
|
||||
dist = b3Sqrt(delta);
|
||||
|
||||
//printf("gjkDetector->m_cachedSeparatingAxis = %f,%f,%f delta/dist = %f\n",gjkDetector->m_cachedSeparatingAxis.x,gjkDetector->m_cachedSeparatingAxis.y,gjkDetector->m_cachedSeparatingAxis.z,dist);
|
||||
// potential exit, they don't overlap
|
||||
if ((delta > b3Scalar(0.0)) && (delta * delta > squaredDistance * maximumDistanceSquared))
|
||||
{
|
||||
@@ -313,8 +269,14 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SPU_COLLISION_DETECTION
|
||||
spu_printf("addVertex 1\n");
|
||||
#endif
|
||||
//add current vertex to simplex
|
||||
gjkDetector->m_simplexSolver->addVertex(w, pWorld, qWorld);
|
||||
#ifdef DEBUG_SPU_COLLISION_DETECTION
|
||||
spu_printf("addVertex 2\n");
|
||||
#endif
|
||||
b3Vector3 newCachedSeparatingAxis;
|
||||
|
||||
//calculate the closest point to the origin (update vector v)
|
||||
@@ -325,12 +287,9 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
break;
|
||||
}
|
||||
|
||||
if(0)//newCachedSeparatingAxis.length2()<REL_ERROR2)
|
||||
if(newCachedSeparatingAxis.length2()<REL_ERROR2)
|
||||
{
|
||||
if (delta<bestDeltaN)
|
||||
{
|
||||
gjkDetector->m_cachedSeparatingAxis = newCachedSeparatingAxis;
|
||||
}
|
||||
gjkDetector->m_cachedSeparatingAxis = newCachedSeparatingAxis;
|
||||
gjkDetector->m_degenerateSimplex = 6;
|
||||
checkSimplex = true;
|
||||
break;
|
||||
@@ -338,17 +297,24 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
|
||||
b3Scalar previousSquaredDistance = squaredDistance;
|
||||
squaredDistance = newCachedSeparatingAxis.length2();
|
||||
|
||||
b3Vector3 sepAxis=newCachedSeparatingAxis.normalized();
|
||||
|
||||
#if 0
|
||||
///warning: this termination condition leads to some problems in 2d test case see Bullet/Demos/Box2dDemo
|
||||
if (squaredDistance>previousSquaredDistance)
|
||||
{
|
||||
gjkDetector->m_degenerateSimplex = 7;
|
||||
squaredDistance = previousSquaredDistance;
|
||||
checkSimplex = false;
|
||||
break;
|
||||
}
|
||||
#endif //
|
||||
|
||||
|
||||
|
||||
//redundant m_simplexSolver->compute_points(pointOnA, pointOnB);
|
||||
//redundant gjkDetector->m_simplexSolver->compute_points(pointOnA, pointOnB);
|
||||
|
||||
//are we getting any closer ?
|
||||
if (previousSquaredDistance - squaredDistance <= B3_EPSILON * previousSquaredDistance)
|
||||
{
|
||||
// gjkDetector->m_simplexSolver->backup_closest(gjkDetector->m_cachedSeparatingAxis);
|
||||
checkSimplex = true;
|
||||
gjkDetector->m_degenerateSimplex = 12;
|
||||
|
||||
@@ -357,55 +323,32 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
|
||||
gjkDetector->m_cachedSeparatingAxis = newCachedSeparatingAxis;
|
||||
|
||||
{
|
||||
b3Scalar l2 = gjkDetector->m_cachedSeparatingAxis.length2();
|
||||
if (l2>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
//degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject
|
||||
if (gjkDetector->m_curIter++ > gGjkMaxIter)
|
||||
{
|
||||
#if defined(DEBUG) || defined (_DEBUG) || defined (DEBUG_SPU_COLLISION_DETECTION)
|
||||
|
||||
b3Vector3 testAxis = gjkDetector->m_cachedSeparatingAxis*(1.f/b3Sqrt(l2));
|
||||
float computedDepth=1e30f;
|
||||
if (!TestSepAxis(hullA,hullB,transA.getOrigin(),transA.getRotation(),
|
||||
transB.getOrigin(),transB.getRotation(),testAxis,verticesA,verticesB,computedDepth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("btGjkPairDetector maxIter exceeded:%i\n",gjkDetector->m_curIter);
|
||||
printf("sepAxis=(%f,%f,%f), squaredDistance = %f\n",
|
||||
gjkDetector->m_cachedSeparatingAxis.getX(),
|
||||
gjkDetector->m_cachedSeparatingAxis.getY(),
|
||||
gjkDetector->m_cachedSeparatingAxis.getZ(),
|
||||
squaredDistance);
|
||||
|
||||
|
||||
|
||||
if(computedDepth<resultSepDistance)
|
||||
{
|
||||
if (testAxis.length2()>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
resultSepDistance = computedDepth;
|
||||
resultSepNormal = testAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
//degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject
|
||||
if (gjkDetector->m_curIter++ > gGjkMaxIter)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool check = (!gjkDetector->m_simplexSolver->fullSimplex());
|
||||
|
||||
float projectedDepth = 0;
|
||||
|
||||
if (delta<0)
|
||||
{
|
||||
projectedDepth = -b3Sqrt(b3Fabs(delta));
|
||||
} else
|
||||
{
|
||||
projectedDepth = b3Sqrt(delta);
|
||||
}
|
||||
|
||||
//printf("dist2 = %f dist= %f projectedDepth = %f\n", squaredDistance,b3Sqrt(squaredDistance),projectedDepth);
|
||||
//bool check = (!gjkDetector->m_simplexSolver->fullSimplex() && squaredDistance > B3_EPSILON * gjkDetector->m_simplexSolver->maxVertex());
|
||||
|
||||
if (!check)
|
||||
{
|
||||
//do we need this backup_closest here ?
|
||||
// gjkDetector->m_simplexSolver->backup_closest(gjkDetector->m_cachedSeparatingAxis);
|
||||
gjkDetector->m_degenerateSimplex = 13;
|
||||
break;
|
||||
}
|
||||
@@ -413,16 +356,7 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
|
||||
if (checkSimplex)
|
||||
{
|
||||
if (bestSepAxis.length2())
|
||||
{
|
||||
pointOnA = bestPointOnA;
|
||||
pointOnB = bestPointOnB;
|
||||
gjkDetector->m_cachedSeparatingAxis = bestSepAxis;
|
||||
} else
|
||||
{
|
||||
gjkDetector->m_simplexSolver->compute_points(pointOnA, pointOnB);
|
||||
}
|
||||
|
||||
gjkDetector->m_simplexSolver->compute_points(pointOnA, pointOnB);
|
||||
normalInB = gjkDetector->m_cachedSeparatingAxis;
|
||||
b3Scalar lenSqr =gjkDetector->m_cachedSeparatingAxis.length2();
|
||||
|
||||
@@ -450,7 +384,8 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
}
|
||||
}
|
||||
|
||||
bool catchDegeneratePenetrationCase = (gjkDetector->m_catchDegeneracies && gjkDetector->m_penetrationDepthSolver && gjkDetector->m_degenerateSimplex && ((distance+margin) < 0.01));
|
||||
bool catchDegeneratePenetrationCase =
|
||||
(gjkDetector->m_catchDegeneracies && gjkDetector->m_penetrationDepthSolver && gjkDetector->m_degenerateSimplex && ((distance+margin) < 0.01));
|
||||
|
||||
//if (checkPenetration && !isValid)
|
||||
if (checkPenetration && (!isValid || catchDegeneratePenetrationCase ))
|
||||
@@ -543,10 +478,11 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
|
||||
|
||||
|
||||
if (isValid && ((distance < 0) || (distance*distance < maximumDistanceSquared)))
|
||||
if (isValid && (distance < 0))
|
||||
//if (isValid && ((distance < 0) || (distance*distance < maximumDistanceSquared)))
|
||||
{
|
||||
|
||||
if (gjkDetector->m_fixContactNormalDirection)
|
||||
if (1)//m_fixContactNormalDirection)
|
||||
{
|
||||
///@workaround for sticky convex collisions
|
||||
//in some degenerate cases (usually when the use uses very small margins)
|
||||
@@ -556,104 +492,37 @@ bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA,
|
||||
//We like to use a dot product of the normal against the difference of the centroids,
|
||||
//once the centroid is available in the API
|
||||
//until then we use the center of the aabb to approximate the centroid
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
//m_minkowskiA->getAabb(localTransA,aabbMin,aabbMax);
|
||||
//b3Vector3 posA = (aabbMax+aabbMin)*b3Scalar(0.5);
|
||||
|
||||
//m_minkowskiB->getAabb(localTransB,aabbMin,aabbMax);
|
||||
//b3Vector3 posB = (aabbMin+aabbMax)*b3Scalar(0.5);
|
||||
b3Vector3 posA = localTransA*hullA.m_localCenter;
|
||||
b3Vector3 posB = localTransB*hullB.m_localCenter;
|
||||
|
||||
|
||||
b3Vector3 diff = transA.getOrigin()-transB.getOrigin();
|
||||
|
||||
b3Vector3 diff = posA-posB;
|
||||
if (diff.dot(normalInB) < 0.f)
|
||||
normalInB *= -1.f;
|
||||
}
|
||||
gjkDetector->m_cachedSeparatingAxis = normalInB;
|
||||
gjkDetector->m_cachedSeparatingDistance = distance;
|
||||
|
||||
{
|
||||
b3Scalar l2 = gjkDetector->m_cachedSeparatingAxis.length2();
|
||||
if (l2>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
|
||||
b3Vector3 testAxis = gjkDetector->m_cachedSeparatingAxis*(1.f/b3Sqrt(l2));
|
||||
float computedDepth=1e30f;
|
||||
if (!TestSepAxis(hullA,hullB,transA.getOrigin(),transA.getRotation(),
|
||||
transB.getOrigin(),transB.getRotation(),testAxis,verticesA,verticesB,computedDepth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(computedDepth<resultSepDistance)
|
||||
{
|
||||
if (testAxis.length2()>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
resultSepDistance = computedDepth;
|
||||
resultSepNormal = testAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*output.addContactPoint(
|
||||
normalInB,
|
||||
pointOnB+positionOffset,
|
||||
distance);
|
||||
*/
|
||||
|
||||
static float maxPenetrationDistance = 0.f;
|
||||
if (distance<maxPenetrationDistance)
|
||||
{
|
||||
maxPenetrationDistance = distance;
|
||||
printf("maxPenetrationDistance = %f\n",maxPenetrationDistance);
|
||||
}
|
||||
resultSepNormal = normalInB;
|
||||
//printf("normalInB = %f,%f,%f, distance = %f\n",normalInB.x,normalInB.y,normalInB.z,distance);
|
||||
resultSepDistance = distance;
|
||||
|
||||
|
||||
b3Scalar lsqr = resultSepNormal.length2();
|
||||
b3Assert(lsqr>B3_EPSILON*B3_EPSILON);
|
||||
if (lsqr<B3_EPSILON*B3_EPSILON)
|
||||
return false;
|
||||
resultSepNormal *= 1.f/b3Sqrt(lsqr);
|
||||
|
||||
#if 0
|
||||
float dot = resultSepNormal.dot(b3Vector3(0,-1,0));
|
||||
//float dot = b3Vector3(-0.7,-0.6,-0.2).dot(b3Vector3(0,-1,0));
|
||||
|
||||
static float minDot = 1e30f;
|
||||
|
||||
if (dot<minDot)
|
||||
{
|
||||
//printf("minDot = %f\n", dot);
|
||||
minDot=dot;
|
||||
}
|
||||
|
||||
//printf("gNumGjkChecks = %d, gNumDeepPenetrationChecks = %d, minDot = %f\n", gNumGjkChecks,gNumDeepPenetrationChecks,minDot);
|
||||
if (0)//dot<0.64)
|
||||
{
|
||||
{
|
||||
b3Scalar l2 = resultSepNormal.length2();
|
||||
if (l2>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
|
||||
b3Vector3 testAxis = gjkDetector->m_cachedSeparatingAxis*(1./b3Sqrt(l2));
|
||||
float computedDepth=1e30f;
|
||||
if (!TestSepAxis(hullA,hullB,transA.getOrigin(),transA.getRotation(),
|
||||
transB.getOrigin(),transB.getRotation(),testAxis,verticesA,verticesB,computedDepth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(computedDepth<resultSepDistance)
|
||||
{
|
||||
if (testAxis.length2()>B3_EPSILON*B3_EPSILON)
|
||||
{
|
||||
resultSepDistance = computedDepth;
|
||||
resultSepNormal = testAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
resultPointOnB = pointOnB+positionOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class b3Transform;
|
||||
struct b3GjkEpaSolver2;
|
||||
class b3VoronoiSimplexSolver;
|
||||
struct b3ConvexPolyhedronCL;
|
||||
struct b3ConvexPolyhedronData;
|
||||
|
||||
B3_ATTRIBUTE_ALIGNED16(struct) b3GjkPairDetector
|
||||
{
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
|
||||
bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA, const b3Transform& transB,
|
||||
const b3ConvexPolyhedronCL& hullA, const b3ConvexPolyhedronCL& hullB,
|
||||
const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesB,
|
||||
b3Scalar maximumDistanceSquared,
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "b3VectorFloat4.h"
|
||||
|
||||
struct b3ConvexPolyhedronCL;
|
||||
|
||||
struct b3GjkPairDetector;
|
||||
|
||||
inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec,const struct b3ConvexPolyhedronCL* hull,
|
||||
|
||||
|
||||
inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec,const struct b3ConvexPolyhedronData* hull,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA, b3Scalar margin)
|
||||
{
|
||||
b3Vector3 supVec = b3MakeVector3(b3Scalar(0.),b3Scalar(0.),b3Scalar(0.));
|
||||
@@ -27,7 +29,7 @@ inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec,const
|
||||
|
||||
}
|
||||
|
||||
inline b3Vector3 localGetSupportVertexWithoutMargin(const float4& supportVec,const struct b3ConvexPolyhedronCL* hull,
|
||||
inline b3Vector3 localGetSupportVertexWithoutMargin(const float4& supportVec,const struct b3ConvexPolyhedronData* hull,
|
||||
const b3AlignedObjectArray<b3Vector3>& verticesA)
|
||||
{
|
||||
return localGetSupportVertexWithMargin(supportVec,hull,verticesA,0.f);
|
||||
|
||||
@@ -3,18 +3,9 @@
|
||||
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
|
||||
#define cross3(a,b) (a.cross(b))
|
||||
//#define cross3(a,b) (a.cross(b))
|
||||
#define float4 b3Vector3
|
||||
#define make_float4(x,y,z,w) b3Vector4(x,y,z,w)
|
||||
//#define make_float4(x,y,z,w) b3Vector4(x,y,z,w)
|
||||
|
||||
inline b3Vector3 transform(const b3Vector3* v, const b3Vector3* pos, const b3Quaternion* orn)
|
||||
{
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(*pos);
|
||||
tr.setRotation(*orn);
|
||||
b3Vector3 res = tr(*v);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif //B3_VECTOR_FLOAT4_H
|
||||
|
||||
89
src/Bullet3OpenCL/NarrowphaseCollision/kernels/mpr.cl
Normal file
89
src/Bullet3OpenCL/NarrowphaseCollision/kernels/mpr.cl
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h"
|
||||
|
||||
#define AppendInc(x, out) out = atomic_inc(x)
|
||||
#define GET_NPOINTS(x) (x).m_worldNormalOnB.w
|
||||
#ifdef cl_ext_atomic_counters_32
|
||||
#pragma OPENCL EXTENSION cl_ext_atomic_counters_32 : enable
|
||||
#else
|
||||
#define counter32_t volatile __global int*
|
||||
#endif
|
||||
|
||||
|
||||
__kernel void mprPenetrationKernel( __global int4* pairs,
|
||||
__global const b3RigidBodyData_t* rigidBodies,
|
||||
__global const b3Collidable_t* collidables,
|
||||
__global const b3ConvexPolyhedronData_t* convexShapes,
|
||||
__global const float4* vertices,
|
||||
__global float4* separatingNormals,
|
||||
__global int* hasSeparatingAxis,
|
||||
__global struct b3Contact4Data* restrict globalContactsOut,
|
||||
counter32_t nGlobalContactsOut,
|
||||
int contactCapacity,
|
||||
int numPairs)
|
||||
{
|
||||
int i = get_global_id(0);
|
||||
int pairIndex = i;
|
||||
if (i<numPairs)
|
||||
{
|
||||
int bodyIndexA = pairs[i].x;
|
||||
int bodyIndexB = pairs[i].y;
|
||||
|
||||
int collidableIndexA = rigidBodies[bodyIndexA].m_collidableIdx;
|
||||
int collidableIndexB = rigidBodies[bodyIndexB].m_collidableIdx;
|
||||
|
||||
int shapeIndexA = collidables[collidableIndexA].m_shapeIndex;
|
||||
int shapeIndexB = collidables[collidableIndexB].m_shapeIndex;
|
||||
|
||||
|
||||
//once the broadphase avoids static-static pairs, we can remove this test
|
||||
if ((rigidBodies[bodyIndexA].m_invMass==0) &&(rigidBodies[bodyIndexB].m_invMass==0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ((collidables[collidableIndexA].m_shapeType!=SHAPE_CONVEX_HULL) ||(collidables[collidableIndexB].m_shapeType!=SHAPE_CONVEX_HULL))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float depthOut;
|
||||
b3Float4 dirOut;
|
||||
b3Float4 posOut;
|
||||
|
||||
|
||||
int res = b3MprPenetration(pairIndex, bodyIndexA, bodyIndexB,rigidBodies,convexShapes,collidables,vertices,separatingNormals,hasSeparatingAxis,&depthOut, &dirOut, &posOut);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (res==0)
|
||||
{
|
||||
//add a contact
|
||||
|
||||
int dstIdx;
|
||||
AppendInc( nGlobalContactsOut, dstIdx );
|
||||
if (dstIdx<contactCapacity)
|
||||
{
|
||||
__global struct b3Contact4Data* c = globalContactsOut + dstIdx;
|
||||
c->m_worldNormalOnB = -dirOut;//normal;
|
||||
c->m_restituitionCoeffCmp = (0.f*0xffff);c->m_frictionCoeffCmp = (0.7f*0xffff);
|
||||
c->m_batchIdx = pairIndex;
|
||||
int bodyA = pairs[pairIndex].x;
|
||||
int bodyB = pairs[pairIndex].y;
|
||||
c->m_bodyAPtrAndSignBit = rigidBodies[bodyA].m_invMass==0 ? -bodyA:bodyA;
|
||||
c->m_bodyBPtrAndSignBit = rigidBodies[bodyB].m_invMass==0 ? -bodyB:bodyB;
|
||||
c->m_childIndexA = -1;
|
||||
c->m_childIndexB = -1;
|
||||
//for (int i=0;i<nContacts;i++)
|
||||
posOut.w = -depthOut;
|
||||
c->m_worldPosB[0] = posOut;//localPoints[contactIdx[i]];
|
||||
GET_NPOINTS(*c) = 1;//nContacts;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1244
src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h
Normal file
1244
src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "b3GpuRaycast.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhaseInternalData.h"
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ bool sphere_intersect(const b3Vector3& spherePos, b3Scalar radius, const b3Vect
|
||||
return false;
|
||||
}
|
||||
|
||||
bool rayConvex(const b3Vector3& rayFromLocal, const b3Vector3& rayToLocal, const b3ConvexPolyhedronCL& poly,
|
||||
bool rayConvex(const b3Vector3& rayFromLocal, const b3Vector3& rayToLocal, const b3ConvexPolyhedronData& poly,
|
||||
const b3AlignedObjectArray<b3GpuFace>& faces, float& hitFraction, b3Vector3& hitNormal)
|
||||
{
|
||||
float exitFraction = hitFraction;
|
||||
@@ -125,7 +125,7 @@ bool rayConvex(const b3Vector3& rayFromLocal, const b3Vector3& rayToLocal, const
|
||||
}
|
||||
|
||||
void b3GpuRaycast::castRaysHost(const b3AlignedObjectArray<b3RayInfo>& rays, b3AlignedObjectArray<b3RayHit>& hitResults,
|
||||
int numBodies,const struct b3RigidBodyCL* bodies, int numCollidables,const struct b3Collidable* collidables, const struct b3GpuNarrowPhaseInternalData* narrowphaseData)
|
||||
int numBodies,const struct b3RigidBodyData* bodies, int numCollidables,const struct b3Collidable* collidables, const struct b3GpuNarrowPhaseInternalData* narrowphaseData)
|
||||
{
|
||||
|
||||
// return castRays(rays,hitResults,numBodies,bodies,numCollidables,collidables);
|
||||
@@ -173,7 +173,7 @@ void b3GpuRaycast::castRaysHost(const b3AlignedObjectArray<b3RayInfo>& rays, b3A
|
||||
|
||||
|
||||
int shapeIndex = collidables[bodies[b].m_collidableIdx].m_shapeIndex;
|
||||
const b3ConvexPolyhedronCL& poly = narrowphaseData->m_convexPolyhedra[shapeIndex];
|
||||
const b3ConvexPolyhedronData& poly = narrowphaseData->m_convexPolyhedra[shapeIndex];
|
||||
if (rayConvex(rayFromLocal, rayToLocal,poly,narrowphaseData->m_convexFaces, hitFraction, hitNormal))
|
||||
{
|
||||
hitBodyIndex = b;
|
||||
@@ -206,7 +206,7 @@ void b3GpuRaycast::castRaysHost(const b3AlignedObjectArray<b3RayInfo>& rays, b3A
|
||||
}
|
||||
///todo: add some acceleration structure (AABBs, tree etc)
|
||||
void b3GpuRaycast::castRays(const b3AlignedObjectArray<b3RayInfo>& rays, b3AlignedObjectArray<b3RayHit>& hitResults,
|
||||
int numBodies,const struct b3RigidBodyCL* bodies, int numCollidables, const struct b3Collidable* collidables, const struct b3GpuNarrowPhaseInternalData* narrowphaseData)
|
||||
int numBodies,const struct b3RigidBodyData* bodies, int numCollidables, const struct b3Collidable* collidables, const struct b3GpuNarrowPhaseInternalData* narrowphaseData)
|
||||
{
|
||||
|
||||
//castRaysHost(rays,hitResults,numBodies,bodies,numCollidables,collidables,narrowphaseData);
|
||||
|
||||
@@ -18,40 +18,15 @@ public:
|
||||
virtual ~b3GpuRaycast();
|
||||
|
||||
void castRaysHost(const b3AlignedObjectArray<b3RayInfo>& raysIn, b3AlignedObjectArray<b3RayHit>& hitResults,
|
||||
int numBodies, const struct b3RigidBodyCL* bodies, int numCollidables, const struct b3Collidable* collidables,
|
||||
int numBodies, const struct b3RigidBodyData* bodies, int numCollidables, const struct b3Collidable* collidables,
|
||||
const struct b3GpuNarrowPhaseInternalData* narrowphaseData);
|
||||
|
||||
void castRays(const b3AlignedObjectArray<b3RayInfo>& rays, b3AlignedObjectArray<b3RayHit>& hitResults,
|
||||
int numBodies,const struct b3RigidBodyCL* bodies, int numCollidables, const struct b3Collidable* collidables,
|
||||
int numBodies,const struct b3RigidBodyData* bodies, int numCollidables, const struct b3Collidable* collidables,
|
||||
const struct b3GpuNarrowPhaseInternalData* narrowphaseData
|
||||
);
|
||||
|
||||
/* const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
int maxContactCapacity,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
|
||||
const b3OpenCLArray<b3Vector3>& vertices,
|
||||
const b3OpenCLArray<b3Vector3>& uniqueEdges,
|
||||
const b3OpenCLArray<b3GpuFace>& faces,
|
||||
const b3OpenCLArray<int>& indices,
|
||||
const b3OpenCLArray<b3Collidable>& gpuCollidables,
|
||||
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
|
||||
|
||||
const b3OpenCLArray<b3YetAnotherAabb>& clAabbs,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
|
||||
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
|
||||
b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
|
||||
b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
|
||||
b3OpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
int numObjects,
|
||||
int maxTriConvexPairCapacity,
|
||||
b3OpenCLArray<b3Int4>& triangleConvexPairs,
|
||||
int& numTriConvexPairsOut
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ subject to the following restrictions:
|
||||
//Originally written by Erwin Coumans
|
||||
|
||||
#include "b3GpuGenericConstraint.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
|
||||
#include <new>
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
|
||||
void b3GpuGenericConstraint::getInfo1 (unsigned int* info,const b3RigidBodyCL* bodies)
|
||||
void b3GpuGenericConstraint::getInfo1 (unsigned int* info,const b3RigidBodyData* bodies)
|
||||
{
|
||||
switch (m_constraintType)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void b3GpuGenericConstraint::getInfo1 (unsigned int* info,const b3RigidBodyCL* b
|
||||
};
|
||||
}
|
||||
|
||||
void getInfo2Point2Point(b3GpuGenericConstraint* constraint, b3GpuConstraintInfo2* info, const b3RigidBodyCL* bodies)
|
||||
void getInfo2Point2Point(b3GpuGenericConstraint* constraint, b3GpuConstraintInfo2* info, const b3RigidBodyData* bodies)
|
||||
{
|
||||
b3Transform trA;
|
||||
trA.setIdentity();
|
||||
@@ -120,7 +120,7 @@ void getInfo2Point2Point(b3GpuGenericConstraint* constraint, b3GpuConstraintInfo
|
||||
|
||||
}
|
||||
|
||||
void b3GpuGenericConstraint::getInfo2 (b3GpuConstraintInfo2* info, const b3RigidBodyCL* bodies)
|
||||
void b3GpuGenericConstraint::getInfo2 (b3GpuConstraintInfo2* info, const b3RigidBodyData* bodies)
|
||||
{
|
||||
switch (m_constraintType)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
||||
#define B3_GPU_GENERIC_CONSTRAINT_H
|
||||
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
struct b3RigidBodyCL;
|
||||
struct b3RigidBodyData;
|
||||
enum B3_CONSTRAINT_FLAGS
|
||||
{
|
||||
B3_CONSTRAINT_FLAG_ENABLED=1,
|
||||
@@ -121,10 +121,10 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3GpuGenericConstraint
|
||||
}
|
||||
|
||||
///internal method used by the constraint solver, don't use them directly
|
||||
void getInfo1 (unsigned int* info,const b3RigidBodyCL* bodies);
|
||||
void getInfo1 (unsigned int* info,const b3RigidBodyData* bodies);
|
||||
|
||||
///internal method used by the constraint solver, don't use them directly
|
||||
void getInfo2 (b3GpuConstraintInfo2* info, const b3RigidBodyCL* bodies);
|
||||
void getInfo2 (b3GpuConstraintInfo2* info, const b3RigidBodyData* bodies);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -455,7 +455,7 @@ void setConstraint4( const b3Vector3& posA, const b3Vector3& linVelA, const b3Ve
|
||||
|
||||
|
||||
|
||||
void ContactToConstraintKernel(b3Contact4* gContact, b3RigidBodyCL* gBodies, b3InertiaCL* gShapes, b3GpuConstraint4* gConstraintOut, int nContacts,
|
||||
void ContactToConstraintKernel(b3Contact4* gContact, b3RigidBodyData* gBodies, b3InertiaData* gShapes, b3GpuConstraint4* gConstraintOut, int nContacts,
|
||||
float dt,
|
||||
float positionDrift,
|
||||
float positionConstraintCoeff, int gIdx, b3AlignedObjectArray<unsigned int>& bodyCount
|
||||
@@ -496,7 +496,7 @@ float positionConstraintCoeff, int gIdx, b3AlignedObjectArray<unsigned int>& bod
|
||||
}
|
||||
|
||||
|
||||
void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,const b3JacobiSolverInfo& solverInfo)
|
||||
void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyData* bodies,b3InertiaData* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,const b3JacobiSolverInfo& solverInfo)
|
||||
{
|
||||
B3_PROFILE("b3GpuJacobiContactSolver::solveGroup");
|
||||
|
||||
@@ -579,8 +579,8 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)contactConstraints[i].m_bodyA;
|
||||
int bIdx = (int)contactConstraints[i].m_bodyB;
|
||||
b3RigidBodyCL& bodyA = bodies[aIdx];
|
||||
b3RigidBodyCL& bodyB = bodies[bIdx];
|
||||
b3RigidBodyData& bodyA = bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = bodies[bIdx];
|
||||
|
||||
b3Vector3 zero = b3MakeVector3(0,0,0);
|
||||
|
||||
@@ -589,7 +589,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
b3Vector3* dlvBPtr=&zero;
|
||||
b3Vector3* davBPtr=&zero;
|
||||
|
||||
if (bodyA.getInvMass())
|
||||
if (bodyA.m_invMass)
|
||||
{
|
||||
int bodyOffsetA = offsetSplitBodies[aIdx];
|
||||
int constraintOffsetA = contactConstraintOffsets[i].x;
|
||||
@@ -598,7 +598,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
davAPtr = &deltaAngularVelocities[splitIndexA];
|
||||
}
|
||||
|
||||
if (bodyB.getInvMass())
|
||||
if (bodyB.m_invMass)
|
||||
{
|
||||
int bodyOffsetB = offsetSplitBodies[bIdx];
|
||||
int constraintOffsetB = contactConstraintOffsets[i].y;
|
||||
@@ -626,7 +626,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
//easy
|
||||
for (int i=0;i<numBodies;i++)
|
||||
{
|
||||
if (bodies[i].getInvMass())
|
||||
if (bodies[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
@@ -667,8 +667,8 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)contactConstraints[i].m_bodyA;
|
||||
int bIdx = (int)contactConstraints[i].m_bodyB;
|
||||
b3RigidBodyCL& bodyA = bodies[aIdx];
|
||||
b3RigidBodyCL& bodyB = bodies[bIdx];
|
||||
b3RigidBodyData& bodyA = bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = bodies[bIdx];
|
||||
|
||||
b3Vector3 zero = b3MakeVector3(0,0,0);
|
||||
|
||||
@@ -677,7 +677,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
b3Vector3* dlvBPtr=&zero;
|
||||
b3Vector3* davBPtr=&zero;
|
||||
|
||||
if (bodyA.getInvMass())
|
||||
if (bodyA.m_invMass)
|
||||
{
|
||||
int bodyOffsetA = offsetSplitBodies[aIdx];
|
||||
int constraintOffsetA = contactConstraintOffsets[i].x;
|
||||
@@ -686,7 +686,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
davAPtr = &deltaAngularVelocities[splitIndexA];
|
||||
}
|
||||
|
||||
if (bodyB.getInvMass())
|
||||
if (bodyB.m_invMass)
|
||||
{
|
||||
int bodyOffsetB = offsetSplitBodies[bIdx];
|
||||
int constraintOffsetB = contactConstraintOffsets[i].y;
|
||||
@@ -710,7 +710,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
//easy
|
||||
for (int i=0;i<numBodies;i++)
|
||||
{
|
||||
if (bodies[i].getInvMass())
|
||||
if (bodies[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
@@ -740,7 +740,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
//easy
|
||||
for (int i=0;i<numBodies;i++)
|
||||
{
|
||||
if (bodies[i].getInvMass())
|
||||
if (bodies[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
@@ -758,7 +758,7 @@ void b3GpuJacobiContactSolver::solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL*
|
||||
void b3GpuJacobiContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem inertiaBuf, int numContacts, cl_mem contactBuf, const struct b3Config& config, int static0Index)
|
||||
//
|
||||
//
|
||||
//void b3GpuJacobiContactSolver::solveGroup(b3OpenCLArray<b3RigidBodyCL>* bodies,b3OpenCLArray<b3InertiaCL>* inertias,b3OpenCLArray<b3Contact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo)
|
||||
//void b3GpuJacobiContactSolver::solveGroup(b3OpenCLArray<b3RigidBodyData>* bodies,b3OpenCLArray<b3InertiaData>* inertias,b3OpenCLArray<b3Contact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo)
|
||||
{
|
||||
b3JacobiSolverInfo solverInfo;
|
||||
solverInfo.m_fixedBodyIndex = static0Index;
|
||||
@@ -947,12 +947,12 @@ void b3GpuJacobiContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_m
|
||||
|
||||
#if 0
|
||||
|
||||
void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bodiesGPU,b3OpenCLArray<b3InertiaCL>* inertiasGPU,b3OpenCLArray<b3Contact4>* manifoldPtrGPU,const btJacobiSolverInfo& solverInfo)
|
||||
void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyData>* bodiesGPU,b3OpenCLArray<b3InertiaData>* inertiasGPU,b3OpenCLArray<b3Contact4>* manifoldPtrGPU,const btJacobiSolverInfo& solverInfo)
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> bodiesCPU;
|
||||
b3AlignedObjectArray<b3RigidBodyData> bodiesCPU;
|
||||
bodiesGPU->copyToHost(bodiesCPU);
|
||||
b3AlignedObjectArray<b3InertiaCL> inertiasCPU;
|
||||
b3AlignedObjectArray<b3InertiaData> inertiasCPU;
|
||||
inertiasGPU->copyToHost(inertiasCPU);
|
||||
b3AlignedObjectArray<b3Contact4> manifoldPtrCPU;
|
||||
manifoldPtrGPU->copyToHost(manifoldPtrCPU);
|
||||
@@ -1141,8 +1141,8 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)contactConstraints[i].m_bodyA;
|
||||
int bIdx = (int)contactConstraints[i].m_bodyB;
|
||||
b3RigidBodyCL& bodyA = bodiesCPU[aIdx];
|
||||
b3RigidBodyCL& bodyB = bodiesCPU[bIdx];
|
||||
b3RigidBodyData& bodyA = bodiesCPU[aIdx];
|
||||
b3RigidBodyData& bodyB = bodiesCPU[bIdx];
|
||||
|
||||
b3Vector3 zero(0,0,0);
|
||||
|
||||
@@ -1151,7 +1151,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
b3Vector3* dlvBPtr=&zero;
|
||||
b3Vector3* davBPtr=&zero;
|
||||
|
||||
if (bodyA.getInvMass())
|
||||
if (bodyA.m_invMass)
|
||||
{
|
||||
int bodyOffsetA = offsetSplitBodies[aIdx];
|
||||
int constraintOffsetA = contactConstraintOffsets[i].x;
|
||||
@@ -1160,7 +1160,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
davAPtr = &deltaAngularVelocities[splitIndexA];
|
||||
}
|
||||
|
||||
if (bodyB.getInvMass())
|
||||
if (bodyB.m_invMass)
|
||||
{
|
||||
int bodyOffsetB = offsetSplitBodies[bIdx];
|
||||
int constraintOffsetB = contactConstraintOffsets[i].y;
|
||||
@@ -1200,7 +1200,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
//easy
|
||||
for (int i=0;i<numBodiesCPU;i++)
|
||||
{
|
||||
if (bodiesCPU[i].getInvMass())
|
||||
if (bodiesCPU[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
@@ -1263,8 +1263,8 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
float frictionCoeff = contactConstraints[i].getFrictionCoeff();
|
||||
int aIdx = (int)contactConstraints[i].m_bodyA;
|
||||
int bIdx = (int)contactConstraints[i].m_bodyB;
|
||||
b3RigidBodyCL& bodyA = bodiesCPU[aIdx];
|
||||
b3RigidBodyCL& bodyB = bodiesCPU[bIdx];
|
||||
b3RigidBodyData& bodyA = bodiesCPU[aIdx];
|
||||
b3RigidBodyData& bodyB = bodiesCPU[bIdx];
|
||||
|
||||
b3Vector3 zero(0,0,0);
|
||||
|
||||
@@ -1273,7 +1273,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
b3Vector3* dlvBPtr=&zero;
|
||||
b3Vector3* davBPtr=&zero;
|
||||
|
||||
if (bodyA.getInvMass())
|
||||
if (bodyA.m_invMass)
|
||||
{
|
||||
int bodyOffsetA = offsetSplitBodies[aIdx];
|
||||
int constraintOffsetA = contactConstraintOffsets[i].x;
|
||||
@@ -1282,7 +1282,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
davAPtr = &deltaAngularVelocities[splitIndexA];
|
||||
}
|
||||
|
||||
if (bodyB.getInvMass())
|
||||
if (bodyB.m_invMass)
|
||||
{
|
||||
int bodyOffsetB = offsetSplitBodies[bIdx];
|
||||
int constraintOffsetB = contactConstraintOffsets[i].y;
|
||||
@@ -1319,7 +1319,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
//easy
|
||||
for (int i=0;i<numBodiesCPU;i++)
|
||||
{
|
||||
if (bodiesCPU[i].getInvMass())
|
||||
if (bodiesCPU[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
@@ -1362,7 +1362,7 @@ void b3GpuJacobiContactSolver::solveGroupMixed(b3OpenCLArray<b3RigidBodyCL>* bo
|
||||
//easy
|
||||
for (int i=0;i<numBodiesCPU;i++)
|
||||
{
|
||||
if (bodiesCPU[i].getInvMass())
|
||||
if (bodiesCPU[i].m_invMass)
|
||||
{
|
||||
int bodyOffset = offsetSplitBodies[i];
|
||||
int count = bodyCount[i];
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#define B3_GPU_JACOBI_CONTACT_SOLVER_H
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
|
||||
//#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
|
||||
|
||||
//struct b3InertiaCL;
|
||||
//struct b3InertiaData;
|
||||
//b3InertiaData
|
||||
|
||||
class b3TypedConstraint;
|
||||
@@ -49,10 +49,10 @@ public:
|
||||
|
||||
|
||||
void solveContacts(int numBodies, cl_mem bodyBuf, cl_mem inertiaBuf, int numContacts, cl_mem contactBuf, const struct b3Config& config, int static0Index);
|
||||
void solveGroupHost(b3RigidBodyCL* bodies,b3InertiaCL* inertias,int numBodies,struct b3Contact4* manifoldPtr, int numManifolds,const b3JacobiSolverInfo& solverInfo);
|
||||
void solveGroupHost(b3RigidBodyData* bodies,b3InertiaData* inertias,int numBodies,struct b3Contact4* manifoldPtr, int numManifolds,const b3JacobiSolverInfo& solverInfo);
|
||||
//void solveGroupHost(btRigidBodyCL* bodies,b3InertiaData* inertias,int numBodies,btContact4* manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btJacobiSolverInfo& solverInfo);
|
||||
|
||||
//b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyCL>* gpuBodies,b3OpenCLArray<b3InertiaCL>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
//b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
|
||||
//void solveGroup(btOpenCLArray<btRigidBodyCL>* bodies,btOpenCLArray<btInertiaCL>* inertias,btOpenCLArray<btContact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo);
|
||||
//void solveGroupMixed(btOpenCLArray<btRigidBodyCL>* bodies,btOpenCLArray<btInertiaCL>* inertias,btOpenCLArray<btContact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexHullContact.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3SapAabb.h"
|
||||
#include <string.h>
|
||||
@@ -45,16 +45,16 @@ m_queue(queue)
|
||||
|
||||
m_data->m_pBufContactOutCPU = new b3AlignedObjectArray<b3Contact4>();
|
||||
m_data->m_pBufContactOutCPU->resize(config.m_maxBroadphasePairs);
|
||||
m_data->m_bodyBufferCPU = new b3AlignedObjectArray<b3RigidBodyCL>();
|
||||
m_data->m_bodyBufferCPU = new b3AlignedObjectArray<b3RigidBodyData>();
|
||||
m_data->m_bodyBufferCPU->resize(config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<b3InertiaCL>();
|
||||
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<b3InertiaData>();
|
||||
m_data->m_inertiaBufferCPU->resize(config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_pBufContactBuffersGPU[0] = new b3OpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
|
||||
m_data->m_pBufContactBuffersGPU[1] = new b3OpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
|
||||
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaData>(ctx,queue,config.m_maxConvexBodies,false);
|
||||
m_data->m_collidablesGPU = new b3OpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
|
||||
m_data->m_collidablesCPU.reserve(config.m_maxConvexShapes);
|
||||
|
||||
@@ -63,14 +63,14 @@ m_queue(queue)
|
||||
|
||||
|
||||
//m_data->m_solverDataGPU = adl::Solver<adl::TYPE_CL>::allocate(ctx,queue, config.m_maxBroadphasePairs,false);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,queue, config.m_maxConvexBodies,false);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyData>(ctx,queue, config.m_maxConvexBodies,false);
|
||||
|
||||
m_data->m_convexFacesGPU = new b3OpenCLArray<b3GpuFace>(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false);
|
||||
m_data->m_convexFaces.reserve(config.m_maxConvexShapes*config.m_maxFacesPerShape);
|
||||
|
||||
m_data->m_gpuChildShapes = new b3OpenCLArray<b3GpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
|
||||
|
||||
m_data->m_convexPolyhedraGPU = new b3OpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
|
||||
m_data->m_convexPolyhedraGPU = new b3OpenCLArray<b3ConvexPolyhedronData>(ctx,queue,config.m_maxConvexShapes,false);
|
||||
m_data->m_convexPolyhedra.reserve(config.m_maxConvexShapes);
|
||||
|
||||
m_data->m_uniqueEdgesGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
|
||||
@@ -271,7 +271,7 @@ int b3GpuNarrowPhase::registerConvexHullShapeInternal(b3ConvexUtility* convexPtr
|
||||
m_data->m_convexPolyhedra.resize(m_data->m_numAcceleratedShapes+1);
|
||||
|
||||
|
||||
b3ConvexPolyhedronCL& convex = m_data->m_convexPolyhedra.at(m_data->m_convexPolyhedra.size()-1);
|
||||
b3ConvexPolyhedronData& convex = m_data->m_convexPolyhedra.at(m_data->m_convexPolyhedra.size()-1);
|
||||
convex.mC = convexPtr->mC;
|
||||
convex.mE = convexPtr->mE;
|
||||
convex.m_extents= convexPtr->m_extents;
|
||||
@@ -673,7 +673,7 @@ int b3GpuNarrowPhase::registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>*
|
||||
m_data->m_convexPolyhedra.resize(m_data->m_numAcceleratedShapes+1);
|
||||
|
||||
|
||||
b3ConvexPolyhedronCL& convex = m_data->m_convexPolyhedra.at(m_data->m_convexPolyhedra.size()-1);
|
||||
b3ConvexPolyhedronData& convex = m_data->m_convexPolyhedra.at(m_data->m_convexPolyhedra.size()-1);
|
||||
convex.mC = b3MakeVector3(0,0,0);
|
||||
convex.mE = b3MakeVector3(0,0,0);
|
||||
convex.m_extents= b3MakeVector3(0,0,0);
|
||||
@@ -738,7 +738,7 @@ cl_mem b3GpuNarrowPhase::getBodiesGpu()
|
||||
return (cl_mem)m_data->m_bodyBufferGPU->getBufferCL();
|
||||
}
|
||||
|
||||
const struct b3RigidBodyCL* b3GpuNarrowPhase::getBodiesCpu() const
|
||||
const struct b3RigidBodyData* b3GpuNarrowPhase::getBodiesCpu() const
|
||||
{
|
||||
return &m_data->m_bodyBufferCPU->at(0);
|
||||
};
|
||||
@@ -910,7 +910,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
|
||||
|
||||
m_data->m_bodyBufferCPU->resize(m_data->m_numAcceleratedRigidBodies+1);
|
||||
|
||||
b3RigidBodyCL& body = m_data->m_bodyBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
b3RigidBodyData& body = m_data->m_bodyBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
|
||||
float friction = 1.f;
|
||||
float restitution = 0.f;
|
||||
@@ -940,7 +940,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
|
||||
m_data->m_bodyBufferGPU->copyFromHostPointer(&body,1,m_data->m_numAcceleratedRigidBodies);
|
||||
}
|
||||
|
||||
b3InertiaCL& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
b3InertiaData& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
|
||||
if (mass==0.f)
|
||||
{
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
|
||||
|
||||
cl_mem getBodiesGpu();
|
||||
const struct b3RigidBodyCL* getBodiesCpu() const;
|
||||
//struct b3RigidBodyCL* getBodiesCpu();
|
||||
const struct b3RigidBodyData* getBodiesCpu() const;
|
||||
//struct b3RigidBodyData* getBodiesCpu();
|
||||
|
||||
int getNumBodiesGpu() const;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define B3_GPU_NARROWPHASE_INTERNAL_DATA_H
|
||||
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexPolyhedronCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3SapAabb.h"
|
||||
|
||||
@@ -27,12 +27,12 @@ struct b3GpuNarrowPhaseInternalData
|
||||
{
|
||||
b3AlignedObjectArray<b3ConvexUtility*>* m_convexData;
|
||||
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronCL> m_convexPolyhedra;
|
||||
b3AlignedObjectArray<b3ConvexPolyhedronData> m_convexPolyhedra;
|
||||
b3AlignedObjectArray<b3Vector3> m_uniqueEdges;
|
||||
b3AlignedObjectArray<b3Vector3> m_convexVertices;
|
||||
b3AlignedObjectArray<int> m_convexIndices;
|
||||
|
||||
b3OpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
|
||||
b3OpenCLArray<b3ConvexPolyhedronData>* m_convexPolyhedraGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_convexVerticesGPU;
|
||||
b3OpenCLArray<int>* m_convexIndicesGPU;
|
||||
@@ -60,11 +60,11 @@ struct b3GpuNarrowPhaseInternalData
|
||||
b3AlignedObjectArray<b3Contact4>* m_pBufContactOutCPU;
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL>* m_bodyBufferCPU;
|
||||
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
b3AlignedObjectArray<b3RigidBodyData>* m_bodyBufferCPU;
|
||||
b3OpenCLArray<b3RigidBodyData>* m_bodyBufferGPU;
|
||||
|
||||
b3AlignedObjectArray<b3InertiaCL>* m_inertiaBufferCPU;
|
||||
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
|
||||
b3AlignedObjectArray<b3InertiaData>* m_inertiaBufferCPU;
|
||||
b3OpenCLArray<b3InertiaData>* m_inertiaBufferGPU;
|
||||
|
||||
int m_numAcceleratedShapes;
|
||||
int m_numAcceleratedRigidBodies;
|
||||
|
||||
@@ -24,7 +24,7 @@ bool gpuBreakConstraints = true;
|
||||
|
||||
#include "b3GpuPgsConstraintSolver.h"
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
|
||||
#include "Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h"
|
||||
#include <new>
|
||||
@@ -72,8 +72,8 @@ struct b3GpuPgsJacobiSolverInternalData
|
||||
b3AlignedObjectArray<unsigned int> m_cpuConstraintInfo1;
|
||||
b3AlignedObjectArray<unsigned int> m_cpuConstraintRowOffsets;
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> m_cpuBodies;
|
||||
b3AlignedObjectArray<b3InertiaCL> m_cpuInertias;
|
||||
b3AlignedObjectArray<b3RigidBodyData> m_cpuBodies;
|
||||
b3AlignedObjectArray<b3InertiaData> m_cpuInertias;
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuGenericConstraint> m_cpuConstraints;
|
||||
@@ -85,7 +85,7 @@ struct b3GpuPgsJacobiSolverInternalData
|
||||
|
||||
|
||||
|
||||
static b3Transform getWorldTransform(b3RigidBodyCL* rb)
|
||||
static b3Transform getWorldTransform(b3RigidBodyData* rb)
|
||||
{
|
||||
b3Transform newTrans;
|
||||
newTrans.setOrigin(rb->m_pos);
|
||||
@@ -93,24 +93,24 @@ static b3Transform getWorldTransform(b3RigidBodyCL* rb)
|
||||
return newTrans;
|
||||
}
|
||||
|
||||
static const b3Matrix3x3& getInvInertiaTensorWorld(b3InertiaCL* inertia)
|
||||
static const b3Matrix3x3& getInvInertiaTensorWorld(b3InertiaData* inertia)
|
||||
{
|
||||
return inertia->m_invInertiaWorld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const b3Vector3& getLinearVelocity(b3RigidBodyCL* rb)
|
||||
static const b3Vector3& getLinearVelocity(b3RigidBodyData* rb)
|
||||
{
|
||||
return rb->m_linVel;
|
||||
}
|
||||
|
||||
static const b3Vector3& getAngularVelocity(b3RigidBodyCL* rb)
|
||||
static const b3Vector3& getAngularVelocity(b3RigidBodyData* rb)
|
||||
{
|
||||
return rb->m_angVel;
|
||||
}
|
||||
|
||||
b3Vector3 getVelocityInLocalPoint(b3RigidBodyCL* rb, const b3Vector3& rel_pos)
|
||||
b3Vector3 getVelocityInLocalPoint(b3RigidBodyData* rb, const b3Vector3& rel_pos)
|
||||
{
|
||||
//we also calculate lin/ang velocity for kinematic objects
|
||||
return getLinearVelocity(rb) + getAngularVelocity(rb).cross(rel_pos);
|
||||
@@ -204,7 +204,7 @@ void b3GpuPgsConstraintSolver::recomputeBatches()
|
||||
|
||||
|
||||
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3RigidBodyCL>* gpuBodies, b3OpenCLArray<b3InertiaCL>* gpuInertias, int numBodies, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal)
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal)
|
||||
{
|
||||
B3_PROFILE("GPU solveGroupCacheFriendlySetup");
|
||||
batchConstraints.resize(numConstraints);
|
||||
@@ -216,7 +216,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
/* m_gpuData->m_gpuBodies->resize(numBodies);
|
||||
m_gpuData->m_gpuBodies->copyFromHostPointer(bodies,numBodies);
|
||||
|
||||
b3OpenCLArray<b3InertiaCL> gpuInertias(m_gpuData->m_context,m_gpuData->m_queue);
|
||||
b3OpenCLArray<b3InertiaData> gpuInertias(m_gpuData->m_context,m_gpuData->m_queue);
|
||||
gpuInertias.resize(numBodies);
|
||||
gpuInertias.copyFromHostPointer(inertias,numBodies);
|
||||
*/
|
||||
@@ -245,7 +245,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
for (int i=0;i<numBodies;i++)
|
||||
{
|
||||
|
||||
b3RigidBodyCL& body = m_gpuData->m_cpuBodies[i];
|
||||
b3RigidBodyData& body = m_gpuData->m_cpuBodies[i];
|
||||
b3GpuSolverBody& solverBody = m_tmpSolverBodyPool[i];
|
||||
initSolverBody(i,&solverBody,&body);
|
||||
solverBody.m_originalBodyIndex = i;
|
||||
@@ -394,10 +394,10 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
b3GpuSolverConstraint* currentConstraintRow = &m_tmpSolverNonContactConstraintPool[constraintRowOffset];
|
||||
b3GpuGenericConstraint& constraint = m_gpuData->m_cpuConstraints[i];
|
||||
|
||||
b3RigidBodyCL& rbA = m_gpuData->m_cpuBodies[ constraint.getRigidBodyA()];
|
||||
b3RigidBodyData& rbA = m_gpuData->m_cpuBodies[ constraint.getRigidBodyA()];
|
||||
//b3RigidBody& rbA = constraint.getRigidBodyA();
|
||||
// b3RigidBody& rbB = constraint.getRigidBodyB();
|
||||
b3RigidBodyCL& rbB = m_gpuData->m_cpuBodies[ constraint.getRigidBodyB()];
|
||||
b3RigidBodyData& rbB = m_gpuData->m_cpuBodies[ constraint.getRigidBodyB()];
|
||||
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
b3GpuSolverBody* bodyAPtr = &m_tmpSolverBodyPool[solverBodyIdA];
|
||||
b3GpuSolverBody* bodyBPtr = &m_tmpSolverBodyPool[solverBodyIdB];
|
||||
|
||||
if (rbA.getInvMass())
|
||||
if (rbA.m_invMass)
|
||||
{
|
||||
batchConstraints[i].m_bodyAPtrAndSignBit = solverBodyIdA;
|
||||
} else
|
||||
@@ -417,7 +417,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
batchConstraints[i].m_bodyAPtrAndSignBit = -solverBodyIdA;
|
||||
}
|
||||
|
||||
if (rbB.getInvMass())
|
||||
if (rbB.m_invMass)
|
||||
{
|
||||
batchConstraints[i].m_bodyBPtrAndSignBit = solverBodyIdB;
|
||||
} else
|
||||
@@ -531,9 +531,9 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlySetup(b3OpenCLArray<b3
|
||||
{
|
||||
//it is ok to use solverConstraint.m_contactNormal instead of -solverConstraint.m_contactNormal
|
||||
//because it gets multiplied iMJlB
|
||||
b3Vector3 iMJlA = solverConstraint.m_contactNormal*rbA.getInvMass();
|
||||
b3Vector3 iMJlA = solverConstraint.m_contactNormal*rbA.m_invMass;
|
||||
b3Vector3 iMJaA = invInertiaWorldA*solverConstraint.m_relpos1CrossNormal;
|
||||
b3Vector3 iMJlB = solverConstraint.m_contactNormal*rbB.getInvMass();//sign of normal?
|
||||
b3Vector3 iMJlB = solverConstraint.m_contactNormal*rbB.m_invMass;//sign of normal?
|
||||
b3Vector3 iMJaB = invInertiaWorldB*solverConstraint.m_relpos2CrossNormal;
|
||||
|
||||
b3Scalar sum = iMJlA.dot(solverConstraint.m_contactNormal);
|
||||
@@ -655,7 +655,7 @@ void resolveSingleConstraintRowGeneric2( b3GpuSolverBody* body1, b3GpuSolverBod
|
||||
|
||||
|
||||
|
||||
void b3GpuPgsConstraintSolver::initSolverBody(int bodyIndex, b3GpuSolverBody* solverBody, b3RigidBodyCL* rb)
|
||||
void b3GpuPgsConstraintSolver::initSolverBody(int bodyIndex, b3GpuSolverBody* solverBody, b3RigidBodyData* rb)
|
||||
{
|
||||
|
||||
solverBody->m_deltaLinearVelocity.setValue(0.f,0.f,0.f);
|
||||
@@ -665,7 +665,7 @@ void b3GpuPgsConstraintSolver::initSolverBody(int bodyIndex, b3GpuSolverBody* so
|
||||
|
||||
b3Assert(rb);
|
||||
// solverBody->m_worldTransform = getWorldTransform(rb);
|
||||
solverBody->internalSetInvMass(b3MakeVector3(rb->getInvMass(),rb->getInvMass(),rb->getInvMass()));
|
||||
solverBody->internalSetInvMass(b3MakeVector3(rb->m_invMass,rb->m_invMass,rb->m_invMass));
|
||||
solverBody->m_originalBodyIndex = bodyIndex;
|
||||
solverBody->m_angularFactor = b3MakeVector3(1,1,1);
|
||||
solverBody->m_linearFactor = b3MakeVector3(1,1,1);
|
||||
@@ -991,7 +991,7 @@ inline int b3GpuPgsConstraintSolver::sortConstraintByBatch3( b3BatchConstraint*
|
||||
|
||||
|
||||
/// b3PgsJacobiSolver Sequentially applies impulses
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroup(b3OpenCLArray<b3RigidBodyCL>* gpuBodies, b3OpenCLArray<b3InertiaCL>* gpuInertias,
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroup(b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias,
|
||||
int numBodies, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints, const b3ContactSolverInfo& infoGlobal)
|
||||
{
|
||||
|
||||
@@ -1007,7 +1007,7 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroup(b3OpenCLArray<b3RigidBodyCL>* gpuB
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
void b3GpuPgsConstraintSolver::solveJoints(int numBodies, b3OpenCLArray<b3RigidBodyCL>* gpuBodies, b3OpenCLArray<b3InertiaCL>* gpuInertias,
|
||||
void b3GpuPgsConstraintSolver::solveJoints(int numBodies, b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias,
|
||||
int numConstraints, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints)
|
||||
{
|
||||
b3ContactSolverInfo infoGlobal;
|
||||
@@ -1026,10 +1026,10 @@ void b3GpuPgsConstraintSolver::solveJoints(int numBodies, b3OpenCLArray<b3RigidB
|
||||
|
||||
}
|
||||
|
||||
//b3AlignedObjectArray<b3RigidBodyCL> testBodies;
|
||||
//b3AlignedObjectArray<b3RigidBodyData> testBodies;
|
||||
|
||||
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyCL>* gpuBodies,b3OpenCLArray<b3InertiaCL>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal)
|
||||
b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal)
|
||||
{
|
||||
B3_PROFILE("solveGroupCacheFriendlyFinish");
|
||||
int numPoolConstraints = m_tmpSolverContactConstraintPool.size();
|
||||
@@ -1113,8 +1113,8 @@ b3Scalar b3GpuPgsConstraintSolver::solveGroupCacheFriendlyFinish(b3OpenCLArray<b
|
||||
//printf("bodyIndex=%d\n",bodyIndex);
|
||||
b3Assert(i==bodyIndex);
|
||||
|
||||
b3RigidBodyCL* body = &m_gpuData->m_cpuBodies[bodyIndex];
|
||||
if (body->getInvMass())
|
||||
b3RigidBodyData* body = &m_gpuData->m_cpuBodies[bodyIndex];
|
||||
if (body->m_invMass)
|
||||
{
|
||||
if (infoGlobal.m_splitImpulse)
|
||||
m_tmpSolverBodyPool[i].writebackVelocityAndTransform(infoGlobal.m_timeStep, infoGlobal.m_splitImpulseTurnErp);
|
||||
|
||||
@@ -27,8 +27,8 @@ class b3Dispatcher;
|
||||
#include "b3GpuSolverBody.h"
|
||||
#include "b3GpuSolverConstraint.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
struct b3RigidBodyCL;
|
||||
struct b3InertiaCL;
|
||||
struct b3RigidBodyData;
|
||||
struct b3InertiaData;
|
||||
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
|
||||
#include "b3GpuGenericConstraint.h"
|
||||
@@ -55,20 +55,20 @@ protected:
|
||||
|
||||
int m_numSplitImpulseRecoveries;
|
||||
|
||||
// int getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies,b3InertiaCL* inertias);
|
||||
void initSolverBody(int bodyIndex, b3GpuSolverBody* solverBody, b3RigidBodyCL* rb);
|
||||
// int getOrInitSolverBody(int bodyIndex, b3RigidBodyData* bodies,b3InertiaData* inertias);
|
||||
void initSolverBody(int bodyIndex, b3GpuSolverBody* solverBody, b3RigidBodyData* rb);
|
||||
|
||||
public:
|
||||
b3GpuPgsConstraintSolver (cl_context ctx, cl_device_id device, cl_command_queue queue,bool usePgs);
|
||||
virtual~b3GpuPgsConstraintSolver ();
|
||||
|
||||
virtual b3Scalar solveGroupCacheFriendlyIterations(b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints1,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
virtual b3Scalar solveGroupCacheFriendlySetup(b3OpenCLArray<b3RigidBodyCL>* gpuBodies, b3OpenCLArray<b3InertiaCL>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
b3Scalar solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyCL>* gpuBodies,b3OpenCLArray<b3InertiaCL>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
virtual b3Scalar solveGroupCacheFriendlySetup(b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
b3Scalar solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
|
||||
|
||||
b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyCL>* gpuBodies,b3OpenCLArray<b3InertiaCL>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
void solveJoints(int numBodies, b3OpenCLArray<b3RigidBodyCL>* gpuBodies, b3OpenCLArray<b3InertiaCL>* gpuInertias,
|
||||
b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
|
||||
void solveJoints(int numBodies, b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias,
|
||||
int numConstraints, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints);
|
||||
|
||||
int sortConstraintByBatch3( struct b3BatchConstraint* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies);
|
||||
|
||||
@@ -82,8 +82,8 @@ struct b3GpuBatchingPgsSolverInternalData
|
||||
b3OpenCLArray<b3SortData>* m_sortDataBuffer;
|
||||
b3OpenCLArray<b3Contact4>* m_contactBuffer;
|
||||
|
||||
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
|
||||
b3OpenCLArray<b3RigidBodyData>* m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3InertiaData>* m_inertiaBufferGPU;
|
||||
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPU;
|
||||
|
||||
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPUCopy;
|
||||
@@ -111,8 +111,8 @@ b3GpuPgsContactSolver::b3GpuPgsContactSolver(cl_context ctx,cl_device_id device,
|
||||
m_data->m_pairCapacity = pairCapacity;
|
||||
m_data->m_nIterations = 4;
|
||||
m_data->m_batchSizesGpu = new b3OpenCLArray<int>(ctx,q);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,q);
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,q);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyData>(ctx,q);
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaData>(ctx,q);
|
||||
m_data->m_pBufContactOutGPU = new b3OpenCLArray<b3Contact4>(ctx,q);
|
||||
|
||||
m_data->m_pBufContactOutGPUCopy = new b3OpenCLArray<b3Contact4>(ctx,q);
|
||||
@@ -293,7 +293,7 @@ struct b3ConstraintCfg
|
||||
|
||||
|
||||
|
||||
void b3GpuPgsContactSolver::solveContactConstraintBatchSizes( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void b3GpuPgsContactSolver::solveContactConstraintBatchSizes( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations, const b3AlignedObjectArray<int>* batchSizes)//const b3OpenCLArray<int>* gpuBatchSizes)
|
||||
{
|
||||
B3_PROFILE("solveContactConstraintBatchSizes");
|
||||
@@ -353,7 +353,7 @@ void b3GpuPgsContactSolver::solveContactConstraintBatchSizes( const b3OpenCLArr
|
||||
}
|
||||
}
|
||||
|
||||
void b3GpuPgsContactSolver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void b3GpuPgsContactSolver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations, const b3AlignedObjectArray<int>* batchSizes)//,const b3OpenCLArray<int>* gpuBatchSizes)
|
||||
{
|
||||
|
||||
@@ -582,7 +582,7 @@ static const int gridTable8x8[] =
|
||||
#define USE_4x4_GRID 1
|
||||
|
||||
|
||||
void SetSortDataCPU(b3Contact4* gContact, b3RigidBodyCL* gBodies, b3SortData* gSortDataOut, int nContacts,float scale,const b3Int4& nSplit,int staticIdx)
|
||||
void SetSortDataCPU(b3Contact4* gContact, b3RigidBodyData* gBodies, b3SortData* gSortDataOut, int nContacts,float scale,const b3Int4& nSplit,int staticIdx)
|
||||
{
|
||||
for (int gIdx=0;gIdx<nContacts;gIdx++)
|
||||
{
|
||||
@@ -761,10 +761,10 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
csCfg.m_staticIdx = static0Index;
|
||||
|
||||
|
||||
b3OpenCLArray<b3RigidBodyCL>* bodyBuf = m_data->m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3RigidBodyData>* bodyBuf = m_data->m_bodyBufferGPU;
|
||||
|
||||
void* additionalData = 0;//m_data->m_frictionCGPU;
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf = m_data->m_inertiaBufferGPU;
|
||||
const b3OpenCLArray<b3InertiaData>* shapeBuf = m_data->m_inertiaBufferGPU;
|
||||
b3OpenCLArray<b3GpuConstraint4>* contactConstraintOut = m_data->m_contactCGPU;
|
||||
int nContacts = nContactOut;
|
||||
|
||||
@@ -795,12 +795,12 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
|
||||
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyNative = bodyBuf;
|
||||
const b3OpenCLArray<b3RigidBodyData>* bodyNative = bodyBuf;
|
||||
|
||||
|
||||
{
|
||||
|
||||
//b3OpenCLArray<b3RigidBodyCL>* bodyNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
|
||||
//b3OpenCLArray<b3RigidBodyData>* bodyNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
|
||||
//b3OpenCLArray<b3Contact4>* contactNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, contactsIn );
|
||||
|
||||
const int sortAlignment = 512; // todo. get this out of sort
|
||||
@@ -855,7 +855,7 @@ void b3GpuPgsContactSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
b3AlignedObjectArray<b3Contact4> contactCPU;
|
||||
m_data->m_pBufContactOutGPU->copyToHost(contactCPU);
|
||||
b3AlignedObjectArray<b3RigidBodyCL> bodiesCPU;
|
||||
b3AlignedObjectArray<b3RigidBodyData> bodiesCPU;
|
||||
bodyBuf->copyToHost(bodiesCPU);
|
||||
float scale = 1.f/csCfg.m_batchCellSize;
|
||||
b3Int4 nSplit;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "b3GpuConstraint4.h"
|
||||
|
||||
@@ -24,10 +24,10 @@ protected:
|
||||
|
||||
|
||||
|
||||
void solveContactConstraintBatchSizes( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void solveContactConstraintBatchSizes( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations, const b3AlignedObjectArray<int>* batchSizes);//const b3OpenCLArray<int>* gpuBatchSizes);
|
||||
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations, const b3AlignedObjectArray<int>* batchSizes);//const b3OpenCLArray<int>* gpuBatchSizes);
|
||||
|
||||
public:
|
||||
|
||||
@@ -48,7 +48,7 @@ bool gIntegrateOnCpu = false;
|
||||
#include "b3GpuJacobiContactSolver.h"
|
||||
#endif //TEST_OTHER_GPU_SOLVER
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuPgsConstraintSolver.h"
|
||||
|
||||
@@ -317,9 +317,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
|
||||
//solve constraints
|
||||
|
||||
b3OpenCLArray<b3RigidBodyCL> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
|
||||
b3OpenCLArray<b3RigidBodyData> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuBodies.setFromOpenCLBuffer(m_data->m_narrowphase->getBodiesGpu(),m_data->m_narrowphase->getNumRigidBodies());
|
||||
b3OpenCLArray<b3InertiaCL> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
|
||||
b3OpenCLArray<b3InertiaData> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuInertias.setFromOpenCLBuffer(m_data->m_narrowphase->getBodyInertiasGpu(),m_data->m_narrowphase->getNumRigidBodies());
|
||||
b3OpenCLArray<b3Contact4> gpuContacts(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuContacts.setFromOpenCLBuffer(m_data->m_narrowphase->getContactsGpu(),m_data->m_narrowphase->getNumContactsGpu());
|
||||
@@ -340,9 +340,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
m_data->m_gpuSolver->solveJoints(m_data->m_narrowphase->getNumRigidBodies(),&gpuBodies,&gpuInertias,numJoints, m_data->m_gpuConstraints);
|
||||
} else
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodies;
|
||||
gpuBodies.copyToHost(hostBodies);
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3InertiaData> hostInertias;
|
||||
gpuInertias.copyToHost(hostInertias);
|
||||
|
||||
b3TypedConstraint** joints = numJoints? &m_data->m_joints[0] : 0;
|
||||
@@ -366,8 +366,8 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
bool forceHost = false;
|
||||
if (forceHost)
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodies;
|
||||
b3AlignedObjectArray<b3InertiaData> hostInertias;
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
|
||||
{
|
||||
@@ -399,9 +399,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
}
|
||||
} else
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
b3AlignedObjectArray<b3RigidBodyData> hostBodies;
|
||||
gpuBodies.copyToHost(hostBodies);
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3InertiaData> hostInertias;
|
||||
gpuInertias.copyToHost(hostInertias);
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
gpuContacts.copyToHost(hostContacts);
|
||||
|
||||
@@ -359,7 +359,7 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
|
||||
struct SolveTask// : public ThreadPool::Task
|
||||
{
|
||||
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<b3InertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
|
||||
SolveTask(b3AlignedObjectArray<b3RigidBodyData>& bodies, b3AlignedObjectArray<b3InertiaData>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
|
||||
int start, int nConstraints,int maxNumBatches,b3AlignedObjectArray<int>* wgUsedBodies, int curWgidx, b3AlignedObjectArray<int>* batchSizes, int cellIndex)
|
||||
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ),m_maxNumBatches(maxNumBatches),
|
||||
@@ -388,8 +388,8 @@ struct SolveTask// : public ThreadPool::Task
|
||||
int aIdx = (int)m_constraints[i].m_bodyA;
|
||||
int bIdx = (int)m_constraints[i].m_bodyB;
|
||||
int localBatch = m_constraints[i].m_batchIdx;
|
||||
b3RigidBodyCL& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyCL& bodyB = m_bodies[bIdx];
|
||||
b3RigidBodyData& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = m_bodies[bIdx];
|
||||
|
||||
if( !m_solveFriction )
|
||||
{
|
||||
@@ -439,8 +439,8 @@ struct SolveTask// : public ThreadPool::Task
|
||||
int aIdx = (int)m_constraints[i].m_bodyA;
|
||||
int bIdx = (int)m_constraints[i].m_bodyB;
|
||||
int localBatch = m_constraints[i].m_batchIdx;
|
||||
b3RigidBodyCL& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyCL& bodyB = m_bodies[bIdx];
|
||||
b3RigidBodyData& bodyA = m_bodies[aIdx];
|
||||
b3RigidBodyData& bodyB = m_bodies[bIdx];
|
||||
|
||||
if( !m_solveFriction )
|
||||
{
|
||||
@@ -479,8 +479,8 @@ struct SolveTask// : public ThreadPool::Task
|
||||
|
||||
}
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL>& m_bodies;
|
||||
b3AlignedObjectArray<b3InertiaCL>& m_shapes;
|
||||
b3AlignedObjectArray<b3RigidBodyData>& m_bodies;
|
||||
b3AlignedObjectArray<b3InertiaData>& m_shapes;
|
||||
b3AlignedObjectArray<b3GpuConstraint4>& m_constraints;
|
||||
b3AlignedObjectArray<int>* m_batchSizes;
|
||||
int m_cellIndex;
|
||||
@@ -492,7 +492,7 @@ struct SolveTask// : public ThreadPool::Task
|
||||
};
|
||||
|
||||
|
||||
void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyData>* bodyBuf, b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,b3AlignedObjectArray<int>* batchSizes)
|
||||
{
|
||||
|
||||
@@ -541,9 +541,9 @@ void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBu
|
||||
}
|
||||
#endif
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> bodyNative;
|
||||
b3AlignedObjectArray<b3RigidBodyData> bodyNative;
|
||||
bodyBuf->copyToHost(bodyNative);
|
||||
b3AlignedObjectArray<b3InertiaCL> shapeNative;
|
||||
b3AlignedObjectArray<b3InertiaData> shapeNative;
|
||||
shapeBuf->copyToHost(shapeNative);
|
||||
b3AlignedObjectArray<b3GpuConstraint4> constraintNative;
|
||||
constraint->copyToHost(constraintNative);
|
||||
@@ -674,8 +674,8 @@ void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBu
|
||||
|
||||
}
|
||||
|
||||
void checkConstraintBatch(const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void checkConstraintBatch(const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint,
|
||||
b3OpenCLArray<unsigned int>* m_numConstraints,
|
||||
b3OpenCLArray<unsigned int>* m_offsets,
|
||||
@@ -751,7 +751,7 @@ void checkConstraintBatch(const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
|
||||
static bool verify=false;
|
||||
|
||||
void b3Solver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void b3Solver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
|
||||
{
|
||||
|
||||
@@ -926,8 +926,8 @@ void b3Solver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* body
|
||||
|
||||
}
|
||||
|
||||
void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const ConstraintCfg& cfg )
|
||||
{
|
||||
@@ -952,13 +952,13 @@ void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf
|
||||
|
||||
if (gConvertConstraintOnCpu)
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> gBodies;
|
||||
b3AlignedObjectArray<b3RigidBodyData> gBodies;
|
||||
bodyBuf->copyToHost(gBodies);
|
||||
|
||||
b3AlignedObjectArray<b3Contact4> gContact;
|
||||
contactsIn->copyToHost(gContact);
|
||||
|
||||
b3AlignedObjectArray<b3InertiaCL> gShapes;
|
||||
b3AlignedObjectArray<b3InertiaData> gShapes;
|
||||
shapeBuf->copyToHost(gShapes);
|
||||
|
||||
b3AlignedObjectArray<b3GpuConstraint4> gConstraintOut;
|
||||
@@ -1021,7 +1021,7 @@ void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf
|
||||
}
|
||||
|
||||
/*
|
||||
void b3Solver::sortContacts( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
void b3Solver::sortContacts( const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, void* additionalData,
|
||||
int nContacts, const b3Solver::ConstraintCfg& cfg )
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "b3GpuConstraint4.h"
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3PrefixScanCL.h"
|
||||
@@ -103,15 +103,15 @@ class b3Solver : public b3SolverBase
|
||||
|
||||
virtual ~b3Solver();
|
||||
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* inertiaBuf,
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyData>* bodyBuf, const b3OpenCLArray<b3InertiaData>* inertiaBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
|
||||
|
||||
void solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void solveContactConstraintHost( b3OpenCLArray<b3RigidBodyData>* bodyBuf, b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, b3AlignedObjectArray<int>* batchSizes);
|
||||
|
||||
|
||||
void convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
void convertToConstraints( const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaData>* shapeBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const ConstraintCfg& cfg );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user