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

Function AnimateComponent

engine/gui/src/gui.cpp:3936–3998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3934 }
3935
3936 static Animation* AnimateComponent(HScene scene,
3937 HNode node,
3938 float* value,
3939 float to,
3940 dmEasing::Curve easing,
3941 Playback playback,
3942 float duration,
3943 float delay,
3944 float playback_rate,
3945 AnimationComplete animation_complete,
3946 void* userdata1,
3947 void* userdata2)
3948 {
3949 uint16_t version = (uint16_t) (node >> 16);
3950 uint16_t index = node & 0xffff;
3951 InternalNode* n = &scene->m_Nodes[index];
3952 assert(n->m_Version == version);
3953
3954 Animation animation;
3955 uint32_t animation_index = FindAnimation(scene->m_Animations, value);
3956
3957 if (animation_index == 0xffffffff)
3958 {
3959 if (scene->m_Animations.Full())
3960 {
3961 dmLogWarning("Out of animation resources (%d)", scene->m_Animations.Size());
3962 return NULL;
3963 }
3964 animation_index = scene->m_Animations.Size();
3965 scene->m_Animations.SetSize(animation_index+1);
3966 }
3967 else
3968 {
3969 // Make sure to invoke the callback when we are re-using the
3970 // animation index so that we can clean up dangling ref's in
3971 // the gui_script module.
3972 Animation* anim = &scene->m_Animations[animation_index];
3973 if (anim->m_AnimationComplete && !anim->m_AnimationCompleteCalled)
3974 {
3975 anim->m_AnimationComplete(scene, anim->m_Node, false, anim->m_Userdata1, anim->m_Userdata2);
3976 }
3977 }
3978
3979 animation.m_Node = node;
3980 animation.m_Value = value;
3981 animation.m_To = to;
3982 animation.m_Delay = delay < 0.0f ? 0.0f : delay;
3983 animation.m_Elapsed = 0.0f;
3984 animation.m_Duration = duration < 0.0f ? 0.0f : duration;
3985 animation.m_PlaybackRate = playback_rate;
3986 animation.m_Easing = easing;
3987 animation.m_Playback = playback;
3988 animation.m_AnimationComplete = animation_complete;
3989 animation.m_Userdata1 = userdata1;
3990 animation.m_Userdata2 = userdata2;
3991 animation.m_FirstUpdate = 1;
3992 animation.m_AnimationCompleteCalled = 0;
3993 animation.m_Cancelled = 0;

Callers 2

AnimateNodeHashFunction · 0.85
AnimateTextureSetAnimFunction · 0.85

Calls 6

InsertAnimationFunction · 0.85
FindAnimationFunction · 0.70
assertFunction · 0.50
FullMethod · 0.45
SizeMethod · 0.45
SetSizeMethod · 0.45

Tested by

no test coverage detected