Skip to content

Commit

Permalink
Refactor: Reimplemented and reinstated map load time vertex pruning
Browse files Browse the repository at this point in the history
Moved data out of Vertex that is only needed whilst loading a map.

Also removed the algorithms for Line and Sector pruning as we must
tolerate these for mod compatibility purposes (although, we could
shift them to separate lists...).
  • Loading branch information
danij-deng committed Apr 15, 2013
1 parent 95e0e7b commit 56942c2
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 252 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/map/bsp/hedgeintercept.h
Expand Up @@ -60,7 +60,7 @@ struct HEdgeIntercept
static void DebugPrint(HEdgeIntercept const &inst)
{
LOG_INFO("Vertex #%i [x:%f, y:%f] beforeSector: #%d afterSector: #%d %s")
<< inst.vertex->_buildData.index
<< (inst.vertex->origIndex() - 1)
<< inst.vertex->origin()[VX]
<< inst.vertex->origin()[VY]
<< (inst.before? inst.before->origIndex() : -1)
Expand Down
23 changes: 18 additions & 5 deletions doomsday/client/include/map/line.h
Expand Up @@ -526,8 +526,9 @@ class Line : public de::MapElement

public:
Line(Vertex &from, Vertex &to,
Sector *frontSector = 0,
Sector *backSector = 0);
int flags = 0,
Sector *frontSector = 0,
Sector *backSector = 0);

/**
* Returns @c true iff the line is part of some Polyobj.
Expand Down Expand Up @@ -718,7 +719,7 @@ class Line : public de::MapElement
}

/**
* Returns the specified edge vertex for the line.
* Returns the specified edge vertex of the line.
*
* @param to If not @c 0 return the To vertex; otherwise the From vertex.
*/
Expand All @@ -733,8 +734,7 @@ class Line : public de::MapElement
*
* @see vertex()
*/
inline const_pvec2d_t &vertexOrigin(int to) const
{
inline const_pvec2d_t &vertexOrigin(int to) const {
return vertex(to).origin();
}

Expand Down Expand Up @@ -925,6 +925,19 @@ class Line : public de::MapElement
return pointOnSide(point);
}

/**
* Replace the specified edge vertex of the line.
*
* @attention Should only be called in map edit mode.
*
* @param to If not @c 0 replace the To vertex; otherwise the From vertex.
* @param newVertex The replacement vertex.
*/
void replaceVertex(int to, Vertex &newVertex);

inline void replaceFrom(Vertex &newVertex) { replaceVertex(FROM, newVertex); }
inline void replaceTo(Vertex &newVertex) { replaceVertex(TO, newVertex); }

/**
* Get a property value, selected by DMU_* name.
*
Expand Down
45 changes: 22 additions & 23 deletions doomsday/client/include/map/vertex.h
@@ -1,4 +1,4 @@
/** @file vertex.h Map Geometry Vertex
/** @file vertex.h World Map Vertex.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -18,14 +18,17 @@
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_MAP_VERTEX
#define LIBDENG_MAP_VERTEX
#ifndef DENG_WORLD_MAP_VERTEX
#define DENG_WORLD_MAP_VERTEX

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

#include <de/Error>
#include <de/Vector>
#include <de/vector1.h> /// @todo remove me
#include <de/binangle.h>

#include "resource/r_data.h"

#include "map/p_dmu.h"
#include "MapElement"

Expand Down Expand Up @@ -166,24 +169,8 @@ class Vertex : public de::MapElement
LineOwner *_lineOwners;
uint _numLineOwners; ///< Total number of line owners.

/// @todo This temporary load-time data does not belong here. -ds
struct {
/// Vertex index. Always valid after loading and pruning of unused
/// vertices has occurred.
int index;

/// Reference count. When building normal node info, unused vertices
/// will be pruned.
int refCount;

/// Usually NULL, unless this vertex occupies the same location as a
/// previous vertex. Only used during the pruning phase.
Vertex *equiv;
} _buildData;

public:
Vertex(coord_t x = 0, coord_t y = 0);
Vertex(de::Vector2d const &origin);
Vertex(de::Vector2d const &origin = de::Vector2d(0, 0));

/**
* Returns the origin (i.e., location) of the vertex in the map coordinate space.
Expand Down Expand Up @@ -231,6 +218,18 @@ class Vertex : public de::MapElement
*/
LineOwner *firstLineOwner() const;

/**
* Returns the original index of the vertex.
*/
uint origIndex() const;

/**
* Change the original index of the vertex.
*
* @param newIndex New original index.
*/
void setOrigIndex(uint newIndex);

/**
* Get a property value, selected by DMU_* name.
*
Expand All @@ -251,4 +250,4 @@ class Vertex : public de::MapElement
DENG2_PRIVATE(d)
};

#endif // LIBDENG_MAP_VERTEX
#endif // DENG_WORLD_MAP_VERTEX

0 comments on commit 56942c2

Please sign in to comment.