Fix affine sprites "dissolving" in Software

This commit is contained in:
yamamama 2026-03-04 12:32:21 -05:00
parent 143af29983
commit 3d229f3768
3 changed files with 14 additions and 6 deletions

View file

@ -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);

View file

@ -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];

View file

@ -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);