Fixed animations so they are no longer updating when the current frame is not in range
This commit is contained in:
parent
85b99b17a2
commit
121e9efa93
|
@ -182,6 +182,18 @@ Panel_GetCurrentTypeIndex(panel* Panel)
|
||||||
return Result;
|
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
|
internal void
|
||||||
Panel_SetCurrentTypeStateMemory(panel* Panel, gs_data StateMemory)
|
Panel_SetCurrentTypeStateMemory(panel* Panel, gs_data StateMemory)
|
||||||
{
|
{
|
||||||
|
@ -197,18 +209,6 @@ Panel_SetCurrentTypeStateMemory(panel* Panel, gs_data StateMemory)
|
||||||
Panel->TypeStateMemory[CurrentTypeIndex] = 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
|
internal void
|
||||||
Panel_PushTypeWithReturn(panel* Panel, s32 NewPanelType, gs_data ReturnDestMemory)
|
Panel_PushTypeWithReturn(panel* Panel, s32 NewPanelType, gs_data ReturnDestMemory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -260,10 +260,10 @@ SecondsToFrames(r32 Seconds, animation_system System)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline b32
|
inline bool
|
||||||
FrameIsInRange(frame_range Range, s32 Frame)
|
FrameIsInRange(frame_range Range, s32 Frame)
|
||||||
{
|
{
|
||||||
b32 Result = (Frame >= Range.Min) && (Frame <= Range.Max);
|
bool Result = (Frame >= Range.Min) && (Frame <= Range.Max);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,6 +348,7 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren
|
||||||
Result.BlocksCountMax = ActiveAnim->Layers.Count;
|
Result.BlocksCountMax = ActiveAnim->Layers.Count;
|
||||||
Result.Blocks = PushArray(Arena, animation_block, Result.BlocksCountMax);
|
Result.Blocks = PushArray(Arena, animation_block, Result.BlocksCountMax);
|
||||||
Result.BlocksFilled = PushArray(Arena, b8, Result.BlocksCountMax);
|
Result.BlocksFilled = PushArray(Arena, b8, Result.BlocksCountMax);
|
||||||
|
ZeroArray(Result.BlocksFilled, b8, Result.BlocksCountMax);
|
||||||
|
|
||||||
for (u32 i = 0; i < ActiveAnim->Blocks.Used; i++)
|
for (u32 i = 0; i < ActiveAnim->Blocks.Used; i++)
|
||||||
{
|
{
|
||||||
|
@ -356,12 +357,13 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren
|
||||||
|
|
||||||
animation_block Block = BlockEntry->Value;
|
animation_block Block = BlockEntry->Value;
|
||||||
|
|
||||||
if (FrameIsInRange(Block.Range, System->CurrentFrame)){ continue; }
|
if (FrameIsInRange(Block.Range, System->CurrentFrame))
|
||||||
|
{
|
||||||
Result.BlocksFilled[Block.Layer] = true;
|
Result.BlocksFilled[Block.Layer] = true;
|
||||||
Result.Blocks[Block.Layer] = Block;
|
Result.Blocks[Block.Layer] = Block;
|
||||||
Result.BlocksCount++;
|
Result.BlocksCount++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CurrentFrame = State->AnimationSystem.CurrentFrame;
|
s32 CurrentFrame = State->AnimationSystem.CurrentFrame;
|
||||||
if (CurrentFrame != State->AnimationSystem.LastUpdatedFrame)
|
if (true || CurrentFrame != State->AnimationSystem.LastUpdatedFrame)
|
||||||
{
|
{
|
||||||
State->AnimationSystem.LastUpdatedFrame = CurrentFrame;
|
State->AnimationSystem.LastUpdatedFrame = CurrentFrame;
|
||||||
r32 FrameTime = CurrentFrame * State->AnimationSystem.SecondsPerFrame;
|
r32 FrameTime = CurrentFrame * State->AnimationSystem.SecondsPerFrame;
|
||||||
|
|
Loading…
Reference in New Issue