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:
@@ -24,6 +24,11 @@ static const char* batchingKernelsCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* batchingKernelsCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"typedef struct b3Contact4Data b3Contact4Data_t;\n"
|
||||
"struct b3Contact4Data\n"
|
||||
|
||||
@@ -24,6 +24,11 @@ static const char* batchingKernelsNewCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* batchingKernelsNewCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"typedef struct b3Contact4Data b3Contact4Data_t;\n"
|
||||
"struct b3Contact4Data\n"
|
||||
|
||||
@@ -24,6 +24,11 @@ static const char* integrateKernelCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* integrateKernelCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"#ifndef B3_QUAT_H\n"
|
||||
"#define B3_QUAT_H\n"
|
||||
@@ -89,6 +117,7 @@ static const char* integrateKernelCL= \
|
||||
"inline b3Quat b3QuatNormalized(b3QuatConstArg in);\n"
|
||||
"inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)\n"
|
||||
"{\n"
|
||||
" b3Quat ans;\n"
|
||||
@@ -123,6 +152,10 @@ static const char* integrateKernelCL= \
|
||||
" float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);\n"
|
||||
" return out;\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
|
||||
@@ -24,6 +24,11 @@ static const char* solverSetupCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* solverSetupCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"typedef struct b3Contact4Data b3Contact4Data_t;\n"
|
||||
"struct b3Contact4Data\n"
|
||||
@@ -151,6 +179,7 @@ static const char* solverSetupCL= \
|
||||
"inline b3Quat b3QuatNormalized(b3QuatConstArg in);\n"
|
||||
"inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)\n"
|
||||
"{\n"
|
||||
" b3Quat ans;\n"
|
||||
@@ -185,6 +214,10 @@ static const char* solverSetupCL= \
|
||||
" float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);\n"
|
||||
" return out;\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
|
||||
@@ -24,6 +24,11 @@ static const char* solverSetup2CL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* solverSetup2CL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"typedef struct b3Contact4Data b3Contact4Data_t;\n"
|
||||
"struct b3Contact4Data\n"
|
||||
|
||||
@@ -24,6 +24,11 @@ static const char* solverUtilsCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -60,6 +65,29 @@ static const char* solverUtilsCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"typedef struct b3Contact4Data b3Contact4Data_t;\n"
|
||||
"struct b3Contact4Data\n"
|
||||
|
||||
@@ -11,3 +11,12 @@ __kernel void initializeGpuAabbsFull( const int numNodes, __global b3RigidBodyD
|
||||
b3ComputeWorldAabb(nodeID, gBodies, collidables, plocalShapeAABB,pAABB);
|
||||
}
|
||||
}
|
||||
|
||||
__kernel void clearOverlappingPairsKernel( __global int4* pairs, int numPairs)
|
||||
{
|
||||
int pairId = get_global_id(0);
|
||||
if( pairId< numPairs )
|
||||
{
|
||||
pairs[pairId].z = 0xffffffff;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ static const char* updateAabbsKernelCL= \
|
||||
"};\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"#else\n"
|
||||
"//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
|
||||
"#define B3_LARGE_FLOAT 1e18f\n"
|
||||
"#define B3_INFINITY 1e18f\n"
|
||||
"#define b3Assert(a)\n"
|
||||
"#define b3ConstArray(a) __global const a*\n"
|
||||
"#define b3AtomicInc atomic_inc\n"
|
||||
"#define b3AtomicAdd atomic_add\n"
|
||||
"#define b3Fabs fabs\n"
|
||||
@@ -50,6 +55,29 @@ static const char* updateAabbsKernelCL= \
|
||||
" return false;\n"
|
||||
" return true;\n"
|
||||
"}\n"
|
||||
"inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
|
||||
"{\n"
|
||||
" float maxDot = -B3_INFINITY;\n"
|
||||
" int i = 0;\n"
|
||||
" int ptIndex = -1;\n"
|
||||
" for( i = 0; i < vecLen; i++ )\n"
|
||||
" {\n"
|
||||
" float dot = b3Dot3F4(vecArray[i],vec);\n"
|
||||
" \n"
|
||||
" if( dot > maxDot )\n"
|
||||
" {\n"
|
||||
" maxDot = dot;\n"
|
||||
" ptIndex = i;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" b3Assert(ptIndex>=0);\n"
|
||||
" if (ptIndex<0)\n"
|
||||
" {\n"
|
||||
" ptIndex = 0;\n"
|
||||
" }\n"
|
||||
" *dotOut = maxDot;\n"
|
||||
" return ptIndex;\n"
|
||||
"}\n"
|
||||
"#endif //B3_FLOAT4_H\n"
|
||||
"#ifndef B3_MAT3x3_H\n"
|
||||
"#define B3_MAT3x3_H\n"
|
||||
@@ -81,6 +109,7 @@ static const char* updateAabbsKernelCL= \
|
||||
"inline b3Quat b3QuatNormalized(b3QuatConstArg in);\n"
|
||||
"inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q);\n"
|
||||
"inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)\n"
|
||||
"{\n"
|
||||
" b3Quat ans;\n"
|
||||
@@ -115,6 +144,10 @@ static const char* updateAabbsKernelCL= \
|
||||
" float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);\n"
|
||||
" return out;\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInverse(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
"}\n"
|
||||
"inline b3Quat b3QuatInvert(b3QuatConstArg q)\n"
|
||||
"{\n"
|
||||
" return (b3Quat)(-q.xyz, q.w);\n"
|
||||
@@ -422,4 +455,12 @@ static const char* updateAabbsKernelCL= \
|
||||
" b3ComputeWorldAabb(nodeID, gBodies, collidables, plocalShapeAABB,pAABB);\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"__kernel void clearOverlappingPairsKernel( __global int4* pairs, int numPairs)\n"
|
||||
"{\n"
|
||||
" int pairId = get_global_id(0);\n"
|
||||
" if( pairId< numPairs )\n"
|
||||
" {\n"
|
||||
" pairs[pairId].z = 0xffffffff;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user