| 127 | } |
| 128 | |
| 129 | Result PlayAnimation(HRigInstance instance, dmhash_t animation_id, dmRig::RigPlayback playback, float blend_duration, float offset, float playback_rate) |
| 130 | { |
| 131 | const dmRigDDF::RigAnimation* anim = FindAnimation(instance->m_AnimationSet, animation_id); |
| 132 | if (anim == 0x0) |
| 133 | { |
| 134 | RigPlayer* player = GetPlayer(instance); |
| 135 | player->m_Playing = 0; |
| 136 | instance->m_HasPoseMatrixCacheAnimatedPose = 0; |
| 137 | return dmRig::RESULT_ANIM_NOT_FOUND; |
| 138 | } |
| 139 | |
| 140 | if (blend_duration > 0.0f) |
| 141 | { |
| 142 | instance->m_BlendTimer = 0.0f; |
| 143 | instance->m_BlendDuration = blend_duration; |
| 144 | instance->m_Blending = 1; |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | RigPlayer* player = GetPlayer(instance); |
| 149 | player->m_Playing = 0; |
| 150 | } |
| 151 | |
| 152 | RigPlayer* player = SwitchPlayer(instance); |
| 153 | player->m_AnimationId = animation_id; |
| 154 | player->m_Animation = anim; |
| 155 | player->m_Playing = 1; |
| 156 | player->m_Playback = playback; |
| 157 | instance->m_HasPoseMatrixCacheAnimatedPose = 0; |
| 158 | |
| 159 | if (player->m_Playback == dmRig::PLAYBACK_ONCE_BACKWARD || player->m_Playback == dmRig::PLAYBACK_LOOP_BACKWARD) { |
| 160 | player->m_Backwards = 1; |
| 161 | offset = 1.0f - dmMath::Clamp(offset, 0.0f, 1.0f); |
| 162 | } else { |
| 163 | player->m_Backwards = 0; |
| 164 | } |
| 165 | |
| 166 | SetCursor(instance, offset, true); |
| 167 | SetPlaybackRate(instance, playback_rate); |
| 168 | return dmRig::RESULT_OK; |
| 169 | } |
| 170 | |
| 171 | Result CancelAnimation(HRigInstance instance) |
| 172 | { |