From 29a92837a6e70b9d60ab46ee18f895d956d5ce16 Mon Sep 17 00:00:00 2001 From: PS Date: Thu, 8 Apr 2021 17:42:20 -1000 Subject: [PATCH] Added a way to test hues on the sculpture from the debug panel --- .../panels/foldhaus_panel_assembly_debug.h | 5 +++++ .../engine/assembly/foldhaus_assembly_debug.h | 11 +++++++++++ src/app/foldhaus_app.h | 4 +++- src/app/patterns/blumen_patterns.h | 16 +--------------- src/app/ss_blumen_lumen/blumen_lumen.cpp | 2 +- src/app/ss_blumen_lumen/gfx_math.h | 14 ++++++++++++++ 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/app/editor/panels/foldhaus_panel_assembly_debug.h b/src/app/editor/panels/foldhaus_panel_assembly_debug.h index d1c912e..24922b3 100644 --- a/src/app/editor/panels/foldhaus_panel_assembly_debug.h +++ b/src/app/editor/panels/foldhaus_panel_assembly_debug.h @@ -118,6 +118,11 @@ AssemblyDebug_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); }break; + case ADS_Override_AllHue: + { + State->AssemblyDebugState.TargetHue = (u32)ui_LabeledRangeSlider(Interface, MakeString("Hue"), (r32)State->AssemblyDebugState.TargetHue, 0, 360); + }break; + default: { InterfaceAssert(Interface->PerFrameMemory); diff --git a/src/app/engine/assembly/foldhaus_assembly_debug.h b/src/app/engine/assembly/foldhaus_assembly_debug.h index c7c59d8..ffe33ed 100644 --- a/src/app/engine/assembly/foldhaus_assembly_debug.h +++ b/src/app/engine/assembly/foldhaus_assembly_debug.h @@ -16,6 +16,7 @@ enum override_type ADS_Override_AllBlue, ADS_Override_AllOff, ADS_Override_AllWhite, + ADS_Override_AllHue, ADS_Override_TagWhite, ADS_Override_TagStripWhite, ADS_Override_ChannelWhite, @@ -32,6 +33,7 @@ global gs_const_string OverrideTypeStrings[] = { LitString("Override_AllBlue" ), LitString("ADS_Override_AllOff" ), LitString("ADS_Override_AllWhite" ), + LitString("ADS_Override_AllHue" ), LitString("ADS_Override_TagWhite" ), LitString("ADS_Override_TagStripWhite" ), LitString("ADS_Override_ChannelWhite," ), @@ -49,6 +51,7 @@ struct assembly_debug_state gs_string TagName; gs_string TagValue; + u32 TargetHue; pixel TargetColor; u32 TargetChannel; @@ -158,6 +161,14 @@ AssemblyDebug_OverrideOutputForAssembly(assembly_debug_state State, led_system AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{V, V, V}); }break; + case ADS_Override_AllHue: + { + v4 HSV = v4{(r32)State.TargetHue, 1, 1, 1}; + v4 RGB = HSVToRGB(HSV); + pixel P = V4ToRGBPixel(RGB); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, P); + }break; + case ADS_Override_TagWhite: { AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 0, 0}); diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index 9d9e857..c0e425d 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -18,6 +18,9 @@ #include "engine/foldhaus_network_ordering.h" #include "engine/assembly/foldhaus_assembly.h" + +#include "ss_blumen_lumen/gfx_math.h" + #include "engine/assembly/foldhaus_assembly_parser.cpp" #include "engine/assembly/foldhaus_assembly_debug.h" @@ -42,7 +45,6 @@ typedef struct panel panel; #include "engine/animation/foldhaus_animation_renderer.cpp" #include "engine/user_space.h" -#include "ss_blumen_lumen/gfx_math.h" #include "ss_blumen_lumen/phrase_hue_map.h" #include "ss_blumen_lumen/blumen_lumen.h" diff --git a/src/app/patterns/blumen_patterns.h b/src/app/patterns/blumen_patterns.h index bac4015..8684d56 100644 --- a/src/app/patterns/blumen_patterns.h +++ b/src/app/patterns/blumen_patterns.h @@ -7,20 +7,6 @@ #define FLOWER_COLORS_COUNT 12 -internal pixel -V4ToRGBPixel(v4 C) -{ - C.x = Clamp01(C.x); - C.y = Clamp01(C.y); - C.z = Clamp01(C.z); - - pixel Result = {}; - Result.R = (u8)(C.x * 255); - Result.G = (u8)(C.y * 255); - Result.B = (u8)(C.z * 255); - return Result; -} - internal void Pattern_AltBloomMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { @@ -647,7 +633,7 @@ Pattern_VoicePattern(led_buffer* Leds, led_buffer_range Range, assembly Assembly v4 C = {}; C += GenPatchyColor(P, Time, C0, C2, {}); //C = GenVerticalLeaves((P - Assembly.Center) + v3{0, 150, 0}, Time, C0, C1, C2); - r32 Bands = GenLiquidBands(P, -250, Time); + //r32 Bands = GenLiquidBands(P, -250, Time); //C = V4Lerp(Bands, C * .5f, C1); //C = WhiteV4 * GenDotBands(P - Assembly.Center, Time); diff --git a/src/app/ss_blumen_lumen/blumen_lumen.cpp b/src/app/ss_blumen_lumen/blumen_lumen.cpp index ede2fb1..b80c80e 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen.cpp +++ b/src/app/ss_blumen_lumen/blumen_lumen.cpp @@ -357,7 +357,7 @@ BlumenLumen_CustomInit(app_state* State, context Context) for (u32 i = 0; i < BL_FLOWER_COUNT; i++) { assembly Assembly = State->Assemblies.Values[i]; - BLState->StemStrips[i] = AssemblyStripsGetWithTagValue(Assembly, ConstString("section"), ConstString("stem"), &State->Permanent); + BLState->StemStrips[Assembly.AssemblyIndex] = AssemblyStripsGetWithTagValue(Assembly, ConstString("section"), ConstString("stem"), &State->Permanent); } BLState->AssemblyNameToClearCoreMapCount = 3; diff --git a/src/app/ss_blumen_lumen/gfx_math.h b/src/app/ss_blumen_lumen/gfx_math.h index b4409e7..8b1acc8 100644 --- a/src/app/ss_blumen_lumen/gfx_math.h +++ b/src/app/ss_blumen_lumen/gfx_math.h @@ -443,4 +443,18 @@ while (Hue > 360.0f) { Hue -= 360.0f; } return Result; } +internal pixel +V4ToRGBPixel(v4 C) +{ + C.x = Clamp01(C.x); + C.y = Clamp01(C.y); + C.z = Clamp01(C.z); + + pixel Result = {}; + Result.R = (u8)(C.x * 255); + Result.G = (u8)(C.y * 255); + Result.B = (u8)(C.z * 255); + return Result; +} + #endif //GFX_MATH_H