bugfix for compound versus concave: compute the DeltaC2 after computing the (child) transforms for proper center
This commit is contained in:
@@ -53,12 +53,17 @@ m_totalContactsOut(m_context, m_queue)
|
||||
m_totalContactsOut.push_back(0);
|
||||
|
||||
cl_int errNum=0;
|
||||
bool disableKernelCaching = true;
|
||||
|
||||
if (1)
|
||||
{
|
||||
const char* src = satKernelsCL;
|
||||
cl_program satProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,src,&errNum,"","opencl/gpu_sat/kernels/sat.cl",true);
|
||||
|
||||
char flags[1024]={0};
|
||||
//#ifdef CL_PLATFORM_INTEL
|
||||
// sprintf(flags,"-g -s \"%s\"","C:/develop/bullet3_experiments2/opencl/gpu_sat/kernels/sat.cl");
|
||||
//#endif
|
||||
|
||||
cl_program satProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,src,&errNum,flags,"opencl/gpu_sat/kernels/sat.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
|
||||
m_findSeparatingAxisKernel = btOpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findSeparatingAxisKernel",&errNum,satProg );
|
||||
@@ -80,7 +85,13 @@ m_totalContactsOut(m_context, m_queue)
|
||||
if (1)
|
||||
{
|
||||
const char* srcClip = satClipKernelsCL;
|
||||
cl_program satClipContactsProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,srcClip,&errNum,"","opencl/gpu_sat/kernels/satClipHullContacts.cl",true);
|
||||
|
||||
char flags[1024]={0};
|
||||
//#ifdef CL_PLATFORM_INTEL
|
||||
// sprintf(flags,"-g -s \"%s\"","C:/develop/bullet3_experiments2/opencl/gpu_sat/kernels/satClipHullContacts.cl");
|
||||
//#endif
|
||||
|
||||
cl_program satClipContactsProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,srcClip,&errNum,flags,"opencl/gpu_sat/kernels/satClipHullContacts.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
|
||||
m_clipHullHullKernel = btOpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipHullHullKernel",&errNum,satClipContactsProg);
|
||||
@@ -120,8 +131,7 @@ m_totalContactsOut(m_context, m_queue)
|
||||
if (1)
|
||||
{
|
||||
const char* srcBvh = bvhTraversalKernelCL;
|
||||
cl_program bvhTraversalProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,srcBvh,&errNum,"","opencl/gpu_sat/kernels/bvhTraversal.cl",true);
|
||||
//cl_program bvhTraversalProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,0,&errNum,"","opencl/gpu_sat/kernels/bvhTraversal.cl", true);
|
||||
cl_program bvhTraversalProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,srcBvh,&errNum,"","opencl/gpu_sat/kernels/bvhTraversal.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
|
||||
m_bvhTraversalKernel = btOpenCLUtils::compileCLKernelFromString(m_context, m_device,srcBvh, "bvhTraversalKernel",&errNum,bvhTraversalProg,"");
|
||||
@@ -131,7 +141,7 @@ m_totalContactsOut(m_context, m_queue)
|
||||
|
||||
{
|
||||
const char* primitiveContactsSrc = primitiveContactsKernelsCL;
|
||||
cl_program primitiveContactsProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,primitiveContactsSrc,&errNum,"","opencl/gpu_sat/kernels/primitiveContacts.cl",true);
|
||||
cl_program primitiveContactsProg = btOpenCLUtils::compileCLProgramFromString(m_context,m_device,primitiveContactsSrc,&errNum,"","opencl/gpu_sat/kernels/primitiveContacts.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
|
||||
m_primitiveContactsKernel = btOpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "primitiveContactsKernel",&errNum,primitiveContactsProg,"");
|
||||
@@ -1132,12 +1142,11 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
|
||||
btAlignedObjectArray<btVector3> cpuCompoundSepNormals;
|
||||
concaveSepNormals.copyToHost(cpuCompoundSepNormals);
|
||||
btAlignedObjectArray<btInt4> cpuConcavePairs;
|
||||
triangleConvexPairsOut.copyToHost(cpuConcavePairs);
|
||||
// btAlignedObjectArray<btVector3> cpuCompoundSepNormals;
|
||||
// concaveSepNormals.copyToHost(cpuCompoundSepNormals);
|
||||
// btAlignedObjectArray<btInt4> cpuConcavePairs;
|
||||
// triangleConvexPairsOut.copyToHost(cpuConcavePairs);
|
||||
|
||||
printf("!\n");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1345,7 +1354,10 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
launcher.launch1D( num);
|
||||
clFinish(m_queue);
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
//printf("nContacts after = %d\n", nContacts);
|
||||
contactOut->resize(nContacts);
|
||||
btAlignedObjectArray<btContact4> cpuContacts;
|
||||
contactOut->copyToHost(cpuContacts);
|
||||
// printf("nContacts after = %d\n", nContacts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -357,12 +357,18 @@ void btConvexUtility::initialize()
|
||||
edge.normalize();
|
||||
|
||||
bool found = false;
|
||||
btVector3 diff,diff2;
|
||||
|
||||
for (int p=0;p<m_uniqueEdges.size();p++)
|
||||
{
|
||||
|
||||
if (IsAlmostZero(m_uniqueEdges[p]-edge) ||
|
||||
IsAlmostZero(m_uniqueEdges[p]+edge))
|
||||
diff = m_uniqueEdges[p]-edge;
|
||||
diff2 = m_uniqueEdges[p]+edge;
|
||||
|
||||
// if ((diff.length2()==0.f) ||
|
||||
// (diff2.length2()==0.f))
|
||||
|
||||
if (IsAlmostZero(diff) ||
|
||||
IsAlmostZero(diff2))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@@ -376,8 +382,9 @@ void btConvexUtility::initialize()
|
||||
|
||||
if (edptr)
|
||||
{
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1<0);
|
||||
//TBD: figure out why I added this assert
|
||||
// btAssert(edptr->m_face0>=0);
|
||||
// btAssert(edptr->m_face1<0);
|
||||
edptr->m_face1 = i;
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -1222,13 +1222,10 @@ __kernel void findConcaveSeparatingAxisKernel( __global int4* concavePairs,
|
||||
posA.w = 0.f;
|
||||
float4 posB = rigidBodies[bodyIndexB].m_pos;
|
||||
posB.w = 0.f;
|
||||
float4 c0local = convexPolyhedronA.m_localCenter;
|
||||
|
||||
float4 ornA = rigidBodies[bodyIndexA].m_quat;
|
||||
float4 c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c1local = convexShapes[shapeIndexB].m_localCenter;
|
||||
float4 ornB =rigidBodies[bodyIndexB].m_quat;
|
||||
float4 c1 = transform(&c1local,&posB,&ornB);
|
||||
const float4 DeltaC2 = c0 - c1;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1250,6 +1247,12 @@ __kernel void findConcaveSeparatingAxisKernel( __global int4* concavePairs,
|
||||
}
|
||||
//////////////////
|
||||
|
||||
float4 c0local = convexPolyhedronA.m_localCenter;
|
||||
float4 c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c1local = convexShapes[shapeIndexB].m_localCenter;
|
||||
float4 c1 = transform(&c1local,&posB,&ornB);
|
||||
const float4 DeltaC2 = c0 - c1;
|
||||
|
||||
|
||||
bool sepA = findSeparatingAxisLocalA( &convexPolyhedronA, &convexShapes[shapeIndexB],
|
||||
posA,ornA,
|
||||
|
||||
@@ -1404,13 +1404,9 @@ __kernel void clipHullHullConcaveConvexKernel( __global int4* concavePairsIn,
|
||||
posA.w = 0.f;
|
||||
float4 posB = rigidBodies[bodyIndexB].m_pos;
|
||||
posB.w = 0.f;
|
||||
float4 c0local = convexPolyhedronA.m_localCenter;
|
||||
float4 ornA = rigidBodies[bodyIndexA].m_quat;
|
||||
float4 c0 = transform(&c0local, &posA, &ornA);
|
||||
float4 c1local = convexShapes[shapeIndexB].m_localCenter;
|
||||
float4 ornB =rigidBodies[bodyIndexB].m_quat;
|
||||
float4 c1 = transform(&c1local,&posB,&ornB);
|
||||
const float4 DeltaC2 = c0 - c1;
|
||||
|
||||
|
||||
float4 sepAxis = separatingNormals[i];
|
||||
|
||||
@@ -1419,16 +1415,17 @@ __kernel void clipHullHullConcaveConvexKernel( __global int4* concavePairsIn,
|
||||
{
|
||||
///////////////////
|
||||
///compound shape support
|
||||
int compoundChild = concavePairsIn[pairIndex].w;
|
||||
int childShapeIndexB = collidables[collidableIndexB].m_shapeIndex+compoundChild;
|
||||
|
||||
int childShapeIndexB = concavePairsIn[pairIndex].w;
|
||||
int childColIndexB = gpuChildShapes[childShapeIndexB].m_shapeIndex;
|
||||
shapeIndexB = collidables[childColIndexB].m_shapeIndex;
|
||||
float4 childPosB = gpuChildShapes[childShapeIndexB].m_childPosition;
|
||||
float4 childOrnB = gpuChildShapes[childShapeIndexB].m_childOrientation;
|
||||
float4 newPosB = transform(&childPosB,&posB,&ornB);
|
||||
float4 newOrnB = qtMul(ornB,childOrnB);
|
||||
posB = newPosB;
|
||||
ornB = newOrnB;
|
||||
shapeIndexB = collidables[childColIndexB].m_shapeIndex;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
@@ -1406,13 +1406,9 @@ static const char* satClipKernelsCL= \
|
||||
" posA.w = 0.f;\n"
|
||||
" float4 posB = rigidBodies[bodyIndexB].m_pos;\n"
|
||||
" posB.w = 0.f;\n"
|
||||
" float4 c0local = convexPolyhedronA.m_localCenter;\n"
|
||||
" float4 ornA = rigidBodies[bodyIndexA].m_quat;\n"
|
||||
" float4 c0 = transform(&c0local, &posA, &ornA);\n"
|
||||
" float4 c1local = convexShapes[shapeIndexB].m_localCenter;\n"
|
||||
" float4 ornB =rigidBodies[bodyIndexB].m_quat;\n"
|
||||
" float4 c1 = transform(&c1local,&posB,&ornB);\n"
|
||||
" const float4 DeltaC2 = c0 - c1;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" float4 sepAxis = separatingNormals[i];\n"
|
||||
" \n"
|
||||
@@ -1421,16 +1417,17 @@ static const char* satClipKernelsCL= \
|
||||
" {\n"
|
||||
" ///////////////////\n"
|
||||
" ///compound shape support\n"
|
||||
" int compoundChild = concavePairsIn[pairIndex].w;\n"
|
||||
" int childShapeIndexB = collidables[collidableIndexB].m_shapeIndex+compoundChild;\n"
|
||||
" \n"
|
||||
" int childShapeIndexB = concavePairsIn[pairIndex].w;\n"
|
||||
" int childColIndexB = gpuChildShapes[childShapeIndexB].m_shapeIndex;\n"
|
||||
" shapeIndexB = collidables[childColIndexB].m_shapeIndex;\n"
|
||||
" float4 childPosB = gpuChildShapes[childShapeIndexB].m_childPosition;\n"
|
||||
" float4 childOrnB = gpuChildShapes[childShapeIndexB].m_childOrientation;\n"
|
||||
" float4 newPosB = transform(&childPosB,&posB,&ornB);\n"
|
||||
" float4 newOrnB = qtMul(ornB,childOrnB);\n"
|
||||
" posB = newPosB;\n"
|
||||
" ornB = newOrnB;\n"
|
||||
" shapeIndexB = collidables[childColIndexB].m_shapeIndex;\n"
|
||||
" \n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" ////////////////////////////////////////\n"
|
||||
|
||||
@@ -1224,13 +1224,10 @@ static const char* satKernelsCL= \
|
||||
" posA.w = 0.f;\n"
|
||||
" float4 posB = rigidBodies[bodyIndexB].m_pos;\n"
|
||||
" posB.w = 0.f;\n"
|
||||
" float4 c0local = convexPolyhedronA.m_localCenter;\n"
|
||||
"\n"
|
||||
" float4 ornA = rigidBodies[bodyIndexA].m_quat;\n"
|
||||
" float4 c0 = transform(&c0local, &posA, &ornA);\n"
|
||||
" float4 c1local = convexShapes[shapeIndexB].m_localCenter;\n"
|
||||
" float4 ornB =rigidBodies[bodyIndexB].m_quat;\n"
|
||||
" float4 c1 = transform(&c1local,&posB,&ornB);\n"
|
||||
" const float4 DeltaC2 = c0 - c1;\n"
|
||||
"\n"
|
||||
" \n"
|
||||
"\n"
|
||||
"\n"
|
||||
@@ -1252,6 +1249,12 @@ static const char* satKernelsCL= \
|
||||
" }\n"
|
||||
" //////////////////\n"
|
||||
"\n"
|
||||
" float4 c0local = convexPolyhedronA.m_localCenter;\n"
|
||||
" float4 c0 = transform(&c0local, &posA, &ornA);\n"
|
||||
" float4 c1local = convexShapes[shapeIndexB].m_localCenter;\n"
|
||||
" float4 c1 = transform(&c1local,&posB,&ornB);\n"
|
||||
" const float4 DeltaC2 = c0 - c1;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" bool sepA = findSeparatingAxisLocalA( &convexPolyhedronA, &convexShapes[shapeIndexB],\n"
|
||||
" posA,ornA,\n"
|
||||
|
||||
Reference in New Issue
Block a user