Make r_bsp and r_line stop sharing floorplane and ceiling plane variables

This commit is contained in:
Magnus Norddahl 2017-01-04 05:10:16 +01:00
parent 38280b9315
commit c396e7f949
4 changed files with 18 additions and 19 deletions

View file

@ -51,7 +51,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector) void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *linefloorplane, visplane_t *lineceilingplane)
{ {
static sector_t tempsec; // killough 3/8/98: ceiling/water hack static sector_t tempsec; // killough 3/8/98: ceiling/water hack
bool solid; bool solid;
@ -60,6 +60,8 @@ namespace swrenderer
InSubsector = subsector; InSubsector = subsector;
frontsector = sector; frontsector = sector;
backsector = fakebacksector; backsector = fakebacksector;
floorplane = linefloorplane;
ceilingplane = lineceilingplane;
curline = line; curline = line;

View file

@ -15,6 +15,8 @@
namespace swrenderer namespace swrenderer
{ {
struct visplane_t;
struct FWallCoords struct FWallCoords
{ {
FVector2 tleft; // coords at left of wall in view space rx1,ry1 FVector2 tleft; // coords at left of wall in view space rx1,ry1
@ -38,7 +40,7 @@ namespace swrenderer
class SWRenderLine class SWRenderLine
{ {
public: public:
void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector); void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *floorplane, visplane_t *ceilingplane);
private: private:
bool RenderWallSegment(int x1, int x2); bool RenderWallSegment(int x1, int x2);
@ -51,6 +53,8 @@ namespace swrenderer
subsector_t *InSubsector; subsector_t *InSubsector;
sector_t *frontsector; sector_t *frontsector;
sector_t *backsector; sector_t *backsector;
visplane_t *floorplane;
visplane_t *ceilingplane;
seg_t *curline; seg_t *curline;
side_t *sidedef; side_t *sidedef;

View file

@ -63,17 +63,13 @@ namespace swrenderer
{ {
subsector_t *InSubsector; subsector_t *InSubsector;
sector_t *frontsector; sector_t *frontsector;
uint8_t FakeSide;
SWRenderLine render_line; SWRenderLine render_line;
} }
bool r_fakingunderwater; bool r_fakingunderwater;
static BYTE FakeSide;
visplane_t *floorplane;
visplane_t *ceilingplane;
// Clip values are the solid pixel bounding the range. // Clip values are the solid pixel bounding the range.
// floorclip starts out SCREENHEIGHT and is just outside the range // floorclip starts out SCREENHEIGHT and is just outside the range
// ceilingclip starts out 0 and is just inside the range // ceilingclip starts out 0 and is just inside the range
@ -415,7 +411,7 @@ static void R_AddPolyobjs(subsector_t *sub)
} }
// kg3D - add fake segs, never rendered // kg3D - add fake segs, never rendered
void R_FakeDrawLoop(subsector_t *sub) void R_FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane)
{ {
int count; int count;
seg_t* line; seg_t* line;
@ -427,7 +423,7 @@ void R_FakeDrawLoop(subsector_t *sub)
{ {
if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ)) if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ))
{ {
render_line.Render(line, InSubsector, frontsector, nullptr); render_line.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane);
} }
line++; line++;
} }
@ -517,7 +513,7 @@ void R_Subsector (subsector_t *sub)
portal = frontsector->ValidatePortal(sector_t::ceiling); portal = frontsector->ValidatePortal(sector_t::ceiling);
ceilingplane = frontsector->ceilingplane.PointOnSide(ViewPos) > 0 || visplane_t *ceilingplane = frontsector->ceilingplane.PointOnSide(ViewPos) > 0 ||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum || frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
portal != NULL || portal != NULL ||
(frontsector->heightsec && (frontsector->heightsec &&
@ -557,7 +553,7 @@ void R_Subsector (subsector_t *sub)
// killough 10/98: add support for skies transferred from sidedefs // killough 10/98: add support for skies transferred from sidedefs
portal = frontsector->ValidatePortal(sector_t::floor); portal = frontsector->ValidatePortal(sector_t::floor);
floorplane = frontsector->floorplane.PointOnSide(ViewPos) > 0 || // killough 3/7/98 visplane_t *floorplane = frontsector->floorplane.PointOnSide(ViewPos) > 0 || // killough 3/7/98
frontsector->GetTexture(sector_t::floor) == skyflatnum || frontsector->GetTexture(sector_t::floor) == skyflatnum ||
portal != NULL || portal != NULL ||
(frontsector->heightsec && (frontsector->heightsec &&
@ -636,7 +632,7 @@ void R_Subsector (subsector_t *sub)
if (floorplane) if (floorplane)
R_AddPlaneLights(floorplane, frontsector->lighthead); R_AddPlaneLights(floorplane, frontsector->lighthead);
R_FakeDrawLoop(sub); R_FakeDrawLoop(sub, floorplane, ceilingplane);
fake3D = 0; fake3D = 0;
frontsector = sub->sector; frontsector = sub->sector;
} }
@ -700,7 +696,7 @@ void R_Subsector (subsector_t *sub)
if (ceilingplane) if (ceilingplane)
R_AddPlaneLights(ceilingplane, frontsector->lighthead); R_AddPlaneLights(ceilingplane, frontsector->lighthead);
R_FakeDrawLoop(sub); R_FakeDrawLoop(sub, floorplane, ceilingplane);
fake3D = 0; fake3D = 0;
frontsector = sub->sector; frontsector = sub->sector;
} }
@ -719,8 +715,7 @@ void R_Subsector (subsector_t *sub)
// lightlevels on floor & ceiling lightlevels in the surrounding area. // lightlevels on floor & ceiling lightlevels in the surrounding area.
// [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by // [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by
// it, otherwise they are lit by the floor. // it, otherwise they are lit by the floor.
R_AddSprites (sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ? R_AddSprites (sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ? ceilinglightlevel : floorlightlevel, FakeSide);
ceilinglightlevel : floorlightlevel, FakeSide);
// [RH] Add particles // [RH] Add particles
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors) if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
@ -761,14 +756,14 @@ void R_Subsector (subsector_t *sub)
fakeFloor->validcount = validcount; fakeFloor->validcount = validcount;
R_3D_NewClip(); R_3D_NewClip();
} }
render_line.Render(line, InSubsector, frontsector, &tempsec); // fake render_line.Render(line, InSubsector, frontsector, &tempsec, floorplane, ceilingplane); // fake
} }
fakeFloor = NULL; fakeFloor = NULL;
fake3D = 0; fake3D = 0;
floorplane = backupfp; floorplane = backupfp;
ceilingplane = backupcp; ceilingplane = backupcp;
} }
render_line.Render(line, InSubsector, frontsector, nullptr); // now real render_line.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane); // now real
} }
line++; line++;
} }

View file

@ -52,8 +52,6 @@ void R_RenderBSPNode (void *node);
// killough 4/13/98: fake floors/ceilings for deep water / fake ceilings: // killough 4/13/98: fake floors/ceilings for deep water / fake ceilings:
sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, seg_t *backline, int backx1, int backx2, double frontcz1, double frontcz2); sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, seg_t *backline, int backx1, int backx2, double frontcz1, double frontcz2);
extern visplane_t *floorplane;
extern visplane_t *ceilingplane;
extern short floorclip[MAXWIDTH]; extern short floorclip[MAXWIDTH];
extern short ceilingclip[MAXWIDTH]; extern short ceilingclip[MAXWIDTH];