Skip to content

Commit

Permalink
BSP Builder|Refactor: Take ownership of the BSP object data in MPE_Sa…
Browse files Browse the repository at this point in the history
…veBsp
  • Loading branch information
danij-deng committed Apr 2, 2012
1 parent ecfae31 commit 2ad0104
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions doomsday/engine/portable/src/edit_bsp.cpp
Expand Up @@ -173,12 +173,15 @@ typedef struct {

static int C_DECL populateBspObjectLuts(BinaryTree* tree, void* parameters)
{
populatebspobjectluts_params_t* p = static_cast<populatebspobjectluts_params_t*>(parameters);
Q_ASSERT(p);

// We are only interested in BspNodes at this level.
if(BinaryTree_IsLeaf(tree)) return false; // Continue iteration.

// Take ownership of this BspNode.
BspNode* node = static_cast<BspNode*>(BinaryTree_UserData(tree));
populatebspobjectluts_params_t* p = static_cast<populatebspobjectluts_params_t*>(parameters);
Q_ASSERT(p);
BinaryTree_SetUserData(tree, NULL);

// Add this BspNode to the LUT.
p->dest->bspNodes[p->nodeCurIndex++] = node;
Expand All @@ -187,7 +190,10 @@ static int C_DECL populateBspObjectLuts(BinaryTree* tree, void* parameters)
{
if(BinaryTree_IsLeaf(right))
{
// Take ownership of this BspLeaf.
BspLeaf* leaf = static_cast<BspLeaf*>(BinaryTree_UserData(right));
BinaryTree_SetUserData(right, NULL);

// Add this BspLeaf to the LUT.
p->dest->bspLeafs[p->leafCurIndex++] = leaf;
}
Expand All @@ -197,7 +203,10 @@ static int C_DECL populateBspObjectLuts(BinaryTree* tree, void* parameters)
{
if(BinaryTree_IsLeaf(left))
{
// Take ownership of this BspLeaf.
BspLeaf* leaf = static_cast<BspLeaf*>(BinaryTree_UserData(left));
BinaryTree_SetUserData(left, NULL);

// Add this BspLeaf to the LUT.
p->dest->bspLeafs[p->leafCurIndex++] = leaf;
}
Expand Down Expand Up @@ -235,7 +244,10 @@ static void hardenBSP(GameMap* dest, BinaryTree* rootNode)

if(BinaryTree_IsLeaf(rootNode))
{
// Take ownership of this leaf.
BspLeaf* leaf = static_cast<BspLeaf*>(BinaryTree_UserData(rootNode));
BinaryTree_SetUserData(rootNode, NULL);

dest->bsp = reinterpret_cast<runtime_mapdata_header_t*>(leaf);
return;
}
Expand Down

0 comments on commit 2ad0104

Please sign in to comment.