| 963 | } |
| 964 | |
| 965 | Result SetCursor(HRigInstance instance, float cursor, bool normalized) |
| 966 | { |
| 967 | float t = cursor; |
| 968 | RigPlayer* player = GetPlayer(instance); |
| 969 | |
| 970 | if (!player) |
| 971 | { |
| 972 | return dmRig::RESULT_ERROR; |
| 973 | } |
| 974 | |
| 975 | if (!player->m_Animation) |
| 976 | { |
| 977 | return RESULT_OK; |
| 978 | } |
| 979 | |
| 980 | float duration = player->m_Animation->m_Duration; |
| 981 | if (normalized) |
| 982 | { |
| 983 | t = t * duration; |
| 984 | } |
| 985 | |
| 986 | if (player->m_Playback == dmRig::PLAYBACK_LOOP_PINGPONG && player->m_Backwards) |
| 987 | { |
| 988 | // NEVER set cursor on the "looped" part of a pingpong animation |
| 989 | player->m_Backwards = 0; |
| 990 | } |
| 991 | |
| 992 | if (fabs(t) > duration) |
| 993 | { |
| 994 | t = fmod(t, duration); |
| 995 | if (fabs(t) < CURSOR_EPSILON) |
| 996 | { |
| 997 | t = duration; |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | if (t < 0.0f) |
| 1002 | { |
| 1003 | t = duration - fmod(fabs(t), duration); |
| 1004 | } |
| 1005 | |
| 1006 | if (player->m_Backwards) |
| 1007 | { |
| 1008 | t = duration - t; |
| 1009 | } |
| 1010 | |
| 1011 | player->m_Cursor = t; |
| 1012 | |
| 1013 | return dmRig::RESULT_OK; |
| 1014 | } |
| 1015 | |
| 1016 | float GetPlaybackRate(HRigInstance instance) |
| 1017 | { |