mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 13:01:48 +00:00
Only render line portals once
This commit is contained in:
parent
40b68bfea0
commit
a1bb6e6b23
3 changed files with 35 additions and 11 deletions
|
@ -117,6 +117,8 @@ void PolyRenderer::ClearBuffers()
|
|||
PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0);
|
||||
PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight());
|
||||
NextStencilValue = 0;
|
||||
SeenLinePortals.clear();
|
||||
SeenMirrors.clear();
|
||||
}
|
||||
|
||||
void PolyRenderer::SetSceneViewport()
|
||||
|
@ -170,3 +172,13 @@ void PolyRenderer::SetupPerspectiveMatrix()
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ public:
|
|||
|
||||
uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; }
|
||||
|
||||
bool InsertSeenLinePortal(FLinePortal *portal);
|
||||
bool InsertSeenMirror(line_t *mirrorLine);
|
||||
|
||||
private:
|
||||
void ClearBuffers();
|
||||
void SetSceneViewport();
|
||||
|
@ -57,4 +60,7 @@ private:
|
|||
PolySkyDome Skydome;
|
||||
RenderPolyPlayerSprites PlayerSprites;
|
||||
uint32_t NextStencilValue = 0;
|
||||
|
||||
std::set<FLinePortal *> SeenLinePortals;
|
||||
std::set<line_t *> SeenMirrors;
|
||||
};
|
||||
|
|
|
@ -40,24 +40,30 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP
|
|||
PolyDrawLinePortal *polyportal = nullptr;
|
||||
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));
|
||||
polyportal = linePortals.back().get();
|
||||
if (PolyRenderer::Instance()->InsertSeenMirror(line->linedef))
|
||||
{
|
||||
linePortals.push_back(std::make_unique<PolyDrawLinePortal>(line->linedef));
|
||||
polyportal = linePortals.back().get();
|
||||
}
|
||||
}
|
||||
else if (line->linedef && line->linedef->isVisualPortal())
|
||||
{
|
||||
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();
|
||||
break;
|
||||
if (p->Portal == portal) // To do: what other criterias do we need to check for?
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue