Skip to content

Commit

Permalink
Sector: Ignore degenerate BSP leafs when determining bounding box/rou…
Browse files Browse the repository at this point in the history
…gh area
  • Loading branch information
danij-deng committed May 20, 2013
1 parent 446e6f5 commit a4d984a
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions doomsday/client/src/map/sector.cpp
Expand Up @@ -18,7 +18,6 @@
* 02110-1301 USA</small>
*/

#include <QListIterator>
#include <QtAlgorithms>

#include <de/Log>
Expand Down Expand Up @@ -345,34 +344,31 @@ void Sector::updateAABox()
{
d->aaBox.clear();

if(!d->bspLeafs.count()) return;

QListIterator<BspLeaf *> leafIt(d->bspLeafs);

BspLeaf *leaf = leafIt.next();
V2d_CopyBox(d->aaBox.arvec2, leaf->poly().aaBox().arvec2);

while(leafIt.hasNext())
bool isFirst = false;
foreach(BspLeaf *leaf, d->bspLeafs)
{
leaf = leafIt.next();
V2d_UniteBox(d->aaBox.arvec2, leaf->poly().aaBox().arvec2);
if(leaf->isDegenerate()) continue;

if(!isFirst)
{
V2d_UniteBox(d->aaBox.arvec2, leaf->poly().aaBox().arvec2);
}
else
{
V2d_CopyBox(d->aaBox.arvec2, leaf->poly().aaBox().arvec2);
isFirst = false;
}
}
}

void Sector::updateRoughArea()
{
d->roughArea = 0;
if(!d->bspLeafs.count()) return;

QListIterator<BspLeaf *> leafIt(d->bspLeafs);

BspLeaf *leaf = leafIt.next();
d->roughArea += (leaf->poly().aaBox().maxX - leaf->poly().aaBox().minX) *
(leaf->poly().aaBox().maxY - leaf->poly().aaBox().minY);

while(leafIt.hasNext())
foreach(BspLeaf *leaf, d->bspLeafs)
{
leaf = leafIt.next();
if(leaf->isDegenerate()) continue;

d->roughArea += (leaf->poly().aaBox().maxX - leaf->poly().aaBox().minX) *
(leaf->poly().aaBox().maxY - leaf->poly().aaBox().minY);
}
Expand Down

0 comments on commit a4d984a

Please sign in to comment.