Only render line portals once

This commit is contained in:
Magnus Norddahl 2016-12-08 10:29:52 +01:00
parent 40b68bfea0
commit a1bb6e6b23
3 changed files with 35 additions and 11 deletions

View File

@ -117,6 +117,8 @@ void PolyRenderer::ClearBuffers()
PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0);
PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight());
NextStencilValue = 0; NextStencilValue = 0;
SeenLinePortals.clear();
SeenMirrors.clear();
} }
void PolyRenderer::SetSceneViewport() void PolyRenderer::SetSceneViewport()
@ -170,3 +172,13 @@ void PolyRenderer::SetupPerspectiveMatrix()
WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; WorldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView;
} }
bool PolyRenderer::InsertSeenLinePortal(FLinePortal *portal)
{
return SeenLinePortals.insert(portal).second;
}
bool PolyRenderer::InsertSeenMirror(line_t *mirrorLine)
{
return SeenMirrors.insert(mirrorLine).second;
}

View File

@ -47,6 +47,9 @@ public:
uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; } uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; }
bool InsertSeenLinePortal(FLinePortal *portal);
bool InsertSeenMirror(line_t *mirrorLine);
private: private:
void ClearBuffers(); void ClearBuffers();
void SetSceneViewport(); void SetSceneViewport();
@ -57,4 +60,7 @@ private:
PolySkyDome Skydome; PolySkyDome Skydome;
RenderPolyPlayerSprites PlayerSprites; RenderPolyPlayerSprites PlayerSprites;
uint32_t NextStencilValue = 0; uint32_t NextStencilValue = 0;
std::set<FLinePortal *> SeenLinePortals;
std::set<line_t *> SeenMirrors;
}; };

View File

@ -40,24 +40,30 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP
PolyDrawLinePortal *polyportal = nullptr; PolyDrawLinePortal *polyportal = nullptr;
if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors))
{ {
linePortals.push_back(std::make_unique<PolyDrawLinePortal>(line->linedef)); if (PolyRenderer::Instance()->InsertSeenMirror(line->linedef))
polyportal = linePortals.back().get(); {
linePortals.push_back(std::make_unique<PolyDrawLinePortal>(line->linedef));
polyportal = linePortals.back().get();
}
} }
else if (line->linedef && line->linedef->isVisualPortal()) else if (line->linedef && line->linedef->isVisualPortal())
{ {
FLinePortal *portal = line->linedef->getPortal(); FLinePortal *portal = line->linedef->getPortal();
for (auto &p : linePortals) if (PolyRenderer::Instance()->InsertSeenLinePortal(portal))
{ {
if (p->Portal == portal) // To do: what other criterias do we need to check for? for (auto &p : linePortals)
{ {
polyportal = p.get(); if (p->Portal == portal) // To do: what other criterias do we need to check for?
break; {
polyportal = p.get();
break;
}
}
if (!polyportal)
{
linePortals.push_back(std::make_unique<PolyDrawLinePortal>(portal));
polyportal = linePortals.back().get();
} }
}
if (!polyportal)
{
linePortals.push_back(std::make_unique<PolyDrawLinePortal>(portal));
polyportal = linePortals.back().get();
} }
} }