From 5b3f1b2c101dffbf970440d66184c2e88302e655 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 8 Jun 2022 00:30:41 -0700 Subject: [PATCH] Scale precipitation to mapobjectscale --- src/hardware/hw_main.c | 10 ++++++++-- src/r_fps.c | 4 ++-- src/r_things.c | 22 ++++++++++++++-------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bd0c874ad..871ecf6ad 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5564,6 +5564,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) float x1, x2; float z1, z2; float rightsin, rightcos; + float this_scale; spritedef_t *sprdef; spriteframe_t *sprframe; size_t lumpoff; @@ -5586,6 +5587,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } + this_scale = FIXED_TO_FLOAT(interp.scale); + // transform the origin point tr_x = FIXED_TO_FLOAT(interp.x) - gl_viewx; tr_y = FIXED_TO_FLOAT(interp.y) - gl_viewy; @@ -5638,6 +5641,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); } + x1 *= this_scale; + x2 *= this_scale; + z1 = tr_y + x1 * rightsin; z2 = tr_y - x2 * rightsin; x1 = tr_x + x1 * rightcos; @@ -5665,8 +5671,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); - vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); + vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale); + vis->gz = vis->gzt - (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale); vis->precip = true; diff --git a/src/r_fps.c b/src/r_fps.c index aff481910..32d24ba10 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -316,7 +316,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->x = mobj->x; out->y = mobj->y; out->z = mobj->z; - out->scale = FRACUNIT; + out->scale = mapobjectscale; out->subsector = mobj->subsector; out->angle = mobj->angle; out->spritexscale = mobj->spritexscale; @@ -329,7 +329,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->scale = FRACUNIT; + out->scale = mapobjectscale; out->spritexscale = R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); out->spriteyscale = R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); out->spritexoffset = R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); diff --git a/src/r_things.c b/src/r_things.c index 05276ea8e..2fe008dd8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1034,6 +1034,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) #endif fixed_t frac; patch_t *patch; + fixed_t this_scale = vis->thingscale; INT64 overflow_test; //Fab : R_InitSprites now sets a wad lump number @@ -1061,7 +1062,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) } dc_iscale = FixedDiv(FRACUNIT, vis->scale); - dc_texturemid = vis->texturemid; + dc_texturemid = FixedDiv(vis->texturemid, this_scale); dc_texheight = 0; frac = vis->startfrac; @@ -2187,6 +2188,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //SoM: 3/17/2000 fixed_t gz, gzt; + fixed_t this_scale; UINT32 blendmode; UINT32 trans; @@ -2204,6 +2206,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } + this_scale = interp.scale; + // transform the origin point tr_x = interp.x - viewx; tr_y = interp.y - viewy; @@ -2211,7 +2215,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? - if (tz < MINZ) + if (tz < FixedMul(MINZ, this_scale)) return; tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance @@ -2250,14 +2254,14 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) lump = sprframe->lumpid[0]; //Fab: see note above // calculate edges of the shape - tx -= spritecachedinfo[lump].offset; + tx -= FixedMul(spritecachedinfo[lump].offset, this_scale); x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; // off the right side? if (x1 > viewwidth) return; - tx += spritecachedinfo[lump].width; + tx += FixedMul(spritecachedinfo[lump].width, this_scale); x2 = ((centerxfrac + FixedMul (tx,xscale)) >>FRACBITS) - 1; // off the left side @@ -2275,8 +2279,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - gzt = interp.z + spritecachedinfo[lump].topoffset; - gz = gzt - spritecachedinfo[lump].height; + gzt = interp.z + FixedMul(spritecachedinfo[lump].topoffset, this_scale); + gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); if (thing->subsector->sector->cullheight) { @@ -2297,7 +2301,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // store information in a vissprite vis = R_NewVisSprite(); - vis->scale = vis->sortscale = yscale; //<scale = FixedMul(yscale, this_scale); + vis->sortscale = yscale; //<thingscale = interp.scale; vis->dispoffset = 0; // Monster Iestyn: 23/11/15 vis->gx = interp.x; vis->gy = interp.y; @@ -2323,7 +2329,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) iscale = FixedDiv(FRACUNIT, xscale); vis->startfrac = 0; - vis->xiscale = iscale; + vis->xiscale = FixedDiv(iscale, this_scale); if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1);