* 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
| 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 | { |
no outgoing calls
no test coverage detected