port and update the opengl map preprocessor from Doom-Legacy

this fixes numerous issues with holes in map geometry, misplaced sectors/planes, rare infinite loop hangs

most notably fixes most rendering issues on UDMF/RR maps

needs some testing as this may be slower than the old one
This commit is contained in:
Alug 2026-03-09 18:15:38 +01:00
parent 3f0e421085
commit b7ade32020
8 changed files with 2682 additions and 722 deletions

View file

@ -478,7 +478,7 @@ static void HWR_AddPolyObjectPlanes(void)
sector_t *polyobjsector;
INT32 light = 0;
// Polyobject Planes need their own function for drawing because they don't have extrasubsectors by themselves
// Polyobject Planes need their own function for drawing because they don't have poly_subsectors by themselves
// It should be okay because polyobjects should always be convex anyway
for (i = 0; i < numpolys; i++)
@ -567,9 +567,9 @@ static void HWR_Subsector(size_t num)
// CONS_Printf("subsector %d in portal\n", (INT32)num);
#ifdef PARANOIA //no risk while developing, enough debugging nights!
if (num >= addsubsector)
if (num >= num_poly_subsector)
I_Error("HWR_Subsector: ss %s with numss = %s, addss = %s\n",
sizeu1(num), sizeu2(numsubsectors), sizeu3(addsubsector));
sizeu1(num), sizeu2(numsubsectors), sizeu3(num_poly_subsector));
/*if (num >= numsubsectors)
I_Error("HWR_Subsector: ss %i with numss = %i",
@ -668,7 +668,7 @@ static void HWR_Subsector(size_t num)
if (sub->validcount != validcount)
{
HWR_GetLevelFlat(&levelflats[gl_frontsector->floorpic], R_NoEncore(gl_frontsector, &levelflats[gl_frontsector->floorpic], false));
HWR_RenderPlane(sub, &extrasubsectors[num], false,
HWR_RenderPlane(sub, &poly_subsectors[num], false,
// Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight,
// We now return you to your regularly scheduled rendering.
@ -685,7 +685,7 @@ static void HWR_Subsector(size_t num)
if (sub->validcount != validcount)
{
HWR_GetLevelFlat(&levelflats[gl_frontsector->ceilingpic], R_NoEncore(gl_frontsector, &levelflats[gl_frontsector->ceilingpic], true));
HWR_RenderPlane(sub, &extrasubsectors[num], true,
HWR_RenderPlane(sub, &poly_subsectors[num], true,
// Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering.
@ -725,7 +725,7 @@ static void HWR_Subsector(size_t num)
alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
&poly_subsectors[num],
false,
*rover->bottomheight,
*gl_frontsector->lightlist[light].lightlevel,
@ -740,7 +740,7 @@ static void HWR_Subsector(size_t num)
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < cullHeight ? true : false);
HWR_AddTransparentFloor(&levelflats[*rover->bottompic],
&extrasubsectors[num],
&poly_subsectors[num],
false,
*rover->bottomheight,
*gl_frontsector->lightlist[light].lightlevel,
@ -751,7 +751,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetLevelFlat(&levelflats[*rover->bottompic], R_NoEncore(gl_frontsector, &levelflats[*rover->bottompic], false));
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < cullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false) | PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic],
HWR_RenderPlane(sub, &poly_subsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false) | PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic],
rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap);
}
}
@ -773,7 +773,7 @@ static void HWR_Subsector(size_t num)
alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
&poly_subsectors[num],
true,
*rover->topheight,
*gl_frontsector->lightlist[light].lightlevel,
@ -788,7 +788,7 @@ static void HWR_Subsector(size_t num)
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < cullHeight ? true : false);
HWR_AddTransparentFloor(&levelflats[*rover->toppic],
&extrasubsectors[num],
&poly_subsectors[num],
true,
*rover->topheight,
*gl_frontsector->lightlist[light].lightlevel,
@ -799,7 +799,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetLevelFlat(&levelflats[*rover->toppic], R_NoEncore(gl_frontsector, &levelflats[*rover->toppic], true));
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < cullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, true) | PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic],
HWR_RenderPlane(sub, &poly_subsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, true) | PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic],
rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap);
}
}

View file

@ -37,7 +37,7 @@ typedef struct
typedef struct
{
extrasubsector_t *xsub;
poly_subsector_t *xsub;
boolean isceiling;
fixed_t fixedheight;
INT32 lightlevel;
@ -143,7 +143,7 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 te
}
// This will likely turn into a copy of HWR_Add3DWater and replace it.
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
void HWR_AddTransparentFloor(levelflat_t *levelflat, poly_subsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
{
planeinfo_t *planeinfo = HWR_CreateDrawNode(DRAWNODE_PLANE);

View file

@ -54,7 +54,7 @@ typedef struct
typedef struct
{
poly_t *planepoly; // the generated convex polygon
} extrasubsector_t;
} poly_subsector_t;
// needed for sprite rendering
// equivalent of the software renderer's vissprites
@ -117,16 +117,14 @@ typedef struct gl_vissprite_s
void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model);
// --------
// hw_bsp.c
// hw_map.c
// --------
extern extrasubsector_t *extrasubsectors;
extern size_t addsubsector;
extern poly_subsector_t *poly_subsectors;
extern size_t num_poly_subsector;
void HWR_InitPolyPool(void);
void HWR_FreePolyPool(void);
void HWR_FreeExtraSubsectors(void);
// --------
// hw_cache.c
// --------
@ -176,7 +174,7 @@ extern INT32 textureformat;
// --------
// hw_plane.c
// --------
void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_RenderPlane(subsector_t *subsector, poly_subsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
FBITFIELD blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector,
UINT8 alpha, extracolormap_t *planecolormap);
@ -185,7 +183,7 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t
// hw_drawnodes.c
// --------
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentFloor(levelflat_t *levelflat, poly_subsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
void HWR_PushDrawNodeState(void);

View file

@ -1255,6 +1255,17 @@ consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_SAVE|C
consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL);
consvar_t cv_glpolytile = CVAR_INIT ("gr_polytile", "On", 0, CV_OnOff, NULL);
CV_PossibleValue_t grpolyshape_cons_t[] = {
{0, "Subsector"},
{1, "Fat"},
{2, "Trim"},
{3, "NotConvex"},
{0, NULL}
};
consvar_t cv_glpolyshape = CVAR_INIT ("gr_polygon_shape", "Trim", CV_SAVE, grpolyshape_cons_t, NULL);
consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL);
CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}};
@ -1365,7 +1376,10 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glallowshaders);
CV_RegisterVar(&cv_glfiltermode);
CV_RegisterVar(&cv_glsolvetjoin);
CV_RegisterVar(&cv_glpolytile);
CV_RegisterVar(&cv_glpolyshape);
CV_RegisterVar(&cv_glbatching);
@ -1399,6 +1413,7 @@ void HWR_Startup(void)
textureformat = patchformat = GL_TEXFMT_RGBA;
HWR_InitPolyPool();
HWR_AddSessionCommands();
HWR_InitMapTextures();
HWR_InitModels();
@ -1445,7 +1460,6 @@ void HWR_Switch(void)
void HWR_Shutdown(void)
{
CONS_Printf("HWR_Shutdown()\n");
HWR_FreeExtraSubsectors();
HWR_FreePolyPool();
HWR_FreeMapTextures();
GL_FlushScreenTextures();

View file

@ -110,11 +110,13 @@ extern consvar_t cv_glmodellighting;
extern consvar_t cv_glfiltermode;
extern consvar_t cv_glanisotropicmode;
extern consvar_t cv_fovchange;
extern consvar_t cv_glsolvetjoin;
extern consvar_t cv_glshearing;
extern consvar_t cv_glspritebillboarding;
extern consvar_t cv_glskydome;
extern consvar_t cv_glsolvetjoin, cv_glpolytile, cv_glpolyshape;
extern consvar_t cv_glbatching;
extern consvar_t cv_glpaletterendering;
extern consvar_t cv_glpalettedepth;

File diff suppressed because it is too large Load diff

View file

@ -40,7 +40,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t
// -----------------+
// HWR_RenderPlane : Render a floor or ceiling convex polygon
// -----------------+
void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
void HWR_RenderPlane(subsector_t *subsector, poly_subsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
{
polyvertex_t * pv;
float height; //constant y for all points on the convex flat polygon

View file

@ -9051,21 +9051,20 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
// Load the ccheckpoints and waypoints please!
if (gametyperules & GTR_CIRCUIT && gamestate != GS_TITLESCREEN)
{
if ((K_SetupWaypointList() == false))
if ((K_SetupWaypointList() == false))
{
if (!K_UsingLegacyCheckpoints())
{
if (!K_UsingLegacyCheckpoints())
{
CONS_Alert(CONS_ERROR, "Waypoints were not able to be setup and legacy checkpoints do not exist! Player positions will not work correctly.\n");
}
CONS_Alert(CONS_ERROR, "Waypoints were not able to be setup and legacy checkpoints do not exist! Player positions will not work correctly.\n");
}
}
}
#ifdef HWRENDER // not win32 only 19990829 by Kin
gl_maploaded = false;
// Lactozilla: Free extrasubsectors regardless of renderer.
HWR_FreeExtraSubsectors();
// Lactozilla: Free poly_subsectors regardless of renderer.
HWR_FreePolyPool();
// Create plane polygons.
if (rendermode == render_opengl)