From 2bdc0140069d9ceb1870e8f01eab1b3c132fafa0 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 9 Sep 2024 15:41:26 +0100 Subject: [PATCH] With the help of GitLab user Lach, I turned my approximated sprite scaling in destroyed-kart.cpp into 100% accurate sprite scaling --- src/objects/destroyed-kart.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/objects/destroyed-kart.cpp b/src/objects/destroyed-kart.cpp index c8325db84..c5043534c 100644 --- a/src/objects/destroyed-kart.cpp +++ b/src/objects/destroyed-kart.cpp @@ -326,20 +326,13 @@ struct Kart : Mobj } Particle::spew(this); - - auto oldScale = scale(); scale(3*scale()/2); if(hasCustomHusk){ flags |= MF_NOSQUISH; //K_Squish() automates spritexscale/spriteyscale & this flag prevents that at the cost of no squish visual when the kart husk hits the ground - - //approximate inverse spritescale() by exaggerating fixed_t values by 100 and then dividing back down instead of doing float maths - //this way there's no decimal points and no potential for desyncs across builds/platforms - //there is potential this could overflow at exceptionally high scale() values - fixed_t z = FixedDiv(FixedMul(scale(),100),oldScale); - auto formula = [&](fixed_t subject){return FixedDiv(FixedMul(subject,100),z);}; - spritexscale(formula(spritexscale())); - spriteyscale(formula(spriteyscale())); + fixed_t huskScale = FixedDiv(mapobjectscale, scale()); + spritexscale(FixedMul(spritexscale(), huskScale)); + spriteyscale(FixedMul(spriteyscale(), huskScale)); } health = 1;