Skip to content

Commit

Permalink
Refactor|Map: Provide only const pointers to the map blockmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 14, 2013
1 parent ad20edf commit e9d660c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/include/world/blockmap.h
Expand Up @@ -122,9 +122,9 @@ class Blockmap

bool unlink(CellBlock const &cellBlock, void *elem);

int iterate(Cell const &cell, int (*callback) (void *elem, void *context), void *context);
int iterate(Cell const &cell, int (*callback) (void *elem, void *context), void *context) const;

int iterate(CellBlock const &cellBlock, int (*callback) (void *elem, void *context), void *context);
int iterate(CellBlock const &cellBlock, int (*callback) (void *elem, void *context), void *context) const;

/**
* Retrieve an immutable pointer to the underlying Gridmap instance
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/include/world/map.h
Expand Up @@ -284,22 +284,22 @@ class Map
/**
* Provides access to the mobj blockmap.
*/
Blockmap /*const*/ *mobjBlockmap() const;
Blockmap const *mobjBlockmap() const;

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

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

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

int mobjsBoxIterator(AABoxd const &box,
int (*callback) (struct mobj_s *, void *), void *parameters = 0) const;
Expand Down
22 changes: 11 additions & 11 deletions doomsday/client/src/render/blockmapvisual.cpp
Expand Up @@ -148,7 +148,7 @@ static int rendBspLeaf(BspLeaf *bspLeaf, void * /*parameters*/)
return false; // Continue iteration.
}

static int rendCellLines(Blockmap &bmap, Blockmap::Cell const &cell, void *parameters)
static int rendCellLines(Blockmap const &bmap, Blockmap::Cell const &cell, void *parameters)
{
glBegin(GL_LINES);
bmap.iterate(cell, (int (*)(void*,void*)) rendLine, parameters);
Expand All @@ -172,29 +172,29 @@ static int rendCellPolyobjLines(void *object, void *parameters)
return false; // Continue iteration.
}

static int rendCellPolyobjs(Blockmap &bmap, Blockmap::Cell const &cell, void *parameters)
static int rendCellPolyobjs(Blockmap const &bmap, Blockmap::Cell const &cell, void *parameters)
{
glBegin(GL_LINES);
bmap.iterate(cell, (int (*)(void*,void*)) rendCellPolyobjLines, parameters);
glEnd();
return false; // Continue iteration.
}

static int rendCellMobjs(Blockmap &bmap, Blockmap::Cell const &cell, void *parameters)
static int rendCellMobjs(Blockmap const &bmap, Blockmap::Cell const &cell, void *parameters)
{
glBegin(GL_QUADS);
bmap.iterate(cell, (int (*)(void*,void*)) rendMobj, parameters);
glEnd();
return false; // Continue iteration.
}

static int rendCellBspLeafs(Blockmap &bmap, Blockmap::Cell const &cell, void *parameters)
static int rendCellBspLeafs(Blockmap const &bmap, Blockmap::Cell const &cell, void *parameters)
{
bmap.iterate(cell, (int (*)(void*,void*)) rendBspLeaf, parameters);
return false; // Continue iteration.
}

static void rendBlockmapBackground(Blockmap &bmap)
static void rendBlockmapBackground(Blockmap const &bmap)
{
Blockmap::Cell const &bmapDimensions = bmap.dimensions();

Expand Down Expand Up @@ -266,7 +266,7 @@ static void drawCellInfo(Point2Raw const *_origin, char const *info)
glDisable(GL_TEXTURE_2D);
}

static void drawBlockmapInfo(Point2Raw const *_origin, Blockmap *blockmap)
static void drawBlockmapInfo(Point2Raw const *_origin, Blockmap const *blockmap)
{
DENG_ASSERT(blockmap != 0);

Expand Down Expand Up @@ -314,7 +314,7 @@ static void drawBlockmapInfo(Point2Raw const *_origin, Blockmap *blockmap)
glDisable(GL_TEXTURE_2D);
}

static void drawCellInfoBox(Blockmap *blockmap, Point2Raw const *origin,
static void drawCellInfoBox(Blockmap const *blockmap, Point2Raw const *origin,
char const *objectTypeName, Blockmap::Cell const &cell)
{
uint count = blockmap->cellElementCount(cell);
Expand All @@ -329,8 +329,8 @@ static void drawCellInfoBox(Blockmap *blockmap, Point2Raw const *origin,
* @param followMobj Mobj to center/focus the visual on. Can be @c NULL.
* @param cellDrawer Blockmap cell content drawing callback. Can be @a NULL.
*/
static void rendBlockmap(Blockmap &bmap, mobj_t *followMobj,
int (*cellDrawer) (Blockmap &bmap, Blockmap::Cell const &cell, void *parameters))
static void rendBlockmap(Blockmap const &bmap, mobj_t *followMobj,
int (*cellDrawer) (Blockmap const &bmap, Blockmap::Cell const &cell, void *parameters))
{
Blockmap::CellBlock vCellBlock;
Blockmap::Cell vCell;
Expand Down Expand Up @@ -511,10 +511,10 @@ static void rendBlockmap(Blockmap &bmap, mobj_t *followMobj,

void Rend_BlockmapDebug()
{
int (*cellDrawer) (Blockmap &blockmap, Blockmap::Cell const &cell, void *parameters);
int (*cellDrawer) (Blockmap const &blockmap, Blockmap::Cell const &cell, void *parameters);
char const *objectTypeName;
mobj_t *followMobj = 0;
Blockmap *blockmap;
Blockmap const *blockmap;
Point2Raw origin;
float scale;

Expand Down
6 changes: 4 additions & 2 deletions doomsday/client/src/world/blockmap.cpp
Expand Up @@ -320,7 +320,8 @@ int Blockmap::cellElementCount(Cell const &cell) const
return 0;
}

int Blockmap::iterate(Cell const &cell, int (*callback) (void *elem, void *parameters), void *parameters)
int Blockmap::iterate(Cell const &cell, int (*callback) (void *elem, void *parameters),
void *parameters) const
{
if(!callback) return false; // Huh?
if(CellData *cellData = (CellData *)d->cellData(cell))
Expand All @@ -343,7 +344,8 @@ static int cellDataIterateWorker(void *cdPtr, void *parameters)
return cellData->iterate(p->callback, p->parameters);
}

int Blockmap::iterate(CellBlock const &cellBlock, int (*callback) (void *elem, void *parameters), void *parameters)
int Blockmap::iterate(CellBlock const &cellBlock, int (*callback) (void *elem, void *parameters),
void *parameters) const
{
if(!callback) return false; // Huh?
CellDataIterateWorkerParams parm;
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -1206,22 +1206,22 @@ void Map::initNodePiles()
LOG_INFO(String("Completed in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
}

Blockmap *Map::mobjBlockmap() const
Blockmap const *Map::mobjBlockmap() const
{
return d->mobjBlockmap.data();
}

Blockmap *Map::polyobjBlockmap() const
Blockmap const *Map::polyobjBlockmap() const
{
return d->polyobjBlockmap.data();
}

Blockmap *Map::lineBlockmap() const
Blockmap const *Map::lineBlockmap() const
{
return d->lineBlockmap.data();
}

Blockmap *Map::bspLeafBlockmap() const
Blockmap const *Map::bspLeafBlockmap() const
{
return d->bspLeafBlockmap.data();
}
Expand Down

0 comments on commit e9d660c

Please sign in to comment.