| 4195 | } |
| 4196 | |
| 4197 | static inline void UpdateTextureSetAnimData(HScene scene, InternalNode* n) |
| 4198 | { |
| 4199 | // if we got a textureset (i.e. texture animation), we want to update the animation in case it is reloaded |
| 4200 | uint64_t anim_hash = n->m_Node.m_FlipbookAnimHash; |
| 4201 | if(n->m_Node.m_TextureType != NODE_TEXTURE_TYPE_TEXTURE_SET || anim_hash == 0) |
| 4202 | return; |
| 4203 | |
| 4204 | // update animationdata, compare state to current and early bail if equal |
| 4205 | TextureSetAnimDesc& anim_desc = n->m_Node.m_TextureSetAnimDesc; |
| 4206 | const TextureSetAnimDesc::State state_previous = anim_desc.m_State; |
| 4207 | if(FetchTextureSetAnim(scene, n, anim_hash)!=FETCH_ANIMATION_OK) |
| 4208 | { |
| 4209 | // general error in retreiving animation. This could be it being deleted or otherwise changed erraneously |
| 4210 | anim_desc.Init(); |
| 4211 | CancelAnimationComponent(scene, GetNodeHandle(n), &n->m_Node.m_FlipbookAnimPosition); |
| 4212 | dmLogWarning("Failed to update animation '%s'.", dmHashReverseSafe64(anim_hash)); |
| 4213 | return; |
| 4214 | } |
| 4215 | |
| 4216 | if (anim_desc.m_State.IsEqual(state_previous)) |
| 4217 | return; |
| 4218 | |
| 4219 | n->m_Node.m_FlipbookAnimPosition = 0.0f; |
| 4220 | HNode node = GetNodeHandle(n); |
| 4221 | if(anim_desc.m_State.m_Playback == PLAYBACK_NONE) |
| 4222 | { |
| 4223 | CancelAnimationComponent(scene, node, &n->m_Node.m_FlipbookAnimPosition); |
| 4224 | return; |
| 4225 | } |
| 4226 | |
| 4227 | Animation* anim = GetComponentAnimation(scene, node, &n->m_Node.m_FlipbookAnimPosition); |
| 4228 | if(anim && (anim->m_Cancelled == 0)) |
| 4229 | AnimateTextureSetAnim(scene, node, 0.0f, 1.0f, anim->m_AnimationComplete, anim->m_Userdata1, anim->m_Userdata2); |
| 4230 | else |
| 4231 | AnimateTextureSetAnim(scene, node, 0.0f, 1.0f, 0, 0, 0); |
| 4232 | } |
| 4233 | |
| 4234 | Result PlayNodeFlipbookAnim(HScene scene, HNode node, dmhash_t anim, float offset, float playback_rate, AnimationComplete anim_complete_callback, void* callback_userdata1, void* callback_userdata2) |
| 4235 | { |
no test coverage detected