From e51188398dd721e4945606547ff36573eb1f2af5 Mon Sep 17 00:00:00 2001 From: PS Date: Sat, 14 Nov 2020 13:48:17 -0800 Subject: [PATCH] cleaned up unneeded fields in animation_frame --- src/app/engine/animation/foldhaus_animation.h | 19 +------------------ .../animation/foldhaus_animation_renderer.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/app/engine/animation/foldhaus_animation.h b/src/app/engine/animation/foldhaus_animation.h index 07ec227..0f160a0 100644 --- a/src/app/engine/animation/foldhaus_animation.h +++ b/src/app/engine/animation/foldhaus_animation.h @@ -102,13 +102,6 @@ struct animation_frame { animation_layer_frame* Layers; u32 LayersCount; - - // NOTE(pjs): These are all parallel arrays of equal length - animation_block* Blocks; - b8* BlocksFilled; - - u32 BlocksCountMax; - u32 BlocksCount; }; #define ANIMATION_SYSTEM_LAYERS_MAX 128 @@ -442,12 +435,7 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren animation_frame Result = {0}; Result.LayersCount = ActiveAnim->Layers.Count; Result.Layers = PushArray(Arena, animation_layer_frame, Result.LayersCount); - ZeroArray(Result.Layers, animation_frame, Result.LayersCount); - - 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); + ZeroArray(Result.Layers, animation_layer_frame, Result.LayersCount); for (u32 i = 0; i < ActiveAnim->Blocks_.Count; i++) { @@ -486,11 +474,6 @@ AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_aren Layer->HotOpacity = 1.0f; Layer->HasHot = true; } - - // TODO(pjs): Get rid of these fields, they're redundant now - Result.BlocksFilled[Block.Layer] = true; - Result.Blocks[Block.Layer] = Block; - Result.BlocksCount++; } } diff --git a/src/app/engine/animation/foldhaus_animation_renderer.cpp b/src/app/engine/animation/foldhaus_animation_renderer.cpp index 1ff7783..83dc221 100644 --- a/src/app/engine/animation/foldhaus_animation_renderer.cpp +++ b/src/app/engine/animation/foldhaus_animation_renderer.cpp @@ -179,17 +179,18 @@ AnimationSystem_RenderToLedBuffers(animation_system* System, assembly_array Asse // Consolidate Temp Buffers // We do this in reverse order so that they go from top to bottom - for (u32 Layer = 0; Layer < CurrFrame.BlocksCountMax; Layer++) + for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) { - if (!CurrFrame.BlocksFilled[Layer]) { continue; } - - led_blend_proc* Blend = LedBlend_GetProc(ActiveAnim->Layers.Values[Layer].BlendMode); - Assert(Blend != 0); - for (u32 LED = 0; LED < AssemblyLedBuffer->LedCount; LED++) + if (CurrFrame.Layers[Layer].HasHot) { - pixel A = AssemblyLedBuffer->Colors[LED]; - pixel B = LayerBuffers[Layer].HotBuffer.Colors[LED]; - AssemblyLedBuffer->Colors[LED] = Blend(A, B); + led_blend_proc* Blend = LedBlend_GetProc(ActiveAnim->Layers.Values[Layer].BlendMode); + Assert(Blend != 0); + for (u32 LED = 0; LED < AssemblyLedBuffer->LedCount; LED++) + { + pixel A = AssemblyLedBuffer->Colors[LED]; + pixel B = LayerBuffers[Layer].HotBuffer.Colors[LED]; + AssemblyLedBuffer->Colors[LED] = Blend(A, B); + } } } }