Skip to content

Commit

Permalink
Refactor|WallSpec: Moved WallSpec to new source files; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed May 23, 2013
1 parent 0e49ce9 commit 22b0e4f
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 45 deletions.
3 changes: 3 additions & 0 deletions doomsday/client/client.pro
Expand Up @@ -122,6 +122,7 @@ DENG_HEADERS += \
include/Polygon \
include/Polyobj \
include/WallEdge \
include/WallSpec \
include/Sector \
include/Surface \
include/Vertex
Expand Down Expand Up @@ -309,6 +310,7 @@ DENG_HEADERS += \
include/render/vignette.h \
include/render/vlight.h \
include/render/walledge.h \
include/render/wallspec.h \
include/resource/animgroups.h \
include/resource/bitmapfont.h \
include/resource/colorpalette.h \
Expand Down Expand Up @@ -583,6 +585,7 @@ SOURCES += \
src/render/vignette.cpp \
src/render/vlight.cpp \
src/render/walledge.cpp \
src/render/wallspec.cpp \
src/resource/animgroups.cpp \
src/resource/api_material.cpp \
src/resource/api_resource.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/WallSpec
@@ -0,0 +1 @@
#include "render/wallspec.h"
47 changes: 2 additions & 45 deletions doomsday/client/include/render/walledge.h
Expand Up @@ -26,6 +26,8 @@
#include <de/Vector>

#include "Line"
#include "WallSpec"

#include "IHPlane"

class HEdge;
Expand All @@ -36,51 +38,6 @@ class Surface;

namespace de {

class WallSpec
{
public:
enum Flag
{
/// Force the geometry to be opaque, irrespective of material opacity.
ForceOpaque = 0x01,

/**
* Clip the geometry if the neighbor plane surface relevant for the specified
* section (i.e., floor if @c Side::Bottom or ceiling if @c Side::Top) has
* a sky-masked material bound to it.
*/
SkyClip = 0x02,

/// Do not generate geometry for dynamic lights.
NoDynLights = 0x04,

/// Do not generate geometry for dynamic (mobj) shadows.
NoDynShadows = 0x08,

/// Do not generate geometry for faked radiosity.
NoFakeRadio = 0x10,

/// Do not apply angle based light level deltas.
NoLightDeltas = 0x20,

/// Do not smooth edge normals.
NoEdgeNormalSmoothing = 0x40,

DefaultFlags = ForceOpaque | SkyClip
};
Q_DECLARE_FLAGS(Flags, Flag)

Flags flags;

/// Wall section identifier.
int section;

WallSpec(int section, Flags flags = DefaultFlags) : flags(flags), section(section)
{}
};

Q_DECLARE_OPERATORS_FOR_FLAGS(WallSpec::Flags)

/**
* Helper/utility class intended to simplify the process of generating
* sections of wall geometry from a map line segment.
Expand Down
90 changes: 90 additions & 0 deletions doomsday/client/include/render/wallspec.h
@@ -0,0 +1,90 @@
/** @file render/wallspec.h Wall Geometry Specification.
*
* @authors Copyright © 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_RENDER_WALLSPEC
#define DENG_RENDER_WALLSPEC

#include <QFlags>

#include "Line"

namespace de {

/**
* Wall geometry specification. The members are public for convenient access.
*/
class WallSpec
{
public:
enum Flag
{
/// Force the geometry to be opaque, irrespective of material opacity.
ForceOpaque = 0x01,

/**
* Clip the geometry if the neighbor plane surface relevant for the
* specified section (i.e., the floor if @c Side::Bottom or ceiling
* if @c Side::Top) has a sky-masked material bound to it.
*/
SkyClip = 0x02,

/// Do not generate geometry for dynamic lights.
NoDynLights = 0x04,

/// Do not generate geometry for dynamic (mobj) shadows.
NoDynShadows = 0x08,

/// Do not generate geometry for faked radiosity.
NoFakeRadio = 0x10,

/// Do not apply angle based light level deltas.
NoLightDeltas = 0x20,

/// Do not smooth edge normals.
NoEdgeNormalSmoothing = 0x40,

DefaultFlags = ForceOpaque | SkyClip
};
Q_DECLARE_FLAGS(Flags, Flag)

/// Specification flags.
Flags flags;

/// Wall section identifier.
int section;

/**
* Construct a default wall geometry specification for the specifed @a section.
*/
WallSpec(int section, Flags flags = DefaultFlags) : flags(flags), section(section)
{}

/**
* Construct a wall geometry specification appropriate for the specified
* @a side and @a section of a map Line considering the current map renderer
* configuration.
*/
static WallSpec fromMapSide(Line::Side const &side, int section);
};

Q_DECLARE_OPERATORS_FOR_FLAGS(WallSpec::Flags)

} // namespace de

#endif // DENG_RENDER_WALLSPEC
66 changes: 66 additions & 0 deletions doomsday/client/src/render/wallspec.cpp
@@ -0,0 +1,66 @@
/** @file render/wallspec.cpp Wall Geometry Specification.
*
* @authors Copyright © 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>
*/

#include "render/rend_main.h"

#include "render/walledge.h"

using namespace de;

/**
* Should angle based light level deltas be applied?
*/
static bool useWallSectionLightLevelDeltas(Line::Side const &side, int section)
{
// Disabled?
if(rendLightWallAngle <= 0)
return false;

// Never if the surface's material was chosen as a HOM fix (lighting must
// be consistent with that applied to the relative back sector plane).
if(side.hasSector() && side.back().hasSector() && side.surface(section).hasFixMaterial())
return false;

return true;
}

WallSpec WallSpec::fromMapSide(Line::Side const &side, int section) // static
{
WallSpec spec(section);

if(side.line().definesPolyobj() || (section == Line::Side::Middle && !side.considerOneSided()))
spec.flags &= ~WallSpec::ForceOpaque;

// Suppress the sky clipping in debug mode.
if(devRendSkyMode)
spec.flags &= ~WallSpec::SkyClip;

if(side.line().definesPolyobj())
spec.flags |= WallSpec::NoFakeRadio;

bool useLightLevelDeltas = useWallSectionLightLevelDeltas(side, section);
if(!useLightLevelDeltas)
spec.flags |= WallSpec::NoLightDeltas;

// We can skip normal smoothing if light level delta smoothing won't be done.
if(!useLightLevelDeltas || !rendLightWallAngleSmooth)
spec.flags |= WallSpec::NoEdgeNormalSmoothing;

return spec;
}

0 comments on commit 22b0e4f

Please sign in to comment.