Scale precipitation to mapobjectscale

This commit is contained in:
James R 2022-06-08 00:30:41 -07:00
parent f609043b2e
commit 5b3f1b2c10
3 changed files with 24 additions and 12 deletions

View file

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

View file

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

View file

@ -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; //<<detailshift;
vis->scale = FixedMul(yscale, this_scale);
vis->sortscale = yscale; //<<detailshift;
vis->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);