From b3bd7b5abca8655fc52adcbccbfd1e1dde6e0ae5 Mon Sep 17 00:00:00 2001 From: danij Date: Mon, 26 Nov 2012 01:29:56 +0000 Subject: [PATCH] Refactor: Merged render/r_fakeradio.h into render/rend_fakeradio.h Also relocated shadowlink_t here and renamed various functions according to existing conventions in this module. --- doomsday/engine/engine.pro | 1 - doomsday/engine/include/de_render.h | 1 - doomsday/engine/include/render/r_fakeradio.h | 64 ----------- .../engine/include/render/rend_fakeradio.h | 101 ++++++++++++------ doomsday/engine/include/resource/r_data.h | 6 -- doomsday/engine/src/map/dam_main.cpp | 2 +- doomsday/engine/src/render/r_fakeradio.c | 77 ++++--------- doomsday/engine/src/render/rend_fakeradio.c | 6 +- 8 files changed, 96 insertions(+), 162 deletions(-) delete mode 100644 doomsday/engine/include/render/r_fakeradio.h diff --git a/doomsday/engine/engine.pro b/doomsday/engine/engine.pro index f75ea79731..bfeb8e16f0 100644 --- a/doomsday/engine/engine.pro +++ b/doomsday/engine/engine.pro @@ -268,7 +268,6 @@ DENG_HEADERS += \ include/network/ui_mpi.h \ include/r_util.h \ include/render/r_draw.h \ - include/render/r_fakeradio.h \ include/render/r_main.h \ include/render/r_lgrid.h \ include/render/r_lumobjs.h \ diff --git a/doomsday/engine/include/de_render.h b/doomsday/engine/include/de_render.h index 045b36ede1..307c952cc8 100644 --- a/doomsday/engine/include/de_render.h +++ b/doomsday/engine/include/de_render.h @@ -24,7 +24,6 @@ #include "render/r_main.h" #include "render/r_draw.h" -#include "render/r_fakeradio.h" #include "render/r_lgrid.h" #include "render/r_lumobjs.h" #include "render/r_shadow.h" diff --git a/doomsday/engine/include/render/r_fakeradio.h b/doomsday/engine/include/render/r_fakeradio.h deleted file mode 100644 index 4e3101637e..0000000000 --- a/doomsday/engine/include/render/r_fakeradio.h +++ /dev/null @@ -1,64 +0,0 @@ -/**\file r_fakeradio.h - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html - * - *\author Copyright © 2004-2012 Jaakko Keränen - *\author Copyright © 2006-2012 Daniel Swanson - * - * 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 - */ - -/** - * Faked Radiosity Lighting. - * - * Perhaps the most distinctive characteristic of radiosity lighting - * is that the corners of a room are slightly dimmer than the rest of - * the surfaces. (It's not the only characteristic, however.) We - * will fake these shadowed areas by generating shadow polygons for - * wall segments and determining, which BSP leaf vertices will be - * shadowed. - * - * In other words, walls use shadow polygons (over entire hedges), while - * planes use vertex lighting. Since planes are usually tesselated - * into a great deal of BSP leafs (and triangles), they are better - * suited for vertex lighting. In some cases we will be forced to - * split a BSP leaf into smaller pieces than strictly necessary in - * order to achieve better accuracy in the shadow effect. - */ - -#ifndef LIBDENG_REFRESH_FAKERADIO_H -#define LIBDENG_REFRESH_FAKERADIO_H - -#include "map/linedef.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * To be called after map load to perform necessary initialization within this module. - */ -void R_InitFakeRadioForMap(void); - -/// @return @c true if @a lineDef qualifies as a (edge) shadow caster. -boolean R_IsShadowingLinedef(LineDef* lineDef); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* LIBDENG_REFRESH_FAKERADIO_H */ diff --git a/doomsday/engine/include/render/rend_fakeradio.h b/doomsday/engine/include/render/rend_fakeradio.h index 6f16f98d83..a954758069 100644 --- a/doomsday/engine/include/render/rend_fakeradio.h +++ b/doomsday/engine/include/render/rend_fakeradio.h @@ -1,75 +1,112 @@ -/**\file rend_fakeradio.h - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html +/** + * @file rend_fakeradio.h Faked Radiosity Lighting + * + * Perhaps the most distinctive characteristic of radiosity lighting + * is that the corners of a room are slightly dimmer than the rest of + * the surfaces. (It's not the only characteristic, however.) We + * will fake these shadowed areas by generating shadow polygons for + * wall segments and determining, which BSP leaf vertices will be + * shadowed. * - *\author Copyright © 2004-2012 Jaakko Keränen - *\author Copyright © 2007-2012 Daniel Swanson + * In other words, walls use shadow polygons (over entire hedges), while + * planes use vertex lighting. Since planes are usually tesselated + * into a great deal of BSP leafs (and triangles), they are better + * suited for vertex lighting. In some cases we will be forced to + * split a BSP leaf into smaller pieces than strictly necessary in + * order to achieve better accuracy in the shadow effect. * - * 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. + * @author Copyright © 2004-2012 Jaakko Keränen + * @author Copyright © 2006-2012 Daniel Swanson * - * 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. + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html * - * 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 + * 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 LIBDENG_RENDER_FAKERADIO_H #define LIBDENG_RENDER_FAKERADIO_H -#ifdef __cplusplus -extern "C" { -#endif +#include "map/linedef.h" +#include "render/rendpoly.h" + +typedef struct shadowlink_s { + struct shadowlink_s *next; + LineDef *lineDef; + byte side; +} shadowlink_t; typedef struct { float shadowRGB[3], shadowDark; float shadowSize; - const shadowcorner_t* botCn, *topCn, *sideCn; - const edgespan_t* spans; - const coord_t* segOffset; - const coord_t* segLength; - const coord_t* linedefLength; - const Sector* frontSec, *backSec; + shadowcorner_t const *botCn, *topCn, *sideCn; + edgespan_t const *spans; + coord_t const *segOffset; + coord_t const *segLength; + coord_t const *linedefLength; + Sector const *frontSec, *backSec; struct { struct { - walldivnode_t* firstDiv; + walldivnode_t *firstDiv; uint divCount; } left; struct { - walldivnode_t* firstDiv; + walldivnode_t *firstDiv; uint divCount; } right; } wall; } rendsegradio_params_t; +#ifdef __cplusplus +extern "C" { +#endif + /// Register the console commands, variables, etc..., of this module. void Rend_RadioRegister(void); +/** + * To be called after map load to perform necessary initialization within this module. + */ +void Rend_RadioInitForMap(void); + +/// @return @c true if @a lineDef qualifies as a (edge) shadow caster. +boolean Rend_RadioIsShadowingLineDef(LineDef *lineDef); + +/** + * Updates all the shadow offsets for the given vertex. + * + * @pre Lineowner rings must be set up. + * + * @param vtx Vertex to be updated. + */ +void Rend_RadioUpdateVertexShadowOffsets(Vertex *vtx); + float Rend_RadioCalcShadowDarkness(float lightLevel); /** * Called to update the shadow properties used when doing FakeRadio for the * given linedef. */ -void Rend_RadioUpdateLinedef(LineDef* line, boolean backSide); +void Rend_RadioUpdateLinedef(LineDef *line, boolean backSide); /** * Render FakeRadio for the given hedge section. */ -void Rend_RadioSegSection(const rvertex_t* rvertices, const rendsegradio_params_t* params); +void Rend_RadioSegSection(rvertex_t const *rvertices, rendsegradio_params_t const *params); /** * Render FakeRadio for the given BSP leaf. */ -void Rend_RadioBspLeafEdges(BspLeaf* bspLeaf); +void Rend_RadioBspLeafEdges(BspLeaf *bspLeaf); /** * Render the shadow poly vertices, for debug. diff --git a/doomsday/engine/include/resource/r_data.h b/doomsday/engine/include/resource/r_data.h index eacdd71e53..40e241bb0b 100644 --- a/doomsday/engine/include/resource/r_data.h +++ b/doomsday/engine/include/resource/r_data.h @@ -63,12 +63,6 @@ typedef struct glcommand_vertex_s { int index; } glcommand_vertex_t; -typedef struct shadowlink_s { - struct shadowlink_s* next; - LineDef* lineDef; - byte side; -} shadowlink_t; - typedef struct { lumpnum_t lumpNum; short offX; /// block origin (always UL), which has allready diff --git a/doomsday/engine/src/map/dam_main.cpp b/doomsday/engine/src/map/dam_main.cpp index 88833abbe8..4f335505be 100644 --- a/doomsday/engine/src/map/dam_main.cpp +++ b/doomsday/engine/src/map/dam_main.cpp @@ -354,7 +354,7 @@ boolean DAM_AttemptMapLoad(Uri const* _uri) // theMap to be set first. P_SetCurrentMap(map); - R_InitFakeRadioForMap(); + Rend_RadioInitForMap(); { uint startTime = Timer_RealMilliseconds(); GameMap_InitSkyFix(map); diff --git a/doomsday/engine/src/render/r_fakeradio.c b/doomsday/engine/src/render/r_fakeradio.c index 7df591c311..ba86d0c584 100644 --- a/doomsday/engine/src/render/r_fakeradio.c +++ b/doomsday/engine/src/render/r_fakeradio.c @@ -1,58 +1,32 @@ -/**\file r_fakeradio.c - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html - * - *\author Copyright © 2003-2012 Jaakko Keränen - *\author Copyright © 2006-2012 Daniel Swanson +/** + * @file r_fakeradio.c Faked Radiosity Lighting * - * 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. + * @author Copyright © 2003-2012 Jaakko Keränen + * @author Copyright © 2006-2012 Daniel Swanson * - * 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. + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html * - * 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 - */ - -/** - * Runtime Map Shadowing (FakeRadio) + * 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 */ -// HEADER FILES ------------------------------------------------------------ - #include "de_base.h" #include "de_console.h" #include "de_misc.h" #include "de_play.h" - -// MACROS ------------------------------------------------------------------ - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ +#include "de_render.h" static zblockset_t *shadowLinksBlockSet; -// CODE -------------------------------------------------------------------- - /** * Line1 and line2 are the (dx,dy)s for two lines, connected at the * origin (0,0). Dist1 and dist2 are the distances from these lines. @@ -122,14 +96,7 @@ double R_ShadowEdgeWidth(const pvec2d_t edge) return normalWidth; } -/** - * Updates all the shadow offsets for the given vertex. - * - * \pre Lineowner rings MUST be set up. - * - * @param vtx Ptr to the vertex being updated. - */ -void R_UpdateVertexShadowOffsets(Vertex* vtx) +void Rend_RadioUpdateVertexShadowOffsets(Vertex* vtx) { vec2d_t left, right; @@ -221,7 +188,7 @@ int RIT_ShadowBspLeafLinker(BspLeaf* bspLeaf, void* parm) return false; // Continue iteration. } -boolean R_IsShadowingLinedef(LineDef* line) +boolean Rend_RadioIsShadowingLineDef(LineDef* line) { if(line) { @@ -236,7 +203,7 @@ boolean R_IsShadowingLinedef(LineDef* line) return false; } -void R_InitFakeRadioForMap(void) +void Rend_RadioInitForMap(void) { uint startTime = Timer_RealMilliseconds(); @@ -249,7 +216,7 @@ void R_InitFakeRadioForMap(void) for(i = 0; i < NUM_VERTEXES; ++i) { - R_UpdateVertexShadowOffsets(VERTEX_PTR(i)); + Rend_RadioUpdateVertexShadowOffsets(VERTEX_PTR(i)); } /** @@ -269,7 +236,7 @@ void R_InitFakeRadioForMap(void) for(i = 0; i < NUM_LINEDEFS; ++i) { LineDef* line = LINE_PTR(i); - if(!R_IsShadowingLinedef(line)) continue; + if(!Rend_RadioIsShadowingLineDef(line)) continue; for(j = 0; j < 2; ++j) { diff --git a/doomsday/engine/src/render/rend_fakeradio.c b/doomsday/engine/src/render/rend_fakeradio.c index 377d47f5cf..294a8ee6b9 100644 --- a/doomsday/engine/src/render/rend_fakeradio.c +++ b/doomsday/engine/src/render/rend_fakeradio.c @@ -32,6 +32,7 @@ #include "gl/sys_opengl.h" #include "m_vector.h" #include "resource/materialvariant.h" +#include "render/rendpoly.h" #define MIN_OPEN (.1f) #define EDGE_OPEN_THRESHOLD (8) // world units (Z axis) @@ -967,8 +968,9 @@ static void quadTexCoords(rtexcoord_t* tc, const rvertex_t* rverts, tc[0].st[1] = tc[3].st[1] + (rverts[3].pos[VZ] - rverts[2].pos[VZ]) / texHeight; } -static void renderShadowSeg(const rvertex_t* origVertices, const rendershadowseg_params_t* segp, - const rendsegradio_params_t* p) +static void renderShadowSeg(const rvertex_t* origVertices, + const rendershadowseg_params_t* segp, + const rendsegradio_params_t* p) { float texOrigin[2][3]; ColorRawf* rcolors;