mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 23:42:11 +00:00
Merge branch 'i-can-see-myself' into 'master'
Don't draw yourself in first person! See merge request STJr/SRB2!697
This commit is contained in:
commit
aad4b6f8a1
5 changed files with 98 additions and 104 deletions
|
@ -5399,7 +5399,7 @@ static void HWR_AddSprites(sector_t *sec)
|
||||||
#ifdef HWPRECIP
|
#ifdef HWPRECIP
|
||||||
precipmobj_t *precipthing;
|
precipmobj_t *precipthing;
|
||||||
#endif
|
#endif
|
||||||
fixed_t approx_dist, limit_dist, hoop_limit_dist;
|
fixed_t limit_dist, hoop_limit_dist;
|
||||||
|
|
||||||
// BSP is traversed by subsector.
|
// BSP is traversed by subsector.
|
||||||
// A sector might have been split into several
|
// A sector might have been split into several
|
||||||
|
@ -5418,34 +5418,9 @@ static void HWR_AddSprites(sector_t *sec)
|
||||||
// If a limit exists, handle things a tiny bit different.
|
// If a limit exists, handle things a tiny bit different.
|
||||||
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
||||||
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
||||||
if (limit_dist || hoop_limit_dist)
|
|
||||||
{
|
|
||||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||||
{
|
{
|
||||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
|
if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist))
|
||||||
continue;
|
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
|
||||||
|
|
||||||
if (thing->sprite == SPR_HOOP)
|
|
||||||
{
|
|
||||||
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (limit_dist && approx_dist > limit_dist)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWR_ProjectSprite(thing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Draw everything in sector, no checks
|
|
||||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
|
||||||
if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW))
|
|
||||||
HWR_ProjectSprite(thing);
|
HWR_ProjectSprite(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5455,14 +5430,7 @@ static void HWR_AddSprites(sector_t *sec)
|
||||||
{
|
{
|
||||||
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
||||||
{
|
{
|
||||||
if (precipthing->precipflags & PCF_INVISIBLE)
|
if (R_PrecipThingVisible(precipthing, limit_dist))
|
||||||
continue;
|
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
|
||||||
|
|
||||||
if (approx_dist > limit_dist)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
HWR_ProjectPrecipitationSprite(precipthing);
|
HWR_ProjectPrecipitationSprite(precipthing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5727,7 +5695,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer)
|
if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer)
|
||||||
{
|
{
|
||||||
// bodge support - not nearly as comprehensive as r_things.c, but better than nothing
|
// bodge support - not nearly as comprehensive as r_things.c, but better than nothing
|
||||||
if (thing->tracer->sprite == SPR_NULL || thing->tracer->flags2 & MF2_DONTDRAW)
|
if (! R_ThingVisible(thing->tracer))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
55
src/r_main.c
55
src/r_main.c
|
@ -71,6 +71,7 @@ angle_t viewangle, aimingangle;
|
||||||
fixed_t viewcos, viewsin;
|
fixed_t viewcos, viewsin;
|
||||||
sector_t *viewsector;
|
sector_t *viewsector;
|
||||||
player_t *viewplayer;
|
player_t *viewplayer;
|
||||||
|
mobj_t *r_viewmobj;
|
||||||
|
|
||||||
//
|
//
|
||||||
// precalculated math tables
|
// precalculated math tables
|
||||||
|
@ -741,8 +742,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
|
||||||
// R_SetupFrame
|
// R_SetupFrame
|
||||||
//
|
//
|
||||||
|
|
||||||
static mobj_t *viewmobj;
|
|
||||||
|
|
||||||
// WARNING: a should be unsigned but to add with 2048, it isn't!
|
// WARNING: a should be unsigned but to add with 2048, it isn't!
|
||||||
#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS, fovtan)
|
#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS, fovtan)
|
||||||
|
|
||||||
|
@ -799,16 +798,16 @@ void R_SetupFrame(player_t *player)
|
||||||
if (player->awayviewtics)
|
if (player->awayviewtics)
|
||||||
{
|
{
|
||||||
// cut-away view stuff
|
// cut-away view stuff
|
||||||
viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN
|
r_viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN
|
||||||
I_Assert(viewmobj != NULL);
|
I_Assert(r_viewmobj != NULL);
|
||||||
viewz = viewmobj->z + 20*FRACUNIT;
|
viewz = r_viewmobj->z + 20*FRACUNIT;
|
||||||
aimingangle = player->awayviewaiming;
|
aimingangle = player->awayviewaiming;
|
||||||
viewangle = viewmobj->angle;
|
viewangle = r_viewmobj->angle;
|
||||||
}
|
}
|
||||||
else if (!player->spectator && chasecam)
|
else if (!player->spectator && chasecam)
|
||||||
// use outside cam view
|
// use outside cam view
|
||||||
{
|
{
|
||||||
viewmobj = NULL;
|
r_viewmobj = NULL;
|
||||||
viewz = thiscam->z + (thiscam->height>>1);
|
viewz = thiscam->z + (thiscam->height>>1);
|
||||||
aimingangle = thiscam->aiming;
|
aimingangle = thiscam->aiming;
|
||||||
viewangle = thiscam->angle;
|
viewangle = thiscam->angle;
|
||||||
|
@ -818,11 +817,11 @@ void R_SetupFrame(player_t *player)
|
||||||
{
|
{
|
||||||
viewz = player->viewz;
|
viewz = player->viewz;
|
||||||
|
|
||||||
viewmobj = player->mo;
|
r_viewmobj = player->mo;
|
||||||
I_Assert(viewmobj != NULL);
|
I_Assert(r_viewmobj != NULL);
|
||||||
|
|
||||||
aimingangle = player->aiming;
|
aimingangle = player->aiming;
|
||||||
viewangle = viewmobj->angle;
|
viewangle = r_viewmobj->angle;
|
||||||
|
|
||||||
if (!demoplayback && player->playerstate != PST_DEAD)
|
if (!demoplayback && player->playerstate != PST_DEAD)
|
||||||
{
|
{
|
||||||
|
@ -856,13 +855,13 @@ void R_SetupFrame(player_t *player)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
viewx = viewmobj->x;
|
viewx = r_viewmobj->x;
|
||||||
viewy = viewmobj->y;
|
viewy = r_viewmobj->y;
|
||||||
viewx += quake.x;
|
viewx += quake.x;
|
||||||
viewy += quake.y;
|
viewy += quake.y;
|
||||||
|
|
||||||
if (viewmobj->subsector)
|
if (r_viewmobj->subsector)
|
||||||
viewsector = viewmobj->subsector->sector;
|
viewsector = r_viewmobj->subsector->sector;
|
||||||
else
|
else
|
||||||
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
||||||
}
|
}
|
||||||
|
@ -884,12 +883,12 @@ void R_SkyboxFrame(player_t *player)
|
||||||
thiscam = &camera;
|
thiscam = &camera;
|
||||||
|
|
||||||
// cut-away view stuff
|
// cut-away view stuff
|
||||||
viewmobj = skyboxmo[0];
|
r_viewmobj = skyboxmo[0];
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
if (!viewmobj)
|
if (!r_viewmobj)
|
||||||
{
|
{
|
||||||
const size_t playeri = (size_t)(player - players);
|
const size_t playeri = (size_t)(player - players);
|
||||||
I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri));
|
I_Error("R_SkyboxFrame: r_viewmobj null (player %s)", sizeu1(playeri));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (player->awayviewtics)
|
if (player->awayviewtics)
|
||||||
|
@ -920,13 +919,13 @@ void R_SkyboxFrame(player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewangle += viewmobj->angle;
|
viewangle += r_viewmobj->angle;
|
||||||
|
|
||||||
viewplayer = player;
|
viewplayer = player;
|
||||||
|
|
||||||
viewx = viewmobj->x;
|
viewx = r_viewmobj->x;
|
||||||
viewy = viewmobj->y;
|
viewy = r_viewmobj->y;
|
||||||
viewz = viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle!
|
viewz = r_viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle!
|
||||||
|
|
||||||
if (mapheaderinfo[gamemap-1])
|
if (mapheaderinfo[gamemap-1])
|
||||||
{
|
{
|
||||||
|
@ -966,29 +965,29 @@ void R_SkyboxFrame(player_t *player)
|
||||||
else if (mh->skybox_scaley < 0)
|
else if (mh->skybox_scaley < 0)
|
||||||
y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||||
|
|
||||||
if (viewmobj->angle == 0)
|
if (r_viewmobj->angle == 0)
|
||||||
{
|
{
|
||||||
viewx += x;
|
viewx += x;
|
||||||
viewy += y;
|
viewy += y;
|
||||||
}
|
}
|
||||||
else if (viewmobj->angle == ANGLE_90)
|
else if (r_viewmobj->angle == ANGLE_90)
|
||||||
{
|
{
|
||||||
viewx -= y;
|
viewx -= y;
|
||||||
viewy += x;
|
viewy += x;
|
||||||
}
|
}
|
||||||
else if (viewmobj->angle == ANGLE_180)
|
else if (r_viewmobj->angle == ANGLE_180)
|
||||||
{
|
{
|
||||||
viewx -= x;
|
viewx -= x;
|
||||||
viewy -= y;
|
viewy -= y;
|
||||||
}
|
}
|
||||||
else if (viewmobj->angle == ANGLE_270)
|
else if (r_viewmobj->angle == ANGLE_270)
|
||||||
{
|
{
|
||||||
viewx += y;
|
viewx += y;
|
||||||
viewy -= x;
|
viewy -= x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
|
angle_t ang = r_viewmobj->angle>>ANGLETOFINESHIFT;
|
||||||
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||||
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
||||||
}
|
}
|
||||||
|
@ -999,8 +998,8 @@ void R_SkyboxFrame(player_t *player)
|
||||||
viewz += campos.z * -mh->skybox_scalez;
|
viewz += campos.z * -mh->skybox_scalez;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewmobj->subsector)
|
if (r_viewmobj->subsector)
|
||||||
viewsector = viewmobj->subsector->sector;
|
viewsector = r_viewmobj->subsector->sector;
|
||||||
else
|
else
|
||||||
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ extern fixed_t viewx, viewy, viewz;
|
||||||
extern angle_t viewangle, aimingangle;
|
extern angle_t viewangle, aimingangle;
|
||||||
extern sector_t *viewsector;
|
extern sector_t *viewsector;
|
||||||
extern player_t *viewplayer;
|
extern player_t *viewplayer;
|
||||||
|
extern mobj_t *r_viewmobj;
|
||||||
|
|
||||||
extern consvar_t cv_allowmlook;
|
extern consvar_t cv_allowmlook;
|
||||||
extern consvar_t cv_maxportals;
|
extern consvar_t cv_maxportals;
|
||||||
|
|
|
@ -1413,7 +1413,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
thing = thing->tracer;
|
thing = thing->tracer;
|
||||||
|
|
||||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
|
if (! R_ThingVisible(thing))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tr_x = thing->x - viewx;
|
tr_x = thing->x - viewx;
|
||||||
|
@ -1808,7 +1808,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||||
mobj_t *thing;
|
mobj_t *thing;
|
||||||
precipmobj_t *precipthing; // Tails 08-25-2002
|
precipmobj_t *precipthing; // Tails 08-25-2002
|
||||||
INT32 lightnum;
|
INT32 lightnum;
|
||||||
fixed_t approx_dist, limit_dist, hoop_limit_dist;
|
fixed_t limit_dist, hoop_limit_dist;
|
||||||
|
|
||||||
if (rendermode != render_soft)
|
if (rendermode != render_soft)
|
||||||
return;
|
return;
|
||||||
|
@ -1841,34 +1841,9 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||||
// If a limit exists, handle things a tiny bit different.
|
// If a limit exists, handle things a tiny bit different.
|
||||||
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
||||||
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
||||||
if (limit_dist || hoop_limit_dist)
|
|
||||||
{
|
|
||||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||||
{
|
{
|
||||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
|
if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist))
|
||||||
continue;
|
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
|
||||||
|
|
||||||
if (thing->sprite == SPR_HOOP)
|
|
||||||
{
|
|
||||||
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (limit_dist && approx_dist > limit_dist)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
R_ProjectSprite(thing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Draw everything in sector, no checks
|
|
||||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
|
||||||
if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW))
|
|
||||||
R_ProjectSprite(thing);
|
R_ProjectSprite(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1877,14 +1852,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||||
{
|
{
|
||||||
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
||||||
{
|
{
|
||||||
if (precipthing->precipflags & PCF_INVISIBLE)
|
if (R_PrecipThingVisible(precipthing, limit_dist))
|
||||||
continue;
|
|
||||||
|
|
||||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
|
||||||
|
|
||||||
if (approx_dist > limit_dist)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
R_ProjectPrecipitationSprite(precipthing);
|
R_ProjectPrecipitationSprite(precipthing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2580,6 +2548,55 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if thing may be drawn from our current view. */
|
||||||
|
boolean R_ThingVisible (mobj_t *thing)
|
||||||
|
{
|
||||||
|
return (!(
|
||||||
|
thing->sprite == SPR_NULL ||
|
||||||
|
( thing->flags2 & (MF2_DONTDRAW) ) ||
|
||||||
|
thing == r_viewmobj
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
||||||
|
fixed_t limit_dist,
|
||||||
|
fixed_t hoop_limit_dist)
|
||||||
|
{
|
||||||
|
fixed_t approx_dist;
|
||||||
|
|
||||||
|
if (! R_ThingVisible(thing))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||||
|
|
||||||
|
if (thing->sprite == SPR_HOOP)
|
||||||
|
{
|
||||||
|
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (limit_dist && approx_dist > limit_dist)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if precipitation may be drawn from our current view. */
|
||||||
|
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
||||||
|
fixed_t limit_dist)
|
||||||
|
{
|
||||||
|
fixed_t approx_dist;
|
||||||
|
|
||||||
|
if (( precipthing->precipflags & PCF_INVISIBLE ))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||||
|
|
||||||
|
return ( approx_dist <= limit_dist );
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_DrawMasked
|
// R_DrawMasked
|
||||||
//
|
//
|
||||||
|
|
|
@ -61,6 +61,15 @@ void R_InitSprites(void);
|
||||||
void R_ClearSprites(void);
|
void R_ClearSprites(void);
|
||||||
void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
|
void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
|
||||||
|
|
||||||
|
boolean R_ThingVisible (mobj_t *thing);
|
||||||
|
|
||||||
|
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
||||||
|
fixed_t draw_dist,
|
||||||
|
fixed_t nights_draw_dist);
|
||||||
|
|
||||||
|
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
||||||
|
fixed_t precip_draw_dist);
|
||||||
|
|
||||||
/** Used to count the amount of masked elements
|
/** Used to count the amount of masked elements
|
||||||
* per portal to later group them in separate
|
* per portal to later group them in separate
|
||||||
* drawnode lists.
|
* drawnode lists.
|
||||||
|
|
Loading…
Reference in a new issue