mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- fixed: The sight checker's portalgroup variable was not initialized.
- got rid of glsegextras. This was probably one of the most ill-conceived means to save some memory in ZDoom, but now, when a pure software rendered engine no longer needs to be considered it's just totally useless to keep this mess in.
This commit is contained in:
parent
12037fdc95
commit
b9ac44e8f2
8 changed files with 39 additions and 107 deletions
|
@ -501,36 +501,6 @@ static void PrepareSegs()
|
|||
|
||||
// count the segs
|
||||
memset(segcount, 0, numsides * sizeof(int));
|
||||
|
||||
// set up the extra data in case the map was loaded with regular nodes that might pass as GL nodes.
|
||||
if (glsegextras == NULL)
|
||||
{
|
||||
for(int i=0;i<numsegs;i++)
|
||||
{
|
||||
segs[i].PartnerSeg = NULL;
|
||||
}
|
||||
for (int i=0; i<numsubsectors; i++)
|
||||
{
|
||||
int seg = int(subsectors[i].firstline-segs);
|
||||
for(DWORD j=0;j<subsectors[i].numlines;j++)
|
||||
{
|
||||
segs[j+seg].Subsector = &subsectors[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0;i<numsegs;i++)
|
||||
{
|
||||
seg_t *seg = &segs[i];
|
||||
|
||||
// Account for ZDoom space optimizations that cannot be done for GL
|
||||
unsigned int partner= glsegextras[i].PartnerSeg;
|
||||
if (partner < unsigned(numsegs)) seg->PartnerSeg = &segs[partner];
|
||||
else seg->PartnerSeg = NULL;
|
||||
seg->Subsector = glsegextras[i].Subsector;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<numsegs;i++)
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
~FNodeBuilder ();
|
||||
|
||||
void Extract(node_t *&nodes, int &nodeCount,
|
||||
seg_t *&segs, glsegextra_t *&glsegextras, int &segCount,
|
||||
seg_t *&segs, int &segCount,
|
||||
subsector_t *&ssecs, int &subCount,
|
||||
TStaticArray<vertex_t> &vertexes);
|
||||
const int *GetOldVertexTable();
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#endif
|
||||
|
||||
void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
||||
seg_t *&outSegs, glsegextra_t *&outSegExtras, int &segCount,
|
||||
seg_t *&outSegs, int &segCount,
|
||||
subsector_t *&outSubs, int &subCount,
|
||||
TStaticArray<vertex_t> &outVerts)
|
||||
{
|
||||
|
@ -116,7 +116,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
|
||||
segCount = segs.Size ();
|
||||
outSegs = new seg_t[segCount];
|
||||
outSegExtras = new glsegextra_t[segCount];
|
||||
|
||||
for (i = 0; i < segCount; ++i)
|
||||
{
|
||||
|
@ -124,11 +123,11 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
|
||||
if (segs[i].Partner != DWORD_MAX)
|
||||
{
|
||||
outSegExtras[i].PartnerSeg = Segs[segs[i].Partner].storedseg;
|
||||
outSegs[i].PartnerSeg = &outSegs[Segs[segs[i].Partner].storedseg];
|
||||
}
|
||||
else
|
||||
{
|
||||
outSegExtras[i].PartnerSeg = DWORD_MAX;
|
||||
outSegs[i].PartnerSeg = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +136,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
memcpy (outSubs, &Subsectors[0], subCount*sizeof(subsector_t));
|
||||
segCount = Segs.Size ();
|
||||
outSegs = new seg_t[segCount];
|
||||
outSegExtras = NULL;
|
||||
for (i = 0; i < segCount; ++i)
|
||||
{
|
||||
const FPrivSeg *org = &Segs[SegList[i].SegNum];
|
||||
|
@ -151,6 +149,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
out->frontsector = org->frontsector;
|
||||
out->linedef = Level.Lines + org->linedef;
|
||||
out->sidedef = Level.Sides + org->sidedef;
|
||||
out->PartnerSeg = nullptr;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < subCount; ++i)
|
||||
|
|
|
@ -319,15 +319,13 @@ static bool LoadGLSegs(FileReader * lump)
|
|||
numsegs/=sizeof(glseg_t);
|
||||
segs = new seg_t[numsegs];
|
||||
memset(segs,0,sizeof(seg_t)*numsegs);
|
||||
glsegextras = new glsegextra_t[numsegs];
|
||||
|
||||
glseg_t * ml = (glseg_t*)data;
|
||||
for(i = 0; i < numsegs; i++)
|
||||
{ // check for gl-vertices
|
||||
segs[i].v1 = &level.vertexes[checkGLVertex(LittleShort(ml->v1))];
|
||||
segs[i].v2 = &level.vertexes[checkGLVertex(LittleShort(ml->v2))];
|
||||
|
||||
glsegextras[i].PartnerSeg = ml->partner == 0xFFFF ? DWORD_MAX : LittleShort(ml->partner);
|
||||
segs[i].PartnerSeg = ml->partner == 0xFFFF ? nullptr : &segs[LittleShort(ml->partner)];
|
||||
if(ml->linedef != 0xffff)
|
||||
{
|
||||
ldef = &level.lines[LittleShort(ml->linedef)];
|
||||
|
@ -372,15 +370,13 @@ static bool LoadGLSegs(FileReader * lump)
|
|||
numsegs/=sizeof(glseg3_t);
|
||||
segs = new seg_t[numsegs];
|
||||
memset(segs,0,sizeof(seg_t)*numsegs);
|
||||
glsegextras = new glsegextra_t[numsegs];
|
||||
|
||||
glseg3_t * ml = (glseg3_t*)(data+ (format5? 0:4));
|
||||
for(i = 0; i < numsegs; i++)
|
||||
{ // check for gl-vertices
|
||||
segs[i].v1 = &level.vertexes[checkGLVertex3(LittleLong(ml->v1))];
|
||||
segs[i].v2 = &level.vertexes[checkGLVertex3(LittleLong(ml->v2))];
|
||||
|
||||
glsegextras[i].PartnerSeg = LittleLong(ml->partner);
|
||||
segs[i].PartnerSeg = LittleLong(ml->partner) == 0xffffffffu? nullptr : &segs[LittleLong(ml->partner)];
|
||||
|
||||
if(ml->linedef != 0xffff) // skip minisegs
|
||||
{
|
||||
|
@ -1011,7 +1007,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime)
|
|||
FNodeBuilder builder (leveldata, polyspots, anchors, true);
|
||||
|
||||
builder.Extract (nodes, numnodes,
|
||||
segs, glsegextras, numsegs,
|
||||
segs, numsegs,
|
||||
subsectors, numsubsectors,
|
||||
level.vertexes);
|
||||
endTime = I_FPSTime ();
|
||||
|
@ -1112,8 +1108,7 @@ static void CreateCachedNodes(MapData *map)
|
|||
for(int i=0;i<numsegs;i++)
|
||||
{
|
||||
WriteLong(ZNodes, segs[i].v1->Index());
|
||||
if (glsegextras != NULL) WriteLong(ZNodes, DWORD(glsegextras[i].PartnerSeg));
|
||||
else WriteLong(ZNodes, 0);
|
||||
WriteLong(ZNodes, segs[i].PartnerSeg == nullptr? 0xffffffffu : DWORD(segs[i].PartnerSeg - segs));
|
||||
if (segs[i].linedef)
|
||||
{
|
||||
WriteLong(ZNodes, DWORD(segs[i].linedef->Index()));
|
||||
|
@ -1440,40 +1435,32 @@ void P_SetRenderSector()
|
|||
#endif
|
||||
|
||||
// Check for incorrect partner seg info so that the following code does not crash.
|
||||
if (glsegextras == NULL)
|
||||
|
||||
for (i = 0; i < numsegs; i++)
|
||||
{
|
||||
// This can be normal nodes, mistakenly identified as GL nodes so we must fill
|
||||
// in the missing pieces differently.
|
||||
|
||||
for (i = 0; i < numsubsectors; i++)
|
||||
auto p = segs[i].PartnerSeg;
|
||||
if (p != nullptr)
|
||||
{
|
||||
ss = &subsectors[i];
|
||||
ss->render_sector = ss->sector;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int partner = (int)(p - segs);
|
||||
|
||||
for(i=0;i<numsegs;i++)
|
||||
{
|
||||
int partner = (int)glsegextras[i].PartnerSeg;
|
||||
if (partner < 0 || partner >= numsegs)
|
||||
{
|
||||
segs[i].PartnerSeg = nullptr;
|
||||
}
|
||||
|
||||
if (partner<0 || partner>=numsegs/*eh? || &segs[partner]!=glsegextras[i].PartnerSeg*/)
|
||||
{
|
||||
glsegextras[i].PartnerSeg=DWORD_MAX;
|
||||
// glbsp creates such incorrect references for Strife.
|
||||
if (segs[i].linedef && segs[i].PartnerSeg != nullptr && !segs[i].PartnerSeg->linedef)
|
||||
{
|
||||
segs[i].PartnerSeg = segs[i].PartnerSeg->PartnerSeg = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// glbsp creates such incorrect references for Strife.
|
||||
if (segs[i].linedef && glsegextras[i].PartnerSeg != DWORD_MAX && !segs[glsegextras[i].PartnerSeg].linedef)
|
||||
for (i = 0; i < numsegs; i++)
|
||||
{
|
||||
glsegextras[i].PartnerSeg = glsegextras[glsegextras[i].PartnerSeg].PartnerSeg = DWORD_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<numsegs;i++)
|
||||
{
|
||||
if (glsegextras[i].PartnerSeg != DWORD_MAX && glsegextras[glsegextras[i].PartnerSeg].PartnerSeg!=(DWORD)i)
|
||||
{
|
||||
glsegextras[i].PartnerSeg=DWORD_MAX;
|
||||
if (segs[i].PartnerSeg != nullptr && segs[i].PartnerSeg->PartnerSeg != &segs[i])
|
||||
{
|
||||
segs[i].PartnerSeg = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1501,7 +1488,7 @@ void P_SetRenderSector()
|
|||
seg = ss->firstline;
|
||||
for(j=0; j<ss->numlines; j++)
|
||||
{
|
||||
if(seg->sidedef && (glsegextras[seg - segs].PartnerSeg == DWORD_MAX || seg->sidedef->sector!=segs[glsegextras[seg - segs].PartnerSeg].sidedef->sector))
|
||||
if(seg->sidedef && (seg->PartnerSeg == nullptr || seg->sidedef->sector!=seg->PartnerSeg->sidedef->sector))
|
||||
{
|
||||
ss->render_sector = seg->sidedef->sector;
|
||||
break;
|
||||
|
@ -1525,15 +1512,14 @@ void P_SetRenderSector()
|
|||
|
||||
for(j=0; j<ss->numlines; j++)
|
||||
{
|
||||
DWORD partner = glsegextras[seg - segs].PartnerSeg;
|
||||
if (partner != DWORD_MAX && glsegextras[partner].Subsector)
|
||||
if (seg->PartnerSeg != nullptr && seg->PartnerSeg->Subsector)
|
||||
{
|
||||
sector_t * backsec = glsegextras[partner].Subsector->render_sector;
|
||||
sector_t * backsec = seg->PartnerSeg->Subsector->render_sector;
|
||||
if (backsec)
|
||||
{
|
||||
ss->render_sector=backsec;
|
||||
ss->render_sector = backsec;
|
||||
undetermined.Delete(i);
|
||||
deleted=1;
|
||||
deleted = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,6 @@ vertexdata_t* vertexdatas;
|
|||
|
||||
int numsegs;
|
||||
seg_t* segs;
|
||||
glsegextra_t* glsegextras;
|
||||
|
||||
int numsubsectors;
|
||||
subsector_t* subsectors;
|
||||
|
@ -933,7 +932,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type)
|
|||
{
|
||||
seg[-1].v2 = seg->v1;
|
||||
}
|
||||
glsegextras[seg - segs].PartnerSeg = partner;
|
||||
seg->PartnerSeg = &segs[partner];
|
||||
if (line != 0xFFFFFFFF)
|
||||
{
|
||||
line_t *ldef;
|
||||
|
@ -1041,7 +1040,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
|||
numsegs = numSegs;
|
||||
segs = new seg_t[numsegs];
|
||||
memset (segs, 0, numsegs*sizeof(seg_t));
|
||||
glsegextras = NULL;
|
||||
|
||||
for (i = 0; i < numSubs; ++i)
|
||||
{
|
||||
|
@ -1054,7 +1052,6 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
|||
}
|
||||
else
|
||||
{
|
||||
glsegextras = new glsegextra_t[numsegs];
|
||||
P_LoadGLZSegs (data, glnodes);
|
||||
}
|
||||
|
||||
|
@ -3092,14 +3089,11 @@ static void P_GroupLines (bool buildmap)
|
|||
{
|
||||
subsectors[i].sector = subsectors[i].firstline->sidedef->sector;
|
||||
}
|
||||
if (glsegextras != NULL)
|
||||
for (int i = 0; i < numsubsectors; i++)
|
||||
{
|
||||
for (int i = 0; i < numsubsectors; i++)
|
||||
for (jj = 0; jj < subsectors[i].numlines; ++jj)
|
||||
{
|
||||
for (jj = 0; jj < subsectors[i].numlines; ++jj)
|
||||
{
|
||||
glsegextras[subsectors[i].firstline - segs + jj].Subsector = &subsectors[i];
|
||||
}
|
||||
subsectors[i].firstline[jj].Subsector = &subsectors[i];
|
||||
}
|
||||
}
|
||||
times[0].Unclock();
|
||||
|
@ -3437,11 +3431,6 @@ void P_FreeLevelData ()
|
|||
segs = NULL;
|
||||
}
|
||||
numsegs = 0;
|
||||
if (glsegextras != NULL)
|
||||
{
|
||||
delete[] glsegextras;
|
||||
glsegextras = NULL;
|
||||
}
|
||||
if (level.sectors.Size() > 0)
|
||||
{
|
||||
delete[] level.sectors[0].e;
|
||||
|
@ -3908,7 +3897,7 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
// if the different machines' am_textured setting differs.
|
||||
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
||||
builder.Extract (nodes, numnodes,
|
||||
segs, glsegextras, numsegs,
|
||||
segs, numsegs,
|
||||
subsectors, numsubsectors,
|
||||
level.vertexes);
|
||||
endTime = I_FPSTime ();
|
||||
|
@ -4165,12 +4154,6 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
MapThingsUserData.Clear();
|
||||
|
||||
P_BackupMapData();
|
||||
|
||||
if (glsegextras != NULL)
|
||||
{
|
||||
delete[] glsegextras;
|
||||
glsegextras = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,6 @@ struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init
|
|||
};
|
||||
extern sidei_t *sidetemp;
|
||||
extern bool hasglnodes;
|
||||
extern struct glsegextra_t *glsegextras;
|
||||
|
||||
struct FMissingCount
|
||||
{
|
||||
|
|
|
@ -117,6 +117,7 @@ public:
|
|||
sightend = t2->PosRelative(task->portalgroup);
|
||||
sightstart.Z += t1->Height * 0.75;
|
||||
|
||||
portalgroup = task->portalgroup;
|
||||
Startfrac = task->Frac;
|
||||
Trace = { sightstart.X, sightstart.Y, sightend.X - sightstart.X, sightend.Y - sightstart.Y };
|
||||
Lastztop = Lastzbottom = sightstart.Z;
|
||||
|
|
|
@ -1418,12 +1418,6 @@ struct seg_t
|
|||
float sidefrac; // relative position of seg's ending vertex on owning sidedef
|
||||
};
|
||||
|
||||
struct glsegextra_t
|
||||
{
|
||||
DWORD PartnerSeg;
|
||||
subsector_t *Subsector;
|
||||
};
|
||||
|
||||
extern seg_t *segs;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue