itsjustcurtis / MenyooSP

[or Menyoo PC] - Trainer/mod menu for Grand Theft Auto V (single-player).
https://www.gta5-mods.com/scripts/menyoo-2-0
GNU General Public License v3.0
36 stars 7 forks source link

"Paint Fade" Doesn't go to Zero #63

Closed The-Officer-DWm closed 2 months ago

The-Officer-DWm commented 5 months ago

Paint fade option doesn't seem to go to true zero without a lot of back and fourth between settings, sometimes sitting at 0.01, 0.02, or 0.00 (but a debugging program like CE would reveal that it's 0.0078...). I don't know too much about coding, but looking at VehicleModShop.cpp I saw that:

if (paintFade_minus)

    {
        if (paintFade > 0.02f)
            paintFade -= 0.02f;
        SET_VEHICLE_ENVEFF_SCALE(Static_12, paintFade);
    }

I feel like it's missing some kind of check that allows the float to actually reach zero. If I actually knew how to program, I would put in some type of check for detecting if the paintFade is less than or equal to 0.02f and then running:

    {
        if (paintFade <= 0.02f)
            paintFade -= paintFade;
        SET_VEHICLE_ENVEFF_SCALE(Static_12, paintFade);
    }

So if paintFade is roughly 0.01f, then the code would just pick up the current paintFade value and subtract that from itself to get 0.00f.

Thoughts?

itsjustcurtis commented 5 months ago

I believe this is intentional, MAFINS wouldn't have set the limit at 0.02 if there wasn't good reason for it. Is there a visible effect in game or would you not notice had the values not been displayed on screen?

metoxys commented 5 months ago

I believe this is intentional, MAFINS wouldn't have set the limit at 0.02 if there wasn't good reason for it. Is there a visible effect in game or would you not notice had the values not been displayed on screen?

To me it looks like the consequences of not properly understanding floating point math
This seems like a very crude way of making sure that it doesn't become a negative number
I imagine a solution would be something like paintFade = max(0.0f, paintFade - 0.02f);

itsjustcurtis commented 5 months ago

I believe this is intentional, MAFINS wouldn't have set the limit at 0.02 if there wasn't good reason for it. Is there a visible effect in game or would you not notice had the values not been displayed on screen?

To me it looks like the consequences of not properly understanding floating point math This seems like a very crude way of making sure that it doesn't become a negative number I imagine a solution would be something like paintFade = max(0.0f, paintFade - 0.02f);

Ooh that is not a bad shout at all. I'll investigate further and see what I come up with

metoxys commented 5 months ago

I believe this is intentional, MAFINS wouldn't have set the limit at 0.02 if there wasn't good reason for it. Is there a visible effect in game or would you not notice had the values not been displayed on screen?

To me it looks like the consequences of not properly understanding floating point math This seems like a very crude way of making sure that it doesn't become a negative number I imagine a solution would be something like paintFade = max(0.0f, paintFade - 0.02f);

Ooh that is not a bad shout at all. I'll investigate further and see what I come up with

get rid of the ifs for adding and subtracting, then do if > 1 then 1; else if < 0 then 0 before SET_VEHICLE_ENVEFF_SCALE, that way the slider behaves as the user expects and you avoid problematic values