Deterministic simulation for concave and compound collision shapes: added childShapeA/B to b3Contact4 + sort on them
Use tetrahedra instead of barrel for convex demo (until performance for edge-edge is improved) Increased #overlapping pair capacity from 12 to 16 / objec
This commit is contained in:
@@ -73,6 +73,12 @@ typedef struct
|
||||
|
||||
int m_bodyA;//sign bit set for fixed objects
|
||||
int m_bodyB;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
}Contact4;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -75,6 +75,12 @@ static const char* batchingKernelsCL= \
|
||||
"\n"
|
||||
" int m_bodyA;//sign bit set for fixed objects\n"
|
||||
" int m_bodyB;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"}Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct \n"
|
||||
|
||||
@@ -74,6 +74,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;//sign bit set for fixed objects
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
}Contact4;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -76,6 +76,12 @@ static const char* batchingKernelsNewCL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;//sign bit set for fixed objects\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"}Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct \n"
|
||||
|
||||
@@ -357,12 +357,10 @@ __kernel void breakViolatedConstraintsKernel(__global b3GpuGenericConstraint* co
|
||||
int numRows = numConstraintRows[cid];
|
||||
if (numRows)
|
||||
{
|
||||
// printf("cid=%d, breakingThreshold =%f\n",cid,breakingThreshold);
|
||||
for (int i=0;i<numRows;i++)
|
||||
{
|
||||
int rowIndex = rowOffsets[cid]+i;
|
||||
float breakingThreshold = constraints[cid].m_breakingImpulseThreshold;
|
||||
// printf("rows[%d].m_appliedImpulse=%f\n",rowIndex,rows[rowIndex].m_appliedImpulse);
|
||||
if (fabs(rows[rowIndex].m_appliedImpulse) >= breakingThreshold)
|
||||
{
|
||||
constraints[cid].m_flags =0;//&= ~B3_CONSTRAINT_FLAG_ENABLED;
|
||||
|
||||
@@ -359,12 +359,10 @@ static const char* solveConstraintRowsCL= \
|
||||
" int numRows = numConstraintRows[cid];\n"
|
||||
" if (numRows)\n"
|
||||
" {\n"
|
||||
" // printf(\"cid=%d, breakingThreshold =%f\n\",cid,breakingThreshold);\n"
|
||||
" for (int i=0;i<numRows;i++)\n"
|
||||
" {\n"
|
||||
" int rowIndex = rowOffsets[cid]+i;\n"
|
||||
" float breakingThreshold = constraints[cid].m_breakingImpulseThreshold;\n"
|
||||
" // printf(\"rows[%d].m_appliedImpulse=%f\n\",rowIndex,rows[rowIndex].m_appliedImpulse);\n"
|
||||
" if (fabs(rows[rowIndex].m_appliedImpulse) >= breakingThreshold)\n"
|
||||
" {\n"
|
||||
" constraints[cid].m_flags =0;//&= ~B3_CONSTRAINT_FLAG_ENABLED;\n"
|
||||
|
||||
@@ -213,6 +213,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
} Contact4;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -215,6 +215,12 @@ static const char* solveContactCL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
" \n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
|
||||
@@ -213,6 +213,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
} Contact4;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -215,6 +215,12 @@ static const char* solveFrictionCL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
|
||||
@@ -412,6 +412,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
} Contact4;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -414,6 +414,12 @@ static const char* solverSetupCL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
|
||||
@@ -386,6 +386,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
} Contact4;
|
||||
|
||||
typedef struct
|
||||
@@ -441,22 +447,53 @@ void ReorderContactKernel(__global Contact4* in, __global Contact4* out, __globa
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__kernel
|
||||
__attribute__((reqd_work_group_size(WG_SIZE,1,1)))
|
||||
void SetDeterminismSortDataBodyA(__global Contact4* contactsIn, __global int2* sortDataOut, int nContacts)
|
||||
__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))
|
||||
void SetDeterminismSortDataChildShapeB(__global Contact4* contactsIn, __global int2* sortDataOut, int nContacts)
|
||||
{
|
||||
int gIdx = GET_GLOBAL_IDX;
|
||||
|
||||
if( gIdx < nContacts )
|
||||
{
|
||||
int2 sd;
|
||||
sd.x = contactsIn[gIdx].m_bodyAPtrAndSignBit;
|
||||
sd.x = contactsIn[gIdx].m_childIndexB;
|
||||
sd.y = gIdx;
|
||||
sortDataOut[gIdx] = sd;
|
||||
}
|
||||
}
|
||||
|
||||
__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))
|
||||
void SetDeterminismSortDataChildShapeA(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)
|
||||
{
|
||||
int gIdx = GET_GLOBAL_IDX;
|
||||
|
||||
if( gIdx < nContacts )
|
||||
{
|
||||
int2 sdIn;
|
||||
sdIn = sortDataInOut[gIdx];
|
||||
int2 sdOut;
|
||||
sdOut.x = contactsIn[sdIn.y].m_childIndexA;
|
||||
sdOut.y = sdIn.y;
|
||||
sortDataInOut[gIdx] = sdOut;
|
||||
}
|
||||
}
|
||||
|
||||
__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))
|
||||
void SetDeterminismSortDataBodyA(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)
|
||||
{
|
||||
int gIdx = GET_GLOBAL_IDX;
|
||||
|
||||
if( gIdx < nContacts )
|
||||
{
|
||||
int2 sdIn;
|
||||
sdIn = sortDataInOut[gIdx];
|
||||
int2 sdOut;
|
||||
sdOut.x = contactsIn[sdIn.y].m_bodyAPtrAndSignBit;
|
||||
sdOut.y = sdIn.y;
|
||||
sortDataInOut[gIdx] = sdOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__kernel
|
||||
__attribute__((reqd_work_group_size(WG_SIZE,1,1)))
|
||||
void SetDeterminismSortDataBodyB(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)
|
||||
|
||||
@@ -388,6 +388,12 @@ static const char* solverSetup2CL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
@@ -443,22 +449,53 @@ static const char* solverSetup2CL= \
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel\n"
|
||||
"__attribute__((reqd_work_group_size(WG_SIZE,1,1)))\n"
|
||||
"void SetDeterminismSortDataBodyA(__global Contact4* contactsIn, __global int2* sortDataOut, int nContacts)\n"
|
||||
"__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))\n"
|
||||
"void SetDeterminismSortDataChildShapeA(__global Contact4* contactsIn, __global int2* sortDataOut, int nContacts)\n"
|
||||
"{\n"
|
||||
" int gIdx = GET_GLOBAL_IDX;\n"
|
||||
"\n"
|
||||
" if( gIdx < nContacts )\n"
|
||||
" {\n"
|
||||
" int2 sd;\n"
|
||||
" sd.x = contactsIn[gIdx].m_bodyAPtrAndSignBit;\n"
|
||||
" sd.x = contactsIn[gIdx].m_childIndexA;\n"
|
||||
" sd.y = gIdx;\n"
|
||||
" sortDataOut[gIdx] = sd;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))\n"
|
||||
"void SetDeterminismSortDataChildShapeB(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)\n"
|
||||
"{\n"
|
||||
" int gIdx = GET_GLOBAL_IDX;\n"
|
||||
"\n"
|
||||
" if( gIdx < nContacts )\n"
|
||||
" {\n"
|
||||
" int2 sdIn;\n"
|
||||
" sdIn = sortDataInOut[gIdx];\n"
|
||||
" int2 sdOut;\n"
|
||||
" sdOut.x = contactsIn[sdIn.y].m_childIndexB;\n"
|
||||
" sdOut.y = sdIn.y;\n"
|
||||
" sortDataInOut[gIdx] = sdOut;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"__kernel __attribute__((reqd_work_group_size(WG_SIZE,1,1)))\n"
|
||||
"void SetDeterminismSortDataBodyA(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)\n"
|
||||
"{\n"
|
||||
" int gIdx = GET_GLOBAL_IDX;\n"
|
||||
"\n"
|
||||
" if( gIdx < nContacts )\n"
|
||||
" {\n"
|
||||
" int2 sdIn;\n"
|
||||
" sdIn = sortDataInOut[gIdx];\n"
|
||||
" int2 sdOut;\n"
|
||||
" sdOut.x = contactsIn[sdIn.y].m_bodyAPtrAndSignBit;\n"
|
||||
" sdOut.y = sdIn.y;\n"
|
||||
" sortDataInOut[gIdx] = sdOut;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel\n"
|
||||
"__attribute__((reqd_work_group_size(WG_SIZE,1,1)))\n"
|
||||
"void SetDeterminismSortDataBodyB(__global Contact4* contactsIn, __global int2* sortDataInOut, int nContacts)\n"
|
||||
|
||||
@@ -389,6 +389,12 @@ typedef struct
|
||||
|
||||
int m_bodyAPtrAndSignBit;
|
||||
int m_bodyBPtrAndSignBit;
|
||||
|
||||
int m_childIndexA;
|
||||
int m_childIndexB;
|
||||
int m_unused1;
|
||||
int m_unused2;
|
||||
|
||||
} Contact4;
|
||||
|
||||
|
||||
|
||||
@@ -391,6 +391,12 @@ static const char* solverUtilsCL= \
|
||||
"\n"
|
||||
" int m_bodyAPtrAndSignBit;\n"
|
||||
" int m_bodyBPtrAndSignBit;\n"
|
||||
"\n"
|
||||
" int m_childIndexA;\n"
|
||||
" int m_childIndexB;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"\n"
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
|
||||
Reference in New Issue
Block a user