MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / scaleToHeaderFrameRate

Function scaleToHeaderFrameRate

src/content/AnimationLibrary.cpp:145–160  ·  view source on GitHub ↗

* This weird function scales the frame when an event occurs according to m_FrameCount (header) * FIXME there are cases when m_LastFrame, m_FirstFrame and other values are obviously incorrect (high values) * I checked for overflows/weird arithmetic with unsigned/signed stuff but the numbers are not even * close to maximum/minimum numbers. m_FrameCount doesn't have this Problem, thats

Source from the content-addressed store, hash-verified

143 * "correctly" ingame. In many cases m_LastFrame, m_FirstFrame and m_FrameCount don't match.
144 */
145 static int32_t scaleToHeaderFrameRate(Animation* anim, int32_t frame)
146 {
147 if(anim->m_LastFrame < anim->m_FirstFrame)
148 {
149 return frame;
150 }
151 auto diff = anim->m_LastFrame - anim->m_FirstFrame;
152 float pos = 0.0f;
153 if(diff == 0)
154 {
155 return anim->m_FrameCount;
156 }
157 pos = frame/(float)diff;
158 return static_cast<int32_t>(pos * anim->m_FrameCount);
159
160 }
161
162 static void animationAddEventSFX(Animation* anim, const zCModelScriptEventSfx& sfx)
163 {

Callers 5

animationAddEventSFXFunction · 0.85
animationAddEventPFXFunction · 0.85
animationAddEventPFXStopFunction · 0.85
animationAddEventTagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected