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

Method Move

extensions/flexExtMovingFrame.cpp:35–64  ·  view source on GitHub ↗

update the frame, returns a matrix representing the delta transform that can be applied to particles to teleport them to the frame's new location

Source from the content-addressed store, hash-verified

33 // update the frame, returns a matrix representing the delta transform that
34 // can be applied to particles to teleport them to the frame's new location
35 void Move(Vec3 newPosition, Quat newRotation, float dt)
36 {
37 const float invDt = 1.0f/dt;
38
39 // calculate new velocity
40 Vec3 newVelocity = (newPosition-position)*invDt;
41 Vec3 newOmega = 2.0f*Vec3(Quat(newRotation-rotation)*Inverse(rotation)*invDt);
42
43 // calculate new acceleration
44 Vec3 newAcceleration = (newVelocity-velocity)*invDt;
45 Vec3 newTau = (newOmega-omega)*invDt;
46
47 // calculate delta transform
48 Matrix44 LocalFromOld = AffineInverse(TranslationMatrix(Point3(position))*RotationMatrix(rotation));
49 Matrix44 NewFromLocal = TranslationMatrix(Point3(newPosition))*RotationMatrix(newRotation);
50
51 // update delta transform
52 delta = NewFromLocal*LocalFromOld;
53
54 // position
55 position = newPosition;
56 rotation = newRotation;
57
58 // update velocity
59 velocity = newVelocity;
60 omega = newOmega;
61
62 acceleration = newAcceleration;
63 tau = newTau;
64 }
65
66 inline Vec3 GetLinearForce() const
67 {

Callers 1

Calls 4

TranslationMatrixFunction · 0.85
Point3Class · 0.85
InverseFunction · 0.50
RotationMatrixFunction · 0.50

Tested by

no test coverage detected