Skip to content

Commit

Permalink
BSP Builder: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 12, 2012
1 parent 45ba67b commit eaac9a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions doomsday/engine/portable/include/map/bsp/superblockmap.h
Expand Up @@ -199,10 +199,10 @@ class SuperBlock
HEdges::const_iterator hedgesEnd() const;

DENG_DEBUG_ONLY(
void DebugPrint() const
static void DebugPrint(SuperBlock const& inst)
{
for(SuperBlock::HEdges::const_iterator it = hedgesBegin();
it != hedgesEnd(); ++it)
for(SuperBlock::HEdges::const_iterator it = inst.hedgesBegin();
it != inst.hedgesEnd(); ++it)
{
HEdge* hedge = *it;
LOG_DEBUG("Build: %s %p sector: %d [%1.1f, %1.1f] -> [%1.1f, %1.1f]")
Expand Down
8 changes: 3 additions & 5 deletions doomsday/engine/portable/src/map/bsp/hplane.cpp
Expand Up @@ -28,6 +28,7 @@
#include "de_base.h"
#include "de_console.h"

#include "map/bsp/hedgeintercept.h"
#include "map/bsp/hplane.h"

using namespace de::bsp;
Expand Down Expand Up @@ -122,14 +123,11 @@ HPlane::Intercepts::const_iterator HPlane::deleteIntercept(Intercepts::iterator
return intercepts.erase(at);
}

#include "map/bsp/hedgeintercept.h"

#if _DEBUG
void HPlane::DebugPrint(const HPlane& hplane)
void HPlane::DebugPrint(const HPlane& inst)
{
Con_Message("HPlane %p:\n", &hplane);
uint n = 0;
for(HPlane::Intercepts::const_iterator it = hplane.begin(); it != hplane.end(); it++, n++)
for(HPlane::Intercepts::const_iterator it = inst.begin(); it != inst.end(); it++, n++)
{
const HPlaneIntercept* inter = &*it;
Con_Printf(" %u: >%1.2f ", n, inter->distance());
Expand Down
48 changes: 25 additions & 23 deletions doomsday/engine/portable/src/map/bsp/partitioner.cpp
Expand Up @@ -56,7 +56,8 @@

using namespace de::bsp;

static const double IFFY_LEN = 4.0;
/// Minimum length of a half-edge post partitioning. Used in cost evaluation.
static const double SHORT_HEDGE_EPSILON = 4.0;

/// Smallest distance between two points before being considered equal.
static const double DIST_EPSILON = (1.0 / 128.0);
Expand Down Expand Up @@ -764,11 +765,11 @@ struct Partitioner::Instance
void evalPartitionCostForHEdge(const HEdgeInfo& partInfo, int costFactorMultiplier,
const HEdge* hedge, PartitionCost& cost)
{
#define ADD_LEFT() \
#define ADD_LEFT() \
if (hedge->lineDef) cost.realLeft += 1; \
else cost.miniLeft += 1; \

#define ADD_RIGHT() \
#define ADD_RIGHT() \
if (hedge->lineDef) cost.realRight += 1; \
else cost.miniRight += 1; \

Expand All @@ -792,7 +793,7 @@ struct Partitioner::Instance
fb = fabs(b);
}

// hedge for being on the same line.
// Collinear?
if(fa <= DIST_EPSILON && fb <= DIST_EPSILON)
{
// This half-edge runs along the same line as the partition.
Expand All @@ -809,16 +810,17 @@ struct Partitioner::Instance
return;
}

// hedge for right side.
// Off to the right?
if(a > -DIST_EPSILON && b > -DIST_EPSILON)
{
ADD_RIGHT();

// hedge for a near miss.
if((a >= IFFY_LEN && b >= IFFY_LEN) ||
(a <= DIST_EPSILON && b >= IFFY_LEN) ||
(b <= DIST_EPSILON && a >= IFFY_LEN))
// Near miss?
if((a >= SHORT_HEDGE_EPSILON && b >= SHORT_HEDGE_EPSILON) ||
(a <= DIST_EPSILON && b >= SHORT_HEDGE_EPSILON) ||
(b <= DIST_EPSILON && a >= SHORT_HEDGE_EPSILON))
{
// No.
return;
}

Expand All @@ -831,34 +833,35 @@ struct Partitioner::Instance
*/

if(a <= DIST_EPSILON || b <= DIST_EPSILON)
qnty = IFFY_LEN / MAX_OF(a, b);
qnty = SHORT_HEDGE_EPSILON / MAX_OF(a, b);
else
qnty = IFFY_LEN / MIN_OF(a, b);
qnty = SHORT_HEDGE_EPSILON / MIN_OF(a, b);

cost.total += (int) (100 * costFactorMultiplier * (qnty * qnty - 1.0));
return;
}

// hedge for left side.
// Off to the left?
if(a < DIST_EPSILON && b < DIST_EPSILON)
{
ADD_LEFT();

// hedge for a near miss.
if((a <= -IFFY_LEN && b <= -IFFY_LEN) ||
(a >= -DIST_EPSILON && b <= -IFFY_LEN) ||
(b >= -DIST_EPSILON && a <= -IFFY_LEN))
// Near miss?
if((a <= -SHORT_HEDGE_EPSILON && b <= -SHORT_HEDGE_EPSILON) ||
(a >= -DIST_EPSILON && b <= -SHORT_HEDGE_EPSILON) ||
(b >= -DIST_EPSILON && a <= -SHORT_HEDGE_EPSILON))
{
// No.
return;
}

cost.nearMiss++;

// The closer the miss, the higher the cost (see note above).
if(a >= -DIST_EPSILON || b >= -DIST_EPSILON)
qnty = IFFY_LEN / -MIN_OF(a, b);
qnty = SHORT_HEDGE_EPSILON / -MIN_OF(a, b);
else
qnty = IFFY_LEN / -MAX_OF(a, b);
qnty = SHORT_HEDGE_EPSILON / -MAX_OF(a, b);

cost.total += (int) (70 * costFactorMultiplier * (qnty * qnty - 1.0));
return;
Expand All @@ -874,15 +877,14 @@ struct Partitioner::Instance

/**
* If the split point is very close to one end, which is quite an undesirable
* situation (producing really short edges). This is perhaps _one_ source of those
* darn slime trails. Hence the name "IFFY segs" and a rather hefty surcharge.
* situation (producing really short edges), thus a rather hefty surcharge.
*/
if(fa < IFFY_LEN || fb < IFFY_LEN)
if(fa < SHORT_HEDGE_EPSILON || fb < SHORT_HEDGE_EPSILON)
{
cost.iffy++;

// The closer to the end, the higher the cost.
qnty = IFFY_LEN / MIN_OF(fa, fb);
qnty = SHORT_HEDGE_EPSILON / MIN_OF(fa, fb);
cost.total += (int) (140 * costFactorMultiplier * (qnty * qnty - 1.0));
}

Expand Down Expand Up @@ -2459,7 +2461,7 @@ static void logUnclosed(const BspLeaf* leaf)
DENG_DEBUG_ONLY(
static int printSuperBlockHEdgesWorker(SuperBlock* block, void* /*parameters*/)
{
block->DebugPrint();
SuperBlock::DebugPrint(*block);
return false; // Continue iteration.
})

Expand Down

0 comments on commit eaac9a2

Please sign in to comment.