Fixed animations so they are no longer updating when the current frame is not in range

This commit is contained in:
PS 2020-10-17 13:12:40 -07:00
parent 85b99b17a2
commit 121e9efa93
3 changed files with 22 additions and 20 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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;