- when rendering mirrors, discard subsectors lying behind them.

This commit is contained in:
Christoph Oelckers 2016-01-27 12:02:43 +01:00
parent 4b0ce7a8db
commit 3c16a23865
3 changed files with 21 additions and 7 deletions

View file

@ -361,11 +361,6 @@ static void DoSubsector(subsector_t * sub)
sector_t * fakesector;
sector_t fake;
// check for visibility of this entire subsector. This requires GL nodes.
// (disabled because it costs more time than it saves.)
//if (!clipper.CheckBox(sub->bbox)) return;
#ifdef _DEBUG
if (sub->sector-sectors==931)
{
@ -387,6 +382,14 @@ static void DoSubsector(subsector_t * sub)
UnclipSubsector(sub);
}
if (GLRenderer->mCurrentPortal)
{
int clipres = GLRenderer->mCurrentPortal->ClipSubsector(sub);
if (clipres == GLPortal::PClip_InFront) return;
}
fakesector=gl_FakeFlat(sector, &fake, false);
if (sector->validcount != validcount)

View file

@ -750,7 +750,6 @@ void GLSectorStackPortal::DrawContents()
viewx += origin->xDisplacement;
viewy += origin->yDisplacement;
GLRenderer->mViewActor = NULL;
GLRenderer->mCurrentPortal = this;
validcount++;
@ -937,7 +936,7 @@ void GLMirrorPortal::DrawContents()
int GLMirrorPortal::ClipSeg(seg_t *seg)
{
// this seg is completely behind the mirror!
// this seg is completely behind the mirror.
if (P_PointOnLineSide(seg->v1->x, seg->v1->y, linedef) &&
P_PointOnLineSide(seg->v2->x, seg->v2->y, linedef))
{
@ -946,6 +945,16 @@ int GLMirrorPortal::ClipSeg(seg_t *seg)
return PClip_Inside;
}
int GLMirrorPortal::ClipSubsector(subsector_t *sub)
{
// this seg is completely behind the mirror!
for(int i=0;i<sub->numlines;i++)
{
if (P_PointOnLineSide(sub->firstline[i].v1->x, sub->firstline[i].v1->y, linedef) == 0) return PClip_Inside;
}
return PClip_InFront;
}
int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y)
{
if (P_PointOnLineSide(x, y, linedef))

View file

@ -160,6 +160,7 @@ public:
}
virtual int ClipSeg(seg_t *seg) { return PClip_Inside; }
virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; }
virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; }
static void BeginScene();
@ -189,6 +190,7 @@ public:
virtual bool NeedCap() { return false; }
virtual int ClipSeg(seg_t *seg);
virtual int ClipSubsector(subsector_t *sub);
virtual int ClipPoint(fixed_t x, fixed_t y);
};