Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 24, 2011
1 parent 5b64f6c commit 593cfc3
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 362 deletions.
91 changes: 55 additions & 36 deletions doomsday/engine/portable/include/rend_dyn.h
@@ -1,4 +1,4 @@
/**\file
/**\file rend_dyn.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
Expand All @@ -23,54 +23,73 @@
*/

/**
* rend_dyn.h: Dynamic Lights.
* Dynamic Light Projections and Projection Lists.
*/

#ifndef __DOOMSDAY_DYNLIGHTS_H__
#define __DOOMSDAY_DYNLIGHTS_H__
#ifndef LIBDENG_RENDER_DYNLIGHT_H
#define LIBDENG_RENDER_DYNLIGHT_H

#include "p_object.h"
#include "rend_list.h"

#define DYN_ASPECT (1.1f) // 1.2f is just too round for Doom.

#define MAX_GLOWHEIGHT (1024.0f) // Absolute max glow height.

// Flags for DL_ProjectOnSurface
#define DLF_SORT_LUMADSC 0x1 // Sort dynlights by luma, brightest to dullest.
#define DLF_NO_PLANAR 0x2 // Surface is not lit by planar lights.
#define DLF_TEX_FLOOR 0x4 // Prefer the "floor" slot when picking textures.
#define DLF_TEX_CEILING 0x8 // Prefer the "ceiling" slot when picking textures.
/**
* @defgroup dynlightProjectFlags Flags for DL_ProjectOnSurface.
* @{
*/
#define DLF_SORT_LUMINOUSE_DESC 0x1 /// Sort by descending luminosity, brightest to dullest.
#define DLF_NO_PLANAR 0x2 /// Surface is not lit by planar lights.
#define DLF_TEX_FLOOR 0x4 /// Prefer the "floor" slot when picking textures.
#define DLF_TEX_CEILING 0x8 /// Prefer the "ceiling" slot when picking textures.
/**@}*/

/**
* The data of a projected dynamic light is stored in this structure.
* A list of these is associated with each surface lit by texture mapped lights
* in a frame.
*/
typedef struct dynlight_s {
float s[2], t[2];
float color[3];
DGLuint texture;
DGLuint texture;
float s[2], t[2];
float color[3];
} dynlight_t;

extern int useDynLights, dlBlend;
extern float dlFactor, dlFogBright;
extern int useWallGlow, glowHeightMax;
extern float glowHeightFactor;
/**
* Initialize the dynlight system in preparation for rendering view(s) of the
* game world. Called by R_InitLevel().
*/
void DL_InitForMap(void);

// Initialization
void DL_Register(void);
/**
* Moves all used dynlight nodes to the list of unused nodes, so they
* can be reused.
*/
void DL_InitForNewFrame(void);

// Setup.
void DL_InitForMap(void);
void DL_InitForNewFrame(void);
/**
* Project all objects affecting the given quad (world space), calculate
* coordinates (in texture space) then store into a new list of projections.
*
* \assume The coordinates of the given quad must be contained wholly within
* the subsector specified. This is due to an optimization within the lumobj
* management which separates them according to their position in the BSP.
*
* @param ssec Subsector within which the quad wholly resides.
* @param topLeft Coordinates of the top left corner of the quad.
* @param bottomRight Coordinates of the bottom right corner of the quad.
* @param normal Normalized normal of the quad.
* @param flags @see dynlightProjectFlags
*
* @return Dynlight list name if the quad is lit by one or more light sources else @c 0.
*/
uint DL_ProjectOnSurface(subsector_t* ssec, const vectorcomp_t topLeft[3],
const vectorcomp_t bottomRight[3], const vectorcomp_t normal[3], int flags);

// Action.
uint DL_ProjectOnSurface(subsector_t* ssec, const vectorcomp_t topLeft[3],
const vectorcomp_t bottomRight[3],
const vectorcomp_t normal[3], byte flags);
// Helpers.
boolean DL_ListIterator(uint listIdx, void* data,
boolean (*func) (const dynlight_t*, void*));
/**
* Calls func for all projected dynlights in the given list.
*
* @param listIdx Identifier of the list to process.
* @param data Ptr to pass to the callback.
* @param func Callback to make for each object.
*
* @return @c true, iff every callback returns @c true.
*/
boolean DL_ListIterator(uint listIdx, void* data, boolean (*func) (const dynlight_t*, void*));

#endif
#endif /* LIBDENG_RENDER_DYNLIGHT_H */
6 changes: 5 additions & 1 deletion doomsday/engine/portable/include/rend_list.h
Expand Up @@ -32,7 +32,7 @@
#include "r_data.h"

// Multiplicative blending for dynamic lights?
#define IS_MUL (dlBlend != 1 && !usingFog)
#define IS_MUL (dynlightBlend != 1 && !usingFog)

// Types of rendering primitives.
typedef enum primtype_e {
Expand Down Expand Up @@ -65,7 +65,11 @@ extern int renderTextures;
extern int renderWireframe;
extern int useMultiTexLights;
extern int useMultiTexDetails;

extern int dynlightBlend;

extern float detailFactor, detailScale;

extern int torchAdditive;
extern float torchColor[];

Expand Down
11 changes: 10 additions & 1 deletion doomsday/engine/portable/include/rend_main.h
Expand Up @@ -33,6 +33,8 @@
#include "rend_list.h"
#include "r_things.h"

#define GLOW_HEIGHT_MAX (1024.0f) // Absolute max glow height.

extern float vx, vy, vz, vang, vpitch, fieldOfView, yfov;
extern byte smoothTexAnim, devMobjVLights;
extern float viewsidex, viewsidey;
Expand All @@ -43,7 +45,14 @@ extern int rAmbient;
extern float rendLightDistanceAttentuation;
extern float lightModRange[255];
extern int devRendSkyMode;
extern float glowingTextures;

extern int useDynLights;
extern float dynlightFactor, dynlightFogBright;

extern int useWallGlow;
extern float glowFactor, glowHeightFactor;
extern int glowHeightMax;

extern int useShinySurfaces;

void Rend_Register(void);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/p_materialmanager.c
Expand Up @@ -1369,7 +1369,7 @@ materialvariant_t* Materials_Prepare(material_snapshot_t* snapshot, material_t*

snapshot->width = Material_Width(mat);
snapshot->height = Material_Height(mat);
snapshot->glowing = MaterialVariant_Layer(variant, 0)->glow * glowingTextures;
snapshot->glowing = MaterialVariant_Layer(variant, 0)->glow * glowFactor;
snapshot->isOpaque = NULL != texUnits[MTU_PRIMARY].tex &&
!TextureVariant_IsMasked(texUnits[MTU_PRIMARY].tex);

Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/r_lumobjs.c
Expand Up @@ -107,6 +107,7 @@ static lumlistnode_t** subLumObjList = NULL;
*/
void LO_Register(void)
{
C_VAR_INT("rend-mobj-light-auto", &useMobjAutoLights, 0, 0, 1);
C_VAR_INT("rend-light-num", &loMaxLumobjs, CVF_NO_MAX, 0, 0);
C_VAR_FLOAT("rend-light-radius-scale", &loRadiusFactor, 0, 0.1f, 10);
C_VAR_INT("rend-light-radius-max", &loMaxRadius, 0, 64, 512);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_things.c
Expand Up @@ -1647,7 +1647,7 @@ boolean visSpriteLightIterator(const lumobj_t* lum, float xyDist, void* data)
(LUM_PLANE(lum)->color[0] > 0 || LUM_PLANE(lum)->color[1] > 0 ||
LUM_PLANE(lum)->color[2] > 0))
{
float glowHeight = (MAX_GLOWHEIGHT * LUM_PLANE(lum)->intensity) * glowHeightFactor;
float glowHeight = (GLOW_HEIGHT_MAX * LUM_PLANE(lum)->intensity) * glowHeightFactor;

// Don't make too small or too large glows.
if(glowHeight > 2)
Expand Down

0 comments on commit 593cfc3

Please sign in to comment.