gzdoom-gles/src/swrenderer/scene/r_3dfloors.h

109 lines
2.1 KiB
C
Raw Normal View History

2017-01-04 17:54:14 +00:00
#pragma once
#include "p_3dfloors.h"
#include <unordered_map>
EXTERN_CVAR(Int, r_3dfloors);
namespace swrenderer
{
class RenderThread;
class FakeFloorClip;
2017-01-04 17:54:14 +00:00
struct HeightLevel
{
double height;
struct HeightLevel *prev;
struct HeightLevel *next;
};
2017-01-04 17:54:14 +00:00
struct HeightStack
{
HeightLevel *height_top;
HeightLevel *height_cur;
int height_max;
};
2017-01-04 17:54:14 +00:00
struct ClipStack
{
short floorclip[MAXWIDTH];
short ceilingclip[MAXWIDTH];
FakeFloorClip *ffloor;
2017-01-04 17:54:14 +00:00
ClipStack *next;
};
// BSP stage
struct Fake3DOpaque
2017-01-04 17:54:14 +00:00
{
enum Type
{
Normal, // Not a 3D floor
FakeFloor, // fake floor, mark seg as FAKE
FakeCeiling, // fake ceiling, mark seg as FAKE
FakeBack // RenderLine with fake backsector, mark seg as FAKE
};
Type type = Normal;
bool clipBotFront = false; // use front sector clipping info (bottom)
bool clipTopFront = false; // use front sector clipping info (top)
Fake3DOpaque() { }
Fake3DOpaque(Type type) : type(type) { }
2017-01-04 17:54:14 +00:00
};
// Drawing stage
struct Fake3DTranslucent
2017-01-04 17:54:14 +00:00
{
bool clipBottom = false;
bool clipTop = false;
bool down2Up = false; // rendering from down to up (floors)
double sclipBottom = 0;
double sclipTop = 0;
2017-01-04 17:54:14 +00:00
};
class FakeFloorClip
{
public:
FakeFloorClip(F3DFloor *fakeFloor) : fakeFloor(fakeFloor) { }
F3DFloor *fakeFloor = nullptr;
short *floorclip = nullptr;
short *ceilingclip = nullptr;
int validcount = -1;
};
2017-01-04 17:54:14 +00:00
class Clip3DFloors
{
public:
Clip3DFloors(RenderThread *thread);
2017-01-04 17:54:14 +00:00
void Cleanup();
2017-01-04 17:54:14 +00:00
void DeleteHeights();
void AddHeight(secplane_t *add, sector_t *sec);
void NewClip();
void ResetClip();
void EnterSkybox();
void LeaveSkybox();
void SetFakeFloor(F3DFloor *fakeFloor);
2017-02-09 04:42:15 +00:00
void ClearFakeFloors() { FakeFloors.clear(); }
RenderThread *Thread = nullptr;
FakeFloorClip *fakeFloor = nullptr;
2017-01-04 17:54:14 +00:00
bool fakeActive = false;
HeightLevel *height_top = nullptr;
HeightLevel *height_cur = nullptr;
int CurrentSkybox = 0;
2017-01-04 17:54:14 +00:00
private:
int height_max = -1;
TArray<HeightStack> toplist;
ClipStack *clip_top = nullptr;
ClipStack *clip_cur = nullptr;
std::unordered_map<F3DFloor *, FakeFloorClip *> FakeFloors;
2017-01-04 17:54:14 +00:00
};
}