From 69e34dfbe0ed8e07c6a69fac15d285c92711b234 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 6 Apr 2013 07:58:51 +0100 Subject: [PATCH] Refactor|GameMap: Construct the BSP leaf blockmap as soon as the BSP is built The BSP leaf blockmap would be useful to accelerate other tasks in the map load process, so get this ready at the earliest opportunity. Also added back the DE_API_MAP_v1 definition in apis.h, as it may be useful in future for reference. Todo for later: Optimize S_DetermineBspLeafsAffectingSectorReverb() (and others), making use of the BSP leaf blockmap. --- doomsday/api/apis.h | 1 + doomsday/client/src/edit_map.cpp | 68 +++++-------------- doomsday/client/src/map/dam_main.cpp | 12 +--- doomsday/client/src/map/gamemap.cpp | 15 +--- .../buildrepository/buildrepository.php | 11 ++- 5 files changed, 28 insertions(+), 79 deletions(-) diff --git a/doomsday/api/apis.h b/doomsday/api/apis.h index adff6fe6b9..a247e57112 100644 --- a/doomsday/api/apis.h +++ b/doomsday/api/apis.h @@ -70,6 +70,7 @@ enum { DE_API_INTERNAL_DATA_v1 = 1000, // 1.10 DE_API_INTERNAL_DATA = DE_API_INTERNAL_DATA_v1, + DE_API_MAP_v1 = 1100, // 1.10 DE_API_MAP_v2 = 1101, // 1.11 DE_API_MAP = DE_API_MAP_v2, diff --git a/doomsday/client/src/edit_map.cpp b/doomsday/client/src/edit_map.cpp index 57bb47cbd2..1b88b06a20 100644 --- a/doomsday/client/src/edit_map.cpp +++ b/doomsday/client/src/edit_map.cpp @@ -969,54 +969,7 @@ void MPE_DetectOverlappingLines(GameMap *map) VERBOSE( Con_Message("Detected %lu overlapping linedefs.", (unsigned long) numOverlaps) ) } -#endif -/** - * Find the extremal coordinates for the given set of vertexes. - * - * @param vertexes List of editable vertexes to be scanned. - * @param min Minimal coordinates will be written here. - * @param max Maximal coordinates will be written here. - */ -static void findBounds(QList const &vertexes, vec2d_t min, vec2d_t max) -{ - if(!min && !max) return; - - if(!vertexes.count()) - { - V2d_Set(min, DDMAXFLOAT, DDMAXFLOAT); - V2d_Set(max, DDMINFLOAT, DDMINFLOAT); - return; - } - - vec2d_t bounds[2], point; - - QListIterator vIt(vertexes); - - // Add the first vertex. - Vertex *vertex = vIt.next(); - V2d_Set(point, vertex->origin()[VX], vertex->origin()[VY]); - V2d_InitBox(bounds, point); - - // Add the rest of the vertexes. - while(vIt.hasNext()) - { - Vertex *vertex = vIt.next(); - V2d_Set(point, vertex->origin()[VX], vertex->origin()[VY]); - V2d_AddToBox(bounds, point); - } - - if(min) - { - V2d_Set(min, bounds[0][VX], bounds[0][VY]); - } - if(max) - { - V2d_Set(max, bounds[1][VX], bounds[1][VY]); - } -} - -#if 0 /** * The REJECT resource is a LUT that provides the results of trivial * line-of-sight tests between sectors. This is done with a matrix of sector @@ -1229,6 +1182,13 @@ boolean MPE_End() foreach(LineDef *line, editMap.lines) { map->_lines.append(line); // Take ownership. + + line->updateSlopeType(); + line->updateAABox(); + + line->_length = V2d_Length(line->_direction); + line->_angle = bamsAtan2(int( line->_direction[VY] ), + int( line->_direction[VX] )); } buildVertexLineOwnerRings(); @@ -1239,8 +1199,10 @@ boolean MPE_End() /* * Build blockmaps. */ + map->updateBounds(); + vec2d_t min, max; - findBounds(editMap.vertexes, min, max); + map->bounds(min, max); map->initLineBlockmap(min, max); foreach(LineDef *line, map->lines()) @@ -1248,7 +1210,7 @@ boolean MPE_End() map->linkLine(*line); } - // Mobj and Polyobj blockmaps are maintained dynamically. + // The mobj and polyobj blockmaps are maintained dynamically. map->initMobjBlockmap(min, max); map->initPolyobjBlockmap(min, max); @@ -1273,7 +1235,13 @@ boolean MPE_End() editMapInited = false; map->finishMapElements(); - map->updateBounds(); + + // We can now initialize the BSP leaf blockmap. + map->initBspLeafBlockmap(min, max); + foreach(BspLeaf *bspLeaf, map->bspLeafs()) + { + map->linkBspLeaf(*bspLeaf); + } S_DetermineBspLeafsAffectingSectorReverb(map); diff --git a/doomsday/client/src/map/dam_main.cpp b/doomsday/client/src/map/dam_main.cpp index 24013fc4fa..d97eeac44b 100644 --- a/doomsday/client/src/map/dam_main.cpp +++ b/doomsday/client/src/map/dam_main.cpp @@ -158,7 +158,7 @@ class MapArchive } #if 0 - bool cachedMapDataIsAvailable() + bool isCachedMapDataAvailable() { if(DAM_MapIsValid(Str_Text(&cachedMapPath), markerLumpNum())) { @@ -339,16 +339,6 @@ GameMap *DAM_LoadMap(de::Uri const &uri) Rend_DecorInit(); - vec2d_t min, max; - map->bounds(min, max); - - // Init blockmap for searching BSP leafs. - map->initBspLeafBlockmap(min, max); - foreach(BspLeaf *bspLeaf, map->bspLeafs()) - { - map->linkBspLeaf(*bspLeaf); - } - // Generate the unique map id. lumpnum_t markerLumpNum = App_FileSystem().lumpNumForName(arcInfo.mapUri().path()); de::File1 &markerLump = App_FileSystem().nameIndex().lump(markerLumpNum); diff --git a/doomsday/client/src/map/gamemap.cpp b/doomsday/client/src/map/gamemap.cpp index 0b4a7baf13..480fcca432 100644 --- a/doomsday/client/src/map/gamemap.cpp +++ b/doomsday/client/src/map/gamemap.cpp @@ -208,19 +208,10 @@ DENG2_PIMPL(GameMap) void finishLines() { foreach(LineDef *line, self._lines) + for(int i = 0; i < 2; ++i) { - line->updateSlopeType(); - line->updateAABox(); - - line->_length = V2d_Length(line->_direction); - line->_angle = bamsAtan2(int( line->_direction[VY] ), - int( line->_direction[VX] )); - - for(int i = 0; i < 2; ++i) - { - line->side(i).updateSurfaceTangents(); - line->side(i).updateSoundEmitterOrigins(); - } + line->side(i).updateSurfaceTangents(); + line->side(i).updateSoundEmitterOrigins(); } } diff --git a/web/plugins/buildrepository/buildrepository.php b/web/plugins/buildrepository/buildrepository.php index dd04aaa55c..0a491cb8b7 100644 --- a/web/plugins/buildrepository/buildrepository.php +++ b/web/plugins/buildrepository/buildrepository.php @@ -338,9 +338,9 @@ private function constructBuilds(&$builds) { try { - // Grab a copy and store it in the local file cache. + // Grab a copy of the latest build log.. $logXml = self::retrieveBuildLogXml($buildLogUri); - if($logXml == FALSE) + if($logXml === false) throw new Exception('Failed retrieving build log'); // Attempt to parse the new log. @@ -352,11 +352,10 @@ private function constructBuilds(&$builds) } catch(Exception $e) { - // Free up resources. - unset($logXml); - // Log the error. - trigger_error(sprintf('Failed parsing new XML build log.\nError:%s', $e->getMessage()), E_USER_WARNING); + $msg = "Failed parsing new XML build log."; + $msg .= "\nError:" . $e->getMessage(); + trigger_error($msg, E_USER_WARNING); // Touch our cached copy so we don't try again too soon. $FrontController->contentCache()->touch($logCacheName);