Skip to content

Commit

Permalink
Refactor|GameMap: Construct the BSP leaf blockmap as soon as the BSP …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
danij-deng committed Apr 6, 2013
1 parent d42cc11 commit 69e34df
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 79 deletions.
1 change: 1 addition & 0 deletions doomsday/api/apis.h
Expand Up @@ -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,

Expand Down
68 changes: 18 additions & 50 deletions doomsday/client/src/edit_map.cpp
Expand Up @@ -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<Vertex *> 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<Vertex *> 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
Expand Down Expand Up @@ -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();
Expand All @@ -1239,16 +1199,18 @@ 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())
{
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);

Expand All @@ -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);

Expand Down
12 changes: 1 addition & 11 deletions doomsday/client/src/map/dam_main.cpp
Expand Up @@ -158,7 +158,7 @@ class MapArchive
}

#if 0
bool cachedMapDataIsAvailable()
bool isCachedMapDataAvailable()
{
if(DAM_MapIsValid(Str_Text(&cachedMapPath), markerLumpNum()))
{
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 3 additions & 12 deletions doomsday/client/src/map/gamemap.cpp
Expand Up @@ -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();
}
}

Expand Down
11 changes: 5 additions & 6 deletions web/plugins/buildrepository/buildrepository.php
Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit 69e34df

Please sign in to comment.