Merge branch 'debug-death-pit' into 'master'

debugfinishline: highlight deathpits and instakill planes

See merge request KartKrew/Kart!1543
This commit is contained in:
Oni 2023-10-08 07:49:39 +00:00
commit 3e9c3526d3
10 changed files with 156 additions and 38 deletions

View file

@ -834,7 +834,7 @@ consvar_t cv_kartdebugnodes = ServerCheat("debugnodes", "Off").on_off().descript
consvar_t cv_1pswap = PlayerCheat("1pswap", "1").min_max(1, MAXSPLITSCREENPLAYERS).description("Let P1's Profile control a different splitscreen player");
consvar_t cv_debugfinishline = PlayerCheat("debugfinishline", "Off").on_off().description("Highlight finish lines and respawn lines with high contrast colors");
consvar_t cv_debugfinishline = PlayerCheat("debugfinishline", "Off").on_off().description("Highlight finish lines, respawn lines, death pits and instakill planes with high contrast colors");
consvar_t cv_debugrank = PlayerCheat("debugrank", "Off").description("Show GP rank state on the HUD; optionally force a rank grade").values({
{0, "Off"},

View file

@ -15,6 +15,7 @@
#include <tracy/tracy/Tracy.hpp>
#include "command.h"
#include "doomdef.h"
#include "g_game.h"
#include "r_local.h"
@ -30,6 +31,8 @@
#include "k_terrain.h"
extern "C" consvar_t cv_debugfinishline;
seg_t *curline;
side_t *sidedef;
line_t *linedef;
@ -404,7 +407,8 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back)
// Consider colormaps
&& back->extra_colormap == front->extra_colormap
&& ((!front->ffloors && !back->ffloors)
|| Tag_Compare(&front->tags, &back->tags)));
|| Tag_Compare(&front->tags, &back->tags))
&& (!cv_debugfinishline.value || back->damagetype == front->damagetype));
}
boolean R_IsDebugLine(seg_t *line)
@ -963,6 +967,11 @@ static void R_Subsector(size_t num)
ceilingcolormap = *frontsector->lightlist[light].extra_colormap;
}
auto sector_damage = [](sector_t* s) { return static_cast<sectordamage_t>(s->damagetype); };
auto floor_damage = [&](sector_t* s) { return s->flags & MSF_FLIPSPECIAL_FLOOR ? sector_damage(s) : SD_NONE; };
auto ceiling_damage = [&](sector_t* s) { return s->flags & MSF_FLIPSPECIAL_CEILING ? sector_damage(s) : SD_NONE; };
sub->sector->extra_colormap = frontsector->extra_colormap;
if (P_GetSectorFloorZAt(frontsector, viewx, viewy) < viewz
@ -975,7 +984,7 @@ static void R_Subsector(size_t num)
floorcolormap, NULL, NULL, frontsector->f_slope,
R_NoEncore(frontsector, &levelflats[frontsector->floorpic], false),
R_IsRipplePlane(frontsector, NULL, false),
false, frontsector
false, frontsector, floor_damage(frontsector)
);
}
else
@ -991,7 +1000,7 @@ static void R_Subsector(size_t num)
ceilingcolormap, NULL, NULL, frontsector->c_slope,
R_NoEncore(frontsector, &levelflats[frontsector->ceilingpic], true),
R_IsRipplePlane(frontsector, NULL, true),
true, frontsector
true, frontsector, ceiling_damage(frontsector)
);
}
else
@ -1005,9 +1014,20 @@ static void R_Subsector(size_t num)
{
fixed_t heightcheck, planecenterz;
auto fof_damage = [&](auto& f)
{
sector_t* s = rover->master->frontsector;
return rover->fofflags & FOF_BLOCKPLAYER ? f(s) : sector_damage(s);
};
auto fof_top_damage = [&] { return fof_damage(floor_damage); };
auto fof_bottom_damage = [&] { return fof_damage(ceiling_damage); };
for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next)
{
if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES))
bool visible = rover->fofflags & FOF_RENDERPLANES;
if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !visible))
continue;
if (frontsector->cullheight)
@ -1030,6 +1050,14 @@ static void R_Subsector(size_t num)
&& ((viewz < heightcheck && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES)))
|| (viewz > heightcheck && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES))))
{
sectordamage_t damage = fof_bottom_damage();
if (!damage && !visible)
{
rover->norender = leveltime; // Tell R_StoreWallRange to skip this
continue;
}
light = R_GetPlaneLight(frontsector, planecenterz,
viewz < heightcheck);
@ -1039,7 +1067,7 @@ static void R_Subsector(size_t num)
*rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope,
R_NoEncore(rover->master->frontsector, &levelflats[*rover->bottompic], true),
R_IsRipplePlane(rover->master->frontsector, rover, true),
true, frontsector
true, frontsector, damage
);
ffloor[numffloors].slope = *rover->b_slope;
@ -1065,6 +1093,14 @@ static void R_Subsector(size_t num)
&& ((viewz > heightcheck && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES)))
|| (viewz < heightcheck && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES))))
{
sectordamage_t damage = fof_top_damage();
if (!damage && !visible)
{
rover->norender = leveltime; // Tell R_StoreWallRange to skip this
continue;
}
light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck);
ffloor[numffloors].plane = R_FindPlane(
@ -1073,7 +1109,7 @@ static void R_Subsector(size_t num)
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope,
R_NoEncore(rover->master->frontsector, &levelflats[*rover->toppic], false),
R_IsRipplePlane(rover->master->frontsector, rover, false),
false, frontsector
false, frontsector, damage
);
ffloor[numffloors].slope = *rover->t_slope;
@ -1095,6 +1131,10 @@ static void R_Subsector(size_t num)
polyobj_t *po = sub->polyList;
sector_t *polysec;
auto poly_damage = [&](auto& f) { return polysec->flags & POF_SOLID ? f(polysec) : sector_damage(polysec); };
auto poly_top_damage = [&] { return poly_damage(floor_damage); };
auto poly_bottom_damage = [&] { return poly_damage(ceiling_damage); };
while (po)
{
if (numffloors >= MAXFFLOORS)
@ -1123,7 +1163,7 @@ static void R_Subsector(size_t num)
NULL, // will ffloors be slopable eventually?
R_NoEncore(polysec, &levelflats[polysec->floorpic], false),
false, /* TODO: wet polyobjects? */
true, frontsector
true, frontsector, poly_bottom_damage()
);
ffloor[numffloors].height = polysec->floorheight;
@ -1152,7 +1192,7 @@ static void R_Subsector(size_t num)
NULL, // will ffloors be slopable eventually?
R_NoEncore(polysec, &levelflats[polysec->ceilingpic], true),
false, /* TODO: wet polyobjects? */
false, frontsector
false, frontsector, poly_top_damage()
);
ffloor[numffloors].polyobj = po;

View file

@ -117,6 +117,7 @@ INT32 ds_y, ds_x1, ds_x2;
lighttable_t *ds_colormap;
lighttable_t *ds_fullbright;
lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer
lighttable_t *ds_flatlighting;
fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
INT32 ds_waterofs, ds_bgofs;

View file

@ -69,6 +69,7 @@ extern INT32 ds_y, ds_x1, ds_x2;
extern lighttable_t *ds_colormap;
extern lighttable_t *ds_fullbright;
extern lighttable_t *ds_translation;
extern lighttable_t *ds_flatlighting;
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern INT32 ds_waterofs, ds_bgofs;
@ -80,8 +81,6 @@ extern UINT8 *ds_source;
extern UINT8 *ds_brightmap;
extern UINT8 *ds_transmap;
extern UINT8 ds_flatcolor;
struct floatv3_t {
float x, y, z;
};

View file

@ -15,6 +15,7 @@
#include <tracy/tracy/Tracy.hpp>
#include "command.h"
#include "doomdef.h"
#include "console.h"
#include "g_game.h"
@ -34,6 +35,8 @@
#include "z_zone.h"
#include "p_tick.h"
extern "C" consvar_t cv_debugfinishline;
//
// opening
//
@ -212,21 +215,29 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
ds_bgofs = -y;
}
pindex = distance >> LIGHTZSHIFT;
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
ds_colormap = planezlight[pindex];
if (!debugrender_highlight)
if (ds_flatlighting)
{
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
ds_colormap = ds_flatlighting;
}
else
{
pindex = distance >> LIGHTZSHIFT;
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
ds_fullbright = colormaps;
if (encoremap && !currentplane->noencore)
ds_colormap = planezlight[pindex];
if (!debugrender_highlight)
{
ds_colormap += COLORMAP_REMAPOFFSET;
ds_fullbright += COLORMAP_REMAPOFFSET;
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
ds_fullbright = colormaps;
if (encoremap && !currentplane->noencore)
{
ds_colormap += COLORMAP_REMAPOFFSET;
ds_fullbright += COLORMAP_REMAPOFFSET;
}
}
}
@ -363,11 +374,17 @@ static visplane_t *new_visplane(unsigned hash)
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap,
ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore,
boolean ripple, boolean reverseLight, const sector_t *lighting_sector)
boolean ripple, boolean reverseLight, const sector_t *lighting_sector,
sectordamage_t damage)
{
visplane_t *check;
unsigned hash;
if (!cv_debugfinishline.value)
{
damage = SD_NONE;
}
if (!slope) // Don't mess with this right now if a slope is involved
{
if (plangle != 0)
@ -446,7 +463,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
&& check->plangle == plangle
&& check->slope == slope
&& check->noencore == noencore
&& check->ripple == ripple)
&& check->ripple == ripple
&& check->damage == damage)
{
return check;
}
@ -477,6 +495,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
check->slope = slope;
check->noencore = noencore;
check->ripple = ripple;
check->damage = damage;
memset(check->top, 0xff, sizeof (check->top));
memset(check->bottom, 0x00, sizeof (check->bottom));
@ -555,6 +574,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
new_pl->slope = pl->slope;
new_pl->noencore = pl->noencore;
new_pl->ripple = pl->ripple;
new_pl->damage = pl->damage;
pl = new_pl;
pl->minx = start;
pl->maxx = stop;
@ -865,6 +885,7 @@ void R_DrawSinglePlane(visplane_t *pl)
INT32 type, spanfunctype = BASEDRAWFUNC;
debugrender_highlight_t debug = debugrender_highlight_t::SW_HI_PLANES;
void (*mapfunc)(INT32, INT32, INT32) = R_MapPlane;
bool highlight = R_PlaneIsHighlighted(pl);
if (!(pl->minx <= pl->maxx))
return;
@ -874,7 +895,22 @@ void R_DrawSinglePlane(visplane_t *pl)
// sky flat
if (pl->picnum == skyflatnum)
{
R_DrawSkyPlane(pl);
if (highlight)
{
r8_flatcolor = 35; // red
dc_lightmap = colormaps;
for (dc_x = pl->minx; dc_x <= pl->maxx; ++dc_x)
{
dc_yl = pl->top[dc_x];
dc_yh = pl->bottom[dc_x];
R_DrawColumn_Flat_8();
}
}
else
{
R_DrawSkyPlane(pl);
}
return;
}
@ -927,6 +963,7 @@ void R_DrawSinglePlane(visplane_t *pl)
// Hacked up support for alpha value in software mode Tails 09-24-2002
// ...unhacked by toaster 04-01-2021
if (!highlight)
{
INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255;
if (trans >= 10)
@ -1121,11 +1158,20 @@ void R_DrawSinglePlane(visplane_t *pl)
planezlight = zlight[light];
}
if (highlight && R_SetSpanFuncFlat(BASEDRAWFUNC))
{
r8_flatcolor = 35; // red
ds_flatlighting = colormaps;
}
else
{
R_CheckDebugHighlight(debug);
R_CheckDebugHighlight(debug);
// Use the correct span drawer depending on the powers-of-twoness
R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL);
// Use the correct span drawer depending on the powers-of-twoness
R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL);
ds_flatlighting = NULL;
}
// set the maximum value for unsigned
pl->top[pl->maxx+1] = 0xffff;
@ -1228,3 +1274,8 @@ void R_PlaneBounds(visplane_t *plane)
plane->high = hi;
plane->low = low;
}
boolean R_PlaneIsHighlighted(const visplane_t *pl)
{
return pl->damage == SD_DEATHPIT || pl->damage == SD_INSTAKILL;
}

View file

@ -20,6 +20,7 @@ extern "C" {
#include "screen.h" // needs MAXVIDWIDTH/MAXVIDHEIGHT
#include "r_data.h"
#include "r_defs.h"
#include "r_textures.h"
#include "p_polyobj.h"
@ -60,6 +61,7 @@ struct visplane_t
boolean noencore;
boolean ripple;
sectordamage_t damage;
};
extern visplane_t *visplanes[MAXVISPLANES];
@ -88,7 +90,7 @@ void R_ClearFFloorClips (void);
void R_DrawPlanes(void);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore,
boolean ripple, boolean reverseLight, const sector_t *lighting_sector);
boolean ripple, boolean reverseLight, const sector_t *lighting_sector, sectordamage_t damage);
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane);
@ -108,6 +110,8 @@ void R_CalculateSlopeVectors(void);
// Sets the slope vector pointers for the current tilted span.
void R_SetTiltedSpan(INT32 span);
boolean R_PlaneIsHighlighted(const visplane_t *pl);
struct visffloor_t
{
visplane_t *plane;

View file

@ -300,7 +300,7 @@ void Portal_AddSkyboxPortals (const player_t *player)
{
for (pl = visplanes[i]; pl; pl = pl->next)
{
if (pl->picnum == skyflatnum)
if (pl->picnum == skyflatnum && !pl->damage)
{
Portal_AddSkybox(player, pl);

View file

@ -13,6 +13,7 @@
#include <tracy/tracy/Tracy.hpp>
#include "command.h"
#include "doomdef.h"
#include "r_local.h"
#include "r_sky.h"
@ -30,6 +31,8 @@
#include "taglist.h"
#include "r_draw.h"
extern "C" consvar_t cv_debugfinishline;
#define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS)
@ -2111,7 +2114,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| frontsector->extra_colormap != backsector->extra_colormap
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
// Portals block traversal behind them
|| g_portal)
|| g_portal
// Highlighting death pits
|| (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype))
{
markfloor = true;
}
@ -2147,7 +2152,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| frontsector->extra_colormap != backsector->extra_colormap
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
// Portals block traversal behind them
|| g_portal)
|| g_portal
// Highlighting death pits
|| (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype))
{
markceiling = true;
}
@ -2713,7 +2720,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{
for (rover = backsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next)
{
if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES))
if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !(rover->fofflags & FOF_RENDERPLANES)))
continue;
if (rover->norender == leveltime)
continue;
@ -2770,7 +2777,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{
for (rover = frontsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next)
{
if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES))
if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !(rover->fofflags & FOF_RENDERPLANES)))
continue;
if (rover->norender == leveltime)
continue;

View file

@ -238,11 +238,12 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped)
{
I_Assert(id < SPANDRAWFUNC_MAX);
if (spanfuncs_flat[id] != NULL && debugrender_highlight != 0)
if (debugrender_highlight != 0 && R_SetSpanFuncFlat(id))
{
spanfunc = spanfuncs_flat[id];
return;
}
else if (spanfuncs_npo2[id] != NULL && npo2 == true)
if (spanfuncs_npo2[id] != NULL && npo2 == true)
{
spanfunc = spanfuncs_npo2[id];
}
@ -258,6 +259,20 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped)
}
}
boolean R_SetSpanFuncFlat(size_t id)
{
I_Assert(id < SPANDRAWFUNC_MAX);
if (spanfuncs_flat[id] == NULL)
{
return false;
}
spanfunc = spanfuncs_flat[id];
return true;
}
boolean R_CheckColumnFunc(size_t id)
{
size_t i;

View file

@ -227,6 +227,7 @@ void SCR_SetDrawFuncs(void);
// Set current column / span drawers
void R_SetColumnFunc(size_t id, boolean brightmapped);
void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped);
boolean R_SetSpanFuncFlat(size_t id); // flat color
// Compare current column drawer
boolean R_CheckColumnFunc(size_t id);