Skip to content

Commit

Permalink
- slightly improve sector portal handling in softpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Apr 22, 2018
1 parent 6e77cb4 commit 2aee68d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/polyrenderer/scene/poly_cull.cpp
Expand Up @@ -28,7 +28,7 @@
#include "poly_cull.h"
#include "polyrenderer/poly_renderer.h"

void PolyCull::CullScene(const PolyClipPlane &portalClipPlane)
void PolyCull::CullScene(const PolyClipPlane &portalClipPlane, sector_t *portalEnter)
{
ClearSolidSegments();
MarkViewFrustum();
Expand All @@ -49,6 +49,7 @@ void PolyCull::CullScene(const PolyClipPlane &portalClipPlane)
PvsLineVisible.resize(level.segs.Size());

PortalClipPlane = portalClipPlane;
PortalEnter = portalEnter;

// Cull front to back
FirstSkyHeight = true;
Expand Down Expand Up @@ -87,6 +88,14 @@ void PolyCull::CullNode(void *node)

void PolyCull::CullSubsector(subsector_t *sub)
{
// Ignore everything in front of the portal
if (PortalEnter)
{
if (sub->sector != PortalEnter)
return;
PortalEnter = nullptr;
}

// Check if subsector is clipped entirely by the portal clip plane
bool visible = false;
for (uint32_t i = 0; i < sub->numlines; i++)
Expand Down
3 changes: 2 additions & 1 deletion src/polyrenderer/scene/poly_cull.h
Expand Up @@ -29,7 +29,7 @@
class PolyCull
{
public:
void CullScene(const PolyClipPlane &portalClipPlane);
void CullScene(const PolyClipPlane &portalClipPlane, sector_t *portalEnter);

bool IsLineSegVisible(uint32_t subsectorDepth, uint32_t lineIndex)
{
Expand Down Expand Up @@ -78,6 +78,7 @@ class PolyCull
bool FirstSkyHeight = true;

PolyClipPlane PortalClipPlane;
sector_t *PortalEnter = nullptr;

std::vector<uint32_t> PvsLineStart;
std::vector<bool> PvsLineVisible;
Expand Down
1 change: 1 addition & 0 deletions src/polyrenderer/scene/poly_portal.cpp
Expand Up @@ -50,6 +50,7 @@ void PolyDrawSectorPortal::Render(int portalDepth)
PortalViewpoint.StencilValue = StencilValue;
PortalViewpoint.PortalPlane = PolyClipPlane(0.0f, 0.0f, 0.0f, 1.0f);
PortalViewpoint.PortalDepth = portalDepth;
PortalViewpoint.PortalEnterSector = Portal->mDestination;

PolyRenderer::Instance()->Scene.Render(&PortalViewpoint);

Expand Down
2 changes: 1 addition & 1 deletion src/polyrenderer/scene/poly_scene.cpp
Expand Up @@ -59,7 +59,7 @@ void RenderPolyScene::Render(PolyPortalViewpoint *viewpoint)
CurrentViewpoint->LinePortalsStart = thread->LinePortals.size();

PolyCullCycles.Clock();
Cull.CullScene(CurrentViewpoint->PortalPlane);
Cull.CullScene(CurrentViewpoint->PortalPlane, CurrentViewpoint->PortalEnterSector);
PolyCullCycles.Unclock();

RenderSectors();
Expand Down
1 change: 1 addition & 0 deletions src/polyrenderer/scene/poly_scene.h
Expand Up @@ -66,6 +66,7 @@ class PolyPortalViewpoint
bool Mirror = false;

line_t *PortalEnterLine = nullptr;
sector_t *PortalEnterSector = nullptr;

size_t ObjectsStart = 0;
size_t ObjectsEnd = 0;
Expand Down

0 comments on commit 2aee68d

Please sign in to comment.