Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor: Extracted BiasSurface from rend_bias.cpp
C++ implementation of a Shadow Bias surface.
  • Loading branch information
danij-deng committed Jun 25, 2013
1 parent 210519c commit 203d4f1
Show file tree
Hide file tree
Showing 4 changed files with 652 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doomsday/client/client.pro
Expand Up @@ -110,6 +110,7 @@ DENG_API_HEADERS = \
# Convenience headers.
DENG_HEADERS += \
include/BiasSource \
include/BiasSurface \
include/BspLeaf \
include/BspNode \
include/EntityDatabase \
Expand Down Expand Up @@ -249,6 +250,7 @@ DENG_HEADERS += \
include/partition.h \
include/r_util.h \
include/render/biassource.h \
include/render/biassurface.h \
include/render/blockmapvisual.h \
include/render/huecirclevisual.h \
include/render/lightgrid.h \
Expand Down Expand Up @@ -546,6 +548,7 @@ SOURCES += \
src/r_util.cpp \
src/render/api_render.cpp \
src/render/biassource.cpp \
src/render/biassurface.cpp \
src/render/blockmapvisual.cpp \
src/render/huecirclevisual.cpp \
src/render/lightgrid.cpp \
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/BiasSurface
@@ -0,0 +1 @@
#include "render/biassurface.h"
73 changes: 73 additions & 0 deletions doomsday/client/include/render/biassurface.h
@@ -0,0 +1,73 @@
/** @file biassurface.h Shadow Bias surface.
*
* @authors Copyright © 2005-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-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, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_RENDER_SHADOWBIAS_SURFACE_H
#define DENG_RENDER_SHADOWBIAS_SURFACE_H

#include <de/Vector>

#include "MapElement"

class BiasTracker; // render/rend_bias.h

/**
* Stores surface data for the Shadow Bias lighting model (e.g., per-vertex
* illumination and casted source lighting contributions).
*/
class BiasSurface
{
public:
/**
* Construct a new surface.
*
* @param owner Map element which will own the surface (either a
* BspLeaf or a Segment).
* @param subElemIndex Index for the subelement of @a owner.
* @param size Number of vertices.
*/
BiasSurface(de::MapElement &owner, int subElemIndex, int size);

/**
* To be called to register the commands and variables of this module.
*/
static void consoleRegister();

/**
* Perform lighting for the supplied geometry. It is assumed that this
* geometry has the @em same number of vertices as the bias surface.
*
* @param colors Array of colors to be written to.
* @param verts Array of vertices to be lit.
* @param vertCount Number of vertices (in the array) to be lit.
* @param surfaceNormal Surface normal.
* @param sectorLightLevel Sector light level.
*/
void lightPoly(struct ColorRawf_s *colors, struct rvertex_s const *verts,
size_t vertCount, de::Vector3f const &surfaceNormal,
float sectorLightLevel);

void updateAfterMove();

void updateAffection(BiasTracker &changes);

private:
DENG2_PRIVATE(d)
};

#endif // DENG_RENDER_SHADOWBIAS_SURFACE_H

0 comments on commit 203d4f1

Please sign in to comment.