- fixed 3D floor initialization for actor spawning.

Since actors are being spawned before the renderer gets set up this needs to fully initialize the list before spawning the actors, then take it down again for creating the vertex buffer and then recreate it.
This commit is contained in:
Christoph Oelckers 2018-12-27 08:28:09 +01:00 committed by drfrag
parent 0635dc1416
commit a82d60bb71
3 changed files with 44 additions and 4 deletions

View file

@ -430,10 +430,7 @@ void P_Recalculate3DFloors(sector_t * sector)
// Translucent and swimmable floors are split if they overlap with solid ones.
if (ffloors.Size()>1)
{
TArray<F3DFloor*> oldlist;
oldlist = ffloors;
ffloors.Clear();
TArray<F3DFloor*> oldlist = std::move(ffloors);
// first delete the old dynamic stuff
for(i=0;i<oldlist.Size();i++)
@ -657,6 +654,40 @@ void P_Recalculate3DFloors(sector_t * sector)
}
}
//==========================================================================
//
// removes all dynamic data. This needs to be done once before creating
// the vertex buffer.
//
//==========================================================================
void P_ClearDynamic3DFloorData()
{
for (auto &sec : level.sectors)
{
TArray<F3DFloor*> & ffloors = sec.e->XFloor.ffloors;
// delete the dynamic stuff
for (unsigned i = 0; i < ffloors.Size(); i++)
{
F3DFloor * rover = ffloors[i];
if (rover->flags&FF_DYNAMIC)
{
delete rover;
ffloors.Delete(i);
i--;
continue;
}
if (rover->flags&FF_CLIPPED)
{
rover->flags &= ~FF_CLIPPED;
rover->flags |= FF_EXISTS;
}
}
}
}
//==========================================================================
//
// recalculates 3D floors for all attached sectors
@ -895,6 +926,11 @@ void P_Spawn3DFloors (void)
line.special=0;
line.args[0] = line.args[1] = line.args[2] = line.args[3] = line.args[4] = 0;
}
for (auto &sec : level.sectors)
{
P_Recalculate3DFloors(&sec);
}
}

View file

@ -123,6 +123,7 @@ void P_Recalculate3DFloors(sector_t *);
void P_RecalculateAttached3DFloors(sector_t * sec);
void P_RecalculateLights(sector_t *sector);
void P_RecalculateAttachedLights(sector_t *sector);
void P_ClearDynamic3DFloorData();
lightlist_t * P_GetPlaneLight(sector_t * , secplane_t * plane, bool underside);
void P_Spawn3DFloors( void );

View file

@ -3709,6 +3709,9 @@ void P_SetupLevel(const char *lumpname, int position, bool newGame)
node.len = (float)g_sqrt(fdx * fdx + fdy * fdy);
}
// CreateVBO must be run on the plain 3D floor data.
P_ClearDynamic3DFloorData();
// This must be done BEFORE the PolyObj Spawn!!!
Renderer->PreprocessLevel();