mirror of
https://github.com/ZDoom/Raze.git
synced 2024-12-02 09:02:18 +00:00
f7dd0ec4a2
As it turned out, the triangulator only works fine for regular polygons, but creates incomplete meshes for sectors with multiple sections or some degenerate areas, which are quite common with swinging doors. The node builder is more costly and creates wall splits, of course, but it does not create broken output for degenerate sectors so it's a good fallback.
48 lines
No EOL
1,012 B
C++
48 lines
No EOL
1,012 B
C++
#pragma once
|
|
|
|
#include "tarray.h"
|
|
#include "vectors.h"
|
|
#include "build.h"
|
|
|
|
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;
|
|
|
|
|