mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
95 lines
No EOL
2 KiB
C++
95 lines
No EOL
2 KiB
C++
#pragma once
|
|
|
|
#include "tarray.h"
|
|
#include "vectors.h"
|
|
#include "build.h"
|
|
|
|
struct Section2;
|
|
|
|
struct SectorGeometryPlane
|
|
{
|
|
TArray<FVector3> vertices;
|
|
TArray<FVector2> texcoords;
|
|
FVector3 normal{};
|
|
};
|
|
|
|
struct SectorGeometryData
|
|
{
|
|
SectorGeometryPlane planes[2];
|
|
sectortype compare[2] = {};
|
|
vec2_t poscompare[2] = {};
|
|
vec2_t poscompare2[2] = {};
|
|
bool degenerate = false;
|
|
};
|
|
|
|
class SectorGeometry
|
|
{
|
|
TArray<SectorGeometryData> data;
|
|
|
|
void ValidateSector(unsigned sectnum, int plane, const FVector2& offset);
|
|
bool MakeVertices(unsigned sectnum, int plane, const FVector2& offset);
|
|
bool MakeVertices2(unsigned sectnum, int plane, const FVector2& offset);
|
|
|
|
public:
|
|
SectorGeometryPlane* get(unsigned sectnum, int plane, const FVector2& offset)
|
|
{
|
|
if (sectnum >= data.Size()) return nullptr;
|
|
ValidateSector(sectnum, plane, offset);
|
|
return &data[sectnum].planes[plane];
|
|
}
|
|
|
|
void SetSize(unsigned sectcount)
|
|
{
|
|
data.Clear(); // delete old content
|
|
data.Resize(sectcount);
|
|
}
|
|
};
|
|
|
|
extern SectorGeometry sectorGeometry;
|
|
|
|
|
|
enum GeomFlags
|
|
{
|
|
NoEarcut = 1,
|
|
NoLibtess = 2,
|
|
FloorDone = 4,
|
|
CeilingDone = 8,
|
|
};
|
|
|
|
using SectionGeometryPlane = SectorGeometryPlane;
|
|
|
|
struct SectionGeometryData
|
|
{
|
|
SectorGeometryPlane planes[2];
|
|
TArray<FVector2> meshVertices; // flat vertices. Stored separately so that plane changes won't require completely new triangulation.
|
|
TArray<int> meshIndices;
|
|
sectortype compare[2] = {};
|
|
vec2_t poscompare[2] = {};
|
|
vec2_t poscompare2[2] = {};
|
|
FVector3 normal[2];
|
|
};
|
|
|
|
class SectionGeometry
|
|
{
|
|
TArray<SectionGeometryData> data;
|
|
|
|
bool ValidateSection(Section2* section, int plane);
|
|
void MarkDirty(sectortype* sector);
|
|
bool CreateMesh(Section2* section);
|
|
void CreatePlaneMesh(Section2* section, int plane, const FVector2& offset);
|
|
|
|
|
|
public:
|
|
SectionGeometryPlane* get(Section2* section, int plane, const FVector2& offset, TArray<int>** pIndices);
|
|
|
|
void SetSize(unsigned sectcount)
|
|
{
|
|
data.Clear(); // delete old content
|
|
data.Resize(sectcount);
|
|
}
|
|
};
|
|
|
|
extern SectorGeometry sectorGeometry;
|
|
extern SectionGeometry sectionGeometry;
|
|
|
|
|