From df1e26d4cd60dc108241d794c2d874f29c13c1bd Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 8 Feb 2023 00:19:48 -0500 Subject: [PATCH] fix rainbow popping (#2441) --- soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 933fc420c..1d68191f0 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -384,13 +384,14 @@ int hue = 0; // Runs every frame to update rainbow hue, a potential future optimization is to only run this a once or twice a second and increase the speed of the rainbow hue rotation. void CosmeticsUpdateTick(bool& open) { int index = 0; + float rainbowSpeed = CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f); for (auto& [id, cosmeticOption] : cosmeticOptions) { if (cosmeticOption.supportsRainbow && CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { - float frequency = 2 * M_PI / (360 * CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f)); + float frequency = 2 * M_PI / (360 * rainbowSpeed); Color_RGBA8 newColor; - newColor.r = sin(frequency * ((hue + index)) + 0) * 127 + 128; - newColor.g = sin(frequency * ((hue + index)) + (2 * M_PI / 3)) * 127 + 128; - newColor.b = sin(frequency * ((hue + index)) + (4 * M_PI / 3)) * 127 + 128; + newColor.r = sin(frequency * (hue + index) + 0) * 127 + 128; + newColor.g = sin(frequency * (hue + index) + (2 * M_PI / 3)) * 127 + 128; + newColor.b = sin(frequency * (hue + index) + (4 * M_PI / 3)) * 127 + 128; newColor.a = 255; cosmeticOption.currentColor.x = newColor.r / 255.0; @@ -404,12 +405,12 @@ void CosmeticsUpdateTick(bool& open) { // Technically this would work if you replaced "60" with 1 but the hue would be so close it's // indistinguishable, 60 gives us a big enough gap to notice the difference. if (!CVarGetInteger("gCosmetics.RainbowSync", 0)) { - index+= (60 * CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f)); + index+= (60 * rainbowSpeed); } } ApplyOrResetCustomGfxPatches(false); hue++; - if (hue >= 360) hue = 0; + if (hue >= (360 * rainbowSpeed)) hue = 0; } /*