From 046453076ed5bc601aa049583ac3ed74f00ae122 Mon Sep 17 00:00:00 2001 From: danij Date: Mon, 18 Mar 2013 07:11:51 +0000 Subject: [PATCH] Refactor: Reorganized load-time sector/plane data initialization --- doomsday/client/src/edit_map.cpp | 53 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/doomsday/client/src/edit_map.cpp b/doomsday/client/src/edit_map.cpp index 3ea72f5295..26fca25fe6 100644 --- a/doomsday/client/src/edit_map.cpp +++ b/doomsday/client/src/edit_map.cpp @@ -593,6 +593,9 @@ static void linkToSectorEmitterChain(Sector §or, ddmobj_base_t &otherEmitter static void finishSectors(GameMap &map) { + buildSectorBspLeafLists(map); + buildSectorLineLists(map); + for(uint i = 0; i < map.sectorCount(); ++i) { Sector §or = map.sectors[i]; @@ -601,22 +604,6 @@ static void finishSectors(GameMap &map) sector.updateRoughArea(); sector.updateSoundEmitterOrigin(); - // Set target heights for each plane. - for(uint k = 0; k < sector.planeCount(); ++k) - { - Plane &plane = sector.plane(k); - - plane._targetHeight = - plane._oldHeight[0] = - plane._oldHeight[1] = - plane._visHeight = plane._height; - - plane._visHeightDelta = 0; - - /// @todo Can't this be deferred? -ds - plane.surface().updateSoundEmitterOrigin(); - } - /* * Chain sound emitters (ddmobj_base_t) owned by all Surfaces in the * sector. These chains are used for efficiently traversing all of the @@ -958,16 +945,18 @@ static void finishPlanes(GameMap &dest) foreach(Plane *plane, sector.planes()) { - // Initialize the surface. - /// @todo The initial material should be the "unknown" material. + // Set target heights for each plane. + plane->_targetHeight = + plane->_oldHeight[0] = + plane->_oldHeight[1] = + plane->_visHeight = plane->_height; + + plane->_visHeightDelta = 0; + plane->surface().updateSoundEmitterOrigin(); #ifdef __CLIENT__ - /** - * Resize the biassurface lists for the BSP leaf planes. - * If we are in map setup mode, don't create the biassurfaces now, - * as planes are created before the bias system is available. - */ + // Resize the biassurface lists for the BSP leaf planes. foreach(BspLeaf *bspLeaf, sector.bspLeafs()) { uint n = 0; @@ -984,7 +973,12 @@ static void finishPlanes(GameMap &dest) bspLeaf->_bsuf = 0; } - if(!ddMapSetup) + /* + * @todo So where is this data initialized now? -ds + * If we are in map setup mode, don't create the biassurfaces now, + * as planes are created before the bias system is available. + */ + /*if(!ddMapSetup) { biassurface_t *bsuf = SB_CreateSurface(); @@ -997,7 +991,7 @@ static void finishPlanes(GameMap &dest) } newList[n] = bsuf; - } + }*/ bspLeaf->_bsuf = newList; } @@ -1639,12 +1633,6 @@ boolean MPE_End() } } - buildSectorBspLeafLists(*gamemap); - - // Map must be polygonized and the sector BSP leaf lists must be built before - // this is called! - finishPlanes(*gamemap); - // Destroy the rest of editable map, we are finished with it. editMap.clear(); @@ -1659,11 +1647,10 @@ boolean MPE_End() } editMapInited = false; - buildSectorLineLists(*gamemap); - finishSideDefs(*gamemap); finishLines(*gamemap); finishSectors(*gamemap); + finishPlanes(*gamemap); gamemap->updateBounds();