Skip to content

Commit

Permalink
Refactor|LineSightTest: Applied pimpl idiom; abandoned divline_t; cle…
Browse files Browse the repository at this point in the history
…anup

Todo for later: Cleanup the math
Todo for later: Add floating-point variant of crossLine()
  • Loading branch information
danij-deng committed Apr 9, 2013
1 parent 007ad22 commit 8e6b130
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 148 deletions.
3 changes: 2 additions & 1 deletion doomsday/client/client.pro
Expand Up @@ -251,6 +251,7 @@ DENG_HEADERS += \
include/map/generators.h \
include/map/hedge.h \
include/map/linedef.h \
include/map/linesighttest.h \
include/map/mapelement.h \
include/map/p_dmu.h \
include/map/p_intercept.h \
Expand Down Expand Up @@ -533,6 +534,7 @@ SOURCES += \
src/map/generators.cpp \
src/map/hedge.cpp \
src/map/linedef.cpp \
src/map/linesighttest.cpp \
src/map/p_data.cpp \
src/map/p_dmu.cpp \
src/map/p_intercept.cpp \
Expand All @@ -542,7 +544,6 @@ SOURCES += \
src/map/p_particle.cpp \
src/map/p_players.cpp \
src/map/p_polyobjs.cpp \
src/map/p_sight.cpp \
src/map/p_think.cpp \
src/map/p_ticker.cpp \
src/map/plane.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/de_play.h
Expand Up @@ -29,6 +29,7 @@
#include "map/surface.h"
#include "map/sidedef.h"
#include "map/linedef.h"
#include "map/linesighttest.h"
#include "map/plane.h"
#include "map/hedge.h"
#include "map/bspleaf.h"
Expand Down
75 changes: 75 additions & 0 deletions doomsday/client/include/map/linesighttest.h
@@ -0,0 +1,75 @@
/** @file linesighttest.h World Map Line of Sight Testing.
*
* @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_MAP_LINE_SIGHT_TEST
#define DENG_MAP_LINE_SIGHT_TEST

#include <de/libdeng2.h>
#include <de/Vector>

#include "MapElement"

namespace de {

/**
* Models the logic, parameters and state of a line (of) sight (LOS) test.
*
* @todo fixme: The state of a discrete trace is not fully encapsulated here
* due to the manipulation of the validCount properties of the various
* map data elements. (Which is used to avoid testing the same element
* multiple times during a trace.)
*
* @todo optimize: Make use of the blockmap to take advantage of the inherent
* spatial locality in this data structure.
*
* @ingroup map
*/
class LineSightTest
{
public:
/**
* Constructs a new line (of) sight test.
*
* @param from Trace origin point in the map coordinate space.
* @param to Trace target point in the map coordinate space.
* @param bottomSlope Lower limit to the Z axis angle/slope range.
* @param topSlope Upper limit to the Z axis angle/slope range.
* @param flags @ref lineSightFlags dictate trace behavior/logic.
*/
LineSightTest(Vector3d const &from, Vector3d const &to,
dfloat bottomSlope, dfloat topSlope, dint flags);

/**
* Execute the trace (i.e., cast the ray).
*
* @param bspRoot Root of BSP to be traced.
*
* @return @c true iff an uninterrupted path exists between the preconfigured
* Start and End points of the trace line.
*/
bool trace(MapElement const &bspRoot);

private:
DENG2_PRIVATE(d)
};

} // namespace de

#endif // DENG_MAP_LINE_SIGHT_TEST
8 changes: 4 additions & 4 deletions doomsday/client/include/map/mapelement.h
Expand Up @@ -18,8 +18,8 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_MAPELEMENT_H
#define LIBDENG_MAPELEMENT_H
#ifndef DENG_MAPELEMENT_H
#define DENG_MAPELEMENT_H

#include "dd_share.h"

Expand Down Expand Up @@ -79,7 +79,7 @@ class MapElement
inline Type const *castTo() const
{
Type const *t = dynamic_cast<Type const *>(this);
DENG2_ASSERT(t != 0);
DENG_ASSERT(t != 0);
return t;
}

Expand All @@ -97,4 +97,4 @@ class MapElement

} // namespace de

#endif // LIBDENG_MAPELEMENT_H
#endif // DENG_MAPELEMENT_H

0 comments on commit 8e6b130

Please sign in to comment.