2021-03-19 22:11:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "vectors.h"
|
|
|
|
#include "build.h"
|
|
|
|
|
2021-12-15 11:01:14 +00:00
|
|
|
struct Section;
|
2021-12-11 22:00:38 +00:00
|
|
|
|
2021-03-19 22:11:23 +00:00
|
|
|
struct SectorGeometryPlane
|
|
|
|
{
|
|
|
|
TArray<FVector3> vertices;
|
|
|
|
TArray<FVector2> texcoords;
|
|
|
|
FVector3 normal{};
|
|
|
|
};
|
|
|
|
|
2021-12-11 22:00:38 +00:00
|
|
|
enum GeomFlags
|
|
|
|
{
|
|
|
|
NoEarcut = 1,
|
|
|
|
NoLibtess = 2,
|
|
|
|
FloorDone = 4,
|
|
|
|
CeilingDone = 8,
|
|
|
|
};
|
|
|
|
|
2021-12-12 17:07:19 +00:00
|
|
|
using SectionGeometryPlane = SectorGeometryPlane;
|
|
|
|
|
2021-12-27 22:14:16 +00:00
|
|
|
struct sectortypelight
|
|
|
|
{
|
|
|
|
float ceilingxpan_;
|
|
|
|
float ceilingypan_;
|
|
|
|
float floorxpan_;
|
|
|
|
float floorypan_;
|
|
|
|
|
|
|
|
ESectorFlags ceilingstat;
|
|
|
|
ESectorFlags floorstat;
|
|
|
|
int16_t ceilingpicnum;
|
|
|
|
int16_t ceilingheinum;
|
|
|
|
int16_t floorpicnum;
|
|
|
|
int16_t floorheinum;
|
|
|
|
|
|
|
|
void copy(sectortype* sec)
|
|
|
|
{
|
|
|
|
ceilingxpan_ = sec->ceilingxpan_;
|
|
|
|
ceilingypan_ = sec->ceilingypan_;
|
|
|
|
floorxpan_ = sec->floorxpan_;
|
|
|
|
floorypan_ = sec->floorypan_;
|
|
|
|
ceilingstat = sec->ceilingstat;
|
|
|
|
floorstat = sec->floorstat;
|
|
|
|
ceilingheinum = sec->ceilingheinum;
|
|
|
|
floorheinum = sec->floorheinum;
|
|
|
|
ceilingpicnum = sec->ceilingpicnum;
|
|
|
|
floorpicnum = sec->floorpicnum;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-11 22:00:38 +00:00
|
|
|
struct SectionGeometryData
|
|
|
|
{
|
|
|
|
SectorGeometryPlane planes[2];
|
2021-12-12 17:07:19 +00:00
|
|
|
TArray<FVector2> meshVertices; // flat vertices. Stored separately so that plane changes won't require completely new triangulation.
|
|
|
|
TArray<int> meshIndices;
|
2021-12-27 22:14:16 +00:00
|
|
|
sectortypelight compare[2] = {};
|
2022-02-13 09:06:41 +00:00
|
|
|
DVector2 poscompare[2] = {};
|
|
|
|
DVector2 poscompare2[2] = {};
|
2021-12-11 22:00:38 +00:00
|
|
|
FVector3 normal[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
class SectionGeometry
|
|
|
|
{
|
|
|
|
TArray<SectionGeometryData> data;
|
|
|
|
|
2021-12-15 11:01:14 +00:00
|
|
|
bool ValidateSection(Section* section, int plane);
|
2021-12-11 22:00:38 +00:00
|
|
|
void MarkDirty(sectortype* sector);
|
2021-12-15 11:01:14 +00:00
|
|
|
bool CreateMesh(Section* section);
|
|
|
|
void CreatePlaneMesh(Section* section, int plane, const FVector2& offset);
|
2021-12-12 17:07:19 +00:00
|
|
|
|
2021-12-11 22:00:38 +00:00
|
|
|
|
|
|
|
public:
|
2021-12-15 11:01:14 +00:00
|
|
|
SectionGeometryPlane* get(Section* section, int plane, const FVector2& offset, TArray<int>** pIndices);
|
2021-12-11 22:00:38 +00:00
|
|
|
|
|
|
|
void SetSize(unsigned sectcount)
|
|
|
|
{
|
|
|
|
data.Clear(); // delete old content
|
|
|
|
data.Resize(sectcount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern SectionGeometry sectionGeometry;
|
|
|
|
|
|
|
|
|