mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
- moved nodes into FLevelLocals.
This commit is contained in:
parent
f818d25542
commit
fea4079b7c
20 changed files with 164 additions and 208 deletions
|
@ -36,6 +36,8 @@ struct FLevelLocals
|
||||||
TStaticArray<seg_t> segs;
|
TStaticArray<seg_t> segs;
|
||||||
TStaticPointableArray<subsector_t> subsectors;
|
TStaticPointableArray<subsector_t> subsectors;
|
||||||
TStaticPointableArray<subsector_t> gamesubsectors;
|
TStaticPointableArray<subsector_t> gamesubsectors;
|
||||||
|
TStaticPointableArray<node_t> nodes;
|
||||||
|
TStaticPointableArray<node_t> gamenodes;
|
||||||
|
|
||||||
TArray<FSectorPortal> sectorPortals;
|
TArray<FSectorPortal> sectorPortals;
|
||||||
|
|
||||||
|
@ -93,6 +95,15 @@ struct FLevelLocals
|
||||||
bool IsJumpingAllowed() const;
|
bool IsJumpingAllowed() const;
|
||||||
bool IsCrouchingAllowed() const;
|
bool IsCrouchingAllowed() const;
|
||||||
bool IsFreelookAllowed() const;
|
bool IsFreelookAllowed() const;
|
||||||
|
|
||||||
|
node_t *HeadNode() const
|
||||||
|
{
|
||||||
|
return &nodes[nodes.Size() - 1];
|
||||||
|
}
|
||||||
|
node_t *HeadGamenode() const
|
||||||
|
{
|
||||||
|
return &gamenodes[gamenodes.Size() - 1];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FLevelLocals level;
|
extern FLevelLocals level;
|
||||||
|
@ -122,6 +133,11 @@ inline int subsector_t::Index() const
|
||||||
return int(this - &level.subsectors[0]);
|
return int(this - &level.subsectors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int node_t::Index() const
|
||||||
|
{
|
||||||
|
return int(this - &level.nodes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
inline FSectorPortal *line_t::GetTransferredPortal()
|
inline FSectorPortal *line_t::GetTransferredPortal()
|
||||||
{
|
{
|
||||||
return portaltransferred >= level.sectorPortals.Size() ? (FSectorPortal*)nullptr : &level.sectorPortals[portaltransferred];
|
return portaltransferred >= level.sectorPortals.Size() ? (FSectorPortal*)nullptr : &level.sectorPortals[portaltransferred];
|
||||||
|
|
|
@ -324,7 +324,7 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, c
|
||||||
build.center.x = xs_CRoundToInt(centerx / subsector->numlines);
|
build.center.x = xs_CRoundToInt(centerx / subsector->numlines);
|
||||||
build.center.y = xs_CRoundToInt(centery / subsector->numlines);
|
build.center.y = xs_CRoundToInt(centery / subsector->numlines);
|
||||||
|
|
||||||
build.CollectNode(nodes + numnodes - 1, shape);
|
build.CollectNode(level.HeadNode(), shape);
|
||||||
coverage->subsectors = new uint32_t[build.collect.Size()];
|
coverage->subsectors = new uint32_t[build.collect.Size()];
|
||||||
coverage->sscount = build.collect.Size();
|
coverage->sscount = build.collect.Size();
|
||||||
memcpy(coverage->subsectors, &build.collect[0], build.collect.Size() * sizeof(uint32_t));
|
memcpy(coverage->subsectors, &build.collect[0], build.collect.Size() * sizeof(uint32_t));
|
||||||
|
@ -359,16 +359,8 @@ void gl_InitPortals()
|
||||||
{
|
{
|
||||||
FPortalMap collection;
|
FPortalMap collection;
|
||||||
|
|
||||||
if (numnodes == 0) return;
|
if (level.nodes.Size() == 0) return;
|
||||||
|
|
||||||
for(int i=0;i<numnodes;i++)
|
|
||||||
{
|
|
||||||
node_t *no = &nodes[i];
|
|
||||||
// Must be converted because the len value is also needed for polyobjects.
|
|
||||||
double fdx = FIXED2DBL(no->dx);
|
|
||||||
double fdy = FIXED2DBL(no->dy);
|
|
||||||
no->len = (float)sqrt(fdx * fdx + fdy * fdy);
|
|
||||||
}
|
|
||||||
|
|
||||||
CollectPortalSectors(collection);
|
CollectPortalSectors(collection);
|
||||||
glSectorPortals.Clear();
|
glSectorPortals.Clear();
|
||||||
|
|
|
@ -160,7 +160,7 @@ void FShadowMap::UploadAABBTree()
|
||||||
{
|
{
|
||||||
// Just comparing the level info is not enough. If two MAPINFO-less levels get played after each other,
|
// Just comparing the level info is not enough. If two MAPINFO-less levels get played after each other,
|
||||||
// they can both refer to the same default level info.
|
// they can both refer to the same default level info.
|
||||||
if (level.info != mLastLevel && numnodes != mLastNumNodes || level.segs.Size() != mLastNumSegs)
|
if (level.info != mLastLevel && level.nodes.Size() != mLastNumNodes || level.segs.Size() != mLastNumSegs)
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (mAABBTree)
|
if (mAABBTree)
|
||||||
|
@ -205,6 +205,6 @@ void FShadowMap::Clear()
|
||||||
mAABBTree.reset();
|
mAABBTree.reset();
|
||||||
|
|
||||||
mLastLevel = level.info;
|
mLastLevel = level.info;
|
||||||
mLastNumNodes = numnodes;
|
mLastNumNodes = level.nodes.Size();
|
||||||
mLastNumSegs = level.segs.Size();
|
mLastNumSegs = level.segs.Size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
|
|
||||||
// Used to detect when a level change requires the AABB tree to be regenerated
|
// Used to detect when a level change requires the AABB tree to be regenerated
|
||||||
level_info_t *mLastLevel = nullptr;
|
level_info_t *mLastLevel = nullptr;
|
||||||
int mLastNumNodes = 0;
|
unsigned mLastNumNodes = 0;
|
||||||
unsigned mLastNumSegs = 0;
|
unsigned mLastNumSegs = 0;
|
||||||
|
|
||||||
// AABB-tree of the level, used for ray tests
|
// AABB-tree of the level, used for ray tests
|
||||||
|
|
|
@ -554,7 +554,7 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
|
||||||
|
|
||||||
void GLSceneDrawer::RenderBSPNode (void *node)
|
void GLSceneDrawer::RenderBSPNode (void *node)
|
||||||
{
|
{
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
DoSubsector (&level.subsectors[0]);
|
DoSubsector (&level.subsectors[0]);
|
||||||
return;
|
return;
|
||||||
|
@ -575,7 +575,7 @@ void GLSceneDrawer::RenderBSPNode (void *node)
|
||||||
// It is not necessary to use the slower precise version here
|
// It is not necessary to use the slower precise version here
|
||||||
if (!clipper.CheckBox(bsp->bbox[side]))
|
if (!clipper.CheckBox(bsp->bbox[side]))
|
||||||
{
|
{
|
||||||
if (!(gl_drawinfo->no_renderflags[bsp-nodes] & SSRF_SEEN))
|
if (!(gl_drawinfo->no_renderflags[bsp->Index()] & SSRF_SEEN))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ void FDrawInfo::StartScene()
|
||||||
|
|
||||||
memset(§orrenderflags[0], 0, level.sectors.Size() * sizeof(sectorrenderflags[0]));
|
memset(§orrenderflags[0], 0, level.sectors.Size() * sizeof(sectorrenderflags[0]));
|
||||||
memset(&ss_renderflags[0], 0, level.subsectors.Size() * sizeof(ss_renderflags[0]));
|
memset(&ss_renderflags[0], 0, level.subsectors.Size() * sizeof(ss_renderflags[0]));
|
||||||
memset(&no_renderflags[0], 0, numnodes * sizeof(no_renderflags[0]));
|
memset(&no_renderflags[0], 0, level.nodes.Size() * sizeof(no_renderflags[0]));
|
||||||
|
|
||||||
next = gl_drawinfo;
|
next = gl_drawinfo;
|
||||||
gl_drawinfo = this;
|
gl_drawinfo = this;
|
||||||
|
|
|
@ -692,7 +692,7 @@ GLSectorStackPortal::~GLSectorStackPortal()
|
||||||
|
|
||||||
static uint8_t SetCoverage(void *node)
|
static uint8_t SetCoverage(void *node)
|
||||||
{
|
{
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -700,7 +700,7 @@ static uint8_t SetCoverage(void *node)
|
||||||
{
|
{
|
||||||
node_t *bsp = (node_t *)node;
|
node_t *bsp = (node_t *)node;
|
||||||
uint8_t coverage = SetCoverage(bsp->children[0]) | SetCoverage(bsp->children[1]);
|
uint8_t coverage = SetCoverage(bsp->children[0]) | SetCoverage(bsp->children[1]);
|
||||||
gl_drawinfo->no_renderflags[bsp-nodes] = coverage;
|
gl_drawinfo->no_renderflags[bsp->Index()] = coverage;
|
||||||
return coverage;
|
return coverage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -723,7 +723,7 @@ void GLSectorStackPortal::SetupCoverage()
|
||||||
gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetCoverage(&nodes[numnodes-1]);
|
SetCoverage(::level.HeadNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -271,7 +271,7 @@ void GLSceneDrawer::CreateScene()
|
||||||
GLRenderer->mVBO->Map();
|
GLRenderer->mVBO->Map();
|
||||||
SetView();
|
SetView();
|
||||||
validcount++; // used for processing sidedefs only once by the renderer.
|
validcount++; // used for processing sidedefs only once by the renderer.
|
||||||
RenderBSPNode (nodes + numnodes - 1);
|
RenderBSPNode (level.HeadNode());
|
||||||
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
|
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
|
||||||
Bsp.Unclock();
|
Bsp.Unclock();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
struct FPolySeg;
|
struct FPolySeg;
|
||||||
struct FMiniBSP;
|
struct FMiniBSP;
|
||||||
|
struct FLevelLocals;
|
||||||
|
|
||||||
struct FEventInfo
|
struct FEventInfo
|
||||||
{
|
{
|
||||||
|
@ -193,10 +194,7 @@ public:
|
||||||
bool makeGLNodes);
|
bool makeGLNodes);
|
||||||
~FNodeBuilder ();
|
~FNodeBuilder ();
|
||||||
|
|
||||||
void Extract(node_t *&nodes, int &nodeCount,
|
void Extract(FLevelLocals &level);
|
||||||
TStaticArray<seg_t> &segs,
|
|
||||||
TStaticPointableArray<subsector_t> &ssecs,
|
|
||||||
TStaticArray<vertex_t> &vertexes);
|
|
||||||
const int *GetOldVertexTable();
|
const int *GetOldVertexTable();
|
||||||
|
|
||||||
// These are used for building sub-BSP trees for polyobjects.
|
// These are used for building sub-BSP trees for polyobjects.
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "nodebuild.h"
|
#include "nodebuild.h"
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
|
#include "g_levellocals.h"
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define D(x) x
|
#define D(x) x
|
||||||
|
@ -52,13 +53,11 @@
|
||||||
#undef DD
|
#undef DD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
void FNodeBuilder::Extract (FLevelLocals &level)
|
||||||
TStaticArray<seg_t> &outSegs,
|
|
||||||
TStaticPointableArray<subsector_t> &outSubs,
|
|
||||||
TStaticArray<vertex_t> &outVerts)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
auto &outVerts = level.vertexes;
|
||||||
int vertCount = Vertices.Size ();
|
int vertCount = Vertices.Size ();
|
||||||
outVerts.Alloc(vertCount);
|
outVerts.Alloc(vertCount);
|
||||||
|
|
||||||
|
@ -67,15 +66,17 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
outVerts[i].set(Vertices[i].x, Vertices[i].y);
|
outVerts[i].set(Vertices[i].x, Vertices[i].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &outSubs = level.subsectors;
|
||||||
auto subCount = Subsectors.Size();
|
auto subCount = Subsectors.Size();
|
||||||
outSubs.Alloc(subCount);
|
outSubs.Alloc(subCount);
|
||||||
memset(&outSubs[0], 0, subCount * sizeof(subsector_t));
|
memset(&outSubs[0], 0, subCount * sizeof(subsector_t));
|
||||||
|
|
||||||
nodeCount = Nodes.Size ();
|
auto &outNodes = level.nodes;
|
||||||
outNodes = new node_t[nodeCount];
|
auto nodeCount = Nodes.Size ();
|
||||||
|
outNodes.Alloc(nodeCount);
|
||||||
|
|
||||||
memcpy (outNodes, &Nodes[0], nodeCount*sizeof(node_t));
|
memcpy (&outNodes[0], &Nodes[0], nodeCount*sizeof(node_t));
|
||||||
for (i = 0; i < nodeCount; ++i)
|
for (unsigned i = 0; i < nodeCount; ++i)
|
||||||
{
|
{
|
||||||
D(Printf(PRINT_LOG, "Node %d: Splitter[%08x,%08x] [%08x,%08x]\n", i,
|
D(Printf(PRINT_LOG, "Node %d: Splitter[%08x,%08x] [%08x,%08x]\n", i,
|
||||||
outNodes[i].x, outNodes[i].y, outNodes[i].dx, outNodes[i].dy));
|
outNodes[i].x, outNodes[i].y, outNodes[i].dx, outNodes[i].dy));
|
||||||
|
@ -91,7 +92,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
D(Printf(PRINT_LOG, " node %d\n", outNodes[i].intchildren[j]));
|
D(Printf(PRINT_LOG, " node %d\n", outNodes[i].intchildren[j]));
|
||||||
outNodes[i].children[j] = outNodes + outNodes[i].intchildren[j];
|
outNodes[i].children[j] = &outNodes[outNodes[i].intchildren[j]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int j = 0; j < 2; ++j)
|
for (int j = 0; j < 2; ++j)
|
||||||
|
@ -103,6 +104,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &outSegs = level.segs;
|
||||||
if (GLNodes)
|
if (GLNodes)
|
||||||
{
|
{
|
||||||
TArray<glseg_t> segs (Segs.Size()*5/4);
|
TArray<glseg_t> segs (Segs.Size()*5/4);
|
||||||
|
|
|
@ -526,7 +526,6 @@ static bool LoadNodes (FileReader * lump)
|
||||||
const int NF_SUBSECTOR = 0x8000;
|
const int NF_SUBSECTOR = 0x8000;
|
||||||
const int GL5_NF_SUBSECTOR = (1 << 31);
|
const int GL5_NF_SUBSECTOR = (1 << 31);
|
||||||
|
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
int k;
|
int k;
|
||||||
node_t* no;
|
node_t* no;
|
||||||
|
@ -535,11 +534,11 @@ static bool LoadNodes (FileReader * lump)
|
||||||
if (!format5)
|
if (!format5)
|
||||||
{
|
{
|
||||||
mapnode_t* mn, * basemn;
|
mapnode_t* mn, * basemn;
|
||||||
numnodes = lump->GetLength() / sizeof(mapnode_t);
|
unsigned numnodes = unsigned(lump->GetLength() / sizeof(mapnode_t));
|
||||||
|
|
||||||
if (numnodes == 0) return false;
|
if (numnodes == 0) return false;
|
||||||
|
|
||||||
nodes = new node_t[numnodes];
|
level.nodes.Alloc(numnodes);
|
||||||
lump->Seek(0, SEEK_SET);
|
lump->Seek(0, SEEK_SET);
|
||||||
|
|
||||||
basemn = mn = new mapnode_t[numnodes];
|
basemn = mn = new mapnode_t[numnodes];
|
||||||
|
@ -548,9 +547,9 @@ static bool LoadNodes (FileReader * lump)
|
||||||
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
||||||
memset (used, 0, sizeof(uint16_t)*numnodes);
|
memset (used, 0, sizeof(uint16_t)*numnodes);
|
||||||
|
|
||||||
no = nodes;
|
no = &level.nodes[0];
|
||||||
|
|
||||||
for (i = 0; i < numnodes; i++, no++, mn++)
|
for (unsigned i = 0; i < numnodes; i++, no++, mn++)
|
||||||
{
|
{
|
||||||
no->x = LittleShort(mn->x)<<FRACBITS;
|
no->x = LittleShort(mn->x)<<FRACBITS;
|
||||||
no->y = LittleShort(mn->y)<<FRACBITS;
|
no->y = LittleShort(mn->y)<<FRACBITS;
|
||||||
|
@ -581,7 +580,7 @@ static bool LoadNodes (FileReader * lump)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
no->children[j] = &nodes[child];
|
no->children[j] = &level.nodes[child];
|
||||||
used[child] = j + 1;
|
used[child] = j + 1;
|
||||||
}
|
}
|
||||||
for (k = 0; k < 4; k++)
|
for (k = 0; k < 4; k++)
|
||||||
|
@ -595,11 +594,11 @@ static bool LoadNodes (FileReader * lump)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl5_mapnode_t* mn, * basemn;
|
gl5_mapnode_t* mn, * basemn;
|
||||||
numnodes = lump->GetLength() / sizeof(gl5_mapnode_t);
|
auto numnodes = unsigned(lump->GetLength() / sizeof(gl5_mapnode_t));
|
||||||
|
|
||||||
if (numnodes == 0) return false;
|
if (numnodes == 0) return false;
|
||||||
|
|
||||||
nodes = new node_t[numnodes];
|
level.nodes.Alloc(numnodes);
|
||||||
lump->Seek(0, SEEK_SET);
|
lump->Seek(0, SEEK_SET);
|
||||||
|
|
||||||
basemn = mn = new gl5_mapnode_t[numnodes];
|
basemn = mn = new gl5_mapnode_t[numnodes];
|
||||||
|
@ -608,9 +607,9 @@ static bool LoadNodes (FileReader * lump)
|
||||||
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
||||||
memset (used, 0, sizeof(uint16_t)*numnodes);
|
memset (used, 0, sizeof(uint16_t)*numnodes);
|
||||||
|
|
||||||
no = nodes;
|
no = &level.nodes[0];
|
||||||
|
|
||||||
for (i = 0; i < numnodes; i++, no++, mn++)
|
for (unsigned i = 0; i < numnodes; i++, no++, mn++)
|
||||||
{
|
{
|
||||||
no->x = LittleShort(mn->x)<<FRACBITS;
|
no->x = LittleShort(mn->x)<<FRACBITS;
|
||||||
no->y = LittleShort(mn->y)<<FRACBITS;
|
no->y = LittleShort(mn->y)<<FRACBITS;
|
||||||
|
@ -629,7 +628,7 @@ static bool LoadNodes (FileReader * lump)
|
||||||
}
|
}
|
||||||
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
||||||
}
|
}
|
||||||
else if (child >= numnodes)
|
else if ((unsigned)child >= numnodes)
|
||||||
{
|
{
|
||||||
delete [] basemn;
|
delete [] basemn;
|
||||||
return false;
|
return false;
|
||||||
|
@ -641,7 +640,7 @@ static bool LoadNodes (FileReader * lump)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
no->children[j] = &nodes[child];
|
no->children[j] = &level.nodes[child];
|
||||||
used[child] = j + 1;
|
used[child] = j + 1;
|
||||||
}
|
}
|
||||||
for (k = 0; k < 4; k++)
|
for (k = 0; k < 4; k++)
|
||||||
|
@ -663,28 +662,12 @@ static bool LoadNodes (FileReader * lump)
|
||||||
|
|
||||||
static bool DoLoadGLNodes(FileReader ** lumps)
|
static bool DoLoadGLNodes(FileReader ** lumps)
|
||||||
{
|
{
|
||||||
if (!LoadGLVertexes(lumps[0]))
|
if (!LoadGLVertexes(lumps[0]) ||
|
||||||
|
!LoadGLSegs(lumps[1]) ||
|
||||||
|
!LoadGLSubsectors(lumps[2]) ||
|
||||||
|
!LoadNodes(lumps[3]))
|
||||||
{
|
{
|
||||||
return false;
|
goto fail;
|
||||||
}
|
|
||||||
if (!LoadGLSegs(lumps[1]))
|
|
||||||
{
|
|
||||||
level.segs.Clear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!LoadGLSubsectors(lumps[2]))
|
|
||||||
{
|
|
||||||
level.subsectors.Clear();
|
|
||||||
level.segs.Clear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!LoadNodes(lumps[3]))
|
|
||||||
{
|
|
||||||
delete [] nodes;
|
|
||||||
nodes = NULL;
|
|
||||||
level.subsectors.Clear();
|
|
||||||
level.segs.Clear();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quick check for the validity of the nodes
|
// Quick check for the validity of the nodes
|
||||||
|
@ -696,11 +679,7 @@ static bool DoLoadGLNodes(FileReader ** lumps)
|
||||||
if (!seg->sidedef)
|
if (!seg->sidedef)
|
||||||
{
|
{
|
||||||
Printf("GL nodes contain invalid data. The BSP has to be rebuilt.\n");
|
Printf("GL nodes contain invalid data. The BSP has to be rebuilt.\n");
|
||||||
delete [] nodes;
|
goto fail;
|
||||||
nodes = NULL;
|
|
||||||
level.subsectors.Clear();
|
|
||||||
level.segs.Clear();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,6 +690,12 @@ static bool DoLoadGLNodes(FileReader ** lumps)
|
||||||
Printf("%d missing segs counted in GL nodes.\nThe BSP has to be rebuilt.\n", missing);
|
Printf("%d missing segs counted in GL nodes.\nThe BSP has to be rebuilt.\n", missing);
|
||||||
}
|
}
|
||||||
return missing == 0;
|
return missing == 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
level.nodes.Clear();
|
||||||
|
level.subsectors.Clear();
|
||||||
|
level.segs.Clear();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -855,7 +840,7 @@ bool P_LoadGLNodes(MapData * map)
|
||||||
{
|
{
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
nodes = NULL;
|
level.nodes.Clear();
|
||||||
P_LoadZNodes (*map->file, id);
|
P_LoadZNodes (*map->file, id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -863,11 +848,7 @@ bool P_LoadGLNodes(MapData * map)
|
||||||
{
|
{
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
if (nodes != NULL)
|
level.nodes.Clear();
|
||||||
{
|
|
||||||
delete[] nodes;
|
|
||||||
nodes = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,8 +943,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
sub.sector = sub.firstline->sidedef->sector;
|
sub.sector = sub.firstline->sidedef->sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes = NULL;
|
level.nodes.Clear();
|
||||||
numnodes = 0;
|
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
|
|
||||||
|
@ -987,10 +967,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
leveldata.FindMapBounds ();
|
leveldata.FindMapBounds ();
|
||||||
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
||||||
|
|
||||||
builder.Extract (nodes, numnodes,
|
builder.Extract (level);
|
||||||
level.segs,
|
|
||||||
level.subsectors,
|
|
||||||
level.vertexes);
|
|
||||||
endTime = I_FPSTime ();
|
endTime = I_FPSTime ();
|
||||||
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%u segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%u segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
||||||
buildtime = endTime - startTime;
|
buildtime = endTime - startTime;
|
||||||
|
@ -1014,10 +991,9 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gamenodes)
|
if (level.gamenodes.Size() == 0)
|
||||||
{
|
{
|
||||||
gamenodes = nodes;
|
level.gamenodes.Point(level.nodes);
|
||||||
numgamenodes = numnodes;
|
|
||||||
level.gamesubsectors.Point(level.subsectors);
|
level.gamesubsectors.Point(level.subsectors);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1101,31 +1077,31 @@ static void CreateCachedNodes(MapData *map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLong(ZNodes, numnodes);
|
WriteLong(ZNodes, level.nodes.Size());
|
||||||
for(int i=0;i<numnodes;i++)
|
for(auto &node : level.nodes)
|
||||||
{
|
{
|
||||||
WriteLong(ZNodes, nodes[i].x);
|
WriteLong(ZNodes, node.x);
|
||||||
WriteLong(ZNodes, nodes[i].y);
|
WriteLong(ZNodes, node.y);
|
||||||
WriteLong(ZNodes, nodes[i].dx);
|
WriteLong(ZNodes, node.dx);
|
||||||
WriteLong(ZNodes, nodes[i].dy);
|
WriteLong(ZNodes, node.dy);
|
||||||
for (int j = 0; j < 2; ++j)
|
for (int j = 0; j < 2; ++j)
|
||||||
{
|
{
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
{
|
{
|
||||||
WriteWord(ZNodes, (short)nodes[i].bbox[j][k]);
|
WriteWord(ZNodes, (short)node.bbox[j][k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 2; ++j)
|
for (int j = 0; j < 2; ++j)
|
||||||
{
|
{
|
||||||
uint32_t child;
|
uint32_t child;
|
||||||
if ((size_t)nodes[i].children[j] & 1)
|
if ((size_t)node.children[j] & 1)
|
||||||
{
|
{
|
||||||
child = 0x80000000 | uint32_t(((subsector_t *)((uint8_t *)nodes[i].children[j] - 1))->Index());
|
child = 0x80000000 | uint32_t(((subsector_t *)((uint8_t *)node.children[j] - 1))->Index());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = uint32_t((node_t *)nodes[i].children[j] - nodes);
|
child = ((node_t *)node.children[j])->Index();
|
||||||
}
|
}
|
||||||
WriteLong(ZNodes, child);
|
WriteLong(ZNodes, child);
|
||||||
}
|
}
|
||||||
|
@ -1222,11 +1198,7 @@ static bool CheckCachedNodes(MapData *map)
|
||||||
|
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
if (nodes != NULL)
|
level.nodes.Clear();
|
||||||
{
|
|
||||||
delete[] nodes;
|
|
||||||
nodes = NULL;
|
|
||||||
}
|
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1297,35 +1269,6 @@ CCMD(clearnodecache)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// P_PointInSubsector
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
subsector_t *P_PointInSubsector (double x, double y)
|
|
||||||
{
|
|
||||||
node_t *node;
|
|
||||||
int side;
|
|
||||||
|
|
||||||
// single subsector is a special case
|
|
||||||
if (numgamenodes == 0)
|
|
||||||
return &level.gamesubsectors[0];
|
|
||||||
|
|
||||||
node = gamenodes + numgamenodes - 1;
|
|
||||||
|
|
||||||
fixed_t xx = FLOAT2FIXED(x);
|
|
||||||
fixed_t yy = FLOAT2FIXED(y);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
side = R_PointOnSide (xx, yy, node);
|
|
||||||
node = (node_t *)node->children[side];
|
|
||||||
}
|
|
||||||
while (!((size_t)node & 1));
|
|
||||||
|
|
||||||
return (subsector_t *)((uint8_t *)node - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// PointOnLine
|
// PointOnLine
|
||||||
|
|
|
@ -426,7 +426,7 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec
|
||||||
|
|
||||||
if (sector == NULL)
|
if (sector == NULL)
|
||||||
{
|
{
|
||||||
if (!spawning || numgamenodes == 0)
|
if (!spawning)
|
||||||
{
|
{
|
||||||
sector = P_PointInSector(Pos());
|
sector = P_PointInSector(Pos());
|
||||||
}
|
}
|
||||||
|
@ -2093,6 +2093,34 @@ int P_VanillaPointOnLineSide(double x, double y, const line_t* line)
|
||||||
return 1; // back side
|
return 1; // back side
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// P_PointInSubsector
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
subsector_t *P_PointInSubsector(double x, double y)
|
||||||
|
{
|
||||||
|
node_t *node;
|
||||||
|
int side;
|
||||||
|
|
||||||
|
// single subsector is a special case
|
||||||
|
if (level.gamenodes.Size() == 0)
|
||||||
|
return &level.gamesubsectors[0];
|
||||||
|
|
||||||
|
node = level.HeadGamenode();
|
||||||
|
|
||||||
|
fixed_t xx = FLOAT2FIXED(x);
|
||||||
|
fixed_t yy = FLOAT2FIXED(y);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
side = R_PointOnSide(xx, yy, node);
|
||||||
|
node = (node_t *)node->children[side];
|
||||||
|
} while (!((size_t)node & 1));
|
||||||
|
|
||||||
|
return (subsector_t *)((uint8_t *)node - 1);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Use buggy PointOnSide and fix actors that lie on
|
// Use buggy PointOnSide and fix actors that lie on
|
||||||
|
@ -2103,10 +2131,10 @@ int P_VanillaPointOnLineSide(double x, double y, const line_t* line)
|
||||||
sector_t *P_PointInSectorBuggy(double x, double y)
|
sector_t *P_PointInSectorBuggy(double x, double y)
|
||||||
{
|
{
|
||||||
// single subsector is a special case
|
// single subsector is a special case
|
||||||
if (numgamenodes == 0)
|
if (level.gamenodes.Size() == 0)
|
||||||
return level.gamesubsectors[0].sector;
|
return level.gamesubsectors[0].sector;
|
||||||
|
|
||||||
node_t *node = gamenodes + numgamenodes - 1;
|
auto node = level.HeadGamenode();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,13 +125,13 @@ inline bool P_LoadBuildMap(uint8_t *mapdata, size_t len, FMapThing **things, int
|
||||||
//
|
//
|
||||||
TArray<vertexdata_t> vertexdatas;
|
TArray<vertexdata_t> vertexdatas;
|
||||||
|
|
||||||
int numnodes;
|
//int numnodes;
|
||||||
node_t* nodes;
|
//node_t* nodes;
|
||||||
|
|
||||||
TArray<zone_t> Zones;
|
TArray<zone_t> Zones;
|
||||||
|
|
||||||
node_t * gamenodes;
|
//node_t * gamenodes;
|
||||||
int numgamenodes;
|
//int numgamenodes;
|
||||||
|
|
||||||
bool hasglnodes;
|
bool hasglnodes;
|
||||||
|
|
||||||
|
@ -1049,9 +1049,9 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
||||||
uint32_t numNodes;
|
uint32_t numNodes;
|
||||||
|
|
||||||
data >> numNodes;
|
data >> numNodes;
|
||||||
numnodes = numNodes;
|
auto &nodes = level.nodes;
|
||||||
nodes = new node_t[numNodes];
|
nodes.Alloc(numNodes);
|
||||||
memset (nodes, 0, sizeof(node_t)*numNodes);
|
memset (&nodes[0], 0, sizeof(node_t)*numNodes);
|
||||||
|
|
||||||
for (i = 0; i < numNodes; ++i)
|
for (i = 0; i < numNodes; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1211,7 +1211,7 @@ void P_LoadSegs (MapData * map)
|
||||||
{
|
{
|
||||||
Printf ("This map has no segs.\n");
|
Printf ("This map has no segs.\n");
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
delete[] vertchanged;
|
delete[] vertchanged;
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
return;
|
return;
|
||||||
|
@ -1357,7 +1357,7 @@ void P_LoadSegs (MapData * map)
|
||||||
Printf ("The BSP will be rebuilt.\n");
|
Printf ("The BSP will be rebuilt.\n");
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1382,7 +1382,7 @@ void P_LoadSubsectors (MapData * map)
|
||||||
if (numsubsectors == 0 || maxseg == 0 )
|
if (numsubsectors == 0 || maxseg == 0 )
|
||||||
{
|
{
|
||||||
Printf ("This map has an incomplete BSP tree.\n");
|
Printf ("This map has an incomplete BSP tree.\n");
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1403,7 +1403,7 @@ void P_LoadSubsectors (MapData * map)
|
||||||
{
|
{
|
||||||
Printf ("Subsector %i is empty.\n", i);
|
Printf ("Subsector %i is empty.\n", i);
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1417,7 @@ void P_LoadSubsectors (MapData * map)
|
||||||
"The BSP will be rebuilt.\n", i, (unsigned)((size_t)subsectors[i].firstline),
|
"The BSP will be rebuilt.\n", i, (unsigned)((size_t)subsectors[i].firstline),
|
||||||
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1427,7 +1427,7 @@ void P_LoadSubsectors (MapData * map)
|
||||||
"The BSP will be rebuilt.\n", i, maxseg,
|
"The BSP will be rebuilt.\n", i, maxseg,
|
||||||
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1538,7 +1538,6 @@ template<class nodetype, class subsectortype>
|
||||||
void P_LoadNodes (MapData * map)
|
void P_LoadNodes (MapData * map)
|
||||||
{
|
{
|
||||||
FMemLump data;
|
FMemLump data;
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
int k;
|
int k;
|
||||||
char *mnp;
|
char *mnp;
|
||||||
|
@ -1548,7 +1547,7 @@ void P_LoadNodes (MapData * map)
|
||||||
int lumplen = map->Size(ML_NODES);
|
int lumplen = map->Size(ML_NODES);
|
||||||
int maxss = map->Size(ML_SSECTORS) / sizeof(subsectortype);
|
int maxss = map->Size(ML_SSECTORS) / sizeof(subsectortype);
|
||||||
|
|
||||||
numnodes = (lumplen - nodetype::NF_LUMPOFFSET) / sizeof(nodetype);
|
unsigned numnodes = (lumplen - nodetype::NF_LUMPOFFSET) / sizeof(nodetype);
|
||||||
|
|
||||||
if ((numnodes == 0 && maxss != 1) || maxss == 0)
|
if ((numnodes == 0 && maxss != 1) || maxss == 0)
|
||||||
{
|
{
|
||||||
|
@ -1556,16 +1555,17 @@ void P_LoadNodes (MapData * map)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes = new node_t[numnodes];
|
auto &nodes = level.nodes;
|
||||||
|
nodes.Alloc(numnodes);
|
||||||
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes);
|
||||||
memset (used, 0, sizeof(uint16_t)*numnodes);
|
memset (used, 0, sizeof(uint16_t)*numnodes);
|
||||||
|
|
||||||
mnp = new char[lumplen];
|
mnp = new char[lumplen];
|
||||||
mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET);
|
mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET);
|
||||||
map->Read(ML_NODES, mnp);
|
map->Read(ML_NODES, mnp);
|
||||||
no = nodes;
|
no = &nodes[0];
|
||||||
|
|
||||||
for (i = 0; i < numnodes; i++, no++, mn++)
|
for (unsigned i = 0; i < numnodes; i++, no++, mn++)
|
||||||
{
|
{
|
||||||
no->x = LittleShort(mn->x)<<FRACBITS;
|
no->x = LittleShort(mn->x)<<FRACBITS;
|
||||||
no->y = LittleShort(mn->y)<<FRACBITS;
|
no->y = LittleShort(mn->y)<<FRACBITS;
|
||||||
|
@ -1582,18 +1582,18 @@ void P_LoadNodes (MapData * map)
|
||||||
Printf ("BSP node %d references invalid subsector %d.\n"
|
Printf ("BSP node %d references invalid subsector %d.\n"
|
||||||
"The BSP will be rebuilt.\n", i, child);
|
"The BSP will be rebuilt.\n", i, child);
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
delete[] mnp;
|
delete[] mnp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
no->children[j] = (uint8_t *)&level.subsectors[child] + 1;
|
||||||
}
|
}
|
||||||
else if (child >= numnodes)
|
else if ((unsigned)child >= numnodes)
|
||||||
{
|
{
|
||||||
Printf ("BSP node %d references invalid node %td.\n"
|
Printf ("BSP node %d references invalid node %td.\n"
|
||||||
"The BSP will be rebuilt.\n", i, (node_t *)no->children[j] - nodes);
|
"The BSP will be rebuilt.\n", i, ((node_t *)no->children[j])->Index());
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
delete[] mnp;
|
delete[] mnp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1603,7 +1603,7 @@ void P_LoadNodes (MapData * map)
|
||||||
"which is already used by node %d.\n"
|
"which is already used by node %d.\n"
|
||||||
"The BSP will be rebuilt.\n", i, child, used[child]-1);
|
"The BSP will be rebuilt.\n", i, child, used[child]-1);
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
delete[] nodes;
|
level.nodes.Clear();
|
||||||
delete[] mnp;
|
delete[] mnp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3451,19 +3451,10 @@ void P_FreeLevelData ()
|
||||||
level.lines.Clear();
|
level.lines.Clear();
|
||||||
level.sides.Clear();
|
level.sides.Clear();
|
||||||
level.vertexes.Clear();
|
level.vertexes.Clear();
|
||||||
|
level.nodes.Clear();
|
||||||
if (gamenodes != NULL && gamenodes != nodes)
|
level.gamenodes.Clear();
|
||||||
{
|
|
||||||
delete[] gamenodes;
|
|
||||||
}
|
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.gamesubsectors.Clear();
|
level.gamesubsectors.Clear();
|
||||||
if (nodes != NULL)
|
|
||||||
{
|
|
||||||
delete[] nodes;
|
|
||||||
}
|
|
||||||
nodes = gamenodes = NULL;
|
|
||||||
numnodes = numgamenodes = 0;
|
|
||||||
|
|
||||||
if (blockmaplump != NULL)
|
if (blockmaplump != NULL)
|
||||||
{
|
{
|
||||||
|
@ -3799,11 +3790,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
ForceNodeBuild = true;
|
ForceNodeBuild = true;
|
||||||
level.subsectors.Clear();
|
level.subsectors.Clear();
|
||||||
level.segs.Clear();
|
level.segs.Clear();
|
||||||
if (nodes != NULL)
|
level.nodes.Clear();
|
||||||
{
|
|
||||||
delete[] nodes;
|
|
||||||
nodes = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!map->isText) // regular nodes are not supported for text maps
|
else if (!map->isText) // regular nodes are not supported for text maps
|
||||||
|
@ -3879,10 +3866,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
// In case a sync critical game mode is started, also build GL nodes to avoid problems
|
// In case a sync critical game mode is started, also build GL nodes to avoid problems
|
||||||
// if the different machines' am_textured setting differs.
|
// if the different machines' am_textured setting differs.
|
||||||
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
||||||
builder.Extract (nodes, numnodes,
|
builder.Extract (level);
|
||||||
level.segs,
|
|
||||||
level.subsectors,
|
|
||||||
level.vertexes);
|
|
||||||
endTime = I_FPSTime ();
|
endTime = I_FPSTime ();
|
||||||
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
DPrintf (DMSG_NOTIFY, "BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, level.segs.Size());
|
||||||
oldvertextable = builder.GetOldVertexTable();
|
oldvertextable = builder.GetOldVertexTable();
|
||||||
|
@ -3911,19 +3895,12 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy pointers to the old nodes so that R_PointInSubsector can use them
|
// duplicate the nodes in the game* arrays so that replacement nodes do not overwrite them.
|
||||||
if (nodes)
|
|
||||||
{
|
|
||||||
gamenodes = nodes;
|
|
||||||
numgamenodes = numnodes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gamenodes=NULL;
|
|
||||||
}
|
|
||||||
// let the game data take ownership, because that is guaranteed to remain intact after here.
|
// let the game data take ownership, because that is guaranteed to remain intact after here.
|
||||||
level.gamesubsectors = std::move(level.subsectors);
|
level.gamesubsectors = std::move(level.subsectors);
|
||||||
level.subsectors.Point(level.gamesubsectors);
|
level.subsectors.Point(level.gamesubsectors);
|
||||||
|
level.gamenodes = std::move(level.nodes);
|
||||||
|
level.nodes.Point(level.gamenodes);
|
||||||
|
|
||||||
if (RequireGLNodes)
|
if (RequireGLNodes)
|
||||||
{
|
{
|
||||||
|
@ -4018,6 +3995,12 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
if (sec.floorplane.isSlope()) sec.reflect[sector_t::floor] = 0;
|
if (sec.floorplane.isSlope()) sec.reflect[sector_t::floor] = 0;
|
||||||
if (sec.ceilingplane.isSlope()) sec.reflect[sector_t::ceiling] = 0;
|
if (sec.ceilingplane.isSlope()) sec.reflect[sector_t::ceiling] = 0;
|
||||||
}
|
}
|
||||||
|
for (auto &node : level.nodes)
|
||||||
|
{
|
||||||
|
double fdx = FIXED2DBL(node.dx);
|
||||||
|
double fdy = FIXED2DBL(node.dy);
|
||||||
|
node.len = (float)g_sqrt(fdx * fdx + fdy * fdy);
|
||||||
|
}
|
||||||
|
|
||||||
// This must be done BEFORE the PolyObj Spawn!!!
|
// This must be done BEFORE the PolyObj Spawn!!!
|
||||||
Renderer->PreprocessLevel();
|
Renderer->PreprocessLevel();
|
||||||
|
|
|
@ -1741,14 +1741,6 @@ void PO_Init (void)
|
||||||
// [RH] Don't need the side lists anymore
|
// [RH] Don't need the side lists anymore
|
||||||
KillSideLists ();
|
KillSideLists ();
|
||||||
|
|
||||||
for(int i=0;i<numnodes;i++)
|
|
||||||
{
|
|
||||||
node_t *no = &nodes[i];
|
|
||||||
double fdx = FIXED2DBL(no->dx);
|
|
||||||
double fdy = FIXED2DBL(no->dy);
|
|
||||||
no->len = (float)g_sqrt(fdx * fdx + fdy * fdy);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mark all subsectors which have a seg belonging to a polyobj
|
// mark all subsectors which have a seg belonging to a polyobj
|
||||||
// These ones should not be rendered on the textured automap.
|
// These ones should not be rendered on the textured automap.
|
||||||
for (auto &ss : level.subsectors)
|
for (auto &ss : level.subsectors)
|
||||||
|
@ -2128,7 +2120,7 @@ void FPolyObj::CreateSubsectorLinks()
|
||||||
}
|
}
|
||||||
if (!(i_compatflags & COMPATF_POLYOBJ))
|
if (!(i_compatflags & COMPATF_POLYOBJ))
|
||||||
{
|
{
|
||||||
SplitPoly(node, nodes + numnodes - 1, dummybbox);
|
SplitPoly(node, level.HeadNode(), dummybbox);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,10 +37,10 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPl
|
||||||
// Cull front to back
|
// Cull front to back
|
||||||
MaxCeilingHeight = 0.0;
|
MaxCeilingHeight = 0.0;
|
||||||
MinFloorHeight = 0.0;
|
MinFloorHeight = 0.0;
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
CullSubsector(&level.subsectors[0]);
|
CullSubsector(&level.subsectors[0]);
|
||||||
else
|
else
|
||||||
CullNode(nodes + numnodes - 1); // The head node is the last node output.
|
CullNode(level.HeadNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyCull::CullNode(void *node)
|
void PolyCull::CullNode(void *node)
|
||||||
|
|
|
@ -134,7 +134,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub)
|
||||||
|
|
||||||
void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right)
|
void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right)
|
||||||
{
|
{
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
subsector_t *sub = &level.subsectors[0];
|
subsector_t *sub = &level.subsectors[0];
|
||||||
auto it = SubsectorDepths.find(sub);
|
auto it = SubsectorDepths.find(sub);
|
||||||
|
@ -143,7 +143,7 @@ void RenderPolyScene::RenderSprite(AActor *thing, double sortDistance, const DVe
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, nodes + numnodes - 1); // The head node is the last node output.
|
RenderSprite(thing, sortDistance, left, right, 0.0, 1.0, level.HeadNode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1447,6 +1447,8 @@ struct node_t
|
||||||
void *children[2]; // If bit 0 is set, it's a subsector.
|
void *children[2]; // If bit 0 is set, it's a subsector.
|
||||||
int intchildren[2]; // Used by nodebuilder.
|
int intchildren[2]; // Used by nodebuilder.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int Index() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,13 @@ extern uint32_t NumStdSprites;
|
||||||
|
|
||||||
extern TArray<vertexdata_t> vertexdatas;
|
extern TArray<vertexdata_t> vertexdatas;
|
||||||
|
|
||||||
extern int numnodes;
|
//extern int numnodes;
|
||||||
extern node_t* nodes;
|
//extern node_t* nodes;
|
||||||
|
|
||||||
extern TArray<zone_t> Zones;
|
extern TArray<zone_t> Zones;
|
||||||
|
|
||||||
extern node_t * gamenodes;
|
//extern node_t * gamenodes;
|
||||||
extern int numgamenodes;
|
//extern int numgamenodes;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -301,10 +301,10 @@ subsector_t *R_PointInSubsector (fixed_t x, fixed_t y)
|
||||||
int side;
|
int side;
|
||||||
|
|
||||||
// single subsector is a special case
|
// single subsector is a special case
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
return &level.subsectors[0];
|
return &level.subsectors[0];
|
||||||
|
|
||||||
node = nodes + numnodes - 1;
|
node = level.HeadNode();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
|
@ -777,7 +777,7 @@ namespace swrenderer
|
||||||
SeenActors.clear();
|
SeenActors.clear();
|
||||||
|
|
||||||
InSubsector = nullptr;
|
InSubsector = nullptr;
|
||||||
RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output.
|
RenderBSPNode(level.HeadNode()); // The head node is the last node output.
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -788,7 +788,7 @@ namespace swrenderer
|
||||||
|
|
||||||
void RenderOpaquePass::RenderBSPNode(void *node)
|
void RenderOpaquePass::RenderBSPNode(void *node)
|
||||||
{
|
{
|
||||||
if (numnodes == 0)
|
if (level.nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
RenderSubsector(&level.subsectors[0]);
|
RenderSubsector(&level.subsectors[0]);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue