From 4a1cc618228aaf6bdbe55fc73e852649b8d72da1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 14 Apr 2016 20:09:38 -0500 Subject: [PATCH] Renderer floatification: Restore playersprite rendering --- src/r_main.cpp | 6 +++--- src/r_things.cpp | 32 ++++++++++++++++---------------- src/r_things.h | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index b30b02e33..92e131e26 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -386,9 +386,9 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, WallTMapScale2 = IYaspectMul * (1 << 18) / CenterX; // psprite scales - pspritexscale = (centerxwide << FRACBITS) / 160; - pspriteyscale = FLOAT2FIXED(pspritexscale * YaspectMul); - pspritexiscale = FixedDiv(FRACUNIT, pspritexscale); + pspritexscale = centerxwide / 160.0; + pspriteyscale = pspritexscale * YaspectMul; + pspritexiscale = 1 / pspritexscale; // thing clipping clearbufshort (screenheightarray, viewwidth, (short)viewheight); diff --git a/src/r_things.cpp b/src/r_things.cpp index c7961f1b5..ec9822a71 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -105,9 +105,9 @@ EXTERN_CVAR(Bool, r_deathcamera); // This is not the same as the angle, // which increases counter clockwise (protractor). // -fixed_t pspritexscale; -fixed_t pspriteyscale; -fixed_t pspritexiscale; +double pspritexscale; +double pspritexiscale; +double pspriteyscale; fixed_t sky1scale; // [RH] Sky 1 scale factor fixed_t sky2scale; // [RH] Sky 2 scale factor @@ -1274,9 +1274,9 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) // // R_DrawPSprite // -void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_t sy) +void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double sy) { - fixed_t tx; + double tx; int x1; int x2; spritedef_t* sprdef; @@ -1313,17 +1313,17 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ return; // calculate edges of the shape - tx = sx-((320/2)<GetScaledLeftOffset() << FRACBITS; - x1 = centerx + (FixedMul(tx, pspritexscale) >> FRACBITS); + tx -= tex->GetScaledLeftOffset(); + x1 = xs_RoundToInt(CenterX + tx * pspritexscale); // off the right side if (x1 > viewwidth) return; - tx += tex->GetScaledWidth() << FRACBITS; - x2 = centerx + (FixedMul(tx, pspritexscale) >> FRACBITS); + tx += tex->GetScaledWidth(); + x2 = xs_RoundToInt(CenterX + tx * pspritexscale); // off the left side if (x2 <= 0) @@ -1334,7 +1334,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ vis->renderflags = owner->renderflags; vis->floorclip = 0; - vis->texturemid = int(((BASEYCENTER<Scale.Y) + (tex->TopOffset << FRACBITS); + vis->texturemid = FLOAT2FIXED((BASEYCENTER - sy) * tex->Scale.Y + tex->TopOffset); if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || @@ -1363,20 +1363,20 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth : x2; - vis->xscale = fixed_t(pspritexscale / tex->Scale.X); - vis->yscale = fixed_t(pspriteyscale / tex->Scale.Y); + vis->xscale = FLOAT2FIXED(pspritexscale / tex->Scale.X); + vis->yscale = FLOAT2FIXED(pspriteyscale / tex->Scale.Y); vis->Translation = 0; // [RH] Use default colors vis->pic = tex; vis->ColormapNum = 0; if (flip) { - vis->xiscale = -int(pspritexiscale * tex->Scale.X); + vis->xiscale = -FLOAT2FIXED(pspritexiscale * tex->Scale.X); vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; } else { - vis->xiscale = int(pspritexiscale * tex->Scale.X); + vis->xiscale = FLOAT2FIXED(pspritexiscale * tex->Scale.X); vis->startfrac = 0; } @@ -1592,7 +1592,7 @@ void R_DrawPlayerSprites () // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. if (psp->state && (i != ps_targetcenter || CrosshairImage == NULL)) { - R_DrawPSprite (psp, i, camera, FLOAT2FIXED(psp->sx + ofsx), FLOAT2FIXED(psp->sy + ofsy)); + R_DrawPSprite (psp, i, camera, psp->sx + ofsx, psp->sy + ofsy); } // [RH] Don't bob the targeter. if (i == ps_flash) diff --git a/src/r_things.h b/src/r_things.h index 17b9d9845..5723a5737 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -112,9 +112,9 @@ extern fixed_t spryscale; extern fixed_t sprtopscreen; extern bool sprflipvert; -extern fixed_t pspritexscale; -extern fixed_t pspriteyscale; -extern fixed_t pspritexiscale; +extern double pspritexscale; +extern double pspritexiscale; +extern double pspriteyscale; extern FTexture *WallSpriteTile;