MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / NvFlexExtMovingFrameApply

Function NvFlexExtMovingFrameApply

extensions/flexExtMovingFrame.cpp:98–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void NvFlexExtMovingFrameApply(NvFlexExtMovingFrame* frame, float* positions, float* velocities, int numParticles, float linearScale, float angularScale, float dt)
99{
100 const MovingFrame& f = (MovingFrame&)(*frame);
101
102 // linear force constant for all particles
103 Vec3 linearForce = f.GetLinearForce()*linearScale;
104
105 for (int i=0; i < numParticles; ++i)
106 {
107 Vec3 particlePos = Vec3(&positions[i*4]);
108 Vec3 particleVel = Vec3(&velocities[i*3]);
109
110 // angular force depends on particles position
111 Vec3 angularForce = f.GetAngularForce(particlePos)*angularScale;
112
113 // transform particle to frame's new location
114 particlePos = Vec3(f.delta*Vec4(particlePos, 1.0f));
115 particleVel += (linearForce + angularForce)*dt;
116
117 // update positions
118 positions[i*4+0] = particlePos.x;
119 positions[i*4+1] = particlePos.y;
120 positions[i*4+2] = particlePos.z;
121
122 velocities[i*3+0] = particleVel.x;
123 velocities[i*3+1] = particleVel.y;
124 velocities[i*3+2] = particleVel.z;
125
126 }
127}

Callers 2

UpdateMethod · 0.85
UpdateMethod · 0.85

Calls 2

GetLinearForceMethod · 0.80
GetAngularForceMethod · 0.80

Tested by

no test coverage detected