Skip to content

Commit

Permalink
Refactor: Moved class LineOwner to map/lineowner.h
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 15, 2013
1 parent 95a6d2e commit 7760651
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 119 deletions.
1 change: 1 addition & 0 deletions doomsday/client/client.pro
Expand Up @@ -233,6 +233,7 @@ DENG_HEADERS += \
include/map/generators.h \
include/map/hedge.h \
include/map/line.h \
include/map/lineowner.h \
include/map/linesighttest.h \
include/map/mapelement.h \
include/map/p_dmu.h \
Expand Down
139 changes: 139 additions & 0 deletions doomsday/client/include/map/lineowner.h
@@ -0,0 +1,139 @@
/** @file lineowner.h World Map Line Owner.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef DENG_WORLD_MAP_LINEOWNER
#define DENG_WORLD_MAP_LINEOWNER

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

class Line;

/**
* @ingroup map
*
* @deprecated Will be replaced with half-edge ring iterator/rover. -ds
*/
class LineOwner
{
public:
/// Ring navigation direction identifiers:
enum Direction
{
/// Previous (anticlockwise).
Previous,

/// Next (clockwise).
Next
};

public: /// @todo Make private:
Line *_line;

/// {Previous, Next} (i.e. {anticlk, clk}).
LineOwner *_link[2];

/// Angle between this and the next line owner, clockwise.
binangle_t _angle;

struct ShadowVert {
vec2d_t inner;
vec2d_t extended;
} _shadowOffsets;

public:
/*LineOwner() : _line(0), _angle(0)
{
_link[Previous] = 0;
_link[Next] = 0;
V2d_Set(_shadowOffsets.inner, 0, 0);
V2d_Set(_shadowOffsets.extended, 0, 0);
}*/

/**
* Returns @c true iff the previous line owner in the ring (anticlockwise)
* is not the same as this LineOwner.
*
* @see prev()
*/
inline bool hasPrev() const { return &prev() != this; }

/**
* Returns @c true iff the next line owner in the ring (clockwise) is not
* the same as this LineOwner.
*
* @see next()
*/
inline bool hasNext() const { return &next() != this; }

/**
* Navigate to the adjacent line owner in the ring (if any). Note this may
* be the same LineOwner.
*/
LineOwner &navigate(Direction dir = Previous) { return *_link[dir]; }

/// @copydoc navigate()
LineOwner const &navigate(Direction dir = Previous) const { return *_link[dir]; }

/**
* Returns the previous line owner in the ring (anticlockwise). Note that
* this may be the same LineOwner.
*
* @see hasPrev()
*/
inline LineOwner &prev() { return navigate(Previous); }

/// @copydoc prev()
inline LineOwner const &prev() const { return navigate(Previous); }

/**
* Returns the next line owner in the ring (clockwise). Note that this may
* be the same LineOwner.
*
* @see hasNext()
*/
inline LineOwner &next() { return navigate(Next); }

/// @copydoc next()
inline LineOwner const &next() const { return navigate(Next); }

/**
* Returns the line "owner".
*/
Line &line() const { return *_line; }

/**
* Returns the angle between the line owner and the next in the ring (clockwise).
*/
binangle_t angle() const { return _angle; }

/**
* Returns the inner shadow offset of the line owner.
*/
vec2d_t const &innerShadowOffset() const { return _shadowOffsets.inner; }

/**
* Returns the extended shadow offset of the line owner.
*/
vec2d_t const &extendedShadowOffset() const { return _shadowOffsets.extended; }
};

#endif // DENG_WORLD_MAP_LINEOWNER
111 changes: 1 addition & 110 deletions doomsday/client/include/map/vertex.h
Expand Up @@ -21,7 +21,6 @@
#ifndef DENG_WORLD_MAP_VERTEX
#define DENG_WORLD_MAP_VERTEX

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

#include <de/Error>
Expand All @@ -31,115 +30,7 @@
#include "map/p_dmu.h"

class Line;

/**
* @todo Replace ring navigation with a circular iterator at Vertex level -ds.
* @ingroup map
*/
class LineOwner
{
public:
/// Ring navigation direction identifiers:
enum Direction
{
/// Previous (anticlockwise).
Previous,

/// Next (clockwise).
Next
};

public: /// @todo Make private:
Line *_line;

/// {Previous, Next} (i.e. {anticlk, clk}).
LineOwner *_link[2];

/// Angle between this and the next line owner, clockwise.
binangle_t _angle;

struct ShadowVert {
vec2d_t inner;
vec2d_t extended;
} _shadowOffsets;

public:
/*LineOwner() : _line(0), _angle(0)
{
_link[Previous] = 0;
_link[Next] = 0;
V2d_Set(_shadowOffsets.inner, 0, 0);
V2d_Set(_shadowOffsets.extended, 0, 0);
}*/

/**
* Returns @c true iff the previous line owner in the ring (anticlockwise)
* is not the same as this LineOwner.
*
* @see prev()
*/
inline bool hasPrev() const { return &prev() != this; }

/**
* Returns @c true iff the next line owner in the ring (clockwise) is not
* the same as this LineOwner.
*
* @see next()
*/
inline bool hasNext() const { return &next() != this; }

/**
* Navigate to the adjacent line owner in the ring (if any). Note this may
* be the same LineOwner.
*/
LineOwner &navigate(Direction dir = Previous) { return *_link[dir]; }

/// @copydoc navigate()
LineOwner const &navigate(Direction dir = Previous) const { return *_link[dir]; }

/**
* Returns the previous line owner in the ring (anticlockwise). Note that
* this may be the same LineOwner.
*
* @see hasPrev()
*/
inline LineOwner &prev() { return navigate(Previous); }

/// @copydoc prev()
inline LineOwner const &prev() const { return navigate(Previous); }

/**
* Returns the next line owner in the ring (clockwise). Note that this may
* be the same LineOwner.
*
* @see hasNext()
*/
inline LineOwner &next() { return navigate(Next); }

/// @copydoc next()
inline LineOwner const &next() const { return navigate(Next); }

/**
* Returns the line "owner".
*/
Line &line() const { return *_line; }

/**
* Returns the angle between the line owner and the next in the ring (clockwise).
*/
binangle_t angle() const { return _angle; }

/**
* Returns the inner shadow offset of the line owner.
*/
vec2d_t const &innerShadowOffset() const { return _shadowOffsets.inner; }

/**
* Returns the extended shadow offset of the line owner.
*/
vec2d_t const &extendedShadowOffset() const { return _shadowOffsets.extended; }
};
class LineOwner;

/**
* World map geometry vertex.
Expand Down
5 changes: 4 additions & 1 deletion doomsday/client/src/edit_map.cpp
Expand Up @@ -37,12 +37,15 @@
#include "de_edit.h"
#include "de_dam.h"
#include "de_filesys.h"

#include "audio/s_environ.h"
#include "map/lineowner.h"
#include "map/gamemap.h"
#ifdef __CLIENT__
# include "render/rend_main.h"
#endif

#include "audio/s_environ.h"
#include "edit_map.h"

using namespace de;

Expand Down
10 changes: 7 additions & 3 deletions doomsday/client/src/map/hedge.cpp
Expand Up @@ -18,12 +18,16 @@
* 02110-1301 USA</small>
*/

#include <QtAlgorithms>

#include <de/Log>

#include "de_base.h"

#include "map/line.h"
#include "map/lineowner.h"
#include "map/r_world.h" /// R_GetVtxLineOwner @todo remove me
#include "map/vertex.h"
#include "map/r_world.h"
#include <de/Log>
#include <QtAlgorithms>

#include "map/hedge.h"

Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/map/r_world.cpp
Expand Up @@ -32,6 +32,7 @@
#include "de_audio.h"
#include "de_misc.h"

#include "map/lineowner.h"
#include "map/plane.h"
#ifdef __CLIENT__
# include "MaterialSnapshot"
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/map/vertex.cpp
Expand Up @@ -23,6 +23,7 @@

#include "dd_share.h"
#include "map/line.h"
#include "map/lineowner.h"

#include "map/vertex.h"

Expand Down
14 changes: 10 additions & 4 deletions doomsday/client/src/render/r_fakeradio.cpp
Expand Up @@ -18,15 +18,21 @@
* 02110-1301 USA</small>
*/

#include "de_base.h"
#include "de_render.h"
#include <de/Error>
#include <de/Log>
#include <de/memoryzone.h>
#include <de/vector1.h>

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

#include "de_base.h"
#include "de_render.h"

#include "map/lineowner.h"
#include "map/gamemap.h"
#include "map/vertex.h"

//#include "render/r_fakeradio.h"

using namespace de;

static zblockset_t *shadowLinksBlockSet;
Expand Down
6 changes: 5 additions & 1 deletion doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -20,6 +20,8 @@

#include <cstring>

#include <de/vector1.h>

#include "de_base.h"
#include "de_console.h"
#include "de_render.h"
Expand All @@ -28,12 +30,14 @@
#include "de_play.h"

#include "gl/sys_opengl.h"
#include <de/vector1.h>
#include "MaterialSnapshot"
#include "MaterialVariantSpec"
#include "map/gamemap.h"
#include "map/lineowner.h"
#include "render/rendpoly.h"

#include "render/rend_fakeradio.h"

using namespace de;

#define MIN_OPEN (.1f)
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -41,9 +41,12 @@
#include "Texture"
#include "map/blockmapvisual.h"
#include "map/gamemap.h"
#include "map/lineowner.h"
#include "render/sprite.h"
#include "gl/sys_opengl.h"

#include "render/rend_main.h"

using namespace de;

// Surface (tangent-space) Vector Flags.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/server/server.pro
Expand Up @@ -205,6 +205,8 @@ DENG_HEADERS += \
$$SRC/include/map/generators.h \
$$SRC/include/map/hedge.h \
$$SRC/include/map/line.h \
$$SRC/include/map/lineowner.h \
$$SRC/include/map/linesighttest.h \
$$SRC/include/map/p_dmu.h \
$$SRC/include/map/p_intercept.h \
$$SRC/include/map/p_mapdata.h \
Expand Down

0 comments on commit 7760651

Please sign in to comment.