From eaa15f2b74bdacc62937a7d0e0967686821eca0f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 25 Nov 2016 20:19:35 +0100 Subject: [PATCH] Render other sector portal types --- src/r_poly_cull.cpp | 6 ++++++ src/r_poly_plane.cpp | 2 ++ src/r_poly_portal.cpp | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/r_poly_cull.cpp b/src/r_poly_cull.cpp index ff349690c0..04d5c3c244 100644 --- a/src/r_poly_cull.cpp +++ b/src/r_poly_cull.cpp @@ -85,6 +85,12 @@ void PolyCull::CullSubsector(subsector_t *sub) seg_t *line = &sub->firstline[i]; if ((line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) && line->backsector == nullptr) { + // Skip lines not facing viewer + DVector2 pt1 = line->v1->fPos() - ViewPos; + DVector2 pt2 = line->v2->fPos() - ViewPos; + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + continue; + int sx1, sx2; if (GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2)) { diff --git a/src/r_poly_plane.cpp b/src/r_poly_plane.cpp index 60b9d7569a..e64d085e78 100644 --- a/src/r_poly_plane.cpp +++ b/src/r_poly_plane.cpp @@ -150,6 +150,8 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin { FSectorPortal *portal = sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor); PolyDrawSectorPortal *polyportal = nullptr; + if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into + portal = nullptr; if (portal) { for (auto &p : sectorPortals) diff --git a/src/r_poly_portal.cpp b/src/r_poly_portal.cpp index 0346a9d7db..d6a67a3175 100644 --- a/src/r_poly_portal.cpp +++ b/src/r_poly_portal.cpp @@ -271,7 +271,7 @@ PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) void PolyDrawSectorPortal::Render(int portalDepth) { - if (Portal->mType != PORTS_SKYVIEWPOINT) + if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE) return; SaveGlobals(); @@ -302,10 +302,14 @@ void PolyDrawSectorPortal::Render(int portalDepth) void PolyDrawSectorPortal::RenderTranslucent(int portalDepth) { - if (Portal->mType != PORTS_SKYVIEWPOINT) + if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE) return; + + SaveGlobals(); RenderPortal.RenderTranslucent(portalDepth); + + RestoreGlobals(); } void PolyDrawSectorPortal::SaveGlobals() @@ -317,20 +321,36 @@ void PolyDrawSectorPortal::SaveGlobals() savedcamera = camera; savedsector = viewsector; - // Don't let gun flashes brighten the sky box - ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); - extralight = 0; - R_SetVisibility(sky->args[0] * 0.25f); - ViewPos = sky->InterpolatedPosition(r_TicFracF); - ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + if (Portal->mType == PORTS_SKYVIEWPOINT) + { + // Don't let gun flashes brighten the sky box + ASkyViewpoint *sky = barrier_cast(Portal->mSkybox); + extralight = 0; + R_SetVisibility(sky->args[0] * 0.25f); + ViewPos = sky->InterpolatedPosition(r_TicFracF); + ViewAngle = savedangle + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * r_TicFracF); + } + else //if (Portal->mType == PORTS_STACKEDSECTORTHING || Portal->mType == PORTS_PORTAL || Portal->mType == PORTS_LINKEDPORTAL) + { + //extralight = pl->extralight; + //R_SetVisibility(pl->visibility); + ViewPos.X += Portal->mDisplacement.X; + ViewPos.Y += Portal->mDisplacement.Y; + } camera = nullptr; viewsector = Portal->mDestination; R_SetViewAngle(); + + Portal->mFlags |= PORTSF_INSKYBOX; + if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags |= PORTSF_INSKYBOX; } void PolyDrawSectorPortal::RestoreGlobals() { + Portal->mFlags &= ~PORTSF_INSKYBOX; + if (Portal->mPartner > 0) sectorPortals[Portal->mPartner].mFlags &= ~PORTSF_INSKYBOX; + camera = savedcamera; viewsector = savedsector; ViewPos = savedpos;