~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL/VSolveLinks.hlsl

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
MSTRINGIFY(
 
2
 
 
3
cbuffer VSolveLinksCB : register( b0 )
 
4
{
 
5
        int startLink;
 
6
        int numLinks;
 
7
        float kst;
 
8
        int padding;
 
9
};
 
10
 
 
11
// Node indices for each link
 
12
StructuredBuffer<int2> g_linksVertexIndices : register( t0 );
 
13
 
 
14
StructuredBuffer<float> g_linksLengthRatio : register( t1 );
 
15
StructuredBuffer<float4> g_linksCurrentLength : register( t2 );
 
16
StructuredBuffer<float> g_vertexInverseMass : register( t3 );
 
17
 
 
18
RWStructuredBuffer<float4> g_vertexVelocity : register( u0 );
 
19
 
 
20
[numthreads(128, 1, 1)]
 
21
void 
 
22
VSolveLinksKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )
 
23
{
 
24
        int linkID = DTid.x + startLink;
 
25
        if( DTid.x < numLinks )
 
26
        {               
 
27
                int2 nodeIndices = g_linksVertexIndices[linkID];
 
28
                int node0 = nodeIndices.x;
 
29
                int node1 = nodeIndices.y;
 
30
                
 
31
                float linkLengthRatio = g_linksLengthRatio[linkID];
 
32
                float3 linkCurrentLength = g_linksCurrentLength[linkID].xyz;
 
33
                
 
34
                float3 vertexVelocity0 = g_vertexVelocity[node0].xyz;
 
35
                float3 vertexVelocity1 = g_vertexVelocity[node1].xyz;
 
36
 
 
37
                float vertexInverseMass0 = g_vertexInverseMass[node0];
 
38
                float vertexInverseMass1 = g_vertexInverseMass[node1]; 
 
39
 
 
40
                float3 nodeDifference = vertexVelocity0 - vertexVelocity1;
 
41
                float dotResult = dot(linkCurrentLength, nodeDifference);
 
42
                float j = -dotResult*linkLengthRatio*kst;
 
43
                
 
44
                float3 velocityChange0 = linkCurrentLength*(j*vertexInverseMass0);
 
45
                float3 velocityChange1 = linkCurrentLength*(j*vertexInverseMass1);
 
46
                
 
47
                vertexVelocity0 += velocityChange0;
 
48
                vertexVelocity1 -= velocityChange1;
 
49
 
 
50
                g_vertexVelocity[node0] = float4(vertexVelocity0, 0.f);
 
51
                g_vertexVelocity[node1] = float4(vertexVelocity1, 0.f);
 
52
        }
 
53
}
 
54
 
 
55
);
 
 
b'\\ No newline at end of file'