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

Function CancelAnimationHash

engine/gui/src/gui.cpp:4054–4109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4052 }
4053
4054 void CancelAnimationHash(HScene scene, HNode node, dmhash_t property_hash)
4055 {
4056 uint16_t version = (uint16_t) (node >> 16);
4057 uint16_t index = node & 0xffff;
4058 InternalNode* n = &scene->m_Nodes[index];
4059 assert(n->m_Version == version);
4060
4061 dmArray<Animation>* animations = &scene->m_Animations;
4062 uint32_t n_animations = animations->Size();
4063
4064 if (property_hash == 0)
4065 {
4066 // if property hash is 0 then cancels all ongoing animation of properties for node
4067 for (uint32_t i = 0; i < n_animations; ++i)
4068 {
4069 Animation* anim = &(*animations)[i];
4070 if (anim->m_Node == node)
4071 {
4072 anim->m_Cancelled = 1;
4073 }
4074 }
4075 return;
4076 }
4077
4078 PropDesc* pd = GetPropertyDesc(property_hash);
4079 if (pd) {
4080 for (uint32_t i = 0; i < n_animations; ++i)
4081 {
4082 Animation* anim = &(*animations)[i];
4083
4084 int from = 0;
4085 int to = 4; // NOTE: Exclusive range
4086 int expect = 4;
4087 if (pd->m_Component != 0xff) {
4088 from = pd->m_Component;
4089 to = pd->m_Component + 1;
4090 expect = 1;
4091 }
4092
4093 float* value = (float*) &n->m_Node.m_Properties[pd->m_Property];
4094 int count = 0;
4095 for (int j = from; j < to; ++j) {
4096 if (anim->m_Node == node && anim->m_Value == (value + j))
4097 {
4098 anim->m_Cancelled = 1;
4099 ++count;
4100 if (count == expect) {
4101 return;
4102 }
4103 }
4104 }
4105 }
4106 } else {
4107 dmLogError("property '%s' not found", dmHashReverseSafe64(property_hash));
4108 }
4109 }
4110
4111

Callers 1

LuaCancelAnimationsFunction · 0.70

Calls 4

GetPropertyDescFunction · 0.85
dmHashReverseSafe64Function · 0.85
assertFunction · 0.50
SizeMethod · 0.45

Tested by

no test coverage detected