Skip to content

Commit

Permalink
Partitioner: Moved HPlane::distanceToVertex to LineSegment (SoC)
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 28, 2013
1 parent 58d1b9f commit 8bcdab5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
8 changes: 0 additions & 8 deletions doomsday/client/include/map/bsp/hplane.h
Expand Up @@ -100,14 +100,6 @@ class HPlane
*/
void configure(LineSegment const &newLineSeg);

/**
* Determine the distance from @a vertex to the half-plane origin (along
* the partition line).
*
* @param vertex Vertex to test.
*/
coord_t distanceToVertex(Vertex const &vertex) const;

/**
* Perform intersection of the half-plane with the specified @a lineSeg.
* If the two are found to intersect -- a new intercept will be added to
Expand Down
16 changes: 12 additions & 4 deletions doomsday/client/include/map/bsp/linesegment.h
Expand Up @@ -270,10 +270,18 @@ class LineSegment
void setHEdge(HEdge *newHEdge);

/**
* Calculate perpendicular distances from one or both of the vertexe(s) of
* "this" line segment to the @a other line segment. For this operation the
* @other line segment is interpreted as an infinite line. The vertexe(s) of
* "this" line segment are projected onto the conceptually infinite line
* Calculates the @em parallel distance from the line segment to the specified
* @a point in the plane (i.e., along the direction of the line).
*
* @return Distance to the point expressed as a fraction/scale factor.
*/
coord_t distance(Vector2d point) const;

/**
* Calculate @em perpendicular distances from one or both of the vertexe(s)
* of "this" line segment to the @a other line segment. For this operation
* the @a other line segment is interpreted as an infinite line. The vertexe(s)
* of "this" line segment are projected onto the conceptually infinite line
* defined by @a other and the length of the resultant vector(s) are then
* determined.
*
Expand Down
12 changes: 1 addition & 11 deletions doomsday/client/src/map/bsp/hplane.cpp
Expand Up @@ -27,8 +27,6 @@

#include <QtAlgorithms>

#include <de/vector1.h> /// @todo Remove me.

#include <de/Error>
#include <de/Log>

Expand Down Expand Up @@ -126,7 +124,7 @@ HPlane::Intercept *HPlane::interceptLineSegment(LineSegment const &lineSeg, int
inter.vertex = &vertex;
inter.selfRef = (lineSeg.hasMapSide() && lineSeg.line().isSelfReferencing());

d->intercepts.append(Intercept(distanceToVertex(vertex), inter));
d->intercepts.append(Intercept(d->lineSegment->distance(vertex.origin()), inter));
Intercept *newIntercept = &d->intercepts.last();

// The addition of a new intercept means we'll need to resort.
Expand Down Expand Up @@ -174,14 +172,6 @@ void HPlane::sortAndMergeIntercepts()
d->needSortIntercepts = false;
}

coord_t HPlane::distanceToVertex(Vertex const &vertex) const
{
coord_t vertexOriginV1[2] = { vertex.x(), vertex.y() };
coord_t lineSegmentDirectionV1[2] = { d->lineSegment->direction().x, d->lineSegment->direction().y };
return V2d_PointLineParaDistance(vertexOriginV1, lineSegmentDirectionV1,
d->lineSegment->pPara, d->lineSegment->pLength);
}

#ifdef DENG_DEBUG
void HPlane::printIntercepts() const
{
Expand Down
7 changes: 7 additions & 0 deletions doomsday/client/src/map/bsp/linesegment.cpp
Expand Up @@ -268,6 +268,13 @@ Line::Side &LineSegment::sourceMapSide() const
throw MissingMapSideError("LineSegment::sourceMapSide", "No source map line side is attributed");
}

coord_t LineSegment::distance(Vector2d point) const
{
coord_t pointV1[2] = { point.x, point.y };
coord_t directionV1[2] = { d->direction.x, d->direction.y };
return V2d_PointLineParaDistance(pointV1, directionV1, pPara, pLength);
}

void LineSegment::distance(LineSegment const &other, coord_t *fromDist, coord_t *toDist) const
{
// Any work to do?
Expand Down

0 comments on commit 8bcdab5

Please sign in to comment.