MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / animate

Method animate

Source/Falcor/Scene/Animation/Animation.cpp:114–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 {}
113
114 float4x4 Animation::animate(double currentTime)
115 {
116 // Calculate the sample time.
117 double time = currentTime;
118 if (time < mKeyframes.front().time || time > mKeyframes.back().time)
119 {
120 time = calcSampleTime(currentTime);
121 }
122
123 // Determine if the animation behaves linearly outside of defined keyframes.
124 bool isLinearPostInfinity = time > mKeyframes.back().time && this->getPostInfinityBehavior() == Behavior::Linear;
125 bool isLinearPreInfinity = time < mKeyframes.front().time && this->getPreInfinityBehavior() == Behavior::Linear;
126
127 Keyframe interpolated;
128
129 if (isLinearPreInfinity && mKeyframes.size() > 1)
130 {
131 const auto& k0 = mKeyframes.front();
132 auto k1 = interpolate(mInterpolationMode, k0.time + kEpsilonTime);
133 double segmentDuration = k1.time - k0.time;
134 float t = (float)((time - k0.time) / segmentDuration);
135 interpolated = interpolateLinear(k0, k1, t);
136 }
137 else if (isLinearPostInfinity && mKeyframes.size() > 1)
138 {
139 const auto& k1 = mKeyframes.back();
140 auto k0 = interpolate(mInterpolationMode, k1.time - kEpsilonTime);
141 double segmentDuration = k1.time - k0.time;
142 float t = (float)((time - k0.time) / segmentDuration);
143 interpolated = interpolateLinear(k0, k1, t);
144 }
145 else
146 {
147 interpolated = interpolate(mInterpolationMode, time);
148 }
149
150 float4x4 T = math::matrixFromTranslation(interpolated.translation);
151 float4x4 R = math::matrixFromQuat(interpolated.rotation);
152 float4x4 S = math::matrixFromScaling(interpolated.scaling);
153 float4x4 transform = mul(mul(T, R), S);
154
155 return transform;
156 }
157
158 Animation::Keyframe Animation::interpolate(InterpolationMode mode, double time) const
159 {

Callers 2

finalizeMethod · 0.45
updateMethod · 0.45

Calls 8

interpolateLinearFunction · 0.85
matrixFromTranslationFunction · 0.85
matrixFromQuatFunction · 0.85
matrixFromScalingFunction · 0.85
frontMethod · 0.80
backMethod · 0.80
mulFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected