Skip to content

Commit

Permalink
Server|World: Trimmed unused fat from Segment that is not needed serv…
Browse files Browse the repository at this point in the history
…er side

Todo: Strictly speaking the server does not need segments at all any
more, so it would be good to get rid of them completely...
  • Loading branch information
danij-deng committed Aug 11, 2013
1 parent aea3110 commit a97b04c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/include/world/segment.h
Expand Up @@ -123,6 +123,8 @@ class Segment : public de::MapElement
*/
inline Line &line() const { return lineSide().line(); }

#ifdef __CLIENT__

/**
* Returns the distance along the attributed map line at which the from vertex
* vertex occurs. If the segment is not attributed to a map line then @c 0 is
Expand All @@ -144,8 +146,6 @@ class Segment : public de::MapElement
/// @todo Refactor away.
void setLength(coord_t newLength);

#ifdef __CLIENT__

/**
* Returns the current value of the flags of the line segment.
*/
Expand Down
4 changes: 4 additions & 0 deletions doomsday/client/src/world/bsp/convexsubspace.cpp
Expand Up @@ -436,9 +436,11 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
// Attribute the segment to half-edge.
hedge->setMapElement(seg);

#ifdef __CLIENT__
seg->setLineSideOffset(Vector2d(mapSide->from().origin() - lineSeg->from().origin()).length());

seg->setLength(Vector2d(lineSeg->to().origin() - lineSeg->from().origin()).length());
#endif
}

// Link the new half-edge for this line segment to the head of
Expand Down Expand Up @@ -530,9 +532,11 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
// Attribute the segment to the half-edge.
hedge->setMapElement(seg);

#ifdef __CLIENT__
seg->setLineSideOffset(Vector2d(mapSide->from().origin() - lineSeg->from().origin()).length());

seg->setLength(Vector2d(lineSeg->to().origin() - lineSeg->from().origin()).length());
#endif
}

// Link the new half-edge for this line segment to the head of
Expand Down
6 changes: 4 additions & 2 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -3523,9 +3523,11 @@ bool Map::endEditing()
hedge->twin().setTwin(hedge);

// Polyobj has ownership of the line segments.
Segment *segment = new Segment(line->front(), *hedge);
new Segment(line->front(), *hedge);

segment->setLength(line->length());
#ifdef __CLIENT__
hedge->mapElement()->as<Segment>()->setLength(line->length());
#endif

line->front().setLeftHEdge(hedge);
line->front().setRightHEdge(hedge);
Expand Down
26 changes: 10 additions & 16 deletions doomsday/client/src/world/segment.cpp
Expand Up @@ -19,15 +19,9 @@
*/

#include <QMap>
#include <QtAlgorithms>

#include <de/binangle.h>

#include "dd_main.h" // App_World()
#include "BspLeaf"
#include "HEdge"
#include "Line"
#include "Sector"

#ifdef __CLIENT__
# include "world/map.h"
Expand Down Expand Up @@ -56,28 +50,28 @@ typedef QMap<int, GeometryGroup> GeometryGroups;

DENG2_PIMPL(Segment)
{
/// Distance along the attributed map line at which the half-edge vertex occurs.
coord_t lineSideOffset;

/// Half-edge attributed to the line segment (not owned).
HEdge *hedge;

#ifdef __CLIENT__
/// Distance along the attributed map line at which the half-edge vertex occurs.
coord_t lineSideOffset;

/// Accurate length of the segment.
coord_t length;

#ifdef __CLIENT__
/// Bias lighting data for each geometry group (i.e., each Line::Side section).
GeometryGroups geomGroups;
Flags flags;
#endif

Instance(Public *i, HEdge *hedge)
: Base(i),
lineSideOffset(0),
hedge(hedge),
length(0)
hedge(hedge)
#ifdef __CLIENT__
,flags(0)
,lineSideOffset(0),
length(0),
flags(0)
#endif
{}

Expand Down Expand Up @@ -189,6 +183,8 @@ Line::Side &Segment::lineSide() const
return *this->parent().as<Line::Side>();
}

#ifdef __CLIENT__

coord_t Segment::lineSideOffset() const
{
return d->lineSideOffset;
Expand All @@ -209,8 +205,6 @@ void Segment::setLength(coord_t newLength)
d->length = newLength;
}

#ifdef __CLIENT__

Segment::Flags Segment::flags() const
{
return d->flags;
Expand Down

0 comments on commit a97b04c

Please sign in to comment.