- GL adjustments for plane changes.

This commit is contained in:
Christoph Oelckers 2016-03-29 13:45:50 +02:00
parent 37e6429cf3
commit 59bb003285
12 changed files with 52 additions and 53 deletions

View file

@ -157,8 +157,8 @@ int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide,
while ((secnum = itr.Next()) >= 0)
{
sector_t * s = &sectors[secnum];
if (s->floorplane.a==0 && s->floorplane.b==0) s->reflect[sector_t::floor] = arg1/255.f;
if (s->ceilingplane.a==0 && s->ceilingplane.b==0) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f;
if (!s->floorplane.isSlope()) s->reflect[sector_t::floor] = arg1/255.f;
if (!s->ceilingplane.isSlope()) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f;
}
return true;

View file

@ -324,7 +324,7 @@ static void PrepareTransparentDoors(sector_t * sector)
if (sector->subsectorcount==0) return;
sector->transdoorheight=sector->GetPlaneTexZ(sector_t::floor);
sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.a || sector->floorplane.b);
sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.isSlope());
if (sector->transdoor)
{

View file

@ -275,14 +275,14 @@ public:
void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom)
{
mGlowTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d));
mGlowBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d));
mGlowTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD());
mGlowBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD());
}
void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom)
{
mSplitTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d));
mSplitBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d));
mSplitTopPlane.Set(top.fA(), top.fB(), 1. / top.fC(), top.fD());
mSplitBottomPlane.Set(bottom.fA(), bottom.fB(), 1. / bottom.fC(), bottom.fD());
}
void SetDynLight(float r, float g, float b)

View file

@ -80,44 +80,44 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
// on large levels this distinction can save some time
// That's a lot of avoided multiplications if there's a lot to see!
if (frontsector->ceilingplane.a | frontsector->ceilingplane.b)
if (frontsector->ceilingplane.isSlope())
{
fs_ceilingheight1=frontsector->ceilingplane.ZatPoint(linedef->v1);
fs_ceilingheight2=frontsector->ceilingplane.ZatPoint(linedef->v2);
}
else
{
fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.d;
fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.fixD();
}
if (frontsector->floorplane.a | frontsector->floorplane.b)
if (frontsector->floorplane.isSlope())
{
fs_floorheight1=frontsector->floorplane.ZatPoint(linedef->v1);
fs_floorheight2=frontsector->floorplane.ZatPoint(linedef->v2);
}
else
{
fs_floorheight2=fs_floorheight1=-frontsector->floorplane.d;
fs_floorheight2=fs_floorheight1=-frontsector->floorplane.fixD();
}
if (backsector->ceilingplane.a | backsector->ceilingplane.b)
if (backsector->ceilingplane.isSlope())
{
bs_ceilingheight1=backsector->ceilingplane.ZatPoint(linedef->v1);
bs_ceilingheight2=backsector->ceilingplane.ZatPoint(linedef->v2);
}
else
{
bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.d;
bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.fixD();
}
if (backsector->floorplane.a | backsector->floorplane.b)
if (backsector->floorplane.isSlope())
{
bs_floorheight1=backsector->floorplane.ZatPoint(linedef->v1);
bs_floorheight2=backsector->floorplane.ZatPoint(linedef->v2);
}
else
{
bs_floorheight2=bs_floorheight1=-backsector->floorplane.d;
bs_floorheight2=bs_floorheight1=-backsector->floorplane.fixD();
}
// now check for closed sectors!
@ -206,7 +206,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
// visual glitches because upper amd lower textures overlap.
if (back && sec->planes[sector_t::floor].TexZ > sec->planes[sector_t::ceiling].TexZ)
{
if (!(sec->floorplane.a | sec->floorplane.b | sec->ceilingplane.a | sec->ceilingplane.b))
if (!sec->floorplane.isSlope() && !sec->ceilingplane.isSlope())
{
*dest = *sec;
dest->ceilingplane=sec->floorplane;

View file

@ -174,7 +174,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
void GLFlat::DrawSubsector(subsector_t * sub)
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
if (plane.plane.a | plane.plane.b)
if (plane.plane.isSlope())
{
for (unsigned int k = 0; k < sub->numlines; k++)
{

View file

@ -810,7 +810,7 @@ void GLPlaneMirrorPortal::DrawContents()
fixed_t planez = origin->ZatPoint(viewx, viewy);
viewz = 2*planez - viewz;
GLRenderer->mViewActor = NULL;
PlaneMirrorMode = ksgn(origin->c);
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
r_showviewer = true;
validcount++;

View file

@ -296,7 +296,7 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true);
// Don't bother with slopes
if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false;
if (sec->ceilingplane.isSlope()) return false;
// Is the neighboring ceiling lower than the desired height?
if (sec->GetPlaneTexZ(sector_t::ceiling)<planez)
@ -354,7 +354,7 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true);
// Don't bother with slopes
if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false;
if (sec->floorplane.isSlope()) return false;
// Is the neighboring floor higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::floor)>planez)
@ -413,7 +413,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true);
// Don't bother with slopes
if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false;
if (sec->floorplane.isSlope()) return false;
// Is the neighboring floor higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::floor)<planez)
@ -466,7 +466,7 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true);
// Don't bother with slopes
if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false;
if (sec->ceilingplane.isSlope()) return false;
// Is the neighboring ceiling higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::ceiling)>planez)

View file

@ -173,8 +173,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect)
}
else if (allowreflect && sector->GetReflect(plane) > 0)
{
if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) ||
(plane == sector_t::floor && viewz < -sector->floorplane.d)) return;
if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.fixD()) ||
(plane == sector_t::floor && viewz < -sector->floorplane.fixD())) return;
ptype = PORTALTYPE_PLANEMIRROR;
planemirror = plane == sector_t::ceiling ? &sector->ceilingplane : &sector->floorplane;
}
@ -263,7 +263,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex
return;
// one more check for some ugly transparent door hacks
if (bs->floorplane.a==0 && bs->floorplane.b==0 && fs->floorplane.a==0 && fs->floorplane.b==0)
if (!bs->floorplane.isSlope() && !fs->floorplane.isSlope())
{
if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+FRACUNIT)
{
@ -309,7 +309,7 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex
if (frontreflect > 0)
{
float backreflect = bs->GetReflect(sector_t::ceiling);
if (backreflect > 0 && bs->ceilingplane.d == fs->ceilingplane.d)
if (backreflect > 0 && bs->ceilingplane.fD() == fs->ceilingplane.fD())
{
// Don't add intra-portal line to the portal.
return;
@ -386,7 +386,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver
if (frontreflect > 0)
{
float backreflect = bs->GetReflect(sector_t::floor);
if (backreflect > 0 && bs->floorplane.d == fs->floorplane.d)
if (backreflect > 0 && bs->floorplane.fD() == fs->floorplane.fD())
{
// Don't add intra-portal line to the portal.
return;

View file

@ -240,8 +240,9 @@ void GLSprite::Draw(int pass)
if (lightlist)
{
// set up the light slice
static secplane_t bottommost = { 0, 0, FRACUNIT, 32767<<FRACBITS, FRACUNIT };
static secplane_t topmost = { 0, 0, FRACUNIT, -(32767<<FRACBITS), FRACUNIT };
#pragma message ("Undo this!")
secplane_t bottommost; bottommost.set(0, 0, FRACUNIT, 32767 << FRACBITS);
secplane_t topmost; topmost.set(0, 0, FRACUNIT, -(32767 << FRACBITS));
secplane_t *topplane = i == 0 ? &topmost : &(*lightlist)[i].plane;
secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottommost : &(*lightlist)[i + 1].plane;

View file

@ -86,7 +86,7 @@ struct GLSectorPlane
angle = sec->GetAngle(ceiling);
texture = sec->GetTexture(ceiling);
plane = sec->GetSecPlane(ceiling);
texheight = (ceiling == sector_t::ceiling)? plane.d : -plane.d;
texheight = (ceiling == sector_t::ceiling)? plane.fixD() : -plane.fixD();
}
};
@ -205,7 +205,7 @@ private:
fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2,
fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2);
void GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right);
void GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right);
void BuildFFBlock(seg_t * seg, F3DFloor * rover,
fixed_t ff_topleft, fixed_t ff_topright,

View file

@ -191,7 +191,7 @@ void GLWall::PutPortal(int ptype)
break;
case PORTALTYPE_PLANEMIRROR:
if (GLPortal::PlaneMirrorMode * planemirror->c <=0)
if (GLPortal::PlaneMirrorMode * planemirror->fC() <=0)
{
//@sync-portal
planemirror=UniquePlaneMirrors.Get(planemirror);
@ -283,7 +283,7 @@ void GLWall::SplitWall(sector_t * frontsector, bool translucent)
if (i<lightlist.Size()-1)
{
secplane_t &p = lightlist[i+1].plane;
if (p.a | p.b)
if (p.isSlope())
{
maplightbottomleft = p.ZatPoint(glseg.x1,glseg.y1);
maplightbottomright= p.ZatPoint(glseg.x2,glseg.y2);
@ -1101,20 +1101,20 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
//
//==========================================================================
__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right)
__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &left, fixed_t &right)
{
if (planeref->plane->a | planeref->plane->b)
if (planeref->plane->isSlope())
{
left=planeref->plane->ZatPoint(vertexes[0]);
right=planeref->plane->ZatPoint(vertexes[1]);
}
else if(planeref->isceiling == sector_t::ceiling)
{
left = right = planeref->plane->d;
left = right = planeref->plane->fixD();
}
else
{
left = right = -planeref->plane->d;
left = right = -planeref->plane->fixD();
}
}
@ -1450,7 +1450,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
bottomplane = frontsector->floorplane;
// Save a little time (up to 0.3 ms per frame ;) )
if (frontsector->floorplane.a | frontsector->floorplane.b)
if (frontsector->floorplane.isSlope())
{
ffh1 = segfront->floorplane.ZatPoint(v1);
ffh2 = segfront->floorplane.ZatPoint(v2);
@ -1459,11 +1459,11 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else
{
ffh1 = ffh2 = -segfront->floorplane.d;
ffh1 = ffh2 = -segfront->floorplane.fixD();
zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2);
}
if (segfront->ceilingplane.a | segfront->ceilingplane.b)
if (segfront->ceilingplane.isSlope())
{
fch1 = segfront->ceilingplane.ZatPoint(v1);
fch2 = segfront->ceilingplane.ZatPoint(v2);
@ -1472,7 +1472,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else
{
fch1 = fch2 = segfront->ceilingplane.d;
fch1 = fch2 = segfront->ceilingplane.fixD();
zceil[0] = zceil[1] = FIXED2FLOAT(fch2);
}
@ -1520,24 +1520,24 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
fixed_t bfh1;
fixed_t bfh2;
if (segback->floorplane.a | segback->floorplane.b)
if (segback->floorplane.isSlope())
{
bfh1 = segback->floorplane.ZatPoint(v1);
bfh2 = segback->floorplane.ZatPoint(v2);
}
else
{
bfh1 = bfh2 = -segback->floorplane.d;
bfh1 = bfh2 = -segback->floorplane.fixD();
}
if (segback->ceilingplane.a | segback->ceilingplane.b)
if (segback->ceilingplane.isSlope())
{
bch1 = segback->ceilingplane.ZatPoint(v1);
bch2 = segback->ceilingplane.ZatPoint(v2);
}
else
{
bch1 = bch2 = segback->ceilingplane.d;
bch1 = bch2 = segback->ceilingplane.fixD();
}
SkyTop(seg, frontsector, backsector, v1, v2);
@ -1568,8 +1568,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
{
if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b |
backsector->ceilingplane.a | backsector->ceilingplane.b) &&
if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) &&
frontsector->GetTexture(sector_t::ceiling) != skyflatnum &&
backsector->GetTexture(sector_t::ceiling) != skyflatnum)
{
@ -1649,8 +1648,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
{
if ((frontsector->floorplane.a | frontsector->floorplane.b |
backsector->floorplane.a | backsector->floorplane.b) &&
if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) &&
frontsector->GetTexture(sector_t::floor) != skyflatnum &&
backsector->GetTexture(sector_t::floor) != skyflatnum)
{

View file

@ -229,10 +229,10 @@ void Plane::Set(secplane_t &plane)
{
float a, b, c, d;
a = FIXED2FLOAT(plane.a);
b = FIXED2FLOAT(plane.b);
c = FIXED2FLOAT(plane.c);
d = FIXED2FLOAT(plane.d);
a = (float)plane.fA();
b = (float)plane.fB();
c = (float)plane.fC();
d = (float)plane.fD();
m_normal.Set(a, c, b);
//m_normal.Normalize(); the vector is already normalized