diff --git a/src/r_debug.cpp b/src/r_debug.cpp index b4dd7120e..fcd21b5e1 100644 --- a/src/r_debug.cpp +++ b/src/r_debug.cpp @@ -15,6 +15,7 @@ #include "r_debug_detail.hpp" #include "command.h" +#include "i_time.h" #include "m_fixed.h" #include "r_draw.h" #include "r_main.h" @@ -69,6 +70,19 @@ INT32 R_AdjustLightLevel(INT32 light) return light / FRACUNIT; } +UINT8 R_DebugLineColor(const line_t *ld) +{ + const bool alt = (I_GetTime() % 70 < 35); + + switch (ld->special) + { + case 2001: // Ring Racers: Finish Line + return alt ? 0x23 : 0x00; // red, white + } + + return 0x00; +} + void Command_Debugrender_highlight(void) { const bool changes = COM_Argc() > 1; diff --git a/src/r_main.h b/src/r_main.h index b09c4b9dc..1a150abeb 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -144,6 +144,7 @@ extern UINT32 debugrender_highlight; void R_CheckDebugHighlight(debugrender_highlight_t type); INT32 R_AdjustLightLevel(INT32 light); +UINT8 R_DebugLineColor(const line_t *ld); void Command_Debugrender_highlight(void); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index cd343306b..89b215808 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -641,11 +641,48 @@ static void R_RenderMaskedSegLoop(drawseg_t *ds, INT32 x1, INT32 x2, INT32 texnu } } +static void R_RenderMaskedSegLoopDebug(drawseg_t *ds, INT32 x1, INT32 x2, void (*colfunc_2s)(column_t *, column_t *, INT32)) +{ + column_t *col; + + dc_lightmap = scalelight[LIGHTLEVELS - 1][0]; // max brightness + + // draw the columns + for (dc_x = x1; dc_x <= x2; dc_x++) + { + if (maskedtexturecol[dc_x] != INT16_MAX) + { + dc_texturemid = ds->maskedtextureheight[dc_x]; + + if (R_OverflowTest()) + { + spryscale += rw_scalestep; + continue; + } + + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); + dc_iscale = 0xffffffffu / (unsigned)spryscale; + + col = (column_t *)((UINT8 *)R_GetColumn(g_texturenum_dbgline, maskedtexturecol[dc_x]) - 3); + colfunc_2s(col, NULL, -1); + } + + spryscale += rw_scalestep; + } +} + static INT32 R_GetTwoSidedMidTexture(seg_t *line) { INT32 texture; - texture = line->sidedef->midtexture; + if (R_IsDebugLine(line)) + { + texture = g_texturenum_dbgline; + } + else + { + texture = line->sidedef->midtexture; + } return R_GetTextureNum(texture); } @@ -703,6 +740,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) void (*colfunc_2s)(column_t *, column_t *, INT32); line_t *ldef; const boolean debug = R_IsDebugLine(ds->curline); + // Calculate light table. // Use different light tables // for horizontal / vertical / diagonal. Diagonal? @@ -753,8 +791,16 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; - - R_RenderMaskedSegLoop(ds, x1, x2, texnum, colfunc_2s); + if (debug) + { + colfunc = R_DrawColumn_Flat_8; + r8_flatcolor = R_DebugLineColor(ldef); + R_RenderMaskedSegLoopDebug(ds, x1, x2, colfunc_2s); + } + else + { + R_RenderMaskedSegLoop(ds, x1, x2, texnum, colfunc_2s); + } R_SetColumnFunc(BASEDRAWFUNC, false); } @@ -1813,7 +1859,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) vertex_t segleft, segright; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; static size_t maxdrawsegs = 0; - //const INT32 twosidedmidtexture = R_GetTwoSidedMidTexture(curline); + const INT32 twosidedmidtexture = R_GetTwoSidedMidTexture(curline); const boolean wantremap = encoremap && !(curline->linedef->flags & ML_TFERLINE); maskedtextureheight = NULL; @@ -2513,7 +2559,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->numthicksides = numthicksides = i; } - if (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) + if (twosidedmidtexture) { // masked midtexture if (!ds_p->thicksidecol) @@ -2564,6 +2610,17 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_midtexturemid += sidedef->rowoffset; rw_midtextureback += sidedef->rowoffset; + if (R_IsDebugLine(curline)) + { + // Line draws at horizon + rw_midtexturemid = 0; + rw_midtextureback = 0; + + // Ignore slopes + rw_midtextureslide = 0; + rw_midtexturebackslide = 0; + } + maskedtexture = true; } } @@ -3050,12 +3107,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (maskedtexture && !(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN: INT32_MAX; + ds_p->tsilheight = twosidedmidtexture ? INT32_MIN: INT32_MAX; } if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM)) { ds_p->silhouette |= SIL_BOTTOM; - ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX: INT32_MIN; + ds_p->bsilheight = twosidedmidtexture ? INT32_MAX: INT32_MIN; } ds_p++; } diff --git a/src/r_textures.c b/src/r_textures.c index 0f54a7983..2146c6777 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -59,6 +59,8 @@ fixed_t *textureheight; // needed for texture pegging INT32 *texturetranslation; INT32 *texturebrightmaps; +INT32 g_texturenum_dbgline; + // Painfully simple texture id cacheing to make maps load faster. :3 static struct { char name[9]; @@ -1472,6 +1474,8 @@ static void R_FinishLoadingTextures(INT32 add) if (rendermode == render_opengl) HWR_LoadMapTextures(numtextures); #endif + + g_texturenum_dbgline = R_CheckTextureNumForName("DBGLINE"); } // diff --git a/src/r_textures.h b/src/r_textures.h index 4190434ec..a469825c7 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -117,6 +117,8 @@ lumpnum_t R_GetFlatNumForName(const char *name); extern INT32 numtextures; +extern INT32 g_texturenum_dbgline; + #ifdef __cplusplus } // extern "C" #endif