diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl index 18626232c..8f517eb1f 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl @@ -1539,7 +1539,7 @@ inline int findClippingFaces(const float4 separatingNormal, int numWorldVertsB1= 0; - int closestFaceB=-1; + int closestFaceB=0; float dmax = -FLT_MAX; { @@ -1573,7 +1573,7 @@ inline int findClippingFaces(const float4 separatingNormal, } } - int closestFaceA=-1; + int closestFaceA=0; { float dmin = FLT_MAX; for(int face=0;facem_numFaces;face++) diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl index 08876460e..aad795a64 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcave.cl @@ -597,7 +597,7 @@ inline int findClippingFaces(const float4 separatingNormal, int numWorldVertsB1= 0; - int closestFaceB=-1; + int closestFaceB=0; float dmax = -FLT_MAX; { @@ -620,6 +620,8 @@ inline int findClippingFaces(const float4 separatingNormal, int numVertices = polyB.m_numIndices; if (numVertices>capacityWorldVerts) numVertices = capacityWorldVerts; + if (numVertices<0) + numVertices = 0; for(int e0=0;e0m_numFaces;face++) @@ -656,6 +658,8 @@ inline int findClippingFaces(const float4 separatingNormal, int numVerticesA = facesA[hullA->m_faceOffset+closestFaceA].m_numIndices; if (numVerticesA>capacityWorldVerts) numVerticesA = capacityWorldVerts; + if (numVerticesA<0) + numVerticesA=0; for(int e0=0;e0capacityWorldVerts)\n" " numVertices = capacityWorldVerts;\n" +" if (numVertices<0)\n" +" numVertices = 0;\n" " \n" " for(int e0=0;e0m_numFaces;face++)\n" @@ -868,6 +870,8 @@ static const char* satConcaveKernelsCL= \ " int numVerticesA = facesA[hullA->m_faceOffset+closestFaceA].m_numIndices;\n" " if (numVerticesA>capacityWorldVerts)\n" " numVerticesA = capacityWorldVerts;\n" +" if (numVerticesA<0)\n" +" numVerticesA=0;\n" " \n" " for(int e0=0;e0m_numFaces;face++)\n"