Skip to content

Commit

Permalink
BSP Builder|Cleanup: Apply pimpl idiom and moved subcomponents into a…
Browse files Browse the repository at this point in the history
…n inner namespace
  • Loading branch information
danij-deng committed Apr 4, 2012
1 parent 1fb936e commit 0bd05a4
Show file tree
Hide file tree
Showing 17 changed files with 906 additions and 821 deletions.
32 changes: 20 additions & 12 deletions doomsday/engine/engine.pro
Expand Up @@ -124,20 +124,28 @@ DENG_API_HEADERS = \
api/uri.h \
api/writer.h

DENG_HEADERS = \
# Convenience headers.
DENG_HEADERS += \
portable/include/BspBuilder \

# Private headers.
DENG_HEADERS += \
portable/src/map/bspbuilder/bspbuilder_instance.h \
portable/include/map/bspbuilder/bsphedgeinfo.h \
portable/include/map/bspbuilder/hedgeintercept.h \
portable/include/map/bspbuilder/hplane.h \
portable/include/map/bspbuilder/linedefinfo.h \
portable/include/map/bspbuilder/superblockmap.h \

DENG_HEADERS += \
portable/include/abstractfile.h \
portable/include/abstractresource.h \
portable/include/audiodriver.h \
portable/include/bitmapfont.h \
portable/include/blockmap.h \
portable/include/blockmapvisual.h \
portable/include/blockset.h \
portable/include/bspbuilder/bspbuilder.hh \
portable/include/bspbuilder/bsphedgeinfo.h \
portable/include/bspbuilder/hedgeintercept.h \
portable/include/bspbuilder/hplane.h \
portable/include/bspbuilder/linedefinfo.h \
portable/include/bspbuilder/superblockmap.h \
portable/include/map/bspbuilder/bspbuilder.h \
portable/include/bspleaf.h \
portable/include/bspnode.h \
portable/include/b_command.h \
Expand Down Expand Up @@ -431,11 +439,11 @@ SOURCES += \
portable/src/b_util.c \
portable/src/blockmap.c \
portable/src/blockmapvisual.c \
portable/src/bspbuilder/bspbuilder.cpp \
portable/src/bspbuilder/hedges.cpp \
portable/src/bspbuilder/hplane.cpp \
portable/src/bspbuilder/node.cpp \
portable/src/bspbuilder/superblockmap.cpp \
portable/src/map/bspbuilder/bspbuilder.cpp \
portable/src/map/bspbuilder/hedges.cpp \
portable/src/map/bspbuilder/hplane.cpp \
portable/src/map/bspbuilder/nodes.cpp \
portable/src/map/bspbuilder/superblockmap.cpp \
portable/src/bspleaf.c \
portable/src/bspnode.c \
portable/src/busytask.cpp \
Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/portable/include/BspBuilder
@@ -0,0 +1,2 @@
#include "map/bspbuilder/bspbuilder.h"
#include "map/bspbuilder/bsphedgeinfo.h"
88 changes: 88 additions & 0 deletions doomsday/engine/portable/include/map/bspbuilder/bspbuilder.h
@@ -0,0 +1,88 @@
/**
* @file bspbuilder.h
* BSP Builder (public interface). @ingroup map
*
* Based on glBSP 2.24 (in turn, based on BSP 2.3), which is hosted on
* SourceForge: http://sourceforge.net/projects/glbsp/
*
* @authors Copyright © 2007-2012 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2000-2007 Andrew Apted <ajapted@gmail.com>
* @authors Copyright © 1998-2000 Colin Reed <cph@moria.org.uk>
* @authors Copyright © 1998-2000 Lee Killough <killough@rsn.hp.com>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_BSPBUILDER
#define LIBDENG_BSPBUILDER

#include "de_play.h"

struct binarytree_s;

namespace de {

namespace bspbuilder { struct BspBuilderImp; }

/**
* BSP node builder.
*
* BspBuilder constructs a BSP object object tree for the specified map.
*
* @ingroup map
*/
class BspBuilder
{
public:
/// Default cost factor attributed to splitting an existing half-edge.
static const int DEFAULT_PARTITION_COST_HEDGESPLIT = 7;

/**
* Create a new BspBuilder initialized for construction using the specified map.
* @param map GameMap for which to construct a BSP object tree.
* @param splitCostFactor Cost factor attributed to splitting an existing half-edge.
*/
explicit BspBuilder(GameMap* map, int splitCostFactor = DEFAULT_PARTITION_COST_HEDGESPLIT);
~BspBuilder();

/**
* Set the cost factor associated with splitting an existing half-edge.
* @param factor New factor value.
* @return Reference to this BspBuilder.
*/
BspBuilder& setSplitCostFactor(int factor);

/**
* Build the BSP for the given map.
* @return @c true= iff completed successfully.
*/
bool build();

/**
* Retrieve a pointer to the root BinaryTree node for the constructed BSP.
* Even if construction fails this will return a valid node.
*
* The only time upon which @c NULL is returned is if called prior to calling
* BspBuilder::build()
*/
struct binarytree_s* root() const;

private:
bspbuilder::BspBuilderImp* d;
};

} // namespace de

#endif /// LIBDENG_BSPBUILDER
Expand Up @@ -34,7 +34,7 @@
#include <de/Log>

namespace de {
//namespace bspbuilder {
namespace bspbuilder {

/**
* Plain-old-data structure containing additional information for a half-edge
Expand All @@ -49,7 +49,7 @@ struct HEdgeIntercept
Vertex* vertex;

// True if this intersection was on a self-referencing linedef.
boolean selfRef;
bool selfRef;

// Sector on each side of the vertex (along the partition),
// or NULL when that direction isn't OPEN.
Expand All @@ -69,7 +69,7 @@ struct HEdgeIntercept
})
};

//} // namespace bspbuilder
} // namespace bspbuilder
} // namespace de

#endif /// LIBDENG_BSPBUILDER_HEDGEINTERCEPT
Expand Up @@ -33,8 +33,7 @@
#include <list>

namespace de {

class BspBuilder;
namespace bspbuilder {

struct HPlanePartition {
double origin[2];
Expand Down Expand Up @@ -157,6 +156,7 @@ class HPlane {
Intercepts intercepts;
};

} // namespace bspbuilder
} // namespace de

#endif /// LIBDENG_BSPBUILDER_HPLANE
Expand Up @@ -25,15 +25,15 @@
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_BSPBUILDER_LINEDEFINFO_H
#define LIBDENG_BSPBUILDER_LINEDEFINFO_H
#ifndef LIBDENG_BSPBUILDER_LINEDEFINFO
#define LIBDENG_BSPBUILDER_LINEDEFINFO

#include "p_mapdata.h"

#include <QGlobalStatic>

namespace de {
//namespace bspbuilder {
namespace bspbuilder {

/**
* Plain old data (POD) structure used to record additional information and
Expand Down Expand Up @@ -62,7 +62,7 @@ struct LineDefInfo

Q_DECLARE_OPERATORS_FOR_FLAGS(LineDefInfo::Flags)

//} // namespace bspbuilder
} // namespace bspbuilder
} // namespace de

#endif /// LIBDENG_BSPBUILDER_LINEDEFINFO
Expand Up @@ -31,11 +31,15 @@
#define LIBDENG_BSPBUILDER_SUPERBLOCKMAP

#include "dd_types.h"
#include "bspbuilder/bsphedgeinfo.h"

#include <de/Log>
#include <list>

namespace de {
namespace bspbuilder {

class SuperBlockmap;

#ifdef RIGHT
# undef RIGHT
#endif
Expand All @@ -44,11 +48,6 @@
# undef LEFT
#endif

namespace de {
//namespace bspbuilder {

class SuperBlockmap;

/**
* Subblocks:
* RIGHT - has the lower coordinates.
Expand Down Expand Up @@ -274,7 +273,7 @@ class SuperBlockmap {
Instance* d;
};

//} // namespace bspbuilder
} // namespace bspbuilder
} // namespace de

#endif /// LIBDENG_BSPBUILDER_SUPERBLOCKMAP

0 comments on commit 0bd05a4

Please sign in to comment.