Improve rain/weather.

* Like Kart, remove cv_precipdensity.
* Like Kart, replace "Infinite" draw distance value with "None".
* Better thinker with more return optimisation.
* Better placement of thinking in rendering, to avoid ceiling-mounted sprite glitches.
This commit is contained in:
toaster 2019-06-18 13:33:35 +01:00
parent 740c561b0e
commit 861d0d0b0a
6 changed files with 52 additions and 59 deletions

View file

@ -5431,7 +5431,7 @@ static void HWR_AddSprites(sector_t *sec)
} }
#ifdef HWPRECIP #ifdef HWPRECIP
// Someone seriously wants infinite draw distance for precipitation? // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS))
{ {
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
@ -5447,13 +5447,6 @@ static void HWR_AddSprites(sector_t *sec)
HWR_ProjectPrecipitationSprite(precipthing); HWR_ProjectPrecipitationSprite(precipthing);
} }
} }
else
{
// Draw everything in sector, no checks
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
if (!(precipthing->precipflags & PCF_INVISIBLE))
HWR_ProjectPrecipitationSprite(precipthing);
}
#endif #endif
} }
@ -5774,16 +5767,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
x1 = tr_x + x1 * rightcos; x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos; x2 = tr_x - x2 * rightcos;
// okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
// //
// store information in a vissprite // store information in a vissprite
// //
@ -5804,6 +5787,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset);
vis->precip = true; vis->precip = true;
// okay... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
} }
#endif #endif

View file

@ -1193,13 +1193,12 @@ static menuitem_t OP_VideoOptionsMenu[] =
{IT_HEADER, NULL, "Level", NULL, 155}, {IT_HEADER, NULL, "Level", NULL, 155},
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 161}, {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 161},
{IT_STRING | IT_CVAR, NULL, "NiGHTS Draw Dist.", &cv_drawdist_nights, 166}, {IT_STRING | IT_CVAR, NULL, "Weather Draw Dist.", &cv_drawdist_precip, 166},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Dist.", &cv_drawdist_precip, 171}, {IT_STRING | IT_CVAR, NULL, "NiGHTS mode Draw Dist.", &cv_drawdist_nights, 171},
{IT_STRING | IT_CVAR, NULL, "Weather Density", &cv_precipdensity, 176},
{IT_HEADER, NULL, "Diagnostic", NULL, 185}, {IT_HEADER, NULL, "Diagnostic", NULL, 180},
{IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 191}, {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 186},
{IT_STRING | IT_CVAR, NULL, "Clear Before Redraw", &cv_homremoval, 196}, {IT_STRING | IT_CVAR, NULL, "Clear Before Redraw", &cv_homremoval, 191},
}; };
static menuitem_t OP_VideoModeMenu[] = static menuitem_t OP_VideoModeMenu[] =

View file

@ -4101,17 +4101,18 @@ void P_RainThinker(precipmobj_t *mobj)
} }
// adjust height // adjust height
if ((mobj->z += mobj->momz) <= mobj->floorz) if ((mobj->z += mobj->momz) > mobj->floorz)
return;
// no splashes on sky or bottomless pits
if (mobj->precipflags & PCF_PIT)
{ {
// no splashes on sky or bottomless pits mobj->z = mobj->ceilingz;
if (mobj->precipflags & PCF_PIT) return;
mobj->z = mobj->ceilingz;
else
{
mobj->z = mobj->floorz;
P_SetPrecipMobjState(mobj, S_SPLASH1);
}
} }
mobj->z = mobj->floorz;
P_SetPrecipMobjState(mobj, S_SPLASH1);
} }
static void P_RingThinker(mobj_t *mobj) static void P_RingThinker(mobj_t *mobj)
@ -9431,7 +9432,7 @@ void P_SpawnPrecipitation(void)
subsector_t *precipsector = NULL; subsector_t *precipsector = NULL;
precipmobj_t *rainmo = NULL; precipmobj_t *rainmo = NULL;
if (dedicated || !cv_precipdensity.value || curWeather == PRECIP_NONE) if (dedicated || /*!cv_precipdensity*/!cv_drawdist_precip.value || curWeather == PRECIP_NONE)
return; return;
// Use the blockmap to narrow down our placing patterns // Use the blockmap to narrow down our placing patterns
@ -9440,7 +9441,7 @@ void P_SpawnPrecipitation(void)
basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE;
basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE;
for (j = 0; j < cv_precipdensity.value; ++j) //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for us always
{ {
x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3); x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3); y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);

View file

@ -98,7 +98,14 @@ static CV_PossibleValue_t drawdist_cons_t[] = {
{1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"},
{8192, "8192"}, {0, "Infinite"}, {0, NULL}}; {8192, "8192"}, {0, "Infinite"}, {0, NULL}};
static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}};
//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}};
static CV_PossibleValue_t drawdist_precip_cons_t[] = {
{256, "256"}, {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{0, "None"}, {0, NULL}};
static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card
static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}};
@ -126,8 +133,8 @@ consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_c
consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// Okay, whoever said homremoval causes a performance hit should be shot. // Okay, whoever said homremoval causes a performance hit should be shot.
consvar_t cv_homremoval = {"homremoval", "No", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_homremoval = {"homremoval", "No", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -1158,7 +1165,6 @@ void R_RegisterEngineStuff(void)
if (dedicated) if (dedicated)
return; return;
CV_RegisterVar(&cv_precipdensity);
CV_RegisterVar(&cv_translucency); CV_RegisterVar(&cv_translucency);
CV_RegisterVar(&cv_drawdist); CV_RegisterVar(&cv_drawdist);
CV_RegisterVar(&cv_drawdist_nights); CV_RegisterVar(&cv_drawdist_nights);

View file

@ -78,7 +78,7 @@ extern consvar_t cv_chasecam, cv_chasecam2;
extern consvar_t cv_flipcam, cv_flipcam2; extern consvar_t cv_flipcam, cv_flipcam2;
extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_shadow, cv_shadowoffs;
extern consvar_t cv_translucency; extern consvar_t cv_translucency;
extern consvar_t cv_precipdensity, cv_drawdist, cv_drawdist_nights, cv_drawdist_precip; extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip;
extern consvar_t cv_skybox; extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup; extern consvar_t cv_tailspickup;

View file

@ -1527,16 +1527,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return; return;
} }
// okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
//SoM: 3/17/2000: Disregard sprites that are out of view.. //SoM: 3/17/2000: Disregard sprites that are out of view..
gzt = thing->z + spritecachedinfo[lump].topoffset; gzt = thing->z + spritecachedinfo[lump].topoffset;
@ -1545,7 +1535,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
if (thing->subsector->sector->cullheight) if (thing->subsector->sector->cullheight)
{ {
if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt)) if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt))
return; goto weatherthink;
} }
// store information in a vissprite // store information in a vissprite
@ -1605,6 +1595,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
// Fullbright // Fullbright
vis->colormap = colormaps; vis->colormap = colormaps;
weatherthink:
// okay... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
} }
// R_AddSprites // R_AddSprites
@ -1669,7 +1670,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
R_ProjectSprite(thing); R_ProjectSprite(thing);
} }
// Someone seriously wants infinite draw distance for precipitation? // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS))
{ {
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
@ -1685,13 +1686,6 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
R_ProjectPrecipitationSprite(precipthing); R_ProjectPrecipitationSprite(precipthing);
} }
} }
else
{
// Draw everything in sector, no checks
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
if (!(precipthing->precipflags & PCF_INVISIBLE))
R_ProjectPrecipitationSprite(precipthing);
}
} }
// //