Merge pull request #1874 from John3/readmeUpdate
[Torque-3d.git] / Engine / lib / bullet / src / BulletMultiThreaded / GpuSoftBodySolvers / OpenCL / OpenCLC10 / UpdateConstants.cl
blob1d925a31fb63443be28798839f397e024d9b354f
1 MSTRINGIFY(
3 /*#define float3 float4
5 float dot3(float3 a, float3 b)
7 return a.x*b.x + a.y*b.y + a.z*b.z;
8 }*/
10 __kernel void
11 UpdateConstantsKernel(
12 const int numLinks,
13 __global int2 * g_linksVertexIndices,
14 __global float4 * g_vertexPositions,
15 __global float * g_vertexInverseMasses,
16 __global float * g_linksMaterialLSC,
17 __global float * g_linksMassLSC,
18 __global float * g_linksRestLengthSquared,
19 __global float * g_linksRestLengths)
21 int linkID = get_global_id(0);
22 if( linkID < numLinks )
24 int2 nodeIndices = g_linksVertexIndices[linkID];
25 int node0 = nodeIndices.x;
26 int node1 = nodeIndices.y;
27 float linearStiffnessCoefficient = g_linksMaterialLSC[ linkID ];
29 float3 position0 = g_vertexPositions[node0].xyz;
30 float3 position1 = g_vertexPositions[node1].xyz;
31 float inverseMass0 = g_vertexInverseMasses[node0];
32 float inverseMass1 = g_vertexInverseMasses[node1];
34 float3 difference = position0 - position1;
35 float length2 = dot(difference, difference);
36 float length = sqrt(length2);
38 g_linksRestLengths[linkID] = length;
39 g_linksMassLSC[linkID] = (inverseMass0 + inverseMass1)/linearStiffnessCoefficient;
40 g_linksRestLengthSquared[linkID] = length*length;