From 91241eb96ea8cbd209c016f9fff7566931dc472b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 May 2007 15:33:05 +0000 Subject: [PATCH] - Fixed: Hirestex replacements for sprites didn't work properly due to some incorrect calculations in R_ProjectSprite. SVN r536 (trunk) --- docs/rh-log.txt | 2 ++ src/r_things.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 8adaa98e2..9fad50b77 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ May 27, 2007 (Changes by Graf Zahl) +- Fixed: Hirestex replacements for sprites didn't work properly due to some + incorrect calculations in R_ProjectSprite. - Fixed: The speed definition of PowerSpeed used PROP_SpeedFixed instead of PROP_SpeedLong. - Fixed: The Chainsaw's kickback was initialized to the default - not 0. diff --git a/src/r_things.cpp b/src/r_things.cpp index 9cf8e0f44..c0bacef63 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1302,8 +1302,10 @@ void R_ProjectSprite (AActor *thing, int fakeside) } // [RH] Added scaling - gzt = fz + MulScale16(thing->scaleY, tex->TopOffset * tex->yScale); - gzb = fz + MulScale16(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->yScale); + int scaled_to = tex->GetScaledTopOffset(); + int scaled_bo = scaled_to - tex->GetScaledHeight(); + gzt = fz + thing->scaleY * scaled_to; + gzb = fz + thing->scaleY * scaled_bo; // [RH] Reject sprites that are off the top or bottom of the screen if (MulScale12 (globaluclip, tz) > viewz - gzb || @@ -1319,7 +1321,7 @@ void R_ProjectSprite (AActor *thing, int fakeside) } // calculate edges of the shape - const fixed_t thingxscalemul = MulScale16(thing->scaleX, tex->xScale); + const fixed_t thingxscalemul = DivScale16(thing->scaleX, tex->xScale); tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; x1 = centerx + MulScale32 (tx, xscale); @@ -1335,7 +1337,7 @@ void R_ProjectSprite (AActor *thing, int fakeside) if (x2 < WindowLeft || x2 <= x1) return; - xscale = FixedMul(FixedMul(thing->scaleX, xscale), tex->xScale); + xscale = FixedDiv(FixedMul(thing->scaleX, xscale), tex->xScale); iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); x2--; @@ -1378,20 +1380,21 @@ void R_ProjectSprite (AActor *thing, int fakeside) vis->heightsec = heightsec; vis->sector = thing->Sector; + fixed_t yscale = DivScale16(thing->scaleY, tex->yScale); vis->renderflags = thing->renderflags; vis->RenderStyle = thing->RenderStyle; vis->AlphaColor = thing->alphacolor; vis->xscale = xscale; - vis->yscale = Scale (InvZtoScale, MulScale16(thing->scaleY, tex->yScale), tz)>>4; + vis->yscale = Scale (InvZtoScale, yscale, tz)>>4; vis->idepth = (DWORD)DivScale32 (1, tz) >> 1; // tz is 20.12, so idepth ought to be 12.20, but vis->cx = tx2; // signed math makes it 13.19 vis->gx = fx; vis->gy = fy; vis->gz = gzb; // [RH] use gzb, not thing->z vis->gzt = gzt; // killough 3/27/98 - vis->floorclip = FixedDiv (thing->floorclip, MulScale16(thing->scaleY, tex->yScale)); + vis->floorclip = FixedDiv (thing->floorclip, yscale); vis->texturemid = (tex->TopOffset << FRACBITS) - - FixedDiv (viewz-fz+thing->floorclip, MulScale16(thing->scaleY, tex->yScale)); + FixedDiv (viewz-fz+thing->floorclip, yscale); vis->x1 = x1 < WindowLeft ? WindowLeft : x1; vis->x2 = x2 > WindowRight ? WindowRight : x2; vis->Translation = thing->Translation; // [RH] thing translation table