| 192 | |
| 193 | template<U32 COUNT> |
| 194 | bool LightAnimData::AnimValue<COUNT>::animate(F32 time, F32 *output, bool multiply) |
| 195 | { |
| 196 | F32 scaledTime, lerpFactor, valueRange, keyFrameLerp; |
| 197 | U32 posFrom, posTo; |
| 198 | S32 keyFrameFrom, keyFrameTo; |
| 199 | F32 initialValue = *output; |
| 200 | if (!multiply) |
| 201 | initialValue = 1; |
| 202 | |
| 203 | bool wasAnimated = false; |
| 204 | |
| 205 | for ( U32 i=0; i < COUNT; i++ ) |
| 206 | { |
| 207 | if ( mIsZero( timeScale[i] ) ) |
| 208 | continue; |
| 209 | |
| 210 | wasAnimated = true; |
| 211 | |
| 212 | scaledTime = mFmod( time, period[i] ) * timeScale[i]; |
| 213 | |
| 214 | posFrom = mFloor( scaledTime ); |
| 215 | posTo = mCeil( scaledTime ); |
| 216 | |
| 217 | keyFrameFrom = dToupper( keys[i][posFrom] ) - 65; |
| 218 | keyFrameTo = dToupper( keys[i][posTo] ) - 65; |
| 219 | valueRange = ( value2[i] - value1[i] ) / 25.0f; |
| 220 | |
| 221 | if ( !smooth[i] ) |
| 222 | output[i] = (value1[i] + (keyFrameFrom * valueRange)) * initialValue; |
| 223 | else |
| 224 | { |
| 225 | lerpFactor = scaledTime - posFrom; |
| 226 | keyFrameLerp = ( keyFrameTo - keyFrameFrom ) * lerpFactor; |
| 227 | |
| 228 | output[i] = (value1[i] + ((keyFrameFrom + keyFrameLerp) * valueRange)) * initialValue; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | return wasAnimated; |
| 233 | } |
| 234 | |
| 235 | template<U32 COUNT> |
| 236 | void LightAnimData::AnimValue<COUNT>::write( BitStream *stream ) const |
no test coverage detected