diff --git a/doomsday/client/include/map/sector.h b/doomsday/client/include/map/sector.h index b36531c316..baffc086d6 100644 --- a/doomsday/client/include/map/sector.h +++ b/doomsday/client/include/map/sector.h @@ -291,32 +291,26 @@ class Sector : public de::MapElement inline uint reverbBspLeafCount() const { return uint(reverbBspLeafs().count()); } /** - * Returns the axis-aligned bounding box which encompases all vertex - * origin points for lines which reference the sector, in map coordinate - * space units. Note that if no lines reference the sector the bounding - * box will be invalid (has negative dimensions). - * - * @deprecated Algorithms which are dependent on this are likely making - * invalid assumptions about the geometry of the map. + * Returns the axis-aligned bounding box which encompases the geometry of + * all BSP leafs attributed to the sector (map units squared). Note that if + * no BSP leafs reference the sector the bounding box will be invalid (has + * negative dimensions). */ AABoxd const &aaBox() const; /** * Update the sector's map space axis-aligned bounding box to encompass - * the points defined by it's LineDefs' vertexes. + * the geometry of all BSP leafs attributed to the sector. * - * @pre Line list must have be initialized. + * @pre BSP leaf list must have be initialized. * - * @see buildLines() + * @see buildBspLeafs() */ void updateAABox(); /** - * Returns a rough approximation of the area of the sector in the map - * coordinate space (units squared). - * - * @deprecated Algorithms which are dependent on this are likely making - * invalid assumptions about the geometry of the map. + * Returns a rough approximation of the total combined area of the geometry + * for all BSP leafs attributed to the sector (map units squared). * * @see updateRoughArea() */ @@ -325,22 +319,24 @@ class Sector : public de::MapElement /** * Update the sector's rough area approximation. * - * @pre Axis-aligned bounding box must be initialized. + * @pre BSP leaf list must have be initialized. * - * @see updateAABox() + * @see buildBspLeafs(), roughArea() */ void updateRoughArea(); /** - * @param base Mobj base to link in @a sector. Caller should ensure that the - * same object is not linked multiple times into the chain. + * @param newEmitter Mobj base to link to the sector. Caller must ensure + * that the object is not linked multiple times into + * the chain. */ void linkSoundEmitter(ddmobj_base_t &newEmitter); /** - * Update the origin of the sector according to the point defined by the - * center of the sector's axis-aligned bounding box (which must be - * initialized before calling). + * Update the sound emitter origin of the sector according to the point + * defined by the center of the sector's axis-aligned bounding box (which + * must be initialized before calling) and the mid point on the map up + * axis between floor and ceiling planes. */ void updateSoundEmitterOrigin(); diff --git a/doomsday/client/src/audio/s_environ.cpp b/doomsday/client/src/audio/s_environ.cpp index b7f0242076..55c5b8f6f4 100644 --- a/doomsday/client/src/audio/s_environ.cpp +++ b/doomsday/client/src/audio/s_environ.cpp @@ -314,14 +314,7 @@ static void calculateSectorReverb(Sector *sec) { if(!sec || !sec->lineCount()) return; - /// @todo fixme: This 3D volume rough estimate may be massively off. - /// Consider the case of a single sector used over an entire map - /// with multiple disjoint groups of small geometries. - /// In general a sector should never be considered as playing any - /// part in the definition of a map's geometry. -ds - uint spaceVolume = (int) (sec->ceiling().height() - sec->floor().height()) * - (sec->aaBox().maxX - sec->aaBox().minX) * - (sec->aaBox().maxY - sec->aaBox().minY); + uint spaceVolume = int((sec->ceiling().height() - sec->floor().height()) * sec->roughArea()); sec->_reverb[SRD_SPACE] = sec->_reverb[SRD_VOLUME] = sec->_reverb[SRD_DECAY] = sec->_reverb[SRD_DAMPING] = 0; diff --git a/doomsday/client/src/map/sector.cpp b/doomsday/client/src/map/sector.cpp index 8c1c73d4f6..68c1bb09e8 100644 --- a/doomsday/client/src/map/sector.cpp +++ b/doomsday/client/src/map/sector.cpp @@ -312,25 +312,37 @@ void Sector::updateAABox() V2d_Set(d->aaBox.min, DDMAXFLOAT, DDMAXFLOAT); V2d_Set(d->aaBox.max, DDMINFLOAT, DDMINFLOAT); - if(!d->lines.count()) return; + if(!d->bspLeafs.count()) return; - QListIterator lineIt(d->lines); + QListIterator leafIt(d->bspLeafs); - LineDef *line = lineIt.next(); - V2d_CopyBox(d->aaBox.arvec2, line->aaBox().arvec2); + BspLeaf *leaf = leafIt.next(); + V2d_CopyBox(d->aaBox.arvec2, leaf->aaBox().arvec2); - while(lineIt.hasNext()) + while(leafIt.hasNext()) { - line = lineIt.next(); - V2d_UniteBox(d->aaBox.arvec2, line->aaBox().arvec2); + leaf = leafIt.next(); + V2d_UniteBox(d->aaBox.arvec2, leaf->aaBox().arvec2); } } void Sector::updateRoughArea() { - // Only a very rough estimate is required. - d->roughArea = ((d->aaBox.maxX - d->aaBox.minX) / 128) * - ((d->aaBox.maxY - d->aaBox.minY) / 128); + d->roughArea = 0; + if(!d->bspLeafs.count()) return; + + QListIterator leafIt(d->bspLeafs); + + BspLeaf *leaf = leafIt.next(); + d->roughArea += (leaf->aaBox().maxX - leaf->aaBox().minX) * + (leaf->aaBox().maxY - leaf->aaBox().minY); + + while(leafIt.hasNext()) + { + leaf = leafIt.next(); + d->roughArea += (leaf->aaBox().maxX - leaf->aaBox().minX) * + (leaf->aaBox().maxY - leaf->aaBox().minY); + } } void Sector::linkSoundEmitter(ddmobj_base_t &newEmitter)