From b31f284e289e370f2de49b884b07f932e4cfbcb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Dec 2018 08:28:09 +0100 Subject: [PATCH] - 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. --- src/p_3dfloors.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- src/p_3dfloors.h | 1 + src/p_setup.cpp | 3 +++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 732866c5b..5e8d05359 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -426,10 +426,7 @@ void P_Recalculate3DFloors(sector_t * sector) // Translucent and swimmable floors are split if they overlap with solid ones. if (ffloors.Size()>1) { - TArray oldlist; - - oldlist = ffloors; - ffloors.Clear(); + TArray oldlist = std::move(ffloors); // first delete the old dynamic stuff for(i=0;i & 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 @@ -891,6 +922,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); + } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index e260f9f5f..d0f4f500a 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -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 ); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 0cb8894da..1dd094655 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3770,6 +3770,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!!! InitRenderInfo(); // create hardware independent renderer resources for the level. screen->mVertexData->CreateVBO();