fix rainbow popping (#2441)

This commit is contained in:
briaguya 2023-02-08 00:19:48 -05:00 committed by GitHub
parent fdf9d51444
commit df1e26d4cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

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