gzdoom/src/r_poly_portal.h

91 lines
2.3 KiB
C
Raw Normal View History

/*
** Polygon Doom software renderer
** Copyright (c) 2016 Magnus Norddahl
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
*/
#pragma once
#include "r_poly_scene.h"
2016-11-24 22:08:36 +00:00
2016-11-25 00:08:25 +00:00
struct PolyPortalVertexRange
{
PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw, uint32_t subsectorDepth) : Vertices(vertices), Count(count), Ccw(ccw), SubsectorDepth(subsectorDepth) { }
2016-11-25 00:08:25 +00:00
const TriVertex *Vertices;
int Count;
bool Ccw;
uint32_t SubsectorDepth;
2016-11-25 00:08:25 +00:00
};
2016-11-24 22:08:36 +00:00
class PolyDrawSectorPortal
{
public:
PolyDrawSectorPortal(FSectorPortal *portal, bool ceiling);
2016-11-25 17:15:48 +00:00
void Render(int portalDepth);
void RenderTranslucent(int portalDepth);
2016-11-25 00:08:25 +00:00
2016-11-25 22:44:55 +00:00
FSectorPortal *Portal = nullptr;
2016-11-25 16:14:26 +00:00
uint32_t StencilValue = 0;
2016-11-25 00:08:25 +00:00
std::vector<PolyPortalVertexRange> Shape;
2016-11-24 22:08:36 +00:00
private:
2016-11-25 00:08:25 +00:00
void SaveGlobals();
void RestoreGlobals();
2016-11-24 22:08:36 +00:00
bool Ceiling;
RenderPolyScene RenderPortal;
2016-11-25 00:08:25 +00:00
int savedextralight;
DVector3 savedpos;
DAngle savedangle;
double savedvisibility;
AActor *savedcamera;
sector_t *savedsector;
2016-11-24 22:08:36 +00:00
};
class PolyDrawLinePortal
{
public:
2016-11-25 22:44:55 +00:00
PolyDrawLinePortal(FLinePortal *portal);
PolyDrawLinePortal(line_t *mirror);
2016-11-24 22:08:36 +00:00
2016-11-25 17:15:48 +00:00
void Render(int portalDepth);
void RenderTranslucent(int portalDepth);
2016-11-24 22:08:36 +00:00
2016-11-25 22:44:55 +00:00
FLinePortal *Portal = nullptr;
line_t *Mirror = nullptr;
2016-11-25 16:14:26 +00:00
uint32_t StencilValue = 0;
2016-11-25 00:08:25 +00:00
std::vector<PolyPortalVertexRange> Shape;
2016-11-24 22:08:36 +00:00
private:
2016-11-25 22:44:55 +00:00
void SaveGlobals();
void RestoreGlobals();
RenderPolyScene RenderPortal;
2016-11-25 22:44:55 +00:00
int savedextralight;
DVector3 savedpos;
DAngle savedangle;
AActor *savedcamera;
sector_t *savedsector;
2016-12-07 21:26:18 +00:00
bool savedinvisibility;
2016-11-25 22:44:55 +00:00
DVector3 savedViewPath[2];
};