aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/src/dx/DxSolverKernel.hlsl
diff options
context:
space:
mode:
authorMarijn Tamis <[email protected]>2017-07-03 11:49:08 +0200
committerMarijn Tamis <[email protected]>2017-07-03 11:49:08 +0200
commitcfa944ded7370fb5f22b1fb894ecf6b9bd3f7381 (patch)
tree5cc014922d20561d87105d279b6f7eb3e628c6d9 /NvCloth/src/dx/DxSolverKernel.hlsl
parentFix windows line endings in github. (diff)
downloadnvcloth-1.1.1.tar.xz
nvcloth-1.1.1.zip
NvCloth 1.1.1 Release. (22392725)v1.1.1
Diffstat (limited to 'NvCloth/src/dx/DxSolverKernel.hlsl')
-rw-r--r--NvCloth/src/dx/DxSolverKernel.hlsl15
1 files changed, 9 insertions, 6 deletions
diff --git a/NvCloth/src/dx/DxSolverKernel.hlsl b/NvCloth/src/dx/DxSolverKernel.hlsl
index 2ca42b3..4d91f4b 100644
--- a/NvCloth/src/dx/DxSolverKernel.hlsl
+++ b/NvCloth/src/dx/DxSolverKernel.hlsl
@@ -202,7 +202,8 @@ void applyWind(IParticles curParticles, IParticles prevParticles, uint32_t threa
{
const float dragCoefficient = gFrameData.mDragCoefficient;
const float liftCoefficient = gFrameData.mLiftCoefficient;
-
+ const float fluidDensity = gFrameData.mFluidDensity;
+ const float itrDt = gFrameData.mIterDt;
if(dragCoefficient == 0.0f && liftCoefficient == 0.0f)
return;
@@ -258,20 +259,22 @@ void applyWind(IParticles curParticles, IParticles prevParticles, uint32_t threa
float3 normal = cross(c2.xyz - c0.xyz, c1.xyz - c0.xyz);
- float doubleArea = sqrt(dot(normal, normal));
+ const float doubleArea = sqrt(dot(normal, normal));
+ normal = normal / doubleArea;
float invSqrScale = dot(delta, delta);
float scale = rsqrt(invSqrScale);
+ float deltaLength = sqrt(invSqrScale);
- float cosTheta = dot(normal, delta) * scale / doubleArea;
+ float cosTheta = dot(normal, delta) * scale;
float sinTheta = sqrt(max(0.0f, 1.0f - cosTheta * cosTheta));
float3 liftDir = cross(cross(delta, normal), scale * delta);
- float3 lift = liftCoefficient * cosTheta * sinTheta * liftDir;
- float3 drag = dragCoefficient * abs(cosTheta) * doubleArea * delta;
+ float3 lift = liftCoefficient * cosTheta * sinTheta * liftDir * deltaLength / itrDt;
+ float3 drag = dragCoefficient * abs(cosTheta) * delta * deltaLength / itrDt;
- float3 impulse = invSqrScale < 1.192092896e-07F ? float3(0.0f, 0.0f, 0.0f) : lift + drag;
+ float3 impulse = invSqrScale < 1.192092896e-07F ? float3(0.0f, 0.0f, 0.0f) : (lift + drag) * fluidDensity * doubleArea;
curParticles.atomicAdd(i0, -impulse * c0.w);
curParticles.atomicAdd(i1, -impulse * c1.w);