MCPcopy Create free account
hub / github.com/defold/defold / PlayAnimation

Function PlayAnimation

engine/rig/src/rig.cpp:129–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 5

InstanceCreateFunction · 0.70
TEST_PFunction · 0.50
TEST_FFunction · 0.50
DEF3121_EventCallbackFunction · 0.50
TESTFunction · 0.50

Calls 6

GetPlayerFunction · 0.85
SwitchPlayerFunction · 0.85
FindAnimationFunction · 0.70
SetCursorFunction · 0.70
SetPlaybackRateFunction · 0.70
ClampFunction · 0.50

Tested by 4

TEST_PFunction · 0.40
TEST_FFunction · 0.40
DEF3121_EventCallbackFunction · 0.40
TESTFunction · 0.40