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

Function AnimateTextureSetAnim

engine/gui/src/gui.cpp:4138–4184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4136 }
4137
4138 static inline void AnimateTextureSetAnim(HScene scene, HNode node, float offset, float playback_rate, AnimationComplete anim_complete_callback, void* callback_userdata1, void* callback_userdata2)
4139 {
4140 InternalNode* n = GetNode(scene, node);
4141 TextureSetAnimDesc& anim_desc = n->m_Node.m_TextureSetAnimDesc;
4142 uint64_t anim_frames = (anim_desc.m_State.m_End - anim_desc.m_State.m_Start);
4143 dmGui::Playback playback = (dmGui::Playback)anim_desc.m_State.m_Playback;
4144 bool pingpong = playback == dmGui::PLAYBACK_ONCE_PINGPONG || playback == dmGui::PLAYBACK_LOOP_PINGPONG;
4145
4146 // Ping pong for flipbook animations should result in double the
4147 // animation duration.
4148 if (pingpong)
4149 anim_frames = anim_frames * 2;
4150
4151 // Convert offset into elapsed time, needed for GUI animation system.
4152 offset = dmMath::Clamp(offset, 0.0f, 1.0f);
4153 float elapsed = offset;
4154 float duration = (float) anim_frames / (float) anim_desc.m_State.m_FPS;
4155 if (pingpong) {
4156 elapsed /= 2.0f;
4157 }
4158 elapsed = elapsed * duration;
4159
4160 Animation* anim = AnimateComponent(
4161 scene,
4162 node,
4163 &n->m_Node.m_FlipbookAnimPosition,
4164 1.0f,
4165 dmEasing::Curve(dmEasing::TYPE_LINEAR),
4166 playback,
4167 duration,
4168 0.0f,
4169 playback_rate,
4170 anim_complete_callback,
4171 callback_userdata1,
4172 callback_userdata2);
4173
4174 if (!anim) {
4175 return;
4176 }
4177
4178 // We force some of the animation properties here to simulate
4179 // elapsed time for flipbook animations that has offset.
4180 anim->m_From = 0.0f,
4181 anim->m_FirstUpdate = 0.0f;
4182 anim->m_Elapsed = elapsed;
4183 n->m_Node.m_FlipbookAnimPosition = offset;
4184 }
4185
4186 static inline FetchTextureSetAnimResult FetchTextureSetAnim(HScene scene, InternalNode* n, dmhash_t anim)
4187 {

Callers 2

UpdateTextureSetAnimDataFunction · 0.85
PlayNodeFlipbookAnimFunction · 0.85

Calls 4

AnimateComponentFunction · 0.85
CurveClass · 0.85
GetNodeFunction · 0.70
ClampFunction · 0.50

Tested by

no test coverage detected