diff --git a/doomsday/api/api_map.h b/doomsday/api/api_map.h index f704e5f22e..a15b4a3fa1 100644 --- a/doomsday/api/api_map.h +++ b/doomsday/api/api_map.h @@ -353,7 +353,7 @@ DENG_API_TYPEDEF(Map) */ void (*PO_SetCallback)(void (*func)(struct mobj_s *, void *, void *)); - int (*BL_BoxIterator)(AABoxd const *box, Sector *sector, int (*callback) (BspLeaf *, void *), void *context); + int (*BL_BoxIterator)(AABoxd const *box, int (*callback) (BspLeaf *, void *), void *context); // Traversers diff --git a/doomsday/client/include/world/map.h b/doomsday/client/include/world/map.h index d45f66ae03..338718b189 100644 --- a/doomsday/client/include/world/map.h +++ b/doomsday/client/include/world/map.h @@ -404,7 +404,7 @@ class Map * the BspLeaf pointer. Can be called without unlinking first. * Should be called AFTER mobj translation to (re-)insert the mobj. */ - void link(struct mobj_s &mobj, byte flags); + void link(struct mobj_s &mobj, int flags); /** * Link the specified @a polyobj in any internal data structures for @@ -489,16 +489,9 @@ class Map return linePathIterator(from, to, LIF_ALL, callback, context); } - int bspLeafBoxIterator(AABoxd const &box, Sector *sector, + int bspLeafBoxIterator(AABoxd const &box, int (*callback) (BspLeaf *bspLeaf, void *context), void *context = 0) const; - /// @copydoc bspLeafsBoxIterator() - inline int bspLeafBoxIterator(AABoxd const &box, - int (*callback) (BspLeaf *bspLeaf, void *context), void *context = 0) const - { - return bspLeafBoxIterator(box, 0, callback, context); - } - /** * @note validCount should be incremented before calling this to begin a * new logical traversal. Otherwise Lines marked with a validCount equal diff --git a/doomsday/client/src/render/r_fakeradio.cpp b/doomsday/client/src/render/r_fakeradio.cpp index 9ac9fed899..e159219359 100644 --- a/doomsday/client/src/render/r_fakeradio.cpp +++ b/doomsday/client/src/render/r_fakeradio.cpp @@ -194,7 +194,11 @@ void Rend_RadioUpdateVertexShadowOffsets(Vertex &vtx) static int linkShadowLineToBspLeafWorker(BspLeaf *bspLeaf, void *context) { - bspLeaf->addShadowLine(*static_cast(context)); + LineSide &side = *static_cast(context); + if(bspLeaf->sectorPtr() == side.sectorPtr()) + { + bspLeaf->addShadowLine(side); + } return false; // Continue iteration. } @@ -252,8 +256,7 @@ void Rend_RadioInitForMap(Map &map) // Link the shadowing line to all the BspLeafs whose axis-aligned // bounding box intersects 'bounds'. - map.bspLeafBoxIterator(bounds, side.sectorPtr(), - linkShadowLineToBspLeafWorker, &side); + map.bspLeafBoxIterator(bounds, linkShadowLineToBspLeafWorker, &side); } } diff --git a/doomsday/client/src/world/api_map.cpp b/doomsday/client/src/world/api_map.cpp index 3230319ac9..0cb7749255 100644 --- a/doomsday/client/src/world/api_map.cpp +++ b/doomsday/client/src/world/api_map.cpp @@ -1618,11 +1618,11 @@ DENG_EXTERN_C int Line_BoxIterator(AABoxd const *box, int flags, } #undef BspLeaf_BoxIterator -DENG_EXTERN_C int BspLeaf_BoxIterator(AABoxd const *box, Sector *sector, +DENG_EXTERN_C int BspLeaf_BoxIterator(AABoxd const *box, int (*callback) (BspLeaf *, void *), void *context) { if(!box || !App_World().hasMap()) return false; // Continue iteration. - return App_World().map().bspLeafBoxIterator(*box, sector, callback, context); + return App_World().map().bspLeafBoxIterator(*box, callback, context); } static void collectLineIntercept(Line &line, divline_t const &traceLos) @@ -1698,7 +1698,7 @@ static void collectMobjIntercept(mobj_t &mobj, divline_t const &traceLos) dl.origin[VY] = DBL2FIX(from[VY]); dl.direction[VX] = DBL2FIX(to[VX] - from[VX]); dl.direction[VY] = DBL2FIX(to[VY] - from[VY]); - coord_t distance = FIX2FLT(Divline_Intersection(&dl, &traceLos)); + float distance = FIX2FLT(Divline_Intersection(&dl, &traceLos)); // On the correct side of the trace origin? if(distance >= 0) diff --git a/doomsday/client/src/world/map.cpp b/doomsday/client/src/world/map.cpp index 35eef2279b..8a6d53f68a 100644 --- a/doomsday/client/src/world/map.cpp +++ b/doomsday/client/src/world/map.cpp @@ -1678,7 +1678,6 @@ static int blockmapCellLinesIterator(void *mapElement, void *context) struct blockmapcellbspleafsiterator_params_t { AABoxd const *box; - Sector *sector; int localValidCount; int (*callback) (BspLeaf *, void *); void *context; @@ -1694,31 +1693,29 @@ static int blockmapCellBspLeafsIterator(void *object, void *context) // This BspLeaf has now been processed for the current iteration. bspLeaf->setValidCount(parm.localValidCount); - // Check the sector restriction. - bool ok = !(parm.sector && bspLeaf->sectorPtr() != parm.sector); - // Check the bounds. AABoxd const &leafAABox = bspLeaf->poly().aaBox(); - if(parm.box && - (leafAABox.maxX < parm.box->minX || - leafAABox.minX > parm.box->maxX || - leafAABox.minY > parm.box->maxY || - leafAABox.maxY < parm.box->minY)) - ok = false; - - if(ok) + if(parm.box) { - // Action the callback. - if(int result = parm.callback(bspLeaf, parm.context)) - return result; // Stop iteration. + if(leafAABox.maxX < parm.box->minX || + leafAABox.minX > parm.box->maxX || + leafAABox.minY > parm.box->maxY || + leafAABox.maxY < parm.box->minY) + { + return false; // Continue iteration. + } } + + // Action the callback. + if(int result = parm.callback(bspLeaf, parm.context)) + return result; // Stop iteration. } return false; // Continue iteration. } -int Map::bspLeafBoxIterator(AABoxd const &box, Sector *sector, - int (*callback) (BspLeaf *, void *), void *context) const +int Map::bspLeafBoxIterator(AABoxd const &box, int (*callback) (BspLeaf *, void *), + void *context) const { if(!d->bspLeafBlockmap.isNull()) { @@ -1730,7 +1727,6 @@ int Map::bspLeafBoxIterator(AABoxd const &box, Sector *sector, parm.localValidCount = localValidCount; parm.callback = callback; parm.context = context; - parm.sector = sector; parm.box = &box; return d->bspLeafBlockmap->iterate(box, blockmapCellBspLeafsIterator, &parm); @@ -1896,7 +1892,7 @@ int Map::unlink(mobj_t &mo) return links; } -void Map::link(mobj_t &mo, byte flags) +void Map::link(mobj_t &mo, int flags) { BspLeaf &bspLeafAtOrigin = bspLeafAt_FixedPrecision(Mobj_Origin(mo)); @@ -2088,7 +2084,7 @@ int Map::linePathIterator(Vector2d const &from, Vector2d const &to, int flags, } // Process sector lines? - if((flags & LIF_SECTOR)) + if(flags & LIF_SECTOR) { if(d->lineBlockmap.isNull()) /// @throw MissingBlockmapError The line blockmap is not yet initialized. diff --git a/doomsday/client/src/world/sectorcluster.cpp b/doomsday/client/src/world/sectorcluster.cpp index 4fc361d16f..a6c2464e99 100644 --- a/doomsday/client/src/world/sectorcluster.cpp +++ b/doomsday/client/src/world/sectorcluster.cpp @@ -695,7 +695,7 @@ DENG2_OBSERVES(Plane, HeightChange) // Link all non-degenerate BspLeafs whose axis-aligned bounding box intersects // with the affection bounds to the reverb set. - self.sector().map().bspLeafBoxIterator(affectionBounds, 0, addReverbBspLeafWorker, this); + self.sector().map().bspLeafBoxIterator(affectionBounds, addReverbBspLeafWorker, this); } /** diff --git a/doomsday/plugins/common/src/hu_automap.c b/doomsday/plugins/common/src/hu_automap.c index 0c53f87936..71bfd640e1 100644 --- a/doomsday/plugins/common/src/hu_automap.c +++ b/doomsday/plugins/common/src/hu_automap.c @@ -710,7 +710,7 @@ static void drawMapLines(uiwidget_t *obj, int objType, boolean addToLists) { AABoxd aaBox; UIAutomap_PVisibleAABounds(obj, &aaBox.minX, &aaBox.maxX, &aaBox.minY, &aaBox.maxY); - BspLeaf_BoxIterator(&aaBox, NULL, drawMapLinesForBspLeafWorker, obj); + BspLeaf_BoxIterator(&aaBox, drawMapLinesForBspLeafWorker, obj); } else {