mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Weather is already run client-side. What if we ran it render-side, for major performance gains? This commit will answer all your questions - and more!
This commit is contained in:
parent
a605ee9c11
commit
b1e02467bf
7 changed files with 85 additions and 65 deletions
|
@ -5140,7 +5140,9 @@ static void HWR_AddSprites(sector_t *sec)
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||||
|
|
||||||
if (approx_dist <= limit_dist)
|
if (approx_dist > limit_dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
HWR_ProjectSprite(thing);
|
HWR_ProjectSprite(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5163,7 +5165,9 @@ static void HWR_AddSprites(sector_t *sec)
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||||
|
|
||||||
if (approx_dist <= limit_dist)
|
if (approx_dist > limit_dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
HWR_ProjectPrecipitationSprite(precipthing);
|
HWR_ProjectPrecipitationSprite(precipthing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5449,6 +5453,16 @@ 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
|
||||||
//
|
//
|
||||||
|
|
33
src/p_mobj.c
33
src/p_mobj.c
|
@ -3840,7 +3840,8 @@ void P_RecalcPrecipInSector(sector_t *sector)
|
||||||
//
|
//
|
||||||
void P_NullPrecipThinker(precipmobj_t *mobj)
|
void P_NullPrecipThinker(precipmobj_t *mobj)
|
||||||
{
|
{
|
||||||
(void)mobj;
|
//(void)mobj;
|
||||||
|
mobj->precipflags &= ~PCF_THUNK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void P_SnowThinker(precipmobj_t *mobj)
|
void P_SnowThinker(precipmobj_t *mobj)
|
||||||
|
@ -3860,25 +3861,26 @@ void P_RainThinker(precipmobj_t *mobj)
|
||||||
{
|
{
|
||||||
// cycle through states,
|
// cycle through states,
|
||||||
// calling action functions at transitions
|
// calling action functions at transitions
|
||||||
if (mobj->tics > 0 && --mobj->tics == 0)
|
if (mobj->tics <= 0)
|
||||||
{
|
return;
|
||||||
// you can cycle through multiple states in a tic
|
|
||||||
if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate))
|
if (--mobj->tics)
|
||||||
return; // freed itself
|
return;
|
||||||
}
|
|
||||||
|
if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mobj->state != &states[S_RAINRETURN])
|
||||||
|
return;
|
||||||
|
|
||||||
if (mobj->state == &states[S_RAINRETURN])
|
|
||||||
{
|
|
||||||
mobj->z = mobj->ceilingz;
|
mobj->z = mobj->ceilingz;
|
||||||
P_SetPrecipMobjState(mobj, S_RAIN1);
|
P_SetPrecipMobjState(mobj, S_RAIN1);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust height
|
// adjust height
|
||||||
mobj->z += mobj->momz;
|
if ((mobj->z += mobj->momz) <= mobj->floorz)
|
||||||
|
|
||||||
if (mobj->z <= mobj->floorz)
|
|
||||||
{
|
{
|
||||||
// no splashes on sky or bottomless pits
|
// no splashes on sky or bottomless pits
|
||||||
if (mobj->precipflags & PCF_PIT)
|
if (mobj->precipflags & PCF_PIT)
|
||||||
|
@ -7926,14 +7928,15 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
|
||||||
static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
||||||
{
|
{
|
||||||
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
|
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
|
||||||
mo->thinker.function.acp1 = (actionf_p1)P_RainThinker;
|
mo->precipflags |= PCF_RAIN;
|
||||||
|
//mo->thinker.function.acp1 = (actionf_p1)P_RainThinker;
|
||||||
return mo;
|
return mo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
||||||
{
|
{
|
||||||
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
|
precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type);
|
||||||
mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker;
|
//mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker;
|
||||||
return mo;
|
return mo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,10 @@ typedef enum {
|
||||||
PCF_FOF = 4,
|
PCF_FOF = 4,
|
||||||
// Above MOVING FOF (this means we need to keep floorz up to date...)
|
// Above MOVING FOF (this means we need to keep floorz up to date...)
|
||||||
PCF_MOVINGFOF = 8,
|
PCF_MOVINGFOF = 8,
|
||||||
|
// Is rain.
|
||||||
|
PCF_RAIN = 16,
|
||||||
|
// Ran the thinker this tic.
|
||||||
|
PCF_THUNK = 32,
|
||||||
} precipflag_t;
|
} precipflag_t;
|
||||||
// Map Object definition.
|
// Map Object definition.
|
||||||
typedef struct mobj_s
|
typedef struct mobj_s
|
||||||
|
|
|
@ -1661,8 +1661,7 @@ static void P_NetArchiveThinkers(void)
|
||||||
for (th = thinkercap.next; th != &thinkercap; th = th->next)
|
for (th = thinkercap.next; th != &thinkercap; th = th->next)
|
||||||
{
|
{
|
||||||
if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed
|
if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed
|
||||||
|| th->function.acp1 == (actionf_p1)P_RainThinker
|
|| th->function.acp1 == (actionf_p1)P_NullPrecipThinker))
|
||||||
|| th->function.acp1 == (actionf_p1)P_SnowThinker))
|
|
||||||
numsaved++;
|
numsaved++;
|
||||||
|
|
||||||
if (th->function.acp1 == (actionf_p1)P_MobjThinker)
|
if (th->function.acp1 == (actionf_p1)P_MobjThinker)
|
||||||
|
@ -1671,8 +1670,7 @@ static void P_NetArchiveThinkers(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
else if (th->function.acp1 == (actionf_p1)P_RainThinker
|
else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker);
|
||||||
|| th->function.acp1 == (actionf_p1)P_SnowThinker);
|
|
||||||
#endif
|
#endif
|
||||||
else if (th->function.acp1 == (actionf_p1)T_MoveCeiling)
|
else if (th->function.acp1 == (actionf_p1)T_MoveCeiling)
|
||||||
{
|
{
|
||||||
|
|
32
src/p_spec.c
32
src/p_spec.c
|
@ -2039,8 +2039,7 @@ void P_SwitchWeather(INT32 weathernum)
|
||||||
|
|
||||||
for (think = thinkercap.next; think != &thinkercap; think = think->next)
|
for (think = thinkercap.next; think != &thinkercap; think = think->next)
|
||||||
{
|
{
|
||||||
if ((think->function.acp1 != (actionf_p1)P_SnowThinker)
|
if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||||
&& (think->function.acp1 != (actionf_p1)P_RainThinker))
|
|
||||||
continue; // not a precipmobj thinker
|
continue; // not a precipmobj thinker
|
||||||
|
|
||||||
precipmobj = (precipmobj_t *)think;
|
precipmobj = (precipmobj_t *)think;
|
||||||
|
@ -2056,14 +2055,12 @@ void P_SwitchWeather(INT32 weathernum)
|
||||||
|
|
||||||
for (think = thinkercap.next; think != &thinkercap; think = think->next)
|
for (think = thinkercap.next; think != &thinkercap; think = think->next)
|
||||||
{
|
{
|
||||||
if (swap == PRECIP_RAIN) // Snow To Rain
|
if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||||
{
|
|
||||||
if (!(think->function.acp1 == (actionf_p1)P_SnowThinker
|
|
||||||
|| think->function.acp1 == (actionf_p1)P_NullPrecipThinker))
|
|
||||||
continue; // not a precipmobj thinker
|
continue; // not a precipmobj thinker
|
||||||
|
|
||||||
precipmobj = (precipmobj_t *)think;
|
precipmobj = (precipmobj_t *)think;
|
||||||
|
|
||||||
|
if (swap == PRECIP_RAIN) // Snow To Rain
|
||||||
|
{
|
||||||
precipmobj->flags = mobjinfo[MT_RAIN].flags;
|
precipmobj->flags = mobjinfo[MT_RAIN].flags;
|
||||||
st = &states[mobjinfo[MT_RAIN].spawnstate];
|
st = &states[mobjinfo[MT_RAIN].spawnstate];
|
||||||
precipmobj->state = st;
|
precipmobj->state = st;
|
||||||
|
@ -2074,18 +2071,13 @@ void P_SwitchWeather(INT32 weathernum)
|
||||||
|
|
||||||
precipmobj->precipflags &= ~PCF_INVISIBLE;
|
precipmobj->precipflags &= ~PCF_INVISIBLE;
|
||||||
|
|
||||||
think->function.acp1 = (actionf_p1)P_RainThinker;
|
precipmobj->precipflags |= PCF_RAIN;
|
||||||
|
//think->function.acp1 = (actionf_p1)P_RainThinker;
|
||||||
}
|
}
|
||||||
else if (swap == PRECIP_SNOW) // Rain To Snow
|
else if (swap == PRECIP_SNOW) // Rain To Snow
|
||||||
{
|
{
|
||||||
INT32 z;
|
INT32 z;
|
||||||
|
|
||||||
if (!(think->function.acp1 == (actionf_p1)P_RainThinker
|
|
||||||
|| think->function.acp1 == (actionf_p1)P_NullPrecipThinker))
|
|
||||||
continue; // not a precipmobj thinker
|
|
||||||
|
|
||||||
precipmobj = (precipmobj_t *)think;
|
|
||||||
|
|
||||||
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
|
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
|
||||||
z = M_RandomByte();
|
z = M_RandomByte();
|
||||||
|
|
||||||
|
@ -2103,19 +2095,13 @@ void P_SwitchWeather(INT32 weathernum)
|
||||||
precipmobj->frame = st->frame;
|
precipmobj->frame = st->frame;
|
||||||
precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed;
|
precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed;
|
||||||
|
|
||||||
precipmobj->precipflags &= ~PCF_INVISIBLE;
|
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN);
|
||||||
|
|
||||||
think->function.acp1 = (actionf_p1)P_SnowThinker;
|
//think->function.acp1 = (actionf_p1)P_SnowThinker;
|
||||||
}
|
}
|
||||||
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
|
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
|
||||||
{
|
{
|
||||||
if (!(think->function.acp1 == (actionf_p1)P_RainThinker
|
//think->function.acp1 = (actionf_p1)P_NullPrecipThinker;
|
||||||
|| think->function.acp1 == (actionf_p1)P_SnowThinker))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
precipmobj = (precipmobj_t *)think;
|
|
||||||
|
|
||||||
think->function.acp1 = (actionf_p1)P_NullPrecipThinker;
|
|
||||||
|
|
||||||
precipmobj->precipflags |= PCF_INVISIBLE;
|
precipmobj->precipflags |= PCF_INVISIBLE;
|
||||||
}
|
}
|
||||||
|
|
24
src/p_tick.c
24
src/p_tick.c
|
@ -56,12 +56,12 @@ void Command_Numthinkers_f(void)
|
||||||
CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n"));
|
CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n"));
|
||||||
CONS_Printf(
|
CONS_Printf(
|
||||||
"\t1: P_MobjThinker\n"
|
"\t1: P_MobjThinker\n"
|
||||||
"\t2: P_RainThinker\n"
|
/*"\t2: P_RainThinker\n"
|
||||||
"\t3: P_SnowThinker\n"
|
"\t3: P_SnowThinker\n"*/
|
||||||
"\t4: P_NullPrecipThinker\n"
|
"\t2: P_NullPrecipThinker\n"
|
||||||
"\t5: T_Friction\n"
|
"\t3: T_Friction\n"
|
||||||
"\t6: T_Pusher\n"
|
"\t4: T_Pusher\n"
|
||||||
"\t7: P_RemoveThinkerDelayed\n");
|
"\t5: P_RemoveThinkerDelayed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,27 +73,27 @@ void Command_Numthinkers_f(void)
|
||||||
action = (actionf_p1)P_MobjThinker;
|
action = (actionf_p1)P_MobjThinker;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker");
|
CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker");
|
||||||
break;
|
break;
|
||||||
case 2:
|
/*case 2:
|
||||||
action = (actionf_p1)P_RainThinker;
|
action = (actionf_p1)P_RainThinker;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker");
|
CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
action = (actionf_p1)P_SnowThinker;
|
action = (actionf_p1)P_SnowThinker;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker");
|
CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker");
|
||||||
break;
|
break;*/
|
||||||
case 4:
|
case 2:
|
||||||
action = (actionf_p1)P_NullPrecipThinker;
|
action = (actionf_p1)P_NullPrecipThinker;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker");
|
CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker");
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 3:
|
||||||
action = (actionf_p1)T_Friction;
|
action = (actionf_p1)T_Friction;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "T_Friction");
|
CONS_Printf(M_GetText("Number of %s: "), "T_Friction");
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 4:
|
||||||
action = (actionf_p1)T_Pusher;
|
action = (actionf_p1)T_Pusher;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "T_Pusher");
|
CONS_Printf(M_GetText("Number of %s: "), "T_Pusher");
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 5:
|
||||||
action = (actionf_p1)P_RemoveThinkerDelayed;
|
action = (actionf_p1)P_RemoveThinkerDelayed;
|
||||||
CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed");
|
CONS_Printf(M_GetText("Number of %s: "), "P_RemoveThinkerDelayed");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1451,6 +1451,17 @@ 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;
|
||||||
gz = gzt - spritecachedinfo[lump].height;
|
gz = gzt - spritecachedinfo[lump].height;
|
||||||
|
@ -1569,7 +1580,9 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||||
|
|
||||||
if (approx_dist <= limit_dist)
|
if (approx_dist > limit_dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
R_ProjectSprite(thing);
|
R_ProjectSprite(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1604,9 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||||
|
|
||||||
if (approx_dist <= limit_dist)
|
if (approx_dist > limit_dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
R_ProjectPrecipitationSprite(precipthing);
|
R_ProjectPrecipitationSprite(precipthing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue