Skip to content

Commit

Permalink
Refactor|Partitioner: Separated the concept of a line segment from ha…
Browse files Browse the repository at this point in the history
…lf-edge

It is inconvenient from the POV of the partitioner to model a finite
line segment in the plane using HEdge. Instead it is better to model
these separately (i.e., using two vertexes and without the HEdge
API semantics) internally within the partitioner.

HEdgeInfo has been remodeled into LineSegment which now references
any HEdge constructed from it. Whilst partitioning the coordinates
of line segment are now used directly with those of the associated
half-edge being updated to match.

Todo: Defer half-edges construction until BSP leaf creation time.
Todo: Cleanup.
  • Loading branch information
danij-deng committed Apr 27, 2013
1 parent f830f03 commit 3d81f2a
Show file tree
Hide file tree
Showing 12 changed files with 718 additions and 491 deletions.
1 change: 1 addition & 0 deletions doomsday/client/client.pro
Expand Up @@ -499,6 +499,7 @@ SOURCES += \
src/map/blockmap.cpp \
src/map/blockmapvisual.cpp \
src/map/bsp/hplane.cpp \
src/map/bsp/linesegment.cpp \
src/map/bsp/partitioner.cpp \
src/map/bsp/superblockmap.cpp \
src/map/bspbuilder.cpp \
Expand Down
46 changes: 22 additions & 24 deletions doomsday/client/include/map/bsp/hedgetip.h
@@ -1,4 +1,4 @@
/** @file hedgetip.h BSP builder half-edge tip.
/** @file hedgetip.h BSP builder Line Segment Tip.
*
* Originally based on glBSP 2.24 (in turn, based on BSP 2.3)
* @see http://sourceforge.net/projects/glbsp/
Expand All @@ -23,23 +23,20 @@
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_BSP_HEDGETIP
#define LIBDENG_BSP_HEDGETIP
#ifndef DENG_WORLD_BSP_LINESEGMENTTIP
#define DENG_WORLD_BSP_LINESEGMENTTIP

#include "dd_types.h"
#include "map/p_mapdata.h"

class HEdge;
#include "map/bsp/linesegment.h"

namespace de {
namespace bsp {

/**
* A "hedgetip" is where a half-edge meets a vertex.
* A "line segment tip" is where a line segment meets a vertex.
*
* @ingroup bsp
*/
class HEdgeTip
class LineSegmentTip
{
public:
enum Side
Expand All @@ -49,23 +46,24 @@ class HEdgeTip
};

public:
explicit HEdgeTip(coord_t angle = 0, HEdge *front = 0, HEdge *back = 0)
explicit LineSegmentTip(coord_t angle = 0, LineSegment *front = 0,
LineSegment *back = 0)
: _angle(angle), _front(front), _back(back)
{}

inline coord_t angle() const { return _angle; }

inline HEdgeTip &setAngle(coord_t newAngle)
inline LineSegmentTip &setAngle(coord_t newAngle)
{
_angle = newAngle;
return *this;
}

inline HEdge &front() const { return *_front; }
inline LineSegment &front() const { return *_front; }

inline HEdge &back() const { return *_back; }
inline LineSegment &back() const { return *_back; }

inline HEdge &side(Side sid) const
inline LineSegment &side(Side sid) const
{
return sid == Front? front() : back();
}
Expand All @@ -79,33 +77,33 @@ class HEdgeTip
return sid == Front? hasFront() : hasBack();
}

inline HEdgeTip &setFront(HEdge *hedge)
inline LineSegmentTip &setFront(LineSegment *lineSeg)
{
_front = hedge;
_front = lineSeg;
return *this;
}

inline HEdgeTip &setBack(HEdge *hedge)
inline LineSegmentTip &setBack(LineSegment *lineSeg)
{
_back = hedge;
_back = lineSeg;
return *this;
}

inline HEdgeTip &setSide(Side sid, HEdge *hedge)
inline LineSegmentTip &setSide(Side sid, LineSegment *lineSeg)
{
return sid == Front? setFront(hedge) : setBack(hedge);
return sid == Front? setFront(lineSeg) : setBack(lineSeg);
}

private:
/// Angle that line makes at vertex (degrees; 0 is E, 90 is N).
coord_t _angle;

/// Half-edge on each side of the tip. Front is the side of increasing
/// angles, back is the side of decreasing angles. Either can be @c NULL
HEdge *_front, *_back;
/// Line segments on each side of the tip. Front is the side of increasing
/// angles, back is the side of decreasing angles. Either can be @c 0.
LineSegment *_front, *_back;
};

} // namespace bsp
} // namespace de

#endif // LIBDENG_BSP_HEDGETIP
#endif // DENG_WORLD_BSP_LINESEGMENTTIP
6 changes: 2 additions & 4 deletions doomsday/client/include/map/bsp/hplane.h
Expand Up @@ -36,14 +36,13 @@
/// Two intercepts whose distance is inclusive of this bound will be merged.
#define HPLANE_INTERCEPT_MERGE_DISTANCE_EPSILON 1.0 / 128

class HEdge;
class Vertex;
class Sector;

namespace de {
namespace bsp {

struct LineSegment;
class LineSegment;

/**
* Models the partitioning binary space half-plane.
Expand Down Expand Up @@ -98,9 +97,8 @@ class HPlane
* Reconfigure the half-plane according to the given line segment.
*
* @param newLineSeg The "new" line segment to configure using.
* @param hedge Map half-edge for the segment (@todo refactor away).
*/
void configure(LineSegment const &newLineSeg, HEdge const &hedge);
void configure(LineSegment const &newLineSeg);

/**
* Determine the distance from @a vertex to the half-plane origin (along
Expand Down

0 comments on commit 3d81f2a

Please sign in to comment.