Imported Upstream version 2.81
[platform/upstream/libbullet.git] / src / BulletMultiThreaded / GpuSoftBodySolvers / OpenCL / OpenCLC10 / UpdatePositions.cl
1 MSTRINGIFY(\r
2 \r
3 __kernel void \r
4 updateVelocitiesFromPositionsWithoutVelocitiesKernel( \r
5         const int numNodes,\r
6         const float isolverdt,\r
7         __global float4 * g_vertexPositions,\r
8         __global float4 * g_vertexPreviousPositions,\r
9         __global int * g_vertexClothIndices,\r
10         __global float * g_clothDampingFactor,\r
11         __global float4 * g_vertexVelocities,\r
12         __global float4 * g_vertexForces GUID_ARG)\r
13 \r
14 {\r
15         int nodeID = get_global_id(0);\r
16         if( nodeID < numNodes )\r
17         {       \r
18                 float4 position = g_vertexPositions[nodeID];\r
19                 float4 previousPosition = g_vertexPreviousPositions[nodeID];\r
20                 float4 velocity = g_vertexVelocities[nodeID];\r
21                 int clothIndex = g_vertexClothIndices[nodeID];\r
22                 float dampingFactor = g_clothDampingFactor[clothIndex];\r
23                 float velocityCoefficient = (1.f - dampingFactor);\r
24                 \r
25                 float4 difference = position - previousPosition;\r
26                                 \r
27                 velocity = difference*velocityCoefficient*isolverdt;            \r
28                 \r
29                 g_vertexVelocities[nodeID] = velocity;\r
30                 g_vertexForces[nodeID] = (float4)(0.f, 0.f, 0.f, 0.f);                                                          \r
31         }\r
32 }\r
33 \r
34 );