mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'scaled-weather' into 'master'
Scale weather with MobjScale Closes #131 See merge request KartKrew/Kart!625
This commit is contained in:
commit
f1936c83fd
4 changed files with 53 additions and 23 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
40
src/p_mobj.c
40
src/p_mobj.c
|
|
@ -10642,30 +10642,26 @@ static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"},
|
|||
consvar_t cv_itemrespawntime = CVAR_INIT ("respawnitemtime", "2", CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL);
|
||||
consvar_t cv_itemrespawn = CVAR_INIT ("respawnitem", "On", CV_NETVAR, CV_OnOff, NULL);
|
||||
|
||||
void P_SpawnPrecipitation(void)
|
||||
static void P_SpawnPrecipitationAt(fixed_t basex, fixed_t basey)
|
||||
{
|
||||
INT32 i, j, k;
|
||||
INT32 j, k;
|
||||
|
||||
const mobjtype_t type = precipprops[curWeather].type;
|
||||
const UINT8 randomstates = (UINT8)mobjinfo[type].damage;
|
||||
const boolean flip = (mobjinfo[type].speed < 0);
|
||||
|
||||
fixed_t basex, basey, x, y, z, height;
|
||||
fixed_t i, x, y, z, height;
|
||||
|
||||
UINT16 numparticles = 0;
|
||||
boolean condition = false;
|
||||
|
||||
subsector_t *precipsector = NULL;
|
||||
precipmobj_t *rainmo = NULL;
|
||||
|
||||
if (dedicated || !cv_drawdist_precip.value || type == MT_NULL)
|
||||
return;
|
||||
|
||||
// Use the blockmap to narrow down our placing patterns
|
||||
for (i = 0; i < bmapwidth*bmapheight; ++i)
|
||||
// If mobjscale < FRACUNIT, each blockmap cell covers
|
||||
// more area so spawn more precipitation in that area.
|
||||
for (i = 0; i < FRACUNIT; i += mapobjectscale)
|
||||
{
|
||||
basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE;
|
||||
basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE;
|
||||
|
||||
x = basex + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
|
||||
y = basey + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
|
||||
|
||||
|
|
@ -10714,6 +10710,7 @@ void P_SpawnPrecipitation(void)
|
|||
}
|
||||
|
||||
height = precipsector->sector->ceilingheight - precipsector->sector->floorheight;
|
||||
height = FixedDiv(height, mapobjectscale);
|
||||
|
||||
// Exists, but is too small for reasonable precipitation.
|
||||
if (height < 64<<FRACBITS)
|
||||
|
|
@ -10751,6 +10748,27 @@ void P_SpawnPrecipitation(void)
|
|||
}
|
||||
}
|
||||
|
||||
void P_SpawnPrecipitation(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
const mobjtype_t type = precipprops[curWeather].type;
|
||||
|
||||
fixed_t basex, basey;
|
||||
|
||||
if (dedicated || !cv_drawdist_precip.value || type == MT_NULL)
|
||||
return;
|
||||
|
||||
// Use the blockmap to narrow down our placing patterns
|
||||
for (i = 0; i < bmapwidth*bmapheight; ++i)
|
||||
{
|
||||
basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE;
|
||||
basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE;
|
||||
|
||||
P_SpawnPrecipitationAt(basex, basey);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// P_PrecipitationEffects
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue