- Added support for loading ZGL3/XGL3 nodes.

- Added additional debug spew for the nodebuilder.
- Restore the nodebuilder's debug spew that was present in ZDBSP but not the internal version.
  Use the CRT's printf for this output to ensure that it is identical to ZDBSP's output for the
  same input.

SVN r3980 (trunk)
This commit is contained in:
Randy Heit 2012-12-07 06:16:07 +00:00
parent b1543fdc08
commit d77297e969
8 changed files with 92 additions and 23 deletions

View file

@ -243,12 +243,16 @@ void FNodeBuilder::CreateSubsectorsForReal ()
D(Printf (PRINT_LOG, "Output subsector %d:\n", Subsectors.Size()));
for (unsigned int i = firstline; i < SegList.Size(); ++i)
{
D(Printf (PRINT_LOG, " Seg %5d%c(%5d,%5d)-(%5d,%5d)\n", SegList[i].SegPtr - &Segs[0],
D(Printf (PRINT_LOG, " Seg %5d%c%d(%5d,%5d)-%d(%5d,%5d) [%08x,%08x]-[%08x,%08x]\n", SegList[i].SegPtr - &Segs[0],
SegList[i].SegPtr->linedef == -1 ? '+' : ' ',
SegList[i].SegPtr->v1,
Vertices[SegList[i].SegPtr->v1].x>>16,
Vertices[SegList[i].SegPtr->v1].y>>16,
SegList[i].SegPtr->v2,
Vertices[SegList[i].SegPtr->v2].x>>16,
Vertices[SegList[i].SegPtr->v2].y>>16));
Vertices[SegList[i].SegPtr->v2].y>>16,
Vertices[SegList[i].SegPtr->v1].x, Vertices[SegList[i].SegPtr->v1].y,
Vertices[SegList[i].SegPtr->v2].x, Vertices[SegList[i].SegPtr->v2].y));
SegList[i].SegNum = DWORD(SegList[i].SegPtr - &Segs[0]);
}
Subsectors.Push (sub);
@ -330,7 +334,8 @@ bool FNodeBuilder::CheckSubsector (DWORD set, node_t &node, DWORD &splitseg)
do
{
D(Printf (PRINT_LOG, " - seg %d(%d,%d)-(%d,%d) line %d front %d back %d\n", seg,
D(Printf (PRINT_LOG, " - seg %d%c(%d,%d)-(%d,%d) line %d front %d back %d\n", seg,
Segs[seg].linedef == -1 ? '+' : ' ',
Vertices[Segs[seg].v1].x>>16, Vertices[Segs[seg].v1].y>>16,
Vertices[Segs[seg].v2].x>>16, Vertices[Segs[seg].v2].y>>16,
Segs[seg].linedef,

View file

@ -34,6 +34,8 @@ public:
FEvent *FindEvent (double distance) const;
void DeleteAll ();
void PrintTree () const { PrintTree (Root); }
private:
FEvent Nil;
FEvent *Root;
@ -42,6 +44,8 @@ private:
void DeletionTraverser (FEvent *event);
FEvent *Successor (FEvent *event) const;
FEvent *Predecessor (FEvent *event) const;
void PrintTree (const FEvent *event) const;
};
struct FSimpleVert

View file

@ -210,3 +210,17 @@ FEvent *FEventTree::GetMinimum ()
}
return node;
}
void FEventTree::PrintTree (const FEvent *event) const
{
// Use the CRT's sprintf so that it shares the same formatting as ZDBSP's output.
char buff[100];
if (event != &Nil)
{
PrintTree(event->Left);
sprintf(buff, " Distance %g, vertex %d, seg %u\n",
sqrt(event->Distance/4294967296.0), event->Info.Vertex, (unsigned)event->Info.FrontSeg);
Printf(PRINT_LOG, "%s", buff);
PrintTree(event->Right);
}
}

View file

@ -78,7 +78,8 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
memcpy (outNodes, &Nodes[0], nodeCount*sizeof(node_t));
for (i = 0; i < nodeCount; ++i)
{
D(Printf(PRINT_LOG, "Node %d:\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));
// Go backwards because on 64-bit systems, both of the intchildren are
// inside the first in-game child.
for (int j = 1; j >= 0; --j)
@ -296,12 +297,14 @@ int FNodeBuilder::CloseSubsector (TArray<glseg_t> &segs, int subsector, vertex_t
{
seg = &Segs[SegList[j].SegNum];
angle_t ang = PointToAngle (Vertices[seg->v1].x - midx, Vertices[seg->v1].y - midy);
Printf(PRINT_LOG, "%d%c %5d(%5d,%5d)->%5d(%5d,%5d) - %3.3f %d,%d\n", j,
Printf(PRINT_LOG, "%d%c %5d(%5d,%5d)->%5d(%5d,%5d) - %3.5f %d,%d [%08x,%08x]-[%08x,%08x]\n", j,
seg->linedef == -1 ? '+' : ':',
seg->v1, Vertices[seg->v1].x>>16, Vertices[seg->v1].y>>16,
seg->v2, Vertices[seg->v2].x>>16, Vertices[seg->v2].y>>16,
double(ang/2)*180/(1<<30),
seg->planenum, seg->planefront);
seg->planenum, seg->planefront,
Vertices[seg->v1].x, Vertices[seg->v1].y,
Vertices[seg->v2].x, Vertices[seg->v2].y);
}
#endif
@ -395,12 +398,16 @@ int FNodeBuilder::CloseSubsector (TArray<glseg_t> &segs, int subsector, vertex_t
Printf(PRINT_LOG, "Output GL subsector %d:\n", subsector);
for (i = segs.Size() - count; i < (int)segs.Size(); ++i)
{
Printf(PRINT_LOG, " Seg %5d%c(%5d,%5d)-(%5d,%5d)\n", i,
Printf(PRINT_LOG, " Seg %5d%c(%5d,%5d)-(%5d,%5d) [%08x,%08x]-[%08x,%08x]\n", i,
segs[i].linedef == NULL ? '+' : ' ',
segs[i].v1->x>>16,
segs[i].v1->y>>16,
segs[i].v2->x>>16,
segs[i].v2->y>>16);
segs[i].v2->y>>16,
segs[i].v1->x,
segs[i].v1->y,
segs[i].v2->x,
segs[i].v2->y);
}
#endif

View file

@ -83,6 +83,8 @@ double FNodeBuilder::AddIntersection (const node_t &node, int vertex)
// seg information will be messed up in the generated tree.
void FNodeBuilder::FixSplitSharers (const node_t &node)
{
D(Printf(PRINT_LOG, "events:\n"));
D(Events.PrintTree());
for (unsigned int i = 0; i < SplitSharers.Size(); ++i)
{
DWORD seg = SplitSharers[i].Seg;
@ -95,6 +97,18 @@ void FNodeBuilder::FixSplitSharers (const node_t &node)
continue;
}
// Use the CRT's printf so the formatting matches ZDBSP's
D(char buff[200]);
D(sprintf(buff, "Considering events on seg %d(%d[%d,%d]->%d[%d,%d]) [%g:%g]\n", seg,
Segs[seg].v1,
Vertices[Segs[seg].v1].x>>16,
Vertices[Segs[seg].v1].y>>16,
Segs[seg].v2,
Vertices[Segs[seg].v2].x>>16,
Vertices[Segs[seg].v2].y>>16,
SplitSharers[i].Distance, event->Distance));
D(Printf(PRINT_LOG, "%s", buff));
if (SplitSharers[i].Forward)
{
event = Events.GetSuccessor (event);

View file

@ -185,6 +185,9 @@ int FNodeBuilder::CreateSeg (int linenum, int sidenum)
segnum = (int)Segs.Push (seg);
Vertices[seg.v1].segs = segnum;
Vertices[seg.v2].segs2 = segnum;
D(Printf(PRINT_LOG, "Seg %4d: From line %d, side %s (%5d,%5d)-(%5d,%5d) [%08x,%08x]-[%08x,%08x]\n", segnum, linenum, sidenum ? "back " : "front",
Vertices[seg.v1].x>>16, Vertices[seg.v1].y>>16, Vertices[seg.v2].x>>16, Vertices[seg.v2].y>>16,
Vertices[seg.v1].x, Vertices[seg.v1].y, Vertices[seg.v2].x, Vertices[seg.v2].y));
return segnum;
}

View file

@ -853,15 +853,18 @@ bool P_LoadGLNodes(MapData * map)
{
if (map->MapLumps[ML_GLZNODES].Reader && map->MapLumps[ML_GLZNODES].Reader->GetLength() != 0)
{
const int idcheck = MAKE_ID('Z','G','L','N');
const int idcheck2 = MAKE_ID('Z','G','L','2');
const int idcheck3 = MAKE_ID('X','G','L','N');
const int idcheck4 = MAKE_ID('X','G','L','2');
const int idcheck1a = MAKE_ID('Z','G','L','N');
const int idcheck2a = MAKE_ID('Z','G','L','2');
const int idcheck3a = MAKE_ID('Z','G','L','3');
const int idcheck1b = MAKE_ID('X','G','L','N');
const int idcheck2b = MAKE_ID('X','G','L','2');
const int idcheck3b = MAKE_ID('X','G','L','3');
int id;
map->Seek(ML_GLZNODES);
map->file->Read (&id, 4);
if (id == idcheck || id == idcheck2 || id == idcheck3 || id == idcheck4)
if (id == idcheck1a || id == idcheck2a || id == idcheck3a ||
id == idcheck1b || id == idcheck2b || id == idcheck3b)
{
try
{

View file

@ -892,7 +892,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type)
BYTE side;
data >> v1 >> partner;
if (type == 2)
if (type >= 2)
{
data >> line;
}
@ -1044,6 +1044,8 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
memset (nodes, 0, sizeof(node_t)*numNodes);
for (i = 0; i < numNodes; ++i)
{
if (glnodes < 3)
{
SWORD x, y, dx, dy;
@ -1052,6 +1054,11 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
nodes[i].y = y << FRACBITS;
nodes[i].dx = dx << FRACBITS;
nodes[i].dy = dy << FRACBITS;
}
else
{
data >> nodes[i].x >> nodes[i].y >> nodes[i].dx >> nodes[i].dy;
}
for (int j = 0; j < 2; ++j)
{
for (int k = 0; k < 4; ++k)
@ -1100,6 +1107,11 @@ void P_LoadZNodes (FileReader &dalump, DWORD id)
compressed = true;
break;
case MAKE_ID('Z','G','L','3'):
type = 3;
compressed = true;
break;
case MAKE_ID('X','N','O','D'):
type = 0;
compressed = false;
@ -1115,6 +1127,11 @@ void P_LoadZNodes (FileReader &dalump, DWORD id)
compressed = false;
break;
case MAKE_ID('X','G','L','3'):
type = 3;
compressed = false;
break;
default:
return;
}
@ -3680,7 +3697,7 @@ void P_SetupLevel (char *lumpname, int position)
{
// Check for compressed nodes first, then uncompressed nodes
FWadLump test;
DWORD id = MAKE_ID('X','x','X','x'), idcheck = 0, idcheck2 = 0, idcheck3 = 0, idcheck4 = 0;
DWORD id = MAKE_ID('X','x','X','x'), idcheck = 0, idcheck2 = 0, idcheck3 = 0, idcheck4 = 0, idcheck5 = 0, idcheck6 = 0;
if (map->Size(ML_ZNODES) != 0)
{
@ -3694,8 +3711,10 @@ void P_SetupLevel (char *lumpname, int position)
map->Seek(ML_GLZNODES);
idcheck = MAKE_ID('Z','G','L','N');
idcheck2 = MAKE_ID('Z','G','L','2');
idcheck3 = MAKE_ID('X','G','L','N');
idcheck4 = MAKE_ID('X','G','L','2');
idcheck3 = MAKE_ID('Z','G','L','3');
idcheck4 = MAKE_ID('X','G','L','N');
idcheck5 = MAKE_ID('X','G','L','2');
idcheck6 = MAKE_ID('X','G','L','3');
}
map->file->Read (&id, 4);