mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 21:01:04 +00:00
Merge branch 'plane-fixes' into 'next'
Software plane rendering fixes/cleanup This is mostly cleanup, with the exception that polyobject planes should now behave somewhat better than they do in 2.1 currently (translucent polyobj planes should now always be actually translucent regardless of where you view them from, for instance). I can't claim I've fixed their rendering once and for all though, there may still be bugs for all I know... See merge request !136
This commit is contained in:
commit
cd0ec0881d
4 changed files with 100 additions and 49 deletions
67
src/r_bsp.c
67
src/r_bsp.c
|
@ -859,6 +859,7 @@ static void R_Subsector(size_t num)
|
|||
static sector_t tempsec; // Deep water hack
|
||||
extracolormap_t *floorcolormap;
|
||||
extracolormap_t *ceilingcolormap;
|
||||
fixed_t floorcenterz, ceilingcenterz;
|
||||
|
||||
#ifdef RANGECHECK
|
||||
if (num >= numsubsectors)
|
||||
|
@ -879,6 +880,18 @@ static void R_Subsector(size_t num)
|
|||
|
||||
floorcolormap = ceilingcolormap = frontsector->extra_colormap;
|
||||
|
||||
floorcenterz =
|
||||
#ifdef ESLOPE
|
||||
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->floorheight;
|
||||
|
||||
ceilingcenterz =
|
||||
#ifdef ESLOPE
|
||||
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->ceilingheight;
|
||||
|
||||
// Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps.
|
||||
if (frontsector->ffloors)
|
||||
{
|
||||
|
@ -891,19 +904,11 @@ static void R_Subsector(size_t num)
|
|||
sub->sector->moved = frontsector->moved = false;
|
||||
}
|
||||
|
||||
light = R_GetPlaneLight(frontsector,
|
||||
#ifdef ESLOPE
|
||||
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->floorheight, false);
|
||||
light = R_GetPlaneLight(frontsector, floorcenterz, false);
|
||||
if (frontsector->floorlightsec == -1)
|
||||
floorlightlevel = *frontsector->lightlist[light].lightlevel;
|
||||
floorcolormap = frontsector->lightlist[light].extra_colormap;
|
||||
light = R_GetPlaneLight(frontsector,
|
||||
#ifdef ESLOPE
|
||||
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->ceilingheight, false);
|
||||
light = R_GetPlaneLight(frontsector, ceilingcenterz, false);
|
||||
if (frontsector->ceilinglightsec == -1)
|
||||
ceilinglightlevel = *frontsector->lightlist[light].lightlevel;
|
||||
ceilingcolormap = frontsector->lightlist[light].extra_colormap;
|
||||
|
@ -920,6 +925,9 @@ static void R_Subsector(size_t num)
|
|||
{
|
||||
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
|
||||
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, NULL
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, frontsector->f_slope
|
||||
#endif
|
||||
|
@ -939,6 +947,9 @@ static void R_Subsector(size_t num)
|
|||
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic,
|
||||
ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
|
||||
ceilingcolormap, NULL
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, NULL
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, frontsector->c_slope
|
||||
#endif
|
||||
|
@ -956,7 +967,7 @@ static void R_Subsector(size_t num)
|
|||
if (frontsector->ffloors)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
fixed_t heightcheck, planecenterz, floorcenterz, ceilingcenterz;
|
||||
fixed_t heightcheck, planecenterz;
|
||||
|
||||
for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next)
|
||||
{
|
||||
|
@ -975,18 +986,6 @@ static void R_Subsector(size_t num)
|
|||
ffloor[numffloors].plane = NULL;
|
||||
ffloor[numffloors].polyobj = NULL;
|
||||
|
||||
floorcenterz =
|
||||
#ifdef ESLOPE
|
||||
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->floorheight;
|
||||
|
||||
ceilingcenterz =
|
||||
#ifdef ESLOPE
|
||||
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
|
||||
#endif
|
||||
frontsector->ceilingheight;
|
||||
|
||||
heightcheck =
|
||||
#ifdef ESLOPE
|
||||
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
|
||||
|
@ -1009,6 +1008,9 @@ static void R_Subsector(size_t num)
|
|||
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
|
||||
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
|
||||
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, NULL
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, *rover->b_slope
|
||||
#endif
|
||||
|
@ -1052,6 +1054,9 @@ static void R_Subsector(size_t num)
|
|||
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
|
||||
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
|
||||
frontsector->lightlist[light].extra_colormap, rover
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, NULL
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, *rover->t_slope
|
||||
#endif
|
||||
|
@ -1093,8 +1098,8 @@ static void R_Subsector(size_t num)
|
|||
polysec = po->lines[0]->backsector;
|
||||
ffloor[numffloors].plane = NULL;
|
||||
|
||||
if (polysec->floorheight <= frontsector->ceilingheight
|
||||
&& polysec->floorheight >= frontsector->floorheight
|
||||
if (polysec->floorheight <= ceilingcenterz
|
||||
&& polysec->floorheight >= floorcenterz
|
||||
&& (viewz < polysec->floorheight))
|
||||
{
|
||||
fixed_t xoff, yoff;
|
||||
|
@ -1118,11 +1123,13 @@ static void R_Subsector(size_t num)
|
|||
polysec->floorpic_angle-po->angle,
|
||||
NULL,
|
||||
NULL
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, po
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, NULL // will ffloors be slopable eventually?
|
||||
#endif
|
||||
);
|
||||
//ffloor[numffloors].plane->polyobj = po;
|
||||
|
||||
ffloor[numffloors].height = polysec->floorheight;
|
||||
ffloor[numffloors].polyobj = po;
|
||||
|
@ -1139,8 +1146,8 @@ static void R_Subsector(size_t num)
|
|||
|
||||
ffloor[numffloors].plane = NULL;
|
||||
|
||||
if (polysec->ceilingheight >= frontsector->floorheight
|
||||
&& polysec->ceilingheight <= frontsector->ceilingheight
|
||||
if (polysec->ceilingheight >= floorcenterz
|
||||
&& polysec->ceilingheight <= ceilingcenterz
|
||||
&& (viewz > polysec->ceilingheight))
|
||||
{
|
||||
fixed_t xoff, yoff;
|
||||
|
@ -1162,11 +1169,13 @@ static void R_Subsector(size_t num)
|
|||
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
|
||||
polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle,
|
||||
NULL, NULL
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, po
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, NULL // will ffloors be slopable eventually?
|
||||
#endif
|
||||
);
|
||||
//ffloor[numffloors].plane->polyobj = po;
|
||||
|
||||
ffloor[numffloors].polyobj = po;
|
||||
ffloor[numffloors].height = polysec->ceilingheight;
|
||||
|
|
|
@ -431,6 +431,9 @@ 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
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, polyobj_t *polyobj
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, pslope_t *slope
|
||||
#endif
|
||||
|
@ -470,6 +473,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
#ifdef POLYOBJECTS_PLANES
|
||||
if (check->polyobj && pfloor)
|
||||
continue;
|
||||
if (polyobj != check->polyobj)
|
||||
continue;
|
||||
#endif
|
||||
if (height == check->height && picnum == check->picnum
|
||||
&& lightlevel == check->lightlevel
|
||||
|
@ -504,7 +509,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
check->viewangle = viewangle;
|
||||
check->plangle = plangle;
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
check->polyobj = NULL;
|
||||
check->polyobj = polyobj;
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
check->slope = slope;
|
||||
|
@ -719,7 +724,11 @@ void R_DrawPlanes(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (pl->ffloor != NULL)
|
||||
if (pl->ffloor != NULL
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
|| pl->polyobj != NULL
|
||||
#endif
|
||||
)
|
||||
continue;
|
||||
|
||||
R_DrawSinglePlane(pl);
|
||||
|
|
|
@ -97,6 +97,9 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
|
|||
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
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
, polyobj_t *polyobj
|
||||
#endif
|
||||
#ifdef ESLOPE
|
||||
, pslope_t *slope
|
||||
#endif
|
||||
|
|
|
@ -1699,21 +1699,25 @@ static void R_CreateDrawNodes(void)
|
|||
entry->ffloor = ds->thicksides[i];
|
||||
}
|
||||
}
|
||||
if (ds->maskedtexturecol)
|
||||
{
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
// Check for a polyobject plane, but only if this is a front line
|
||||
if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) {
|
||||
// Put it in!
|
||||
plane = ds->curline->polyseg->visplane;
|
||||
R_PlaneBounds(plane);
|
||||
|
||||
if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low)
|
||||
;
|
||||
else {
|
||||
// Put it in!
|
||||
entry = R_CreateDrawNode(&nodehead);
|
||||
entry->plane = ds->curline->polyseg->visplane;
|
||||
entry->plane = plane;
|
||||
entry->seg = ds;
|
||||
ds->curline->polyseg->visplane->polyobj = ds->curline->polyseg;
|
||||
}
|
||||
ds->curline->polyseg->visplane = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ds->maskedtexturecol)
|
||||
{
|
||||
entry = R_CreateDrawNode(&nodehead);
|
||||
entry->seg = ds;
|
||||
}
|
||||
|
@ -1756,6 +1760,29 @@ static void R_CreateDrawNodes(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
// find all the remaining polyobject planes and add them on the end of the list
|
||||
// probably this is a terrible idea if we wanted them to be sorted properly
|
||||
// but it works getting them in for now
|
||||
for (i = 0; i < numPolyObjects; i++)
|
||||
{
|
||||
if (!PolyObjects[i].visplane)
|
||||
continue;
|
||||
plane = PolyObjects[i].visplane;
|
||||
R_PlaneBounds(plane);
|
||||
|
||||
if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low)
|
||||
{
|
||||
PolyObjects[i].visplane = NULL;
|
||||
continue;
|
||||
}
|
||||
entry = R_CreateDrawNode(&nodehead);
|
||||
entry->plane = plane;
|
||||
// note: no seg is set, for what should be obvious reasons
|
||||
PolyObjects[i].visplane = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (visspritecount == 0)
|
||||
return;
|
||||
|
||||
|
@ -1812,6 +1839,8 @@ static void R_CreateDrawNodes(void)
|
|||
if (x1 < r2->plane->minx) x1 = r2->plane->minx;
|
||||
if (x2 > r2->plane->maxx) x2 = r2->plane->maxx;
|
||||
|
||||
if (r2->seg) // if no seg set, assume the whole thing is in front or something stupid
|
||||
{
|
||||
for (i = x1; i <= x2; i++)
|
||||
{
|
||||
if (r2->seg->frontscale[i] > rover->scale)
|
||||
|
@ -1819,6 +1848,7 @@ static void R_CreateDrawNodes(void)
|
|||
}
|
||||
if (i > x2)
|
||||
continue;
|
||||
}
|
||||
|
||||
entry = R_CreateDrawNode(NULL);
|
||||
(entry->prev = r2->prev)->next = entry;
|
||||
|
|
Loading…
Reference in a new issue