From 5814270980c027a5a21fe311e2fb61a9a67b86c6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 1 Nov 2016 22:58:53 +0100 Subject: [PATCH] Fix wrapping and scaling issue for the U texture coordinate for sprites --- src/r_things.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index cad434fa5c..6ef4e8027a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -954,15 +954,14 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; tx += tex->GetWidth() * thingxscalemul; - double dtx2 = tx * xscale; - x2 = centerx + xs_RoundToInt(dtx2); + x2 = centerx + xs_RoundToInt(tx * xscale); // off the left side or too small? if ((x2 < WindowLeft || x2 <= x1)) return; xscale = spriteScale.X * xscale / tex->Scale.X; - iscale = (fixed_t)(tex->GetWidth() / (dtx2 - dtx1) * FRACUNIT); + iscale = (fixed_t)(FRACUNIT / xscale); // Round towards zero to avoid wrapping in edge cases double yscale = spriteScale.Y / tex->Scale.Y; @@ -990,7 +989,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->xiscale = iscale; } - vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx - dtx1 + 0.5 * thingxscalemul)); + vis->startfrac += (fixed_t)(vis->xiscale * (vis->x1 - centerx + 0.5 - dtx1)); } else {