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; } /*