mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 21:41:30 +00:00
Add support for multiple portals
This commit is contained in:
parent
3de7f1a387
commit
93af906a1d
5 changed files with 24 additions and 12 deletions
|
@ -44,7 +44,7 @@ void RenderPolyScene::Render()
|
|||
ClearBuffers();
|
||||
SetSceneViewport();
|
||||
SetupPerspectiveMatrix();
|
||||
MainPortal.SetViewpoint(WorldToClip, 0);
|
||||
MainPortal.SetViewpoint(WorldToClip, GetNextStencilValue());
|
||||
MainPortal.Render();
|
||||
Skydome.Render(WorldToClip);
|
||||
MainPortal.RenderTranslucent();
|
||||
|
@ -63,6 +63,7 @@ void RenderPolyScene::ClearBuffers()
|
|||
PolyVertexBuffer::Clear();
|
||||
PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0);
|
||||
PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight());
|
||||
NextStencilValue = 0;
|
||||
}
|
||||
|
||||
void RenderPolyScene::SetSceneViewport()
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
void RenderRemainingPlayerSprites();
|
||||
|
||||
static RenderPolyScene *Instance();
|
||||
|
||||
uint32_t GetNextStencilValue() { uint32_t value = NextStencilValue; NextStencilValue += 2; return value; }
|
||||
|
||||
private:
|
||||
void ClearBuffers();
|
||||
|
@ -51,4 +53,5 @@ private:
|
|||
RenderPolyPortal MainPortal;
|
||||
PolySkyDome Skydome;
|
||||
RenderPolyPlayerSprites PlayerSprites;
|
||||
uint32_t NextStencilValue = 0;
|
||||
};
|
||||
|
|
|
@ -264,7 +264,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
|
|||
}
|
||||
else
|
||||
{
|
||||
args.stencilwritevalue = 252;
|
||||
args.stencilwritevalue = polyportal->StencilValue;
|
||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
||||
polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth });
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
|
|||
{
|
||||
if (portal)
|
||||
{
|
||||
args.stencilwritevalue = 252;
|
||||
args.stencilwritevalue = polyportal->StencilValue;
|
||||
polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth });
|
||||
}
|
||||
else
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "sbar.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "r_poly_portal.h"
|
||||
#include "r_poly.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
|
||||
CVAR(Bool, r_debug_cull, 0, 0)
|
||||
|
@ -192,14 +193,15 @@ void RenderPolyPortal::RenderTranslucent()
|
|||
{
|
||||
for (auto it = SectorPortals.rbegin(); it != SectorPortals.rend(); ++it)
|
||||
{
|
||||
(*it)->RenderTranslucent();
|
||||
auto &portal = *it;
|
||||
portal->RenderTranslucent();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.objectToClip = &WorldToClip;
|
||||
args.mode = TriangleDrawMode::Fan;
|
||||
args.stenciltestvalue = 253;
|
||||
args.stencilwritevalue = 1;
|
||||
for (const auto &verts : (*it)->Shape)
|
||||
args.stenciltestvalue = portal->StencilValue + 1;
|
||||
args.stencilwritevalue = StencilValue;
|
||||
for (const auto &verts : portal->Shape)
|
||||
{
|
||||
args.vinput = verts.Vertices;
|
||||
args.vcount = verts.Count;
|
||||
|
@ -211,14 +213,15 @@ void RenderPolyPortal::RenderTranslucent()
|
|||
|
||||
for (auto it = LinePortals.rbegin(); it != LinePortals.rend(); ++it)
|
||||
{
|
||||
(*it)->RenderTranslucent();
|
||||
auto &portal = *it;
|
||||
portal->RenderTranslucent();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.objectToClip = &WorldToClip;
|
||||
args.mode = TriangleDrawMode::Fan;
|
||||
args.stenciltestvalue = 253;
|
||||
args.stencilwritevalue = 1;
|
||||
for (const auto &verts : (*it)->Shape)
|
||||
args.stenciltestvalue = portal->StencilValue + 1;
|
||||
args.stencilwritevalue = StencilValue;
|
||||
for (const auto &verts : portal->Shape)
|
||||
{
|
||||
args.vinput = verts.Vertices;
|
||||
args.vcount = verts.Count;
|
||||
|
@ -257,6 +260,7 @@ void RenderPolyPortal::RenderTranslucent()
|
|||
|
||||
PolyDrawSectorPortal::PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling) : Portal(portal), Ceiling(ceiling)
|
||||
{
|
||||
StencilValue = RenderPolyScene::Instance()->GetNextStencilValue();
|
||||
}
|
||||
|
||||
void PolyDrawSectorPortal::Render()
|
||||
|
@ -289,7 +293,7 @@ void PolyDrawSectorPortal::Render()
|
|||
TriMatrix::translate((float)-ViewPos.X, (float)-ViewPos.Y, (float)-ViewPos.Z);
|
||||
TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView;
|
||||
|
||||
RenderPortal.SetViewpoint(worldToClip, 252);
|
||||
RenderPortal.SetViewpoint(worldToClip, StencilValue);
|
||||
RenderPortal.Render();
|
||||
|
||||
RestoreGlobals();
|
||||
|
@ -349,6 +353,8 @@ void PolyDrawSectorPortal::RestoreGlobals()
|
|||
PolyDrawLinePortal::PolyDrawLinePortal(line_t *src, line_t *dest, bool mirror) : Src(src), Dest(dest)
|
||||
{
|
||||
// To do: do what R_EnterPortal and PortalDrawseg does
|
||||
|
||||
StencilValue = RenderPolyScene::Instance()->GetNextStencilValue();
|
||||
}
|
||||
|
||||
void PolyDrawLinePortal::Render()
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
void RenderTranslucent();
|
||||
|
||||
FSectorPortal *Portal;
|
||||
uint32_t StencilValue = 0;
|
||||
std::vector<PolyPortalVertexRange> Shape;
|
||||
|
||||
private:
|
||||
|
@ -153,6 +154,7 @@ public:
|
|||
void Render();
|
||||
void RenderTranslucent();
|
||||
|
||||
uint32_t StencilValue = 0;
|
||||
std::vector<PolyPortalVertexRange> Shape;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue