| 321 | } |
| 322 | |
| 323 | static void UpdatePlayer(RigInstance* instance, RigPlayer* player, float dt, float blend_weight) |
| 324 | { |
| 325 | const dmRigDDF::RigAnimation* animation = player->m_Animation; |
| 326 | if (animation == 0x0 || !player->m_Playing) |
| 327 | { |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | // Advance cursor |
| 332 | float prev_cursor = player->m_Cursor; |
| 333 | if (player->m_Playback != dmRig::PLAYBACK_NONE) |
| 334 | { |
| 335 | player->m_Cursor += dt * player->m_PlaybackRate; |
| 336 | } |
| 337 | float duration = GetCursorDuration(player, animation); |
| 338 | if (duration == 0.0f) |
| 339 | { |
| 340 | player->m_Cursor = 0.0f; |
| 341 | } |
| 342 | |
| 343 | // Adjust cursor |
| 344 | bool completed = false; |
| 345 | switch (player->m_Playback) |
| 346 | { |
| 347 | case dmRig::PLAYBACK_ONCE_FORWARD: |
| 348 | case dmRig::PLAYBACK_ONCE_BACKWARD: |
| 349 | case dmRig::PLAYBACK_ONCE_PINGPONG: |
| 350 | if (player->m_Cursor >= duration) |
| 351 | { |
| 352 | player->m_Cursor = duration; |
| 353 | completed = true; |
| 354 | } |
| 355 | break; |
| 356 | case dmRig::PLAYBACK_LOOP_FORWARD: |
| 357 | case dmRig::PLAYBACK_LOOP_BACKWARD: |
| 358 | while (player->m_Cursor >= duration && duration > 0.0f) |
| 359 | { |
| 360 | player->m_Cursor -= duration; |
| 361 | } |
| 362 | break; |
| 363 | case dmRig::PLAYBACK_LOOP_PINGPONG: |
| 364 | while (player->m_Cursor >= duration && duration > 0.0f) |
| 365 | { |
| 366 | player->m_Cursor -= duration; |
| 367 | player->m_Backwards = ~player->m_Backwards; |
| 368 | } |
| 369 | break; |
| 370 | default: |
| 371 | break; |
| 372 | } |
| 373 | |
| 374 | if (prev_cursor != player->m_Cursor && instance->m_EventCallback) |
| 375 | { |
| 376 | PostEvents(instance, player, animation, dt, prev_cursor, duration, completed, blend_weight); |
| 377 | } |
| 378 | |
| 379 | if (completed) |
| 380 | { |
no test coverage detected