Skip to content

Commit

Permalink
Refactor|World: Converted Segment into a subcomponent of Line::Side
Browse files Browse the repository at this point in the history
What remains of the old Segment component now only makes sense in
the context of a Line::Side. Making this a Line::Side subcomponent
presents many opportunities to not only clean up the APIs of these
classes but allow various logics to be pushed up to a higher level
in the map element hierarchy.

Todo: Line::Side should take ownership of the segments and provide
an API for dynamically managing these.
  • Loading branch information
danij-deng committed Aug 11, 2013
1 parent 02c443a commit 65c9146
Show file tree
Hide file tree
Showing 23 changed files with 349 additions and 519 deletions.
3 changes: 0 additions & 3 deletions doomsday/client/client.pro
Expand Up @@ -133,7 +133,6 @@ DENG_HEADERS += \
include/WallEdge \
include/WallSpec \
include/Sector \
include/Segment \
include/Surface \
include/Vertex

Expand Down Expand Up @@ -410,7 +409,6 @@ DENG_HEADERS += \
include/world/propertyvalue.h \
include/world/reject.h \
include/world/sector.h \
include/world/segment.h \
include/world/surface.h \
include/world/thinkers.h \
include/world/vertex.h \
Expand Down Expand Up @@ -717,7 +715,6 @@ SOURCES += \
src/world/propertyvalue.cpp \
src/world/reject.cpp \
src/world/sector.cpp \
src/world/segment.cpp \
src/world/surface.cpp \
src/world/thinkers.cpp \
src/world/vertex.cpp \
Expand Down
1 change: 0 additions & 1 deletion doomsday/client/include/Segment

This file was deleted.

3 changes: 1 addition & 2 deletions doomsday/client/include/render/walledge.h
Expand Up @@ -76,8 +76,7 @@ class WallEdge : public WorldEdge
/**
* @param spec Geometry specification for the wall section. A copy is made.
*
* @param hedge Assumed to have a mapped Segment attributed to a Line::Side
* with sections.
* @param hedge Assumed to have a mapped Line::Side::Segment with sections.
*/
WallEdge(WallSpec const &spec, HEdge &hedge, int edge);

Expand Down
88 changes: 88 additions & 0 deletions doomsday/client/include/world/line.h
Expand Up @@ -37,6 +37,10 @@
#include "Surface"
#include "Vertex"

#ifdef __CLIENT__
# include "BiasSurface"
#endif

class LineOwner;
class Sector;

Expand Down Expand Up @@ -115,6 +119,90 @@ class Line : public de::MapElement
};
Q_DECLARE_FLAGS(SectionFlags, SectionFlag)

/**
* Side geometry segment on the XY plane.
*/
class Segment : public de::MapElement
#ifdef __CLIENT__
, public BiasSurface
#endif
{
DENG2_NO_COPY (Segment)
DENG2_NO_ASSIGN(Segment)

public:
/**
* Construct a new line side segment.
*/
Segment(Line::Side &lineSide, de::HEdge &hedge);

/**
* Returns the line side owner of the segment.
*/
Line::Side &lineSide() const;

/**
* Convenient accessor method for returning the line of the owning
* line side.
*
* @see lineSide()
*/
inline Line &line() const { return lineSide().line(); }

#ifdef __CLIENT__

/**
* Returns the distance along the attributed map line at which the
* from vertex vertex occurs.
*
* @see lineSide()
*/
coord_t lineSideOffset() const;

/// @todo Refactor away.
void setLineSideOffset(coord_t newOffset);

/**
* Returns the accurate length of the segment, from the 'from'
* vertex to the 'to' vertex in map coordinate space units.
*/
coord_t length() const;

/// @todo Refactor away.
void setLength(coord_t newLength);

/**
* Returns @c true iff the segment is marked as "front facing".
*/
bool isFrontFacing() const;

/**
* Mark the current segment as "front facing".
*/
void setFrontFacing(bool yes = true);

/**
* Perform bias lighting for the supplied geometry.
*
* @important It is assumed there are least @em four elements!
*
* @param group Geometry group identifier.
* @param posCoords World coordinates for each vertex.
* @param colorCoords Final lighting values will be written here.
*/
void lightBiasPoly(int group, de::Vector3f const *posCoords,
de::Vector4f *colorCoords);

void updateBiasAfterGeometryMove(int group);

BiasTracker *biasTracker(int group);

#endif // __CLIENT__

private:
DENG2_PRIVATE(d)
};

public:
Side(Line &line, Sector *sector = 0);

Expand Down
193 changes: 0 additions & 193 deletions doomsday/client/include/world/segment.h

This file was deleted.

3 changes: 1 addition & 2 deletions doomsday/client/src/audio/s_environ.cpp
Expand Up @@ -36,7 +36,6 @@
#include "Face"

#include "BspLeaf"
#include "Segment"

#include "audio/s_environ.h"

Expand Down Expand Up @@ -246,7 +245,7 @@ static void accumReverbForFaceEdges(Face const &face,
if(!hedge->mapElement())
continue;

Segment *seg = hedge->mapElement()->as<Segment>();
Line::Side::Segment *seg = hedge->mapElement()->as<Line::Side::Segment>();
if(!seg->lineSide().hasSections() || !seg->lineSide().middle().hasMaterial())
continue;

Expand Down
3 changes: 1 addition & 2 deletions doomsday/client/src/render/lumobj.cpp
Expand Up @@ -37,7 +37,6 @@
#include "world/linesighttest.h"
#include "world/thinkers.h"
#include "BspLeaf"
#include "Segment"

#include "MaterialSnapshot"
#include "MaterialVariantSpec"
Expand Down Expand Up @@ -1172,7 +1171,7 @@ boolean LOIT_ClipLumObjBySight(void *data, void *context)
HEdge *hedge = line->front().leftHEdge();

// Ignore half-edges facing the wrong way.
if(hedge->mapElement()->as<Segment>()->isFlagged(Segment::FacingFront))
if(hedge->mapElement()->as<Line::Side::Segment>()->isFrontFacing())
{
coord_t fromV1[2] = { hedge->origin().x, hedge->origin().y };
coord_t toV1[2] = { hedge->twin().origin().x, hedge->twin().origin().y };
Expand Down

0 comments on commit 65c9146

Please sign in to comment.