mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
After this any old mesh has become invalid and needs to be rebuilt.
- use only one Section type.
This commit is contained in:
parent
8e01d559e8
commit
37e49ed775
8 changed files with 48 additions and 51 deletions
|
@ -46,6 +46,7 @@
|
|||
#include "nodebuilder/nodebuild.h"
|
||||
|
||||
|
||||
FMemArena tempsectionArena(102400);
|
||||
TArray<SectionLine> sectionLines;
|
||||
TArray<Section> Sections;
|
||||
TArray<TArray<int>> sectionspersector; // reverse map, mainly for the automap
|
||||
|
@ -59,13 +60,15 @@ TArray<int> splits;
|
|||
void hw_BuildSections()
|
||||
{
|
||||
Sections.Resize(numsectors);
|
||||
memset(Sections.Data(), 0, numsectors * sizeof(Section));
|
||||
sectionspersector.Resize(numsectors);
|
||||
sectionLines.Resize(numwalls * 5 / 4); // cannot reallocate, unfortunately.
|
||||
numsectionlines = numwalls;
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
Sections[i].sector = i;
|
||||
Sections[i].lines.Resize(sector[i].wallnum);
|
||||
auto lines = (int*)tempsectionArena.Alloc(sector[i].wallnum * sizeof(int));
|
||||
Sections[i].lines.Set(lines, sector[i].wallnum);
|
||||
for (int j = 0; j < sector[i].wallnum; j++) Sections[i].lines[j] = sector[i].wallptr + j;
|
||||
sectionspersector[i].Resize(1);
|
||||
sectionspersector[i][0] = i;
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
#include "build.h"
|
||||
|
||||
enum ESEctionFlag
|
||||
{
|
||||
Unclosed = 1, // at least one unclosed loop
|
||||
Dumped = 2, // builder was unable to properly construct, so content may not be usable for triangulator.
|
||||
BadWinding = 4,
|
||||
};
|
||||
|
||||
|
||||
struct SectionLine
|
||||
{
|
||||
int section;
|
||||
|
@ -25,11 +33,21 @@ inline SectionLine* SectionLine::partnerLine() const
|
|||
return partner == -1 ? nullptr : §ionLines[partner];
|
||||
}
|
||||
|
||||
struct Section2Loop
|
||||
{
|
||||
TArrayView<int> walls;
|
||||
};
|
||||
|
||||
struct Section
|
||||
{
|
||||
uint8_t flags;
|
||||
uint8_t dirty;
|
||||
uint8_t geomflags;
|
||||
unsigned index;
|
||||
int sector;
|
||||
// this is the whole point of sections - instead of just having a start index and count, we have an explicit list of lines that's a lot easier to change when needed.
|
||||
TArray<int> lines;
|
||||
// this uses a memory arena for storage, so use TArrayView instead of TArray
|
||||
TArrayView<int> lines;
|
||||
TArrayView<Section2Loop> loops;
|
||||
};
|
||||
|
||||
extern TArray<Section> Sections;
|
||||
|
|
|
@ -43,12 +43,13 @@
|
|||
#include "memarena.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
FMemArena sectionArena(102400);
|
||||
|
||||
CVAR(Bool, hw_sectiondebug, false, 0)
|
||||
TMap<int, bool> bugged;
|
||||
|
||||
static FMemArena sectionArena(102400);
|
||||
TArray<Section2*> sections2;
|
||||
TArrayView<TArrayView<Section2*>> sections2PerSector;
|
||||
TArray<Section*> sections2;
|
||||
TArrayView<TArrayView<Section*>> sections2PerSector;
|
||||
|
||||
struct loopcollect
|
||||
{
|
||||
|
@ -548,9 +549,9 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
|
|||
auto& builder = builders[i];
|
||||
count += builder.sections.Size();
|
||||
|
||||
size = sizeof(Section2*) * builder.sections.Size();
|
||||
size = sizeof(Section*) * builder.sections.Size();
|
||||
data = sectionArena.Calloc(size);
|
||||
sections2PerSector[i].Set(static_cast<Section2** >(data), builder.sections.Size()); // although this may need reallocation, it is too small to warrant single allocations for each sector.
|
||||
sections2PerSector[i].Set(static_cast<Section** >(data), builder.sections.Size()); // although this may need reallocation, it is too small to warrant single allocations for each sector.
|
||||
}
|
||||
sections2.Resize(count); // this we cannot put into the arena because its size may change.
|
||||
memset(sections2.Data(), 0, count * sizeof(*sections2.Data()));
|
||||
|
@ -563,7 +564,7 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
|
|||
auto& builder = builders[i];
|
||||
for (unsigned j = 0; j < builder.sections.Size(); j++)
|
||||
{
|
||||
auto section = (Section2*)sectionArena.Calloc(sizeof(Section2));
|
||||
auto section = (Section*)sectionArena.Calloc(sizeof(Section));
|
||||
auto& srcsect = builder.sections[j];
|
||||
sections2[cursection] = section;
|
||||
sections2PerSector[i][j] = section;
|
||||
|
@ -661,7 +662,7 @@ void hw_CreateSections2()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
Outline BuildOutline(Section2* section)
|
||||
Outline BuildOutline(Section* section)
|
||||
{
|
||||
Outline output(section->loops.Size(), true);
|
||||
for (unsigned i = 0; i < section->loops.Size(); i++)
|
||||
|
|
|
@ -1,35 +1,10 @@
|
|||
#include "hw_sections.h"
|
||||
struct Section2;
|
||||
|
||||
enum ESEctionFlag
|
||||
{
|
||||
Unclosed = 1, // at least one unclosed loop
|
||||
Dumped = 2, // builder was unable to properly construct, so content may not be usable for triangulator.
|
||||
BadWinding = 4,
|
||||
};
|
||||
|
||||
struct Section2Loop
|
||||
{
|
||||
TArrayView<int> walls;
|
||||
};
|
||||
|
||||
struct Section2
|
||||
{
|
||||
uint8_t flags;
|
||||
uint8_t dirty;
|
||||
uint8_t geomflags;
|
||||
unsigned index;
|
||||
int sector;
|
||||
// this uses a memory arena for storage, so use TArrayView instead of TArray
|
||||
TArrayView<int> lines;
|
||||
TArrayView<Section2Loop> loops;
|
||||
};
|
||||
|
||||
extern TArray<Section2*> sections2;
|
||||
extern TArrayView<TArrayView<Section2*>> sections2PerSector;
|
||||
extern TArray<Section*> sections2;
|
||||
extern TArrayView<TArrayView<Section*>> sections2PerSector;
|
||||
|
||||
void hw_CreateSections2();
|
||||
using Outline = TArray<TArray<vec2_t>>;
|
||||
using Point = std::pair<float, float>;
|
||||
using FOutline = std::vector<std::vector<Point>> ; // Data type was chosen so it can be passed directly into Earcut.
|
||||
Outline BuildOutline(Section2* section);
|
||||
Outline BuildOutline(Section* section);
|
||||
|
|
|
@ -31,7 +31,7 @@ class VSMatrix;
|
|||
struct FSpriteModelFrame;
|
||||
class FRenderState;
|
||||
struct voxmodel_t;
|
||||
struct Section2;
|
||||
struct Section;
|
||||
|
||||
struct HWSectorPlane
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ class HWFlat
|
|||
{
|
||||
public:
|
||||
int oldsection;
|
||||
Section2* section;
|
||||
Section* section;
|
||||
sectortype * sec;
|
||||
tspritetype* Sprite; // for flat sprites.
|
||||
FGameTexture *texture;
|
||||
|
@ -281,7 +281,7 @@ public:
|
|||
//void SetupLights(HWDrawInfo *di, FLightNode *head, FDynLightData &lightdata, int portalgroup);
|
||||
|
||||
void PutFlat(HWDrawInfo* di, int whichplane);
|
||||
void ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section2* sectionp, int sectionnum, int which = 7 /*SSRF_RENDERALL*/); // cannot use constant due to circular dependencies.
|
||||
void ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section* sectionp, int sectionnum, int which = 7 /*SSRF_RENDERALL*/); // cannot use constant due to circular dependencies.
|
||||
void ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype* sector);
|
||||
|
||||
void DrawSubsectors(HWDrawInfo *di, FRenderState &state);
|
||||
|
|
|
@ -261,7 +261,7 @@ void HWFlat::PutFlat(HWDrawInfo *di, int whichplane)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section2* sectionp, int section_, int which)
|
||||
void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section* sectionp, int section_, int which)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (sectnum(sec) == gl_breaksec)
|
||||
|
|
|
@ -424,7 +424,7 @@ ETriangulateResult TriangulateOutlineNodeBuild(const FOutline& polygon, int coun
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SectionGeometry::ValidateSection(Section2* section, int plane)
|
||||
bool SectionGeometry::ValidateSection(Section* section, int plane)
|
||||
{
|
||||
auto sec = §or[section->sector];
|
||||
auto& sdata = data[section->index];
|
||||
|
@ -469,7 +469,7 @@ bool SectionGeometry::ValidateSection(Section2* section, int plane)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SectionGeometry::CreateMesh(Section2* section)
|
||||
bool SectionGeometry::CreateMesh(Section* section)
|
||||
{
|
||||
auto outline = BuildOutline(section);
|
||||
FOutline foutline;
|
||||
|
@ -508,7 +508,7 @@ bool SectionGeometry::CreateMesh(Section2* section)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SectionGeometry::CreatePlaneMesh(Section2* section, int plane, const FVector2& offset)
|
||||
void SectionGeometry::CreatePlaneMesh(Section* section, int plane, const FVector2& offset)
|
||||
{
|
||||
auto sectorp = §or[section->sector];
|
||||
// calculate the rest.
|
||||
|
@ -559,7 +559,7 @@ void SectionGeometry::MarkDirty(sectortype* sector)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
SectionGeometryPlane* SectionGeometry::get(Section2* section, int plane, const FVector2& offset, TArray<int>** pIndices)
|
||||
SectionGeometryPlane* SectionGeometry::get(Section* section, int plane, const FVector2& offset, TArray<int>** pIndices)
|
||||
{
|
||||
if (!section || section->index >= data.Size()) return nullptr;
|
||||
auto sectp = §or[section->sector];
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "vectors.h"
|
||||
#include "build.h"
|
||||
|
||||
struct Section2;
|
||||
struct Section;
|
||||
|
||||
struct SectorGeometryPlane
|
||||
{
|
||||
|
@ -73,14 +73,14 @@ class SectionGeometry
|
|||
{
|
||||
TArray<SectionGeometryData> data;
|
||||
|
||||
bool ValidateSection(Section2* section, int plane);
|
||||
bool ValidateSection(Section* section, int plane);
|
||||
void MarkDirty(sectortype* sector);
|
||||
bool CreateMesh(Section2* section);
|
||||
void CreatePlaneMesh(Section2* section, int plane, const FVector2& offset);
|
||||
bool CreateMesh(Section* section);
|
||||
void CreatePlaneMesh(Section* section, int plane, const FVector2& offset);
|
||||
|
||||
|
||||
public:
|
||||
SectionGeometryPlane* get(Section2* section, int plane, const FVector2& offset, TArray<int>** pIndices);
|
||||
SectionGeometryPlane* get(Section* section, int plane, const FVector2& offset, TArray<int>** pIndices);
|
||||
|
||||
void SetSize(unsigned sectcount)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue