From 121e9efa93f525b4dccbc4021c9f1a85b8d56866 Mon Sep 17 00:00:00 2001 From: PS Date: Sat, 17 Oct 2020 13:12:40 -0700 Subject: [PATCH] Fixed animations so they are no longer updating when the current frame is not in range --- src/app/editor/foldhaus_panel.h | 24 +++++++++---------- src/app/engine/animation/foldhaus_animation.h | 16 +++++++------ src/app/foldhaus_app.cpp | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/app/editor/foldhaus_panel.h b/src/app/editor/foldhaus_panel.h index 100b230..190a118 100644 --- a/src/app/editor/foldhaus_panel.h +++ b/src/app/editor/foldhaus_panel.h @@ -182,6 +182,18 @@ Panel_GetCurrentTypeIndex(panel* Panel) return Result; } +#define Panel_GetCurrentTypeStateMemory(p, type) (type*)Panel_GetCurrentTypeStateMemory_(p).Memory +internal gs_data +Panel_GetCurrentTypeStateMemory_(panel* Panel) +{ + gs_data Result = {0}; + if (Panel->TypeIndicesCount != 0) + { + Result = Panel->TypeStateMemory[Panel->TypeIndicesCount - 1]; + } + return Result; +} + internal void Panel_SetCurrentTypeStateMemory(panel* Panel, gs_data StateMemory) { @@ -197,18 +209,6 @@ Panel_SetCurrentTypeStateMemory(panel* Panel, gs_data StateMemory) Panel->TypeStateMemory[CurrentTypeIndex] = StateMemory; } -#define Panel_GetCurrentTypeStateMemory(p, type) (type*)Panel_GetCurrentTypeStateMemory_(p).Memory -internal gs_data -Panel_GetCurrentTypeStateMemory_(panel* Panel) -{ - gs_data Result = {0}; - if (Panel->TypeIndicesCount != 0) - { - Result = Panel->TypeStateMemory[Panel->TypeIndicesCount - 1]; - } - return Result; -} - internal void Panel_PushTypeWithReturn(panel* Panel, s32 NewPanelType, gs_data ReturnDestMemory) { diff --git a/src/app/engine/animation/foldhaus_animation.h b/src/app/engine/animation/foldhaus_animation.h index 00d4278..7650ce0 100644 --- a/src/app/engine/animation/foldhaus_animation.h +++ b/src/app/engine/animation/foldhaus_animation.h @@ -260,10 +260,10 @@ SecondsToFrames(r32 Seconds, animation_system System) return Result; } -inline b32 +inline bool FrameIsInRange(frame_range Range, s32 Frame) { - b32 Result = (Frame >= Range.Min) && (Frame <= Range.Max); + bool Result = (Frame >= Range.Min) && (Frame <= Range.Max); return Result; } @@ -348,6 +348,7 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren Result.BlocksCountMax = ActiveAnim->Layers.Count; Result.Blocks = PushArray(Arena, animation_block, Result.BlocksCountMax); Result.BlocksFilled = PushArray(Arena, b8, Result.BlocksCountMax); + ZeroArray(Result.BlocksFilled, b8, Result.BlocksCountMax); for (u32 i = 0; i < ActiveAnim->Blocks.Used; i++) { @@ -356,11 +357,12 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren animation_block Block = BlockEntry->Value; - if (FrameIsInRange(Block.Range, System->CurrentFrame)){ continue; } - - Result.BlocksFilled[Block.Layer] = true; - Result.Blocks[Block.Layer] = Block; - Result.BlocksCount++; + if (FrameIsInRange(Block.Range, System->CurrentFrame)) + { + Result.BlocksFilled[Block.Layer] = true; + Result.Blocks[Block.Layer] = Block; + Result.BlocksCount++; + } } return Result; diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index b992ff4..8c028a9 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -258,7 +258,7 @@ UPDATE_AND_RENDER(UpdateAndRender) } s32 CurrentFrame = State->AnimationSystem.CurrentFrame; - if (CurrentFrame != State->AnimationSystem.LastUpdatedFrame) + if (true || CurrentFrame != State->AnimationSystem.LastUpdatedFrame) { State->AnimationSystem.LastUpdatedFrame = CurrentFrame; r32 FrameTime = CurrentFrame * State->AnimationSystem.SecondsPerFrame;