Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BSP Builder: Cleanup in preparation for the next round of refactoring
  • Loading branch information
danij-deng committed Mar 24, 2012
1 parent e2681cc commit 661bb9b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
8 changes: 8 additions & 0 deletions doomsday/engine/portable/include/bspbuilder/bspbuilder.hh
Expand Up @@ -57,6 +57,12 @@ public:
ZBlockSet_Delete(hedgeBlockSet);
}

BspBuilder* setSplitCostFactor(int factor)
{
splitCostFactor = factor;
return this;
}

void initForMap(GameMap* map);

/**
Expand Down Expand Up @@ -253,6 +259,8 @@ private:
Sector* openSectorAtPoint(Vertex* vert, double dx, double dy);

private:
int splitCostFactor;

zblockset_t* hedgeBlockSet;
};

Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/portable/include/edit_bsp.h
Expand Up @@ -82,6 +82,8 @@ BspBuilder_c* BspBuilder_New(void);

void BspBuilder_Delete(BspBuilder_c* builder);

BspBuilder_c* BspBuilder_SetSplitCostFactor(BspBuilder_c* builder, int factor);

void BspBuilder_Save(struct gamemap_s* dest, void* rootNode, struct vertex_s*** vertexes, uint* numVertexes);

/**
Expand Down
7 changes: 7 additions & 0 deletions doomsday/engine/portable/src/bspbuilder/bspbuilder.cpp
Expand Up @@ -68,6 +68,13 @@ void BspBuilder_Delete(BspBuilder_c* builder)
free(builder);
}

BspBuilder_c* BspBuilder_SetSplitCostFactor(BspBuilder_c* builder, int factor)
{
assert(builder);
builder->inst->setSplitCostFactor(factor);
return builder;
}

static void initAABoxFromEditableLineDefVertexes(AABoxf* aaBox, const LineDef* line)
{
const double* from = line->L_v1->buildData.pos;
Expand Down
9 changes: 2 additions & 7 deletions doomsday/engine/portable/src/bspbuilder/hedges.cpp
Expand Up @@ -26,20 +26,15 @@
* 02110-1301 USA</small>
*/

#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>
#include <assert.h>

#include "de_base.h"
#include "de_console.h"
#include "de_bsp.h"
#include "de_edit.h"

#include "edit_map.h"
#include "m_misc.h"

#include "bspbuilder/hedges.hh"
#include "bspbuilder/superblockmap.hh"
#include "bspbuilder/bspbuilder.hh"

using namespace de;
Expand Down
10 changes: 0 additions & 10 deletions doomsday/engine/portable/src/bspbuilder/intersection.cpp
Expand Up @@ -25,20 +25,10 @@
* 02110-1301 USA</small>
*/

#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>

#include "de_base.h"
#include "de_console.h"
#include "de_bsp.h"

#include "m_misc.h"
#include "edit_map.h"

#include "bspbuilder/intersection.hh"
#include "bspbuilder/superblockmap.hh"
#include "bspbuilder/bspbuilder.hh"

using namespace de;
Expand Down
16 changes: 9 additions & 7 deletions doomsday/engine/portable/src/bspbuilder/node.cpp
Expand Up @@ -31,9 +31,9 @@

#include "de_base.h"
#include "de_console.h"
#include "de_bsp.h"
#include "de_play.h"
#include "de_misc.h"
#include "m_misc.h"
#include "m_binarytree.h"

#include "bspbuilder/intersection.hh"
#include "bspbuilder/superblockmap.hh"
Expand Down Expand Up @@ -386,6 +386,7 @@ void BspBuilder::deleteLeaf(bspleafdata_t* leaf)

typedef struct {
const BspHEdgeInfo* partInfo;
int splitCostFactor;
int bestCost;
evalinfo_t* info;
} evalpartitionworkerparams_t;
Expand All @@ -405,7 +406,6 @@ static int evalPartitionWorker2(const bsp_hedge_t* check, void* parameters)
} while (0)

evalpartitionworkerparams_t* p = (evalpartitionworkerparams_t*) parameters;
const int factor = bspFactor;
double qnty, a, b, fa, fb;
assert(p);

Expand Down Expand Up @@ -473,7 +473,7 @@ static int evalPartitionWorker2(const bsp_hedge_t* check, void* parameters)
else
qnty = IFFY_LEN / MIN_OF(a, b);

p->info->cost += (int) (100 * factor * (qnty * qnty - 1.0));
p->info->cost += (int) (100 * p->splitCostFactor * (qnty * qnty - 1.0));
return false; // Continue iteration.
}

Expand All @@ -498,7 +498,7 @@ static int evalPartitionWorker2(const bsp_hedge_t* check, void* parameters)
else
qnty = IFFY_LEN / -MAX_OF(a, b);

p->info->cost += (int) (70 * factor * (qnty * qnty - 1.0));
p->info->cost += (int) (70 * p->splitCostFactor * (qnty * qnty - 1.0));
return false; // Continue iteration.
}

Expand All @@ -508,7 +508,7 @@ static int evalPartitionWorker2(const bsp_hedge_t* check, void* parameters)
*/

p->info->splits++;
p->info->cost += 100 * factor;
p->info->cost += 100 * p->splitCostFactor;

/**
* Check if the split point is very close to one end, which is quite an undesirable
Expand All @@ -521,7 +521,7 @@ static int evalPartitionWorker2(const bsp_hedge_t* check, void* parameters)

// The closer to the end, the higher the cost.
qnty = IFFY_LEN / MIN_OF(fa, fb);
p->info->cost += (int) (140 * factor * (qnty * qnty - 1.0));
p->info->cost += (int) (140 * p->splitCostFactor * (qnty * qnty - 1.0));
}
return false; // Continue iteration.

Expand Down Expand Up @@ -648,6 +648,7 @@ static int evalPartition(SuperBlock* hedgeList, bsp_hedge_t* part, int bestCost)

typedef struct {
SuperBlock* hedgeList;
int splitCostFactor;
bsp_hedge_t** best;
int* bestCost;
} choosehedgefromsuperblockparams_t;
Expand Down Expand Up @@ -710,6 +711,7 @@ boolean BspBuilder::choosePartition(SuperBlock* hedgeList, size_t /*depth*/, HPl
//DEBUG_Message(("BspBuilder::choosePartition: Begun (depth %lu)\n", (unsigned long) depth));

parm.hedgeList = hedgeList;
parm.splitCostFactor = splitCostFactor;
parm.best = &best;
parm.bestCost = &bestCost;

Expand Down
5 changes: 0 additions & 5 deletions doomsday/engine/portable/src/bspbuilder/superblockmap.cpp
Expand Up @@ -29,11 +29,6 @@
#include "bspbuilder/hedges.hh"
#include "bspbuilder/superblockmap.hh"

#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>

using namespace de;

void SuperBlock::clear()
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/edit_map.c
Expand Up @@ -1714,6 +1714,7 @@ boolean MPE_End(void)
* Build a BSP for this map.
*/
bspBuilder = BspBuilder_New();
BspBuilder_SetSplitCostFactor(bspBuilder, bspFactor);
builtOK = BspBuilder_Build(bspBuilder, gamemap, &map->vertexes, &map->numVertexes);
BspBuilder_Delete(bspBuilder);

Expand Down

0 comments on commit 661bb9b

Please sign in to comment.