- instead of copying the sector planes to GLWall, just store pointers to the front and back sector for later use.

Until now this wasn't doable because these could have come from hw_FakeFlat which only were local copies on the stack.
With the recent change these faked sectors live long enough so that they can be passed around here.
This commit is contained in:
Christoph Oelckers 2018-11-10 23:18:34 +01:00
parent 67e012e445
commit c946edd9bf
3 changed files with 10 additions and 10 deletions

View file

@ -95,7 +95,7 @@ void GLDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
for (unsigned k = 0; k < lightlist.Size(); k++)
{
secplane_t &lowplane = k == lightlist.Size() - 1 ? bottomplane : lightlist[k + 1].plane;
secplane_t &lowplane = k == lightlist.Size() - 1 ? frontsector->floorplane : lightlist[k + 1].plane;
float low1 = lowplane.ZatPoint(dv[1].x, dv[1].y);
float low2 = lowplane.ZatPoint(dv[2].x, dv[2].y);
@ -404,7 +404,7 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
gldecal->alpha = decal->Alpha;
gldecal->zcenter = zpos - decalheight * 0.5f;
gldecal->bottomplane = bottomplane;
gldecal->frontsector = frontsector;
gldecal->Normal = normal;
gldecal->lightlist = lightlist;
memcpy(gldecal->dv, dv, sizeof(dv));

View file

@ -186,7 +186,6 @@ public:
};
secplane_t topplane, bottomplane; // we need to save these to pass them to the shader for calculating glows.
// these are not the same as ytop and ybottom!!!
float zceil[2];
@ -198,6 +197,7 @@ public:
public:
seg_t * seg; // this gives the easiest access to all other structs involved
subsector_t * sub; // For polyobjects
sector_t *frontsector, *backsector;
//private:
void PutWall(HWDrawInfo *di, bool translucent);
@ -411,7 +411,7 @@ struct GLDecal
int rellight;
float alpha;
FColormap Colormap;
secplane_t bottomplane;
sector_t *frontsector;
FVector3 Normal;
void DrawDecal(HWDrawInfo *di, FRenderState &state);

View file

@ -140,7 +140,7 @@ void GLWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
state.EnableGlow(true);
state.SetGlowParams(topglowcolor, bottomglowcolor);
}
state.SetGlowPlanes(topplane, bottomplane);
state.SetGlowPlanes(frontsector->ceilingplane, frontsector->floorplane);
state.SetMaterial(gltexture, flags & 3, 0, -1);
if (type == RENDERWALL_M2SNF)
@ -167,7 +167,7 @@ void GLWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
for (unsigned i = 0; i < lightlist->Size(); i++)
{
secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane;
secplane_t &lowplane = i == (*lightlist).Size() - 1 ? frontsector->floorplane : (*lightlist)[i + 1].plane;
// this must use the exact same calculation method as GLWall::Process etc.
float low1 = lowplane.ZatPoint(vertexes[0]);
float low2 = lowplane.ZatPoint(vertexes[1]);
@ -1799,6 +1799,8 @@ void GLWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
// note: we always have a valid sidedef and linedef reference when getting here.
this->seg = seg;
this->frontsector = frontsector;
this->backsector = backsector;
vertindex = 0;
vertcount = 0;
@ -1893,8 +1895,6 @@ void GLWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
topplane = frontsector->ceilingplane;
bottomplane = frontsector->floorplane;
zfloor[0] = ffh1 = segfront->floorplane.ZatPoint(v1);
zfloor[1] = ffh2 = segfront->floorplane.ZatPoint(v2);
@ -2104,6 +2104,8 @@ void GLWall::ProcessLowerMiniseg(HWDrawInfo *di, seg_t *seg, sector_t * frontsec
if (bfh > ffh)
{
this->seg = seg;
this->frontsector = frontsector;
this->backsector = backsector;
this->sub = NULL;
vertex_t * v1 = seg->v1;
@ -2129,8 +2131,6 @@ void GLWall::ProcessLowerMiniseg(HWDrawInfo *di, seg_t *seg, sector_t * frontsec
Colormap = frontsector->Colormap;
if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW;
topplane = frontsector->ceilingplane;
bottomplane = frontsector->floorplane;
dynlightindex = -1;
zfloor[0] = zfloor[1] = ffh;