only applying dimming on frames where the animations were updated

This commit is contained in:
PS 2021-09-26 16:57:15 -05:00
parent 04b351e792
commit a1e6981bf2
3 changed files with 457 additions and 453 deletions

View File

@ -172,6 +172,7 @@ struct animation_system
s32 LastUpdatedFrame; s32 LastUpdatedFrame;
r32 SecondsPerFrame; r32 SecondsPerFrame;
b32 TimelineShouldAdvance; b32 TimelineShouldAdvance;
u32 UpdatesThisFrame;
// Settings // Settings
bool Multithreaded; bool Multithreaded;
@ -756,6 +757,8 @@ AnimationSystem_Update(animation_system* System, r32 DeltaTime)
if (!System->TimelineShouldAdvance) { return; } if (!System->TimelineShouldAdvance) { return; }
if (!AnimationFadeGroup_ShouldRender(System->ActiveFadeGroup)) { return; } if (!AnimationFadeGroup_ShouldRender(System->ActiveFadeGroup)) { return; }
System->UpdatesThisFrame = 0;
AnimationFadeGroup_Update(&System->ActiveFadeGroup, DeltaTime); AnimationFadeGroup_Update(&System->ActiveFadeGroup, DeltaTime);
animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System);
@ -766,6 +769,7 @@ AnimationSystem_Update(animation_system* System, r32 DeltaTime)
{ {
System->CurrentFrame += 1; System->CurrentFrame += 1;
System->SecondsOnCurrentFrame -= System->SecondsPerFrame; System->SecondsOnCurrentFrame -= System->SecondsPerFrame;
System->UpdatesThisFrame += 1;
} }
// Loop back to the beginning // Loop back to the beginning

View File

@ -169,7 +169,7 @@ typedef DRAW_FONT_CODEPOINT(platform_draw_font_codepoint);
// Worker Threads // Worker Threads
#define PLATFORM_THREAD_COUNT 0 #define PLATFORM_THREAD_COUNT 3
RESET_WORK_QUEUE(ResetWorkQueue) RESET_WORK_QUEUE(ResetWorkQueue)
{ {

View File

@ -800,7 +800,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
} }
// Dim the leds based on temp data // Dim the leds based on temp data
if (!BLState->DEBUG_IgnoreWeatherDimmingLeds) if (State->AnimationSystem.UpdatesThisFrame > 0 && !BLState->DEBUG_IgnoreWeatherDimmingLeds)
{ {
led_buffer B0 = State->LedSystem.Buffers[0]; led_buffer B0 = State->LedSystem.Buffers[0];
pixel P0 = B0.Colors[0]; pixel P0 = B0.Colors[0];