From 57c4cc6df1034d27f1ade455eb68f294f099461a Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 30 Dec 2024 13:10:51 -0500 Subject: [PATCH] Use some rendering code from durrr --- src/CMakeLists.txt | 2 + src/r_bsp.cpp | 190 +++++++++--------------- src/r_draw.cpp | 22 ++- src/r_draw_column.cpp | 14 +- src/r_draw_span.cpp | 8 +- src/r_plane.cpp | 40 +++--- src/r_segs.cpp | 327 ++++++++++++++++++++---------------------- src/r_things.cpp | 114 +++++++-------- src/screen.c | 2 +- 9 files changed, 329 insertions(+), 390 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06abc65f0..49bdd58c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -250,6 +250,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields) endif() +target_compile_options(SRB2SDL2 PRIVATE -O3) + # Compiler warnings configuration target_compile_options(SRB2SDL2 PRIVATE # Using generator expressions to handle per-language compile options diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8b69acae1..ec225b53a 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1,8 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -22,6 +23,8 @@ #include "r_local.h" #include "r_state.h" #include "r_portal.h" // Add seg portals +#include "r_fps.h" +#include "r_main.h" #include "r_splats.h" #include "p_local.h" // camera @@ -31,11 +34,7 @@ #include "k_terrain.h" -extern "C" { - #include "qs22j.h" -} -extern "C" consvar_t cv_debugfinishline; -extern "C" consvar_t cv_debugfinishline, cv_debugrender_freezebsp; +extern consvar_t cv_debugfinishline, cv_debugrender_freezebsp; seg_t *curline; side_t *sidedef; @@ -65,16 +64,7 @@ boolean R_NoEncore(sector_t *sector, levelflat_t *flat, boolean ceiling) const boolean invertEncore = (sector->flags & MSF_INVERTENCORE); const terrain_t *terrain = (flat != NULL ? flat->terrain : NULL); - if ((terrain == NULL) || (terrain->flags & TRF_REMAP) - || (terrain->pogoSpring <= 0 - && terrain->speedPad <= 0 - && !(terrain->flags & TRF_SNEAKERPANEL))) - { - return invertEncore; - } - - if ((!(sector->special & (1<<8)) || (sector->special & ((4|8)<<8))) // spring panel - && GETSECSPECIAL(sector->special, 4) != 6) // sneaker panel + if ((terrain == NULL) || (terrain->flags & TRF_REMAP)) { return invertEncore; } @@ -143,7 +133,7 @@ void R_CrunchWallSegment(cliprange_t *start, cliprange_t *next) // NO MORE CRASHING! if (newend - solidsegs > MAXSEGS) - I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); + I_Error("R_CrunchWallSegment: Solid Segs overflow!\n"); } template @@ -293,18 +283,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *viewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i; + UINT8 i = R_GetViewNumber(); - for (i = 0; i <= r_splitscreen; i++) - { - if (viewplayer == &players[displayplayers[i]] && camera[i].chase) - { - heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - break; - } - } - - if (i > r_splitscreen && viewmobj) + if (camera[i].chase) + heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; + else if (i > r_splitscreen && viewmobj) heightsec = R_PointInSubsector(viewmobj->x, viewmobj->y)->sector->heightsec; else return sec; @@ -439,6 +422,7 @@ boolean R_IsDebugLine(seg_t *line) { case 2001: // Ring Racers: Finish Line case 2003: // Ring Racers: Respawn Line + case 2005: // Ring Racers: Dismount flying object Line return true; } } @@ -554,31 +538,21 @@ static void R_AddLine(seg_t *line) doorclosed = 0; - if (udmf) - { + if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum) + bothceilingssky = true; + if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) + bothfloorssky = true; + if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then + { if (!R_IsDebugLine(line) && !line->polyseg && !line->sidedef->midtexture && ((!frontsector->ffloors && !backsector->ffloors) - || Tag_Compare(&frontsector->tags, &backsector->tags))) + || Tag_Compare(&frontsector->tags, &backsector->tags))) return; // line is empty, don't even bother - if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum) - bothceilingssky = true; - if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) - bothfloorssky = true; - - if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!frontsector->ffloors && !backsector->ffloors) - || Tag_Compare(&frontsector->tags, &backsector->tags))) - return; // line is empty, don't even bother - - goto clippass; // treat like wide open window instead - } + goto clippass; // treat like wide open window instead } // Closed door. @@ -595,35 +569,19 @@ static void R_AddLine(seg_t *line) SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector-> floorheight) SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight) #undef SLOPEPARAMS - - - if (udmf || (!udmf && viewsector != backsector && viewsector != frontsector)) + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) { - // if both ceilings are skies, consider it always "open" - // same for floors - if (!bothceilingssky && !bothfloorssky) - { - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) - { - goto clipsolid; - } + doorclosed = (backc1 <= frontf1 && backc2 <= frontf2) + || (backf1 >= frontc1 && backf2 >= frontc2) + // Check for automap fix. Store in doorclosed for r_segs.c + || (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture)); - // Check for automap fix. Store in doorclosed for r_segs.c - if (udmf) - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture)); - else - doorclosed = (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; - } + if (doorclosed) + goto clipsolid; } // Window. @@ -636,49 +594,37 @@ static void R_AddLine(seg_t *line) } else { - if (udmf || (!udmf && viewsector != backsector && viewsector != frontsector)) + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) { - // if both ceilings are skies, consider it always "open" - // same for floors - if (!bothceilingssky && !bothfloorssky) - { - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) - { - goto clipsolid; - } + doorclosed = backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight + // Check for automap fix. Store in doorclosed for r_segs.c + // + // This is used to fix the automap bug which + // showed lines behind closed doors simply because the door had a dropoff. + // + // It assumes that Doom has already ruled out a door being closed because + // of front-back closure (e.g. front floor is taller than back ceiling). + // + // if door is closed because back is shut: + || (backsector->ceilingheight <= backsector->floorheight + // preserve a kind of transparent door/lift special effect: + && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) + && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture)); - // Check for automap fix. Store in doorclosed for r_segs.c - // - // This is used to fix the automap bug which - // showed lines behind closed doors simply because the door had a dropoff. - // - // It assumes that Doom has already ruled out a door being closed because - // of front-back closure (e.g. front floor is taller than back ceiling). - // - // if door is closed because back is shut: - if (udmf) - doorclosed = backsector->ceilingheight <= backsector->floorheight - && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) - && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture); // preserve a kind of transparent door/lift special effect: - else - doorclosed = (backsector->ceilingheight <= backsector->floorheight - && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) - && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; - } - - // Window. - if (!bothceilingssky) // ceilings are always the "same" when sky - if (backsector->ceilingheight != frontsector->ceilingheight) - goto clippass; - if (!bothfloorssky) // floors are always the "same" when sky - if (backsector->floorheight != frontsector->floorheight) - goto clippass; + if (doorclosed) + goto clipsolid; } + + // Window. + if (!bothceilingssky) // ceilings are always the "same" when sky + if (backsector->ceilingheight != frontsector->ceilingheight) + goto clippass; + if (!bothfloorssky) // floors are always the "same" when sky + if (backsector->floorheight != frontsector->floorheight) + goto clippass; } // Reject empty lines used for triggers and special events. @@ -834,7 +780,7 @@ void R_SortPolyObjects(subsector_t *sub) // 03/10/06: only bother if there are actually polys to sort if (numpolys >= 2) { - qs22j(po_ptrs, numpolys, sizeof(polyobj_t *), + qsort(po_ptrs, numpolys, sizeof(polyobj_t *), R_PolyobjCompare); } } @@ -937,7 +883,7 @@ static void R_AddPolyObjects(subsector_t *sub) // render polyobjects for (i = 0; i < numpolys; ++i) { - qs22j(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); + qsort(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); for (j = 0; j < po_ptrs[i]->segCount; ++j) R_AddLine(po_ptrs[i]->segs[j]); } @@ -965,14 +911,12 @@ static void R_Subsector(size_t num) ZoneScoped; -#ifdef RANGECHECK - if (num >= numsubsectors) - I_Error("R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); -#endif - // subsectors added at run-time if (num >= numsubsectors) + { + CONS_Debug(DBG_RENDER, "R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); return; + } sub = &subsectors[num]; frontsector = sub->sector; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index fe9a11096..27889bea7 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1,8 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,6 +16,8 @@ /// not the architecture of the frame buffer. /// The frame buffer is a linear one, and we need only the base address. +#include + #include "doomdef.h" #include "doomstat.h" #include "r_local.h" @@ -125,6 +128,7 @@ INT32 dc_numlights = 0, dc_maxlights; // ========================================================================= // SPAN DRAWING CODE STUFF // ========================================================================= + // Vectors for Software's tilted slope drawers floatv3_t *ds_su, *ds_sv, *ds_sz; float focallengthf[MAXSPLITSCREENPLAYERS]; @@ -141,7 +145,13 @@ float zeroheight; #define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4) #define BLINK_TT_CACHE_INDEX (MAXSKINS + 5) #define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6) -#define TT_CACHE_SIZE (MAXSKINS + 8) +#define HITLAG_TT_CACHE_INDEX (MAXSKINS + 7) +#define INTERMISSION_TT_CACHE_INDEX (MAXSKINS + 8) +#define TT_CACHE_SIZE (MAXSKINS + 9) + +#define SKIN_RAMP_LENGTH 16 +#define DEFAULT_STARTTRANSCOLOR 96 +#define NUM_PALETTE_ENTRIES 256 static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; UINT8 skincolor_modified[MAXSKINCOLORS]; @@ -301,7 +311,7 @@ void R_GenerateTranslucencyTable(UINT8 *table, RGBA_t* sourcepal, int style, UIN } } -#define ClipTransLevel(trans) std::max(std::min((trans), NUMTRANSMAPS-2), 0) +#define ClipTransLevel(trans) std::clamp(trans, 0, NUMTRANSMAPS-2) UINT8 *R_GetTranslucencyTable(INT32 alphalevel) { diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index d9c1cf244..31f1501a8 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -1,7 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -105,12 +107,10 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) return; } -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) { return; } -#endif if constexpr (Type & DrawColumnType::DC_LIGHTLIST) { @@ -341,10 +341,8 @@ void R_DrawFogColumn(drawcolumndata_t *dc) if (count < 0) return; -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) return; -#endif // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. @@ -408,10 +406,8 @@ void R_DrawColumn_Flat(drawcolumndata_t *dc) if (count < 0) // Zero length, column does not exceed a pixel. return; -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) return; -#endif // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index c002f72b7..9d0d0fcae 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -1,7 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_plane.cpp b/src/r_plane.cpp index e1907c714..c7f5a59ae 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1,8 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -18,10 +19,10 @@ #include "command.h" #include "doomdef.h" #include "console.h" -#include "m_easing.h" // For Easing_InOutSine, used in R_UpdatePlaneRipple #include "g_game.h" #include "p_setup.h" // levelflats #include "p_slopes.h" +#include "r_fps.h" #include "r_data.h" #include "r_textures.h" #include "r_local.h" @@ -31,6 +32,7 @@ #include "r_portal.h" #include "core/thread_pool.h" #include "r_fps.h" +#include "r_debug.hpp" #include "v_video.h" #include "w_wad.h" @@ -235,7 +237,10 @@ static void R_MapTiltedPlane(drawspandata_t *ds, void(*spanfunc)(drawspandata_t* { ds->bgofs = R_CalculateRippleOffset(ds, y); - R_SetTiltedSpan(ds, CLAMP(y, 0, viewheight)); + R_SetTiltedSpan(ds, std::min(y, std::max(0, viewheight))); + + R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); + R_SetSlopePlaneVectors(ds, ds->currentplane, y, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac)); ds->bgofs >>= FRACBITS; @@ -573,6 +578,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* spanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel) { + ZoneScoped; // Alam: from r_splats's R_RasterizeFloorSplat if (t1 >= vid.height) t1 = vid.height-1; if (b1 >= vid.height) b1 = vid.height-1; @@ -887,11 +893,11 @@ d.z = (v1.x * v2.y) - (v1.y * v2.x) void R_SetTiltedSpan(drawspandata_t* ds, INT32 span) { if (ds_su == NULL) - ds_su = static_cast(Z_Malloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL)); + ds_su = static_cast(Z_Calloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL)); if (ds_sv == NULL) - ds_sv = static_cast(Z_Malloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL)); + ds_sv = static_cast(Z_Calloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL)); if (ds_sz == NULL) - ds_sz = static_cast(Z_Malloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL)); + ds_sz = static_cast(Z_Calloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL)); ds->sup = ds_su[span]; ds->svp = ds_sv[span]; @@ -1103,9 +1109,9 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle // No idea if this works VID_BlitLinearScreen(screens[0] + offset, - screens[1] + (top*vid.width), // intentionally not +offset - viewwidth, bottom-top, - vid.width, vid.width); + screens[1] + (top*vid.width), // intentionally not +offset + viewwidth, bottom-top, + vid.width, vid.width); } } #endif @@ -1274,11 +1280,11 @@ INT16 R_PlaneIsHighlighted(const visplane_t *pl) { switch (pl->damage) { - case SD_DEATHPIT: - case SD_INSTAKILL: - return 35; // red + case SD_DEATHPIT: + case SD_INSTAKILL: + return 35; // red - default: - return -1; + default: + return -1; } } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 28c8743f2..c31731fce 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1,8 +1,9 @@ -// SONIC ROBO BLAST 2 +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2020 by Sonic Team Junior. +// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -32,9 +33,10 @@ #include "console.h" // con_clipviewtop #include "taglist.h" #include "r_draw.h" -#include "k_terrain.h" #include "core/memory.h" #include "core/thread_pool.h" +#include "k_terrain.h" +#include "r_debug.hpp" extern "C" consvar_t cv_debugfinishline; @@ -194,7 +196,7 @@ static inline boolean R_OverflowTest(drawcolumndata_t* dc) return false; } -static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT32 x1, INT32 x2, INT32 texnum, void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32)) +static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT32 x1, INT32 x2, INT32 texnum, INT32 basetexnum, void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32)) { size_t pindex; column_t *col, *bmCol = NULL; @@ -203,17 +205,17 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 lightlist_t *light; r_lightlist_t *rlight; line_t *ldef; + INT32 range; sector_t *front, *back; INT32 times, repeats; boolean tripwire; boolean brightmapped = R_TextureHasBrightmap(texnum); - boolean remap = encoremap && R_TextureCanRemap(texnum); - INT32 range; + boolean remap = encoremap && R_TextureCanRemap(basetexnum); ldef = curline->linedef; tripwire = P_IsLineTripWire(ldef); - range = std::max(drawseg->x2-drawseg->x1, 1); + range = std::max(drawseg->x2-drawseg->x1, 1); // Setup lighting based on the presence/lack-of 3D floors. dc->numlights = 0; @@ -278,22 +280,18 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 { if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false) || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) - { lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - } else - { lightnum = LIGHTLEVELS - 1; if ((R_CheckColumnFunc(COLDRAWFUNC_FOG) == true) - || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) + || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) ; else if (P_ApplyLightOffset(lightnum, frontsector)) lightnum += curline->lightOffset; - } - } - lightnum = R_AdjustLightLevel(lightnum); + lightnum = R_AdjustLightLevel(lightnum); + } if (lightnum < 0) walllights = scalelight[0]; @@ -303,11 +301,6 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 walllights = scalelight[lightnum]; } - maskedtexturecol = drawseg->maskedtexturecol; - - mfloorclip = drawseg->sprbottomclip; - mceilingclip = drawseg->sprtopclip; - if (frontsector->heightsec != -1) front = §ors[frontsector->heightsec]; else @@ -405,13 +398,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 bmCol = (column_t *)((UINT8 *)R_GetBrightmapColumn(texnum, maskedtexturecol[dc->x]) - 3); } - for (i = 0; i < dc->numlights; i++) + auto set_light_vars = [&](INT32 i) { rlight = &dc->lightlist[i]; - if ((rlight->flags & FOF_NOSHADE)) - continue; - lightnum = R_AdjustLightLevel(rlight->lightnum); if (lightnum < 0) @@ -430,20 +420,38 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); else rlight->rcolormap = xwalllights[pindex]; + }; + + auto set_colormap_below_light = [&] + { + dc->colormap = rlight->rcolormap; + dc->lightmap = xwalllights[pindex]; + dc->fullbright = colormaps; + if (remap && !(ldef->flags & ML_TFERLINE)) + { + dc->colormap += COLORMAP_REMAPOFFSET; + dc->fullbright += COLORMAP_REMAPOFFSET; + } + }; + + // Use the base sector's light level above the first FOF. + // You can imagine it as the sky casting its light on top of the highest FOF. + set_light_vars(0); + set_colormap_below_light(); + + for (i = 0; i < dc->numlights; i++) + { + if ((dc->lightlist[i].flags & FOF_NOSHADE)) + continue; + + set_light_vars(i); height = rlight->height; rlight->height += rlight->heightstep; if (height <= windowtop) { - dc->colormap = rlight->rcolormap; - dc->lightmap = xwalllights[pindex]; - dc->fullbright = colormaps; - if (encoremap && !(ldef->flags & ML_TFERLINE)) - { - dc->colormap += COLORMAP_REMAPOFFSET; - dc->fullbright += COLORMAP_REMAPOFFSET; - } + set_colormap_below_light(); continue; } @@ -462,14 +470,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 } colfunc_2s(dc, col, bmCol, -1); windowtop = windowbottom + 1; - dc->colormap = rlight->rcolormap; - dc->lightmap = xwalllights[pindex]; - dc->fullbright = colormaps; - if (remap && !(ldef->flags & ML_TFERLINE)) - { - dc->colormap += COLORMAP_REMAPOFFSET; - dc->fullbright += COLORMAP_REMAPOFFSET; - } + set_colormap_below_light(); } windowbottom = realbot; if (windowtop < windowbottom) @@ -600,18 +601,12 @@ static void R_RenderMaskedSegLoopDebug(drawcolumndata_t* dc, drawseg_t *ds, INT3 static INT32 R_GetTwoSidedMidTexture(seg_t *line) { - INT32 texture; - if (R_IsDebugLine(line)) { - texture = g_texturenum_dbgline; - } - else - { - texture = line->sidedef->midtexture; + return g_texturenum_dbgline; } - return R_GetTextureNum(texture); + return line->sidedef->midtexture; } static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolean brightmapped) @@ -663,7 +658,7 @@ static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolea void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2) { - INT32 texnum; + INT32 texnum, basetexnum; void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32); line_t *ldef; const boolean debug = R_IsDebugLine(drawseg->curline); @@ -677,7 +672,8 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2) frontsector = curline->frontsector; backsector = curline->backsector; - texnum = R_GetTwoSidedMidTexture(curline); + basetexnum = R_GetTwoSidedMidTexture(curline); + texnum = R_GetTextureNum(basetexnum); windowbottom = windowtop = sprbotscreen = INT32_MAX; ldef = curline->linedef; @@ -727,7 +723,7 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2) } else { - R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, colfunc_2s); + R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, basetexnum, colfunc_2s); } R_SetColumnFunc(BASEDRAWFUNC, false); @@ -768,7 +764,6 @@ static constexpr T saturating_mul(T x, T y) noexcept // Loop through R_DrawMaskedColumn calls static void R_DrawRepeatMaskedColumn(drawcolumndata_t* dc, column_t *col, column_t *bm, INT32 baseclip) { - INT64 z; while (sprtopscreen < sprbotscreen) { R_DrawMaskedColumn(dc, col, bm, baseclip); @@ -802,10 +797,10 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) // Renders all the thick sides in the given range. void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { - size_t pindex; + size_t pindex = 0; column_t * col, *bmCol = NULL; INT32 lightnum; - INT32 texnum; + INT32 texnum, basetexnum; sector_t tempsec; INT32 templight; INT32 i, p; @@ -837,19 +832,21 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) curline = ds->curline; backsector = pfloor->target; frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; - texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); + basetexnum = sides[pfloor->master->sidenum[0]].midtexture; R_CheckDebugHighlight(SW_HI_FOFSIDES); if (pfloor->master->flags & ML_TFERLINE) { - size_t linenum = std::min(curline->linedef-backsector->lines[0], (long int)pfloor->master->frontsector->linecount); + size_t linenum = curline->linedef-backsector->lines[0]; newline = pfloor->master->frontsector->lines[0] + linenum; - texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + basetexnum = sides[newline->sidenum[0]].midtexture; } + texnum = R_GetTextureNum(basetexnum); + boolean brightmapped = R_TextureHasBrightmap(texnum); - boolean remap = encoremap && R_TextureCanRemap(texnum); + boolean remap = encoremap && R_TextureCanRemap(basetexnum); R_SetColumnFunc(BASEDRAWFUNC, brightmapped); @@ -877,7 +874,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) R_SetColumnFunc(COLDRAWFUNC_FOG, brightmapped); } - range = std::max(ds->x2-ds->x1, 1); + range = std::max(ds->x2-ds->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -1170,7 +1167,57 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t height; fixed_t bheight = 0; INT32 solid = 0; - INT32 lighteffect = 0; + + auto set_light_vars = [&](INT32 i) + { + rlight = &dc->lightlist[i]; + + lightnum = R_AdjustLightLevel(rlight->lightnum); + + if (lightnum < 0) + xwalllights = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + xwalllights = scalelight[LIGHTLEVELS-1]; + else + xwalllights = scalelight[lightnum]; + + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; + + if (pindex >= MAXLIGHTSCALE) + pindex = MAXLIGHTSCALE-1; + + if (pfloor->fofflags & FOF_FOG) + { + if (pfloor->master->frontsector->extra_colormap) + rlight->rcolormap = pfloor->master->frontsector->extra_colormap->colormap + (xwalllights[pindex] - colormaps); + else + rlight->rcolormap = xwalllights[pindex]; + } + else + { + if (rlight->extra_colormap) + rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); + else + rlight->rcolormap = xwalllights[pindex]; + } + }; + + auto set_colormap_below_light = [&] + { + dc->colormap = rlight->rcolormap; + dc->lightmap = xwalllights[pindex]; + dc->fullbright = colormaps; + if (remap && !(curline->linedef->flags & ML_TFERLINE)) + { + dc->colormap += COLORMAP_REMAPOFFSET; + dc->fullbright += COLORMAP_REMAPOFFSET; + } + }; + + // Use the base sector's light level above the first FOF. + // You can imagine it as the sky casting its light on top of the highest FOF. + set_light_vars(0); + set_colormap_below_light(); for (i = 0; i < dc->numlights; i++) { @@ -1178,36 +1225,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rlight = &dc->lightlist[i]; xwalllights = NULL; if (!(dc->lightlist[i].flags & FOF_NOSHADE)) - { - lightnum = R_AdjustLightLevel(rlight->lightnum); - - if (lightnum < 0) - xwalllights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - xwalllights = scalelight[LIGHTLEVELS-1]; - else - xwalllights = scalelight[lightnum]; - - pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - - if (pindex >= MAXLIGHTSCALE) - pindex = MAXLIGHTSCALE-1; - - if (pfloor->fofflags & FOF_FOG) - { - if (pfloor->master->frontsector->extra_colormap) - rlight->rcolormap = pfloor->master->frontsector->extra_colormap->colormap + (xwalllights[pindex] - colormaps); - else - rlight->rcolormap = xwalllights[pindex]; - } - else - { - if (rlight->extra_colormap) - rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); - else - rlight->rcolormap = xwalllights[pindex]; - } - } + set_light_vars(i); solid = 0; // don't carry over solid-cutting flag from the previous light @@ -1240,17 +1258,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (height <= windowtop) { - if (lighteffect) - { - dc->colormap = rlight->rcolormap; - dc->lightmap = xwalllights[pindex]; - dc->fullbright = colormaps; - if (remap && !(curline->linedef->flags & ML_TFERLINE)) - { - dc->colormap += COLORMAP_REMAPOFFSET; - dc->fullbright += COLORMAP_REMAPOFFSET; - } - } + if (xwalllights) + set_colormap_below_light(); if (solid && windowtop < bheight) windowtop = bheight; continue; @@ -1277,17 +1286,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) windowtop = bheight; else windowtop = windowbottom + 1; - if (lighteffect) - { - dc->colormap = rlight->rcolormap; - dc->lightmap = xwalllights[pindex]; - dc->fullbright = colormaps; - if (remap && !(curline->linedef->flags & ML_TFERLINE)) - { - dc->colormap += COLORMAP_REMAPOFFSET; - dc->fullbright += COLORMAP_REMAPOFFSET; - } - } + if (xwalllights) + set_colormap_below_light(); } windowbottom = sprbotscreen; // draw the texture, if there is any space left @@ -1385,12 +1385,6 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m coldrawfunc_t* colfunccopy = colfunc; drawcolumndata_t dc_copy = *dc; colfunccopy(const_cast(&dc_copy)); - - if (remap) - { - //dc_copy.colormap += COLORMAP_REMAPOFFSET; - //dc_copy.fullbright += COLORMAP_REMAPOFFSET; - } } static void R_RenderSegLoop (drawcolumndata_t* dc) @@ -1569,7 +1563,8 @@ static void R_RenderSegLoop (drawcolumndata_t* dc) //SoM: Calculate offsets for Thick fake floors. // calculate texture offset angle = (rw_centerangle + xtoviewangle[viewssnum][rw_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset-FixedMul(FINETANGENT(angle),rw_distance); + // Mask 4095 to guarantee this index is within bounds + texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095),rw_distance); if (oldtexturecolumn != -1) { rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn); @@ -1829,12 +1824,10 @@ 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 boolean wantremap = encoremap && !(curline->linedef->flags & ML_TFERLINE); + const INT32 twosidedmidtexture = R_GetTextureNum(R_GetTwoSidedMidTexture(curline)); + const bool wantremap = encoremap && !(curline->linedef->flags & ML_TFERLINE); drawcolumndata_t dc {0}; - //ZoneScoped; - ZoneScoped; maskedtextureheight = NULL; @@ -2073,7 +2066,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) auto get_flat_tex = [](INT32 texnum) { texnum = R_GetTextureNum(texnum); - return textures[texnum]->holes ? 0 : texnum; // R_DrawWallColumn cannot render holey textures + if (textures[texnum]->holes) + { + //srb2::r_debug::add_texture_to_frame_list(texnum); + // R_DrawWallColumn cannot render holey textures + return R_GetTextureNum(R_CheckTextureNumForName("TRANSER1")); + } + return texnum; }; if (!backsector) @@ -2082,7 +2081,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // single sided line midtexture = get_flat_tex(sidedef->midtexture); midbrightmapped = R_TextureHasBrightmap(midtexture); - midremap = wantremap && R_TextureCanRemap(midtexture); + midremap = wantremap && R_TextureCanRemap(sidedef->midtexture); texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; @@ -2129,13 +2128,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { - if (udmf) - bothceilingssky = true; - else - { - worldtopslope = worldhighslope = - worldtop = worldhigh; - } + bothceilingssky = true; } // likewise, but for floors and upper textures @@ -2148,7 +2141,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; - if (!bothfloorssky || !udmf) + if (!bothfloorssky) { if (worldbottomslope > worldlowslope || worldbottom > worldlow) { @@ -2187,24 +2180,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) //SoM: 3/25/2000: This code fixes an automap bug that didn't check // frontsector->ceiling and backsector->floor to see if a door was closed. // Without the following code, sprites get displayed behind closed doors. - if ((!bothceilingssky && !bothfloorssky) || !udmf) + if (doorclosed) { - if (udmf || (!udmf && viewsector != frontsector && viewsector != backsector)) - { - if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)) - { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT32_MAX; - ds_p->silhouette |= SIL_BOTTOM; - } + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT32_MAX; + ds_p->silhouette |= SIL_BOTTOM; - if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope)) - { - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = INT32_MIN; - ds_p->silhouette |= SIL_TOP; - } - } + ds_p->sprtopclip = screenheightarray; + ds_p->tsilheight = INT32_MIN; + ds_p->silhouette |= SIL_TOP; } if (bothfloorssky) @@ -2213,7 +2197,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) // this is the same but for upside down thok barriers where the floor is sky and the ceiling is normal markfloor = false; } - else if (worldlow != worldbottom + else if (doorclosed + || worldlow != worldbottom || worldlowslope != worldbottomslope || backsector->f_slope != frontsector->f_slope || backsector->floorpic != frontsector->floorpic @@ -2250,7 +2235,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) // so we can see the floor of thok barriers always regardless of sector properties markceiling = false; } - else if (worldhigh != worldtop + else if (doorclosed + || worldhigh != worldtop || worldhighslope != worldtopslope || backsector->c_slope != frontsector->c_slope || backsector->ceilingpic != frontsector->ceilingpic @@ -2280,25 +2266,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) markceiling = false; } - if ((!bothceilingssky && !bothfloorssky) || !udmf) - { - if (((worldhigh <= worldbottom && worldhighslope <= worldbottomslope) - || (worldlow >= worldtop && worldlowslope >= worldtopslope)) || (!udmf && (backsector->ceilingheight <= frontsector->floorheight || - backsector->floorheight >= frontsector->ceilingheight))) - { - // closed door - markceiling = markfloor = true; - } - } - // check TOP TEXTURE - if (!bothceilingssky && (worldhigh < worldtop || worldhighslope < worldtopslope)) // never draw the top texture if on + if (!bothceilingssky // never draw the top texture if on + && (worldhigh < worldtop || worldhighslope < worldtopslope)) { fixed_t texheight; // top texture toptexture = get_flat_tex(sidedef->toptexture); topbrightmapped = R_TextureHasBrightmap(toptexture); - topremap = wantremap && R_TextureCanRemap(toptexture); + topremap = wantremap && R_TextureCanRemap(sidedef->toptexture); texheight = textureheight[toptexture]; if (!(linedef->flags & ML_SKEWTD)) @@ -2322,12 +2298,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } // check BOTTOM TEXTURE - if ((!bothfloorssky || !udmf) && (worldlow > worldbottom || worldlowslope > worldbottomslope)) // never draw the top texture if on + if (!bothfloorssky // never draw the bottom texture if on + && (worldlow > worldbottom || worldlowslope > worldbottomslope)) // Only if VISIBLE!!! { // bottom texture bottomtexture = get_flat_tex(sidedef->bottomtexture); bottombrightmapped = R_TextureHasBrightmap(bottomtexture); - bottomremap = wantremap && R_TextureCanRemap(bottomtexture); + bottomremap = wantremap && R_TextureCanRemap(sidedef->bottomtexture); if (!(linedef->flags & ML_SKEWTD)) { @@ -2382,7 +2359,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->fofflags & FOF_RENDERSIDES) || !(rover->fofflags & FOF_EXISTS)) continue; - if ((udmf && !(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) || (!udmf && rover->fofflags & FOF_INVERTSIDES)) + if (!(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) continue; if (rover->norender == leveltime) @@ -2440,7 +2417,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->fofflags & FOF_RENDERSIDES) || !(rover->fofflags & FOF_EXISTS)) continue; - if ((udmf && !(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) || (!udmf && rover->fofflags & FOF_INVERTSIDES)) + if (!(rover->fofflags & FOF_ALLSIDES || rover->fofflags & FOF_INVERTSIDES)) continue; if (rover->norender == leveltime) @@ -2500,7 +2477,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->fofflags & FOF_RENDERSIDES) || !(rover->fofflags & FOF_EXISTS)) continue; - if ((udmf && !(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) || (!udmf && rover->fofflags & FOF_INVERTSIDES)) + if (!(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) continue; if (rover->norender == leveltime) continue; @@ -2522,7 +2499,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->fofflags & FOF_RENDERSIDES) || !(rover->fofflags & FOF_EXISTS)) continue; - if ((udmf && !(rover->fofflags & FOF_ALLSIDES) && rover->fofflags & FOF_INVERTSIDES) || (!udmf && rover->fofflags & FOF_INVERTSIDES)) + if (!(rover->fofflags & FOF_ALLSIDES || rover->fofflags & FOF_INVERTSIDES)) continue; if (rover->norender == leveltime) continue; @@ -2857,7 +2834,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz < planevistest && ((udmf && rover->fofflags & FOF_BOTHPLANES) || !(rover->fofflags & FOF_INVERTPLANES))) || + ((viewz < planevistest && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz > planevistest && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { //ffloor[i].slope = *rover->b_slope; @@ -2880,7 +2857,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz > planevistest && ((udmf && rover->fofflags & FOF_BOTHPLANES) || !(rover->fofflags & FOF_INVERTPLANES))) || + ((viewz > planevistest && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz < planevistest && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { //ffloor[i].slope = *rover->t_slope; @@ -2914,7 +2891,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz < planevistest && ((udmf && rover->fofflags & FOF_BOTHPLANES) || !(rover->fofflags & FOF_INVERTPLANES))) || + ((viewz < planevistest && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz > planevistest && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { //ffloor[i].slope = *rover->b_slope; @@ -2937,7 +2914,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz > planevistest && ((udmf && rover->fofflags & FOF_BOTHPLANES) || !(rover->fofflags & FOF_INVERTPLANES))) || + ((viewz > planevistest && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz < planevistest && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { //ffloor[i].slope = *rover->t_slope; diff --git a/src/r_things.cpp b/src/r_things.cpp index 73fd9cbbd..6020e5e81 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -937,21 +937,21 @@ static void R_DrawVisSprite(vissprite_t *vis) } else if (!(vis->cut & SC_PRECIP) && R_ThingIsFlashing(vis->mobj)) // Bosses "flash" - { - R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white - } - else if (vis->transmap && dc.translation) // Color mapping - { - R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false); - dc.transmap = vis->transmap; - } - else if (vis->transmap) - { - R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); - dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table - } - else if (dc.translation) // translate green skin to another color - R_SetColumnFunc(COLDRAWFUNC_TRANS, false); + { + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white + } + else if (vis->transmap && dc.translation) // Color mapping + { + R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false); + dc.transmap = vis->transmap; + } + else if (vis->transmap) + { + R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); + dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table + } + else if (dc.translation) // translate green skin to another color + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); if (vis->extra_colormap && !(vis->cut & SC_FULLBRIGHT) && !(vis->renderflags & RF_NOCOLORMAPS)) { @@ -1181,10 +1181,11 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) { texturecolumn = frac>>FRACBITS; -#ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= patch->width) - I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); -#endif + { + CONS_Debug(DBG_RENDER, "R_DrawPrecipitationSpriteRange: bad texturecolumn\n"); + break; + } column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); @@ -3335,7 +3336,7 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) INT32 silhouette; INT32 xclip; - if (cv_debugrender_spriteclip.value) + if (/*(spr->renderflags & RF_ALWAYSONTOP) ||*/ cv_debugrender_spriteclip.value) { for (x = x1; x <= x2; x++) { @@ -3379,30 +3380,30 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) if (ds->portalpass > 0 && ds->portalpass <= portalrender) continue; // is a portal - if (ds->scale1 > ds->scale2) - { - lowscale = ds->scale2; - scale = ds->scale1; - } - else - { - lowscale = ds->scale1; - scale = ds->scale2; - } + if (ds->scale1 > ds->scale2) + { + lowscale = ds->scale2; + scale = ds->scale1; + } + else + { + lowscale = ds->scale1; + scale = ds->scale2; + } - if (scale < spr->sortscale || - (lowscale < spr->sortscale && - !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) - { - // masked mid texture? - /* - if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, r1, r2); - */ + if (scale < spr->sortscale || + (lowscale < spr->sortscale && + !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) + { + // masked mid texture? + /* + * if (ds->maskedtexturecol) + * R_RenderMaskedSegRange (ds, r1, r2); + */ - // seg is behind sprite - continue; - } + // seg is behind sprite + continue; + } } r1 = ds->x1 < x1 ? x1 : ds->x1; @@ -3588,7 +3589,7 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) drawsegs_xranges[i].items = static_cast(Z_Realloc( drawsegs_xranges[i].items, drawsegs_xrange_size * sizeof(drawsegs_xranges[i].items[0]), - PU_STATIC, NULL + PU_STATIC, NULL )); } } @@ -3604,15 +3605,15 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) // e6y: ~13% of speed improvement on sunder.wad map10 if (ds->x1 < cx) { - drawsegs_xranges[1].items[drawsegs_xranges[1].count] = - drawsegs_xranges[0].items[drawsegs_xranges[0].count]; + drawsegs_xranges[1].items[drawsegs_xranges[1].count] = + drawsegs_xranges[0].items[drawsegs_xranges[0].count]; drawsegs_xranges[1].count++; } if (ds->x2 >= cx) { - drawsegs_xranges[2].items[drawsegs_xranges[2].count] = - drawsegs_xranges[0].items[drawsegs_xranges[0].count]; + drawsegs_xranges[2].items[drawsegs_xranges[2].count] = + drawsegs_xranges[0].items[drawsegs_xranges[0].count]; drawsegs_xranges[2].count++; } @@ -3751,10 +3752,11 @@ static void R_DrawMaskedList (drawnode_t* head) R_DoneWithNode(r2); r2 = next; } - else if (r2->seg) + else if (r2->seg && r2->seg->maskedtexturecol != NULL) { next = r2->prev; R_RenderMaskedSegRange(r2->seg, r2->seg->x1, r2->seg->x2); + r2->seg->maskedtexturecol = NULL; R_DoneWithNode(r2); r2 = next; } @@ -3783,18 +3785,18 @@ static void R_DrawMaskedList (drawnode_t* head) vissprite_t *ds = r2->sprite->linkdraw; for (; - (ds != NULL && r2->sprite->dispoffset > ds->dispoffset); + (ds != NULL && r2->sprite->dispoffset > ds->dispoffset); ds = ds->next) - { - R_DrawSprite(ds); - } + { + R_DrawSprite(ds); + } - R_DrawSprite(r2->sprite); + R_DrawSprite(r2->sprite); - for (; ds != NULL; ds = ds->next) - { - R_DrawSprite(ds); - } + for (; ds != NULL; ds = ds->next) + { + R_DrawSprite(ds); + } } R_DoneWithNode(r2); diff --git a/src/screen.c b/src/screen.c index dfb8213cb..ddc9f5af0 100644 --- a/src/screen.c +++ b/src/screen.c @@ -231,7 +231,7 @@ void R_SetColumnFunc(size_t id, boolean brightmapped) void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) { - I_Assert(id < COLDRAWFUNC_MAX); + I_Assert(id < SPANDRAWFUNC_MAX); if (debugrender_highlight != 0 && R_SetSpanFuncFlat(id)) {