2021-03-19 22:11:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "vectors.h"
|
|
|
|
#include "build.h"
|
|
|
|
|
2021-12-11 22:00:38 +00:00
|
|
|
struct Section2;
|
|
|
|
|
2021-03-19 22:11:23 +00:00
|
|
|
struct SectorGeometryPlane
|
|
|
|
{
|
|
|
|
TArray<FVector3> vertices;
|
|
|
|
TArray<FVector2> texcoords;
|
|
|
|
FVector3 normal{};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SectorGeometryData
|
|
|
|
{
|
|
|
|
SectorGeometryPlane planes[2];
|
2021-03-30 18:43:21 +00:00
|
|
|
sectortype compare[2] = {};
|
|
|
|
vec2_t poscompare[2] = {};
|
|
|
|
vec2_t poscompare2[2] = {};
|
2021-04-03 10:44:30 +00:00
|
|
|
bool degenerate = false;
|
2021-03-19 22:11:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SectorGeometry
|
|
|
|
{
|
|
|
|
TArray<SectorGeometryData> data;
|
|
|
|
|
2021-04-02 20:52:46 +00:00
|
|
|
void ValidateSector(unsigned sectnum, int plane, const FVector2& offset);
|
2021-04-03 10:44:30 +00:00
|
|
|
bool MakeVertices(unsigned sectnum, int plane, const FVector2& offset);
|
|
|
|
bool MakeVertices2(unsigned sectnum, int plane, const FVector2& offset);
|
2021-03-19 22:11:23 +00:00
|
|
|
|
|
|
|
public:
|
2021-04-02 20:52:46 +00:00
|
|
|
SectorGeometryPlane* get(unsigned sectnum, int plane, const FVector2& offset)
|
2021-03-19 22:11:23 +00:00
|
|
|
{
|
|
|
|
if (sectnum >= data.Size()) return nullptr;
|
2021-04-02 20:52:46 +00:00
|
|
|
ValidateSector(sectnum, plane, offset);
|
2021-03-19 22:11:23 +00:00
|
|
|
return &data[sectnum].planes[plane];
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSize(unsigned sectcount)
|
|
|
|
{
|
|
|
|
data.Clear(); // delete old content
|
|
|
|
data.Resize(sectcount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern SectorGeometry sectorGeometry;
|
|
|
|
|
2021-12-11 22:00:38 +00:00
|
|
|
|
|
|
|
enum GeomFlags
|
|
|
|
{
|
|
|
|
NoEarcut = 1,
|
|
|
|
NoLibtess = 2,
|
|
|
|
FloorDone = 4,
|
|
|
|
CeilingDone = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SectionGeometryData
|
|
|
|
{
|
|
|
|
SectorGeometryPlane planes[2];
|
|
|
|
sectortype compare[2] = {};
|
|
|
|
vec2_t poscompare[2] = {};
|
|
|
|
vec2_t poscompare2[2] = {};
|
|
|
|
FVector3 normal[2];
|
|
|
|
int dirty;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SectionGeometry
|
|
|
|
{
|
|
|
|
TArray<FVector2> meshVerts;
|
|
|
|
TArray<int> meshIndices;
|
|
|
|
TArray<SectionGeometryData> data;
|
|
|
|
|
|
|
|
bool ValidateSection(Section2* section, int plane, const FVector2& offset);
|
|
|
|
void MarkDirty(sectortype* sector);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
SectionGeometryPlane* get(Section2* section, int plane, const FVector2& offset)
|
|
|
|
{
|
|
|
|
if (section->index >= data.Size()) return nullptr;
|
|
|
|
ValidateSector(section->index, plane, offset);
|
|
|
|
return &data[section->index].planes[plane];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetSize(unsigned sectcount)
|
|
|
|
{
|
|
|
|
data.Clear(); // delete old content
|
|
|
|
data.Resize(sectcount);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern SectorGeometry sectorGeometry;
|
|
|
|
extern SectionGeometry sectionGeometry;
|
|
|
|
|
|
|
|
|