From 3d229f37688db355ad77fdc94444219539dc4ac1 Mon Sep 17 00:00:00 2001 From: yamamama Date: Wed, 4 Mar 2026 12:32:21 -0500 Subject: [PATCH] Fix affine sprites "dissolving" in Software --- src/r_things.cpp | 2 +- src/v_video.c | 15 +++++++++++---- src/v_video.h | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 76d5774bc..5939b64b7 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2394,7 +2394,7 @@ static void R_ProjectSprite(mobj_t *thing) affine_transform.ox = affine_pivot.x - rolloffs_x; affine_transform.oy = y_piv - rolloffs_y; - V_GetAffineBounds(&affine_transform, patch, FRACUNIT, &affine_bounds); + V_GetAffineBounds(&affine_transform, patch, FRACUNIT, &affine_bounds, true); // Rescale X and Y so we can multiply the pivot offset differences by them. const fixed_t _affinexscale = FixedDiv(affine_bounds.xlen * FRACUNIT, patch->width * FRACUNIT); diff --git a/src/v_video.c b/src/v_video.c index 48bb5c734..cc4f93ae2 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -813,7 +813,8 @@ static int sortcoords(const void *a, const void *b) affine_bounding_t* V_GetAffineBounds(const affine_t* transform, patch_t* patch, fixed_t divisor, - affine_bounding_t* out) + affine_bounding_t* out, + boolean unrestrict_bound) { // A decent chunk of this code is just fixedpointizing stuff // from HWR_GetAffinePatch; That system's near flawless, why fix what isn't broken? @@ -877,8 +878,14 @@ affine_bounding_t* V_GetAffineBounds(const affine_t* transform, }; // Get the leftmost and uppermost bounds of the current resolution. - const INT32 vw = vid.width, vh = vid.height; - const INT32 leftmost = ((BASEVIDWIDTH - vw) / 2), uppermost = ((BASEVIDHEIGHT - vh) / 2); + INT32 vw = vid.width, vh = vid.height; + INT32 leftmost = ((BASEVIDWIDTH - vw) / 2), uppermost = ((BASEVIDHEIGHT - vh) / 2); + + if (unrestrict_bound) + { + vw = vh = INT32_MAX; + leftmost = uppermost = INT32_MIN; + } // ...okay, now comb through all four vertices and set the output bounds based on this. // "Why not a loop?" According to SM64 programming wizard Kaze Emanuar, @@ -960,7 +967,7 @@ void V_DrawAffinePatch(fixed_t x, fixed_t y, const affine_t *transform, INT32 sc #endif affine_bounding_t bounds = {0}; - V_GetAffineBounds(transform, patch, vid.dup * FRACUNIT, &bounds); + V_GetAffineBounds(transform, patch, vid.dup * FRACUNIT, &bounds, false); Patch_GenerateFlat(patch, 0); const UINT16 *src = patch->flats[0]; diff --git a/src/v_video.h b/src/v_video.h index 264ff55b1..b4d8cf3a4 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -221,7 +221,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ affine_bounding_t* V_GetAffineBounds(const affine_t* transform, patch_t* patch, fixed_t divisor, - affine_bounding_t* out); + affine_bounding_t* out, + boolean unrestrict_bound); void V_DrawAffinePatch(fixed_t x, fixed_t y, const affine_t *transform, INT32 scrn, patch_t *patch, const UINT8 *colormap); void V_DrawRotatedPatch(fixed_t x, fixed_t y, angle_t angle, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap);