From 22b0e4f2327b2c44fe7022ba8c24c47e9435dfd2 Mon Sep 17 00:00:00 2001 From: danij Date: Thu, 23 May 2013 22:38:02 +0100 Subject: [PATCH] Refactor|WallSpec: Moved WallSpec to new source files; cleanup --- doomsday/client/client.pro | 3 + doomsday/client/include/WallSpec | 1 + doomsday/client/include/render/walledge.h | 47 +----------- doomsday/client/include/render/wallspec.h | 90 +++++++++++++++++++++++ doomsday/client/src/render/wallspec.cpp | 66 +++++++++++++++++ 5 files changed, 162 insertions(+), 45 deletions(-) create mode 100644 doomsday/client/include/WallSpec create mode 100644 doomsday/client/include/render/wallspec.h create mode 100644 doomsday/client/src/render/wallspec.cpp diff --git a/doomsday/client/client.pro b/doomsday/client/client.pro index a5a7351ab9..eea7179d39 100644 --- a/doomsday/client/client.pro +++ b/doomsday/client/client.pro @@ -122,6 +122,7 @@ DENG_HEADERS += \ include/Polygon \ include/Polyobj \ include/WallEdge \ + include/WallSpec \ include/Sector \ include/Surface \ include/Vertex @@ -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 \ @@ -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 \ diff --git a/doomsday/client/include/WallSpec b/doomsday/client/include/WallSpec new file mode 100644 index 0000000000..86ecd49a4e --- /dev/null +++ b/doomsday/client/include/WallSpec @@ -0,0 +1 @@ +#include "render/wallspec.h" diff --git a/doomsday/client/include/render/walledge.h b/doomsday/client/include/render/walledge.h index b0b1995539..1c6a5d3f46 100644 --- a/doomsday/client/include/render/walledge.h +++ b/doomsday/client/include/render/walledge.h @@ -26,6 +26,8 @@ #include #include "Line" +#include "WallSpec" + #include "IHPlane" class HEdge; @@ -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. diff --git a/doomsday/client/include/render/wallspec.h b/doomsday/client/include/render/wallspec.h new file mode 100644 index 0000000000..0eb48f4c06 --- /dev/null +++ b/doomsday/client/include/render/wallspec.h @@ -0,0 +1,90 @@ +/** @file render/wallspec.h Wall Geometry Specification. + * + * @authors Copyright © 2013 Daniel Swanson + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * 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 + */ + +#ifndef DENG_RENDER_WALLSPEC +#define DENG_RENDER_WALLSPEC + +#include + +#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 diff --git a/doomsday/client/src/render/wallspec.cpp b/doomsday/client/src/render/wallspec.cpp new file mode 100644 index 0000000000..f72e3e4706 --- /dev/null +++ b/doomsday/client/src/render/wallspec.cpp @@ -0,0 +1,66 @@ +/** @file render/wallspec.cpp Wall Geometry Specification. + * + * @authors Copyright © 2013 Daniel Swanson + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * 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 + */ + +#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; +}