prepare for GPU fixed constraint (not done yet)
This commit is contained in:
@@ -17,6 +17,9 @@ static const char* solveConstraintRowsCL= \
|
||||
"\n"
|
||||
"\n"
|
||||
"#define B3_GPU_POINT2POINT_CONSTRAINT_TYPE 3\n"
|
||||
"#define B3_GPU_FIXED_CONSTRAINT_TYPE 4\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"#define B3_INFINITY 1e30f\n"
|
||||
"\n"
|
||||
"#define mymake_float4 (float4)\n"
|
||||
@@ -361,6 +364,12 @@ static const char* solveConstraintRowsCL= \
|
||||
" batchConstraints[i].m_numConstraintRows = 3;\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" case B3_GPU_FIXED_CONSTRAINT_TYPE:\n"
|
||||
" {\n"
|
||||
" infos[i] = 6;\n"
|
||||
" batchConstraints[i].m_numConstraintRows = 6;\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" default:\n"
|
||||
" {\n"
|
||||
" }\n"
|
||||
@@ -502,6 +511,60 @@ static const char* solveConstraintRowsCL= \
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"/*\n"
|
||||
"@todo: convert this code to OpenCL\n"
|
||||
"void calculateDiffAxisAngleQuaternion(const b3Quaternion& orn0,const b3Quaternion& orn1a,b3Vector3& axis,b3Scalar& angle)\n"
|
||||
"{\n"
|
||||
" Quaternion orn1 = orn0.nearest(orn1a);\n"
|
||||
" Quaternion dorn = orn1 * orn0.inverse();\n"
|
||||
" angle = dorn.getAngle();\n"
|
||||
" axis = b3Vector3(dorn.getX(),dorn.getY(),dorn.getZ());\n"
|
||||
" axis[3] = b3Scalar(0.);\n"
|
||||
" //check for axis length\n"
|
||||
" b3Scalar len = axis.length2();\n"
|
||||
" if (len < B3_EPSILON*B3_EPSILON)\n"
|
||||
" axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.));\n"
|
||||
" else\n"
|
||||
" axis /= b3Sqrt(len);\n"
|
||||
"}\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"void getInfo2FixedOrientation(__global b3GpuGenericConstraint* constraint,b3GpuConstraintInfo2* info,__global b3RigidBodyCL* bodies, int start_row)\n"
|
||||
"{\n"
|
||||
" Quaternion worldOrnA = bodies[constraint->m_rbA].m_quat;\n"
|
||||
" Quaternion worldOrnB = bodies[constraint->m_rbB].m_quat;\n"
|
||||
"\n"
|
||||
" int s = info->rowskip;\n"
|
||||
" int start_index = start_row * s;\n"
|
||||
"\n"
|
||||
" // 3 rows to make body rotations equal\n"
|
||||
" info->m_J1angularAxis[start_index] = 1;\n"
|
||||
" info->m_J1angularAxis[start_index + s + 1] = 1;\n"
|
||||
" info->m_J1angularAxis[start_index + s*2+2] = 1;\n"
|
||||
" if ( info->m_J2angularAxis)\n"
|
||||
" {\n"
|
||||
" info->m_J2angularAxis[start_index] = -1;\n"
|
||||
" info->m_J2angularAxis[start_index + s+1] = -1;\n"
|
||||
" info->m_J2angularAxis[start_index + s*2+2] = -1;\n"
|
||||
" }\n"
|
||||
" /*\n"
|
||||
" @todo\n"
|
||||
" float currERP = info->erp;\n"
|
||||
" float k = info->fps * currERP;\n"
|
||||
" float4 diff;\n"
|
||||
" float angle;\n"
|
||||
" float4 qrelCur = worldOrnA *qtInvert(worldOrnB);\n"
|
||||
"\n"
|
||||
" calculateDiffAxisAngleQuaternion(constraint->m_relTargetAB,qrelCur,diff,angle);\n"
|
||||
" diff*=-angle;\n"
|
||||
" for (j=0; j<3; j++)\n"
|
||||
" {\n"
|
||||
" info->m_constraintError[(start_row+j)*info->rowskip] = k * diff[j];\n"
|
||||
" }\n"
|
||||
" */\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void writeBackVelocitiesKernel(__global b3RigidBodyCL* bodies,__global b3GpuSolverBody* solverBodies,int numBodies)\n"
|
||||
"{\n"
|
||||
@@ -653,6 +716,15 @@ static const char* solveConstraintRowsCL= \
|
||||
" getInfo2Point2Point(constraint,&info2,bodies);\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" case B3_GPU_FIXED_CONSTRAINT_TYPE:\n"
|
||||
" {\n"
|
||||
" getInfo2Point2Point(constraint,&info2,bodies);\n"
|
||||
"\n"
|
||||
" getInfo2FixedOrientation(constraint,&info2,bodies,3);\n"
|
||||
"\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" default:\n"
|
||||
" {\n"
|
||||
" }\n"
|
||||
|
||||
Reference in New Issue
Block a user