Enable MPR by default

Add the contact point from MPR, in addition to SAT/clipping contacts. Added a new kernel to clear/reset the number of contacts in pairs (stored in the z component)
Always sample unit sphere directions, if there are more edge-edge combinations than unit sphere directions (162 by default)
Remember last running demo for Bullet 3 (and save it in a text file, Bullet
Enable the testFileFracture.bullet in the Bullet2FileDemo
This commit is contained in:
Erwin Coumans
2014-01-15 10:35:51 -08:00
parent ca86e135de
commit 472a4068fc
27 changed files with 573 additions and 65 deletions

View File

@@ -16,8 +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 useUnitDirections = false;
bool useMprGpu = true;//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;
@@ -136,8 +135,7 @@ m_unitSphereDirections(m_context,m_queue)
// sprintf(flags,"-g -s \"%s\"","C:/develop/bullet3_experiments2/opencl/gpu_narrowphase/kernels/sat.cl");
//#endif
m_mprPenetrationKernel = 0;
m_findSeparatingAxisUnitSphereKernel = 0;
if (useMprGpu||useUnitDirections)
if (useMprGpu)
{
cl_program mprProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,mprSrc,&errNum,flags,BT_NARROWPHASE_MPR_PATH);
b3Assert(errNum==CL_SUCCESS);
@@ -146,9 +144,6 @@ m_unitSphereDirections(m_context,m_queue)
b3Assert(m_mprPenetrationKernel);
b3Assert(errNum==CL_SUCCESS);
m_findSeparatingAxisUnitSphereKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,mprSrc, "findSeparatingAxisUnitSphereKernel",&errNum,mprProg );
b3Assert(m_findSeparatingAxisUnitSphereKernel);
b3Assert(errNum==CL_SUCCESS);
int numDirections = sizeof(unitSphere162)/sizeof(b3Vector3);
m_unitSphereDirections.resize(numDirections);
@@ -290,8 +285,6 @@ GpuSatCollision::~GpuSatCollision()
if (m_mprPenetrationKernel)
clReleaseKernel(m_mprPenetrationKernel);
if (m_findSeparatingAxisUnitSphereKernel)
clReleaseKernel(m_findSeparatingAxisUnitSphereKernel);
if (m_findSeparatingAxisKernel)
clReleaseKernel(m_findSeparatingAxisKernel);
@@ -3169,7 +3162,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
}
}
// else
if (1)
{
@@ -3200,35 +3193,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
}
int numDirections = sizeof(unitSphere162)/sizeof(b3Vector3);
if (useUnitDirections)
{
B3_PROFILE("findSeparatingAxisUnitSphereKernel");
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( pairs->getBufferCL(), true ),
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
b3BufferInfoCL( convexData.getBufferCL(),true),
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
b3BufferInfoCL( m_unitSphereDirections.getBufferCL(),true),
b3BufferInfoCL( m_sepNormals.getBufferCL()),
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( m_dmins.getBufferCL())
};
b3LauncherCL launcher(m_queue, m_findSeparatingAxisUnitSphereKernel,"findSeparatingAxisUnitSphereKernel");
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
int numDirections = sizeof(unitSphere162)/sizeof(b3Vector3);
launcher.setConst( numDirections);
launcher.setConst( nPairs );
int num = nPairs;
launcher.launch1D( num);
clFinish(m_queue);
} else
{
B3_PROFILE("findSeparatingAxisEdgeEdgeKernel");
b3BufferInfoCL bInfo[] = {
@@ -3243,11 +3209,14 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray<b3Int4>*
b3BufferInfoCL( clAabbsWorldSpace.getBufferCL(),true),
b3BufferInfoCL( m_sepNormals.getBufferCL()),
b3BufferInfoCL( m_hasSeparatingNormals.getBufferCL()),
b3BufferInfoCL( m_dmins.getBufferCL())
b3BufferInfoCL( m_dmins.getBufferCL()),
b3BufferInfoCL( m_unitSphereDirections.getBufferCL(),true)
};
b3LauncherCL launcher(m_queue, m_findSeparatingAxisEdgeEdgeKernel,"findSeparatingAxisEdgeEdgeKernel");
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numDirections);
launcher.setConst( nPairs );
int num = nPairs;