Skip to content

Commit

Permalink
API|Map: Unused functions removed; P_PathTraverse reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Oct 12, 2013
1 parent 76c5eef commit ec3c300
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 279 deletions.
28 changes: 7 additions & 21 deletions doomsday/api/api_map.h
Expand Up @@ -164,8 +164,11 @@ typedef struct lineopening_s {
* @ingroup apiFlags map
*/
///@{
#define PT_ADDLINES 1 ///< Intercept with Lines.
#define PT_ADDMOBJS 2 ///< Intercept with Mobjs.
#define PTF_LINE 0x1 ///< Intercept with map lines.
#define PTF_MOBJ 0x2 ///< Intercept with mobjs.

/// Process all interceptable map element types.
#define PTF_ALL PTF_LINE | PTF_MOBJ
///@}

typedef enum intercepttype_e {
Expand Down Expand Up @@ -273,9 +276,7 @@ DENG_API_TYPEDEF(Map)
int (*L_BoxOnSide)(Line *line, AABoxd const *box);
int (*L_BoxOnSide_FixedPrecision)(Line *line, AABoxd const *box);
coord_t (*L_PointDistance)(Line *line, coord_t const point[2], coord_t *offset);
coord_t (*L_PointXYDistance)(Line *line, coord_t x, coord_t y, coord_t *offset);
coord_t (*L_PointOnSide)(Line const *line, coord_t const point[2]);
coord_t (*L_PointXYOnSide)(Line const *line, coord_t x, coord_t y);
int (*L_MobjsIterator)(Line *line, int (*callback) (struct mobj_s *, void *), void *context);
void (*L_Opening)(Line *line, LineOpening *opening);

Expand Down Expand Up @@ -309,9 +310,6 @@ DENG_API_TYPEDEF(Map)
*/
Sector *(*S_AtPoint_FixedPrecision)(coord_t const point[2]);

/// @copydoc S_AtPoint_FixedPrecision()
Sector *(*S_AtPoint_FixedPrecisionXY)(coord_t x, coord_t y);

// Map Objects

struct mobj_s *(*MO_CreateXYZ)(thinkfunc_t function, coord_t x, coord_t y, coord_t z, angle_t angle, coord_t radius, coord_t height, int ddflags);
Expand Down Expand Up @@ -425,15 +423,8 @@ DENG_API_TYPEDEF(Map)

// Traversers

int (*PathTraverse)(coord_t const from[2], coord_t const to[2], int (*callback) (TraceState *trace, struct intercept_s const *, void *context), void *context);
int (*PathTraverse2)(coord_t const from[2], coord_t const to[2], int flags, int (*callback) (TraceState *trace, struct intercept_s const *, void *context), void *context);
int (*PathTraverse)(coord_t const from[2], coord_t const to[2], int flags, int (*callback) (TraceState *trace, struct intercept_s const *, void *context)/*, context=0*/);

/**
* Same as P_PathTraverse except 'from' and 'to' arguments are specified
* as two sets of separate X and Y map space coordinates.
*/
int (*PathXYTraverse2)(coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, int flags, int (*callback) (TraceState *trace, struct intercept_s const *, void *context), void *context);
int (*PathXYTraverse)(coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, int flags, int (*callback) (TraceState *trace, struct intercept_s const *, void *context)/*, context=0*/);

/**
* Traces a line of sight.
Expand Down Expand Up @@ -663,15 +654,12 @@ DENG_API_T(Map);
#define Line_BoxOnSide _api_Map.L_BoxOnSide
#define Line_BoxOnSide_FixedPrecision _api_Map.L_BoxOnSide_FixedPrecision
#define Line_PointDistance _api_Map.L_PointDistance
#define Line_PointXYDistance _api_Map.L_PointXYDistance
#define Line_PointOnSide _api_Map.L_PointOnSide
#define Line_PointXYOnSide _api_Map.L_PointXYOnSide
#define Line_TouchingMobjsIterator _api_Map.L_MobjsIterator
#define Line_Opening _api_Map.L_Opening

#define Sector_TouchingMobjsIterator _api_Map.S_TouchingMobjsIterator
#define Sector_AtPoint_FixedPrecision _api_Map.S_AtPoint_FixedPrecision
#define Sector_AtPoint_FixedPrecisionXY _api_Map.S_AtPoint_FixedPrecisionXY

#define Mobj_CreateXYZ _api_Map.MO_CreateXYZ
#define Mobj_Destroy _api_Map.MO_Destroy
Expand Down Expand Up @@ -699,10 +687,8 @@ DENG_API_T(Map);

#define BspLeaf_BoxIterator _api_Map.BL_BoxIterator

#define P_PathTraverse2 _api_Map.PathTraverse2
#define P_PathTraverse _api_Map.PathTraverse
#define P_PathXYTraverse2 _api_Map.PathXYTraverse2
#define P_PathXYTraverse _api_Map.PathXYTraverse
#define P_PathTraverse2 _api_Map.PathTraverse2
#define P_CheckLineSight _api_Map.CheckLineSight
#define P_TraceAdjustOpening _api_Map.TraceAdjustOpening
#define P_SetTraceOpening _api_Map.SetTraceOpening
Expand Down
7 changes: 4 additions & 3 deletions doomsday/client/include/world/blockmap.h
Expand Up @@ -138,11 +138,11 @@ class Blockmap

bool link(Cell const &cell, void *elem);

bool link(CellBlock const &cellBlock, void *elem);
bool link(AABoxd const &region, void *elem);

bool unlink(Cell const &cell, void *elem);

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

void unlinkAll();

Expand All @@ -152,7 +152,8 @@ class Blockmap
int iterate(Cell const &cell, int (*callback) (void *elem, void *context), void *context = 0) const;

/**
* Iterate over all elements in the specified map space @a region.
* Iterate over all elements in cells which intercept the specified map space
* @a region.
*/
int iterate(AABoxd const &region, int (*callback) (void *elem, void *context), void *context = 0) const;

Expand Down
57 changes: 5 additions & 52 deletions doomsday/client/src/world/api_map.cpp
Expand Up @@ -1586,14 +1586,6 @@ DENG_EXTERN_C Sector *Sector_AtPoint_FixedPrecision(const_pvec2d_t point)
return App_World().map().bspLeafAt_FixedPrecision(point).sectorPtr();
}

#undef Sector_AtPoint_FixedPrecisionXY
DENG_EXTERN_C Sector *Sector_AtPoint_FixedPrecisionXY(coord_t x, coord_t y)
{
if(!App_World().hasMap()) return 0;
coord_t point[2] = { x, y };
return App_World().map().bspLeafAt_FixedPrecision(point).sectorPtr();
}

#undef Mobj_BoxIterator
DENG_EXTERN_C int Mobj_BoxIterator(AABoxd const *box,
int (*callback) (mobj_t *, void *), void *context)
Expand Down Expand Up @@ -1729,11 +1721,11 @@ static int traverseMapPath(Map &map, Vector2d const &from, Vector2d const &to,
validCount++;

// Step #1: Collect intercepts.
if(flags & PT_ADDLINES)
if(flags & PTF_LINE)
{
map.linePathIterator(from, to, collectCellLineInterceptsWorker, &trace);
}
if(flags & PT_ADDMOBJS)
if(flags & PTF_MOBJ)
{
map.mobjPathIterator(from, to, collectCellMobjInterceptsWorker, &trace);
}
Expand All @@ -1752,30 +1744,10 @@ DENG_EXTERN_C int P_PathTraverse2(const_pvec2d_t from, const_pvec2d_t to,

#undef P_PathTraverse
DENG_EXTERN_C int P_PathTraverse(const_pvec2d_t from, const_pvec2d_t to,
int flags, traverser_t callback)
{
if(!App_World().hasMap()) return false; // Continue iteration.
return traverseMapPath(App_World().map(), from, to, flags, callback);
}

#undef P_PathXYTraverse2
DENG_EXTERN_C int P_PathXYTraverse2(coord_t fromX, coord_t fromY,
coord_t toX, coord_t toY, int flags, traverser_t callback, void *context)
traverser_t callback, void *context)
{
if(!App_World().hasMap()) return false; // Continue iteration.
return traverseMapPath(App_World().map(),
Vector2d(fromX, fromY), Vector2d(toX, toY),
flags, callback, context);
}

#undef P_PathXYTraverse
DENG_EXTERN_C int P_PathXYTraverse(coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, int flags,
traverser_t callback)
{
if(!App_World().hasMap()) return false; // Continue iteration.
return traverseMapPath(App_World().map(),
Vector2d(fromX, fromY), Vector2d(toX, toY),
flags, callback);
return traverseMapPath(App_World().map(), from, to, PTF_ALL, callback, context);
}

#undef P_CheckLineSight
Expand Down Expand Up @@ -1888,13 +1860,6 @@ DENG_EXTERN_C coord_t Line_PointDistance(Line *line, coord_t const point[2], coo
return line->pointDistance(point, offset);
}

#undef Line_PointXYDistance
DENG_EXTERN_C coord_t Line_PointXYDistance(Line* line, coord_t x, coord_t y, coord_t* offset)
{
DENG_ASSERT(line);
return line->pointDistance(Vector2d(x, y), offset);
}

#undef Line_PointOnSide
DENG_EXTERN_C coord_t Line_PointOnSide(Line const *line, coord_t const point[2])
{
Expand All @@ -1908,13 +1873,6 @@ DENG_EXTERN_C coord_t Line_PointOnSide(Line const *line, coord_t const point[2])
return line->pointOnSide(point);
}

#undef Line_PointXYOnSide
DENG_EXTERN_C coord_t Line_PointXYOnSide(Line const *line, coord_t x, coord_t y)
{
DENG_ASSERT(line);
return line->pointOnSide(Vector2d(x, y));
}

#undef Line_BoxOnSide
DENG_EXTERN_C int Line_BoxOnSide(Line *line, AABoxd const *box)
{
Expand Down Expand Up @@ -1948,15 +1906,12 @@ DENG_DECLARE_API(Map) =
Line_BoxOnSide,
Line_BoxOnSide_FixedPrecision,
Line_PointDistance,
Line_PointXYDistance,
Line_PointOnSide,
Line_PointXYOnSide,
Line_TouchingMobjsIterator,
Line_Opening,

Sector_TouchingMobjsIterator,
Sector_AtPoint_FixedPrecision,
Sector_AtPoint_FixedPrecisionXY,

Mobj_CreateXYZ,
Mobj_Destroy,
Expand Down Expand Up @@ -1984,10 +1939,8 @@ DENG_DECLARE_API(Map) =

BspLeaf_BoxIterator,

P_PathTraverse2,
P_PathTraverse,
P_PathXYTraverse2,
P_PathXYTraverse,
P_PathTraverse2,
P_CheckLineSight,
P_TraceAdjustOpening,

Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/world/blockmap.cpp
Expand Up @@ -455,13 +455,13 @@ bool Blockmap::link(Cell const &cell, void *elem)
return false; // Outside the blockmap?
}

bool Blockmap::link(CellBlock const &cellBlock_, void *elem)
bool Blockmap::link(AABoxd const &region, void *elem)
{
if(!elem) return false; // Huh?

bool didLink = false;

CellBlock cellBlock = cellBlock_;
CellBlock cellBlock = toCellBlock(region);
d->clipBlock(cellBlock);

Cell cell;
Expand Down Expand Up @@ -491,13 +491,13 @@ bool Blockmap::unlink(Cell const &cell, void *elem)
return false;
}

bool Blockmap::unlink(CellBlock const &cellBlock_, void *elem)
bool Blockmap::unlink(AABoxd const &region, void *elem)
{
if(!elem) return false; // Huh?

bool didUnlink = false;

CellBlock cellBlock = cellBlock_;
CellBlock cellBlock = toCellBlock(region);
d->clipBlock(cellBlock);

Cell cell;
Expand Down
38 changes: 13 additions & 25 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -834,8 +834,7 @@ DENG2_OBSERVES(bsp::Partitioner, UnclosedSectorFound)
// BspLeafs without a sector cluster don't get in.
if(bspLeaf->hasCluster())
{
BlockmapCellBlock cellBlock = bspLeafBlockmap->toCellBlock(bspLeaf->poly().aaBox());
bspLeafBlockmap->link(cellBlock, bspLeaf);
bspLeafBlockmap->link(bspLeaf->poly().aaBox(), bspLeaf);
}
}
}
Expand Down Expand Up @@ -1854,14 +1853,12 @@ void Map::link(mobj_t &mo, int flags)

void Map::unlink(Polyobj &polyobj)
{
BlockmapCellBlock cellBlock = d->polyobjBlockmap->toCellBlock(polyobj.aaBox);
d->polyobjBlockmap->unlink(cellBlock, &polyobj);
d->polyobjBlockmap->unlink(polyobj.aaBox, &polyobj);
}

void Map::link(Polyobj &polyobj)
{
BlockmapCellBlock cellBlock = d->polyobjBlockmap->toCellBlock(polyobj.aaBox);
d->polyobjBlockmap->link(cellBlock, &polyobj);
d->polyobjBlockmap->link(polyobj.aaBox, &polyobj);
}

struct blockmapcellpolyobjsiterator_params_t
Expand Down Expand Up @@ -2050,7 +2047,6 @@ BspLeaf &Map::bspLeafAt_FixedPrecision(Vector2d const &point) const

fixed_t lineOriginX[2] = { DBL2FIX(partition.origin.x), DBL2FIX(partition.origin.y) };
fixed_t lineDirectionX[2] = { DBL2FIX(partition.direction.x), DBL2FIX(partition.direction.y) };

int side = V2x_PointOnLineSide(pointX, lineOriginX, lineDirectionX);

// Decend to the child subspace on "this" side.
Expand Down Expand Up @@ -2102,14 +2098,12 @@ void Map::initSkyFix()
/// @todo Can't we defer this?
foreach(Sector *sector, d->sectors)
{
if(!sector->sideCount())
continue;
if(!sector->sideCount()) continue;

bool const skyFloor = sector->floorSurface().hasSkyMaskedMaterial();
bool const skyCeil = sector->ceilingSurface().hasSkyMaskedMaterial();

if(!skyFloor && !skyCeil)
continue;
if(!skyFloor && !skyCeil) continue;

if(skyCeil)
{
Expand Down Expand Up @@ -2237,15 +2231,6 @@ Map::Lumobjs const &Map::lumobjs() const
return d->lumobjs;
}

Lumobj *Map::lumobj(int index) const
{
if(index >= 0 && index < lumobjCount())
{
return lumobjs().at(index);
}
return 0;
}

BiasSource &Map::addBiasSource(BiasSource const &biasSource)
{
if(biasSourceCount() < MAX_BIAS_SOURCES)
Expand Down Expand Up @@ -2746,13 +2731,16 @@ struct VertexInfo

// Order is firstly X axis major.
if(int(vertex->origin().x) != int(other.vertex->origin().x))
{
return int(vertex->origin().x) - int(other.vertex->origin().x);
}

// Order is secondly Y axis major.
return int(vertex->origin().y) - int(other.vertex->origin().y);
}

bool operator < (VertexInfo const &other) const {
bool operator < (VertexInfo const &other) const
{
return compareVertexOrigins(other) < 0;
}
};
Expand Down Expand Up @@ -2832,8 +2820,7 @@ void pruneVertexes(Mesh &mesh, Map::Lines const &lines)
{
Vertex *vertex = info.vertex;

if(info.refCount)
continue;
if(info.refCount) continue;

mesh.removeVertex(*vertex);

Expand All @@ -2846,7 +2833,9 @@ void pruneVertexes(Mesh &mesh, Map::Lines const &lines)
// Re-index with a contiguous range of indices.
int ord = 0;
foreach(Vertex *vertex, mesh.vertexes())
{
vertex->setIndexInMap(ord++);
}

/// Update lines. @todo Line should handle this itself.
foreach(Line *line, lines)
Expand All @@ -2862,8 +2851,7 @@ void pruneVertexes(Mesh &mesh, Map::Lines const &lines)

bool Map::endEditing()
{
if(!d->editingEnabled)
return true; // Huh?
if(!d->editingEnabled) return true; // Huh?

d->editingEnabled = false;

Expand Down
12 changes: 12 additions & 0 deletions doomsday/plugins/common/include/dmu_lib.h
Expand Up @@ -151,6 +151,18 @@ typedef enum sidesection_e {
extern "C" {
#endif

/**
* Same as P_PathTraverse except 'from' and 'to' arguments are specified
* as two sets of separate X and Y map space coordinates.
*/
int P_PathXYTraverse2(coord_t fromX, coord_t fromY, coord_t toX, coord_t toY,
int flags, int (*callback) (TraceState *, struct intercept_s const *, void *),
void *context);

int P_PathXYTraverse(coord_t fromX, coord_t fromY, coord_t toX, coord_t toY,
int (*callback) (TraceState *, struct intercept_s const *, void *),
void *context);

void P_BuildLineTagLists(void);

void P_DestroyLineTagLists(void);
Expand Down

0 comments on commit ec3c300

Please sign in to comment.