- Fixed: The nodebuilder is highly likely to renumber vertices, so we need to remember how the

original vertices map to the new ones until after vertex slopes are handled.

SVN r3380 (trunk)
This commit is contained in:
Randy Heit 2012-02-21 21:52:42 +00:00
parent 514f29a34a
commit 472ac1b07c
5 changed files with 38 additions and 13 deletions

View File

@ -65,8 +65,8 @@ const int AAPreference = 16;
FNodeBuilder::FNodeBuilder(FLevel &level) FNodeBuilder::FNodeBuilder(FLevel &level)
: Level(level), GLNodes(false), SegsStuffed(0) : Level(level), GLNodes(false), SegsStuffed(0)
{ {
VertexMap = NULL; VertexMap = NULL;
OldVertexTable = NULL;
} }
FNodeBuilder::FNodeBuilder (FLevel &level, FNodeBuilder::FNodeBuilder (FLevel &level,
@ -84,10 +84,14 @@ FNodeBuilder::FNodeBuilder (FLevel &level,
FNodeBuilder::~FNodeBuilder() FNodeBuilder::~FNodeBuilder()
{ {
if (VertexMap != 0) if (VertexMap != NULL)
{ {
delete VertexMap; delete VertexMap;
} }
if (OldVertexTable != NULL)
{
delete OldVertexTable;
}
} }
void FNodeBuilder::BuildMini(bool makeGLNodes) void FNodeBuilder::BuildMini(bool makeGLNodes)

View File

@ -209,6 +209,7 @@ public:
seg_t *&segs, glsegextra_t *&glsegextras, int &segCount, seg_t *&segs, glsegextra_t *&glsegextras, int &segCount,
subsector_t *&ssecs, int &subCount, subsector_t *&ssecs, int &subCount,
vertex_t *&verts, int &vertCount); vertex_t *&verts, int &vertCount);
const int *GetOldVertexTable();
// These are used for building sub-BSP trees for polyobjects. // These are used for building sub-BSP trees for polyobjects.
void Clear(); void Clear();
@ -227,6 +228,7 @@ public:
private: private:
IVertexMap *VertexMap; IVertexMap *VertexMap;
int *OldVertexTable;
TArray<node_t> Nodes; TArray<node_t> Nodes;
TArray<subsector_t> Subsectors; TArray<subsector_t> Subsectors;

View File

@ -75,7 +75,7 @@ angle_t FNodeBuilder::PointToAngle (fixed_t x, fixed_t y)
void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max) void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max)
{ {
int *map = (int *)alloca (max*sizeof(int)); int *map = new int[max];
int i; int i;
FPrivVert newvert; FPrivVert newvert;
@ -102,6 +102,17 @@ void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max)
Level.Lines[i].v1 = (vertex_t *)(size_t)map[v1]; Level.Lines[i].v1 = (vertex_t *)(size_t)map[v1];
Level.Lines[i].v2 = (vertex_t *)(size_t)map[v2]; Level.Lines[i].v2 = (vertex_t *)(size_t)map[v2];
} }
OldVertexTable = map;
}
// Retrieves the original vertex -> current vertex table.
// Doing so prevents the node builder from freeing it.
const int *FNodeBuilder::GetOldVertexTable()
{
int *table = OldVertexTable;
OldVertexTable = NULL;
return table;
} }
// For every sidedef in the map, create a corresponding seg. // For every sidedef in the map, create a corresponding seg.

View File

@ -73,7 +73,7 @@
#define MISSING_TEXTURE_WARN_LIMIT 20 #define MISSING_TEXTURE_WARN_LIMIT 20
void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt); void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable);
void P_SetSlopes (); void P_SetSlopes ();
void P_CopySlopes(); void P_CopySlopes();
void BloodCrypt (void *data, int key, int len); void BloodCrypt (void *data, int key, int len);
@ -3444,6 +3444,7 @@ void P_SetupLevel (char *lumpname, int position)
int numbuildthings; int numbuildthings;
int i; int i;
bool buildmap; bool buildmap;
const int *oldvertextable = NULL;
// This is motivated as follows: // This is motivated as follows:
@ -3758,7 +3759,7 @@ void P_SetupLevel (char *lumpname, int position)
bool BuildGLNodes; bool BuildGLNodes;
if (ForceNodeBuild) if (ForceNodeBuild)
{ {
BuildGLNodes = Renderer->RequireGLNodes() || am_textured || multiplayer || demoplayback || demorecording || genglnodes; BuildGLNodes = RequireGLNodes || multiplayer || demoplayback || demorecording || genglnodes;
startTime = I_FPSTime (); startTime = I_FPSTime ();
TArray<FNodeBuilder::FPolyStart> polyspots, anchors; TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
@ -3782,6 +3783,7 @@ void P_SetupLevel (char *lumpname, int position)
vertexes, numvertexes); vertexes, numvertexes);
endTime = I_FPSTime (); endTime = I_FPSTime ();
DPrintf ("BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs); DPrintf ("BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
oldvertextable = builder.GetOldVertexTable();
reloop = true; reloop = true;
} }
else else
@ -3868,7 +3870,7 @@ void P_SetupLevel (char *lumpname, int position)
if (!buildmap) if (!buildmap)
{ {
// [RH] Spawn slope creating things first. // [RH] Spawn slope creating things first.
P_SpawnSlopeMakers (&MapThingsConverted[0], &MapThingsConverted[MapThingsConverted.Size()]); P_SpawnSlopeMakers (&MapThingsConverted[0], &MapThingsConverted[MapThingsConverted.Size()], oldvertextable);
P_CopySlopes(); P_CopySlopes();
// Spawn 3d floors - must be done before spawning things so it can't be done in P_SpawnSpecials // Spawn 3d floors - must be done before spawning things so it can't be done in P_SpawnSpecials
@ -3898,6 +3900,10 @@ void P_SetupLevel (char *lumpname, int position)
delete[] buildthings; delete[] buildthings;
} }
delete map; delete map;
if (oldvertextable != NULL)
{
delete[] oldvertextable;
}
// set up world state // set up world state
P_SpawnSpecials (); P_SpawnSpecials ();

View File

@ -280,7 +280,7 @@ enum
// //
//========================================================================== //==========================================================================
static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt) static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable)
{ {
TMap<int, fixed_t> vt_heights[2]; TMap<int, fixed_t> vt_heights[2];
FMapThing *mt; FMapThing *mt;
@ -311,15 +311,17 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt)
for(int i = 0; i < numvertexdatas; i++) for(int i = 0; i < numvertexdatas; i++)
{ {
int ii = oldvertextable == NULL ? i : oldvertextable[i];
if (vertexdatas[i].flags & VERTEXFLAG_ZCeilingEnabled) if (vertexdatas[i].flags & VERTEXFLAG_ZCeilingEnabled)
{ {
vt_heights[1][i] = vertexdatas[i].zCeiling; vt_heights[1][ii] = vertexdatas[i].zCeiling;
vt_found = true; vt_found = true;
} }
if (vertexdatas[i].flags & VERTEXFLAG_ZFloorEnabled) if (vertexdatas[i].flags & VERTEXFLAG_ZFloorEnabled)
{ {
vt_heights[0][i] = vertexdatas[i].zFloor; vt_heights[0][ii] = vertexdatas[i].zFloor;
vt_found = true; vt_found = true;
} }
} }
@ -413,7 +415,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt)
// //
//=========================================================================== //===========================================================================
void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt) void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable)
{ {
FMapThing *mt; FMapThing *mt;
@ -421,7 +423,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt)
{ {
if ((mt->type >= THING_SlopeFloorPointLine && if ((mt->type >= THING_SlopeFloorPointLine &&
mt->type <= THING_SetCeilingSlope) || mt->type <= THING_SetCeilingSlope) ||
mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling) mt->type == THING_VavoomFloor || mt->type == THING_VavoomCeiling)
{ {
fixed_t x, y, z; fixed_t x, y, z;
secplane_t *refplane; secplane_t *refplane;
@ -439,7 +441,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt)
refplane = &sec->floorplane; refplane = &sec->floorplane;
} }
z = refplane->ZatPoint (x, y) + (mt->z); z = refplane->ZatPoint (x, y) + (mt->z);
if (mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling) if (mt->type == THING_VavoomFloor || mt->type == THING_VavoomCeiling)
{ {
P_VavoomSlope(sec, mt->thingid, x, y, mt->z, mt->type & 1); P_VavoomSlope(sec, mt->thingid, x, y, mt->z, mt->type & 1);
} }
@ -465,7 +467,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt)
} }
} }
P_SetSlopesFromVertexHeights(firstmt, lastmt); P_SetSlopesFromVertexHeights(firstmt, lastmt, oldvertextable);
} }