Skip to content

Commit

Permalink
Map: Encapsulate initialization of the various Blockmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 9, 2013
1 parent ef35a43 commit 853db99
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 168 deletions.
59 changes: 21 additions & 38 deletions doomsday/client/include/world/map.h
Expand Up @@ -139,11 +139,6 @@ class Map
EntityDatabase *entityDatabase;

public:
struct blockmap_s *mobjBlockmap;
struct blockmap_s *polyobjBlockmap;
struct blockmap_s *lineBlockmap;
struct blockmap_s *bspLeafBlockmap;

nodepile_t mobjNodes, lineNodes; // All kinds of wacky links.
nodeindex_t *lineLinks; // Indices to roots.

Expand Down Expand Up @@ -321,6 +316,26 @@ class Map
*/
BspLeaf *bspLeafAtPoint_FixedPrecision(Vector2d const &point) const;

/**
* Provides access to the mobj blockmap.
*/
struct blockmap_s /*const*/ *mobjBlockmap() const;

/**
* Provides access to the polyobj blockmap.
*/
struct blockmap_s /*const*/ *polyobjBlockmap() const;

/**
* Provides access to the line blockmap.
*/
struct blockmap_s /*const*/ *lineBlockmap() const;

/**
* Provides access to the BSP leaf blockmap.
*/
struct blockmap_s /*const*/ *bspLeafBlockmap() const;

int mobjsBoxIterator(AABoxd const &box,
int (*callback) (struct mobj_s *, void *), void *parameters = 0) const;

Expand Down Expand Up @@ -684,38 +699,6 @@ class Map
*/
void updateBounds();

/**
* Construct an initial (empty) Mobj Blockmap for this map.
*
* @param min Minimal coordinates for the map.
* @param max Maximal coordinates for the map.
*/
void initMobjBlockmap(const_pvec2d_t min, const_pvec2d_t max);

/**
* Construct an initial (empty) Line Blockmap for this map.
*
* @param min Minimal coordinates for the map.
* @param max Maximal coordinates for the map.
*/
void initLineBlockmap(const_pvec2d_t min, const_pvec2d_t max);

/**
* Construct an initial (empty) BspLeaf Blockmap for this map.
*
* @param min Minimal coordinates for the map.
* @param max Maximal coordinates for the map.
*/
void initBspLeafBlockmap(const_pvec2d_t min, const_pvec2d_t max);

/**
* Construct an initial (empty) Polyobj Blockmap for this map.
*
* @param min Minimal coordinates for the map.
* @param max Maximal coordinates for the map.
*/
void initPolyobjBlockmap(const_pvec2d_t min, const_pvec2d_t max);

/**
* Initialize the node piles and link rings. To be called after map load.
*/
Expand Down Expand Up @@ -779,7 +762,7 @@ class Map

public:
/*
* Runtime map editiing:
* Runtime map editing:
*/

/// @return @c true= a new BSP was built successfully for the map.
Expand Down
16 changes: 8 additions & 8 deletions doomsday/client/src/render/blockmapvisual.cpp
Expand Up @@ -533,33 +533,33 @@ void Rend_BlockmapDebug(void)
switch(bmapShowDebug)
{
default: // MobjLinks.
if(!map.mobjBlockmap) return;
if(!map.mobjBlockmap()) return;

blockmap = map.mobjBlockmap;
blockmap = map.mobjBlockmap();
cellDrawer = rendCellMobjs;
objectTypeName = "Mobj";
break;

case 2: // Lines.
if(!map.lineBlockmap) return;
if(!map.lineBlockmap()) return;

blockmap = map.lineBlockmap;
blockmap = map.lineBlockmap();
cellDrawer = rendCellLines;
objectTypeName = "Line";
break;

case 3: // BspLeafs.
if(!map.bspLeafBlockmap) return;
if(!map.bspLeafBlockmap()) return;

blockmap = map.bspLeafBlockmap;
blockmap = map.bspLeafBlockmap();
cellDrawer = rendCellBspLeafs;
objectTypeName = "BspLeaf";
break;

case 4: // PolyobjLinks.
if(!map.polyobjBlockmap) return;
if(!map.polyobjBlockmap()) return;

blockmap = map.polyobjBlockmap;
blockmap = map.polyobjBlockmap();
cellDrawer = rendCellPolyobjs;
objectTypeName = "Polyobj";
break;
Expand Down

0 comments on commit 853db99

Please sign in to comment.