From 3c16a23865255b14b3fa9b98e9570abddca7e339 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Jan 2016 12:02:43 +0100 Subject: [PATCH] - when rendering mirrors, discard subsectors lying behind them. --- src/gl/scene/gl_bsp.cpp | 13 ++++++++----- src/gl/scene/gl_portal.cpp | 13 +++++++++++-- src/gl/scene/gl_portal.h | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index dd6df82876..ef7af4d21e 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -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) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 5b6c8e27db..a22c25e2d1 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -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;inumlines;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)) diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 384a34f7d8..c7c07986be 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -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); };