Skip to content

Commit

Permalink
Refactor: Updated more map renderer internal APIs to use libdeng2's V…
Browse files Browse the repository at this point in the history
…ector
  • Loading branch information
danij-deng committed Apr 30, 2013
1 parent eceb986 commit 56d7517
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 393 deletions.
23 changes: 10 additions & 13 deletions doomsday/client/include/r_util.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @file r_util.h
/** @file r_util.h Refresh Utility Routines.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,17 +17,13 @@
* http://www.gnu.org/licenses</small>
*/

/**
* Refresh Utility Routines
*/
#ifndef DENG_REFRESH_UTIL_H
#define DENG_REFRESH_UTIL_H

#ifndef LIBDENG_REFRESH_UTIL_H
#define LIBDENG_REFRESH_UTIL_H
#include "api_gl.h"

#include <de/Vector>
#include <de/vector1.h>
#include "BspNode"
#include "map/p_mapdata.h"
#include <de/Vector>

/**
* Get a global angle from Cartesian coordinates relative to the viewer.
Expand Down Expand Up @@ -57,7 +53,7 @@ void R_ProjectViewRelativeLine2D(coord_t const center[2], boolean alignToViewPla
*/
void R_AmplifyColor(de::Vector3f &color);

void R_ScaleAmbientRGB(float* out, const float* in, float mul);
void R_ScaleAmbientRGB(float *out, float const *in, float mul);

/**
* Generate texcoords on the surface centered on point.
Expand All @@ -74,9 +70,10 @@ void R_ScaleAmbientRGB(float* out, const float* in, float mul);
*
* @return @c true if the generated coords are within bounds.
*/
boolean R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point, float xScale, float yScale,
const_pvec3d_t v1, const_pvec3d_t v2, const_pvec3f_t tangent, const_pvec3f_t bitangent);
bool R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point,
float xScale, float yScale, const_pvec3d_t v1, const_pvec3d_t v2,
const_pvec3f_t tangent, const_pvec3f_t bitangent);

char const *R_NameForBlendMode(blendmode_t mode);

#endif /* LIBDENG_REFRESH_UTIL_H */
#endif // DENG_REFRESH_UTIL_H
27 changes: 16 additions & 11 deletions doomsday/client/include/render/lumobj.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @file lumobj.h Luminous Object Management
/** @file render/lumobj.h Luminous Object Management
* @ingroup render
*
* @author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
Expand All @@ -19,17 +19,21 @@
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_RENDER_LUMINOUS_H
#define LIBDENG_RENDER_LUMINOUS_H
#ifndef DENG_RENDER_LUMINOUS_H
#define DENG_RENDER_LUMINOUS_H

#include <de/vector1.h>

#include <de/Vector>

#include "api_gl.h"

#include "dd_types.h"
#include "color.h"
#include <de/vector1.h>
#include "map/p_mapdata.h"
#include "resource/r_data.h"

class BspLeaf;

// Luminous object types.
typedef enum {
LT_OMNI, ///< Omni (spherical) light.
Expand Down Expand Up @@ -180,8 +184,9 @@ void LO_ClipInBspLeafBySight(uint bspLeafIdx);
*
* @return @c 0 iff iteration completed wholly.
*/
int LO_LumobjsRadiusIterator2(BspLeaf *bspLeaf, coord_t x, coord_t y, coord_t radius, int (*callback) (lumobj_t const *lum, coord_t distance, void *paramaters), void* paramaters);
int LO_LumobjsRadiusIterator(BspLeaf *bspLeaf, coord_t x, coord_t y, coord_t radius, int (*callback) (lumobj_t const *lum, coord_t distance, void *paramaters)/*, paramaters = 0 */);
int LO_LumobjsRadiusIterator(BspLeaf *bspLeaf, coord_t x, coord_t y, coord_t radius,
int (*callback) (lumobj_t const *lum, coord_t distance, void *parameters),
void *parameters = 0);

/**
* @defgroup projectLightFlags Flags for LO_ProjectToSurface
Expand Down Expand Up @@ -216,7 +221,7 @@ int LO_LumobjsRadiusIterator(BspLeaf *bspLeaf, coord_t x, coord_t y, coord_t rad
* @return Projection list identifier if surface is lit else @c 0.
*/
uint LO_ProjectToSurface(int flags, BspLeaf *bspLeaf, float blendFactor,
pvec3d_t topLeft, pvec3d_t bottomRight,
de::Vector3d const &topLeft, de::Vector3d const &bottomRight,
de::Vector3f const &tangent, de::Vector3f const &bitangent, de::Vector3f const &normal);

/**
Expand All @@ -230,9 +235,9 @@ uint LO_ProjectToSurface(int flags, BspLeaf *bspLeaf, float blendFactor,
*
* @return @c 0 iff iteration completed wholly.
*/
int LO_IterateProjections2(uint listIdx, int (*callback) (dynlight_t const *, void *), void *parameters);
int LO_IterateProjections(uint listIdx, int (*callback) (dynlight_t const *, void*)/*, parameters = 0*/);
int LO_IterateProjections(uint listIdx, int (*callback) (dynlight_t const *, void *),
void *parameters = 0);

void LO_DrawLumobjs();

#endif // LIBDENG_RENDER_LUMINOUS_H
#endif // DENG_RENDER_LUMINOUS_H
25 changes: 12 additions & 13 deletions doomsday/client/include/render/r_shadow.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @file r_shadow.h Map Object Shadows.
/** @file render/r_shadow.h Map Object Shadows.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,12 +17,10 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_REFRESH_MOBJ_SHADOW_H
#define LIBDENG_REFRESH_MOBJ_SHADOW_H
#ifndef DENG_RENDER_SHADOW_H
#define DENG_RENDER_SHADOW_H

#include "dd_types.h"
#include <de/Vector>
#include <de/vector1.h>

struct mobj_s;
class BspLeaf;
Expand All @@ -31,21 +29,22 @@ class Plane;
/**
* ShadowProjection. Shadow Projection (POD) stores the results of projection.
*/
typedef struct {
struct shadowprojection_t
{
float s[2], t[2];
float alpha;
} shadowprojection_t;
};

/**
* To be called after map load to initialize this module in preparation for
* rendering view(s) of the game world.
*/
void R_InitShadowProjectionListsForMap(void);
void R_InitShadowProjectionListsForMap();

/**
* To be called when begining a new render frame to perform necessary initialization.
*/
void R_InitShadowProjectionListsForNewFrame(void);
void R_InitShadowProjectionListsForNewFrame();

float R_ShadowAttenuationFactor(coord_t distance);

Expand All @@ -68,7 +67,7 @@ float R_ShadowAttenuationFactor(coord_t distance);
* @return Projection list identifier if surface is lit else @c 0.
*/
uint R_ProjectShadowsToSurface(BspLeaf *bspLeaf, float blendFactor,
pvec3d_t topLeft, pvec3d_t bottomRight,
de::Vector3d const &topLeft, de::Vector3d const &bottomRight,
de::Vector3f const &tangent, de::Vector3f const &bitangent, de::Vector3f const &normal);

/**
Expand All @@ -82,8 +81,8 @@ uint R_ProjectShadowsToSurface(BspLeaf *bspLeaf, float blendFactor,
*
* @return @c 0 iff iteration completed wholly.
*/
int R_IterateShadowProjections2(uint listIdx, int (*callback) (shadowprojection_t const *, void *), void *parameters);
int R_IterateShadowProjections(uint listIdx, int (*callback) (shadowprojection_t const *, void *)); /* parameters = NULL */
int R_IterateShadowProjections(uint listIdx, int (*callback) (shadowprojection_t const *, void *),
void *parameters = 0);

/**
* Find the highest plane beneath @a mobj onto which it's shadow should be cast.
Expand All @@ -93,4 +92,4 @@ int R_IterateShadowProjections(uint listIdx, int (*callback) (shadowprojection_t
*/
Plane *R_FindShadowPlane(struct mobj_s *mobj);

#endif /* LIBDENG_REFRESH_SHADOW_H */
#endif // DENG_RENDER_SHADOW_H
26 changes: 12 additions & 14 deletions doomsday/client/include/render/rend_dynlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_RENDER_DYNLIGHT_H
#define LIBDENG_RENDER_DYNLIGHT_H
#ifndef DENG_RENDER_DYNLIGHT_H
#define DENG_RENDER_DYNLIGHT_H

#include <de/Vector>

#include "render/rendpoly.h"
#include "render/walldiv.h"

/// Paramaters for Rend_RenderLightProjections (POD).
typedef struct {
uint lastIdx;
rvertex_t const *rvertices;
uint numVertices, realNumVertices;
coord_t const *texTL, *texBR;
boolean isWall;
de::Vector3d const *texTL;
de::Vector3d const *texBR;
bool isWall;
struct {
struct {
walldivnode_t *firstDiv;
Expand All @@ -39,10 +45,6 @@ typedef struct {
} wall;
} renderlightprojectionparams_t;

#ifdef __cplusplus
extern "C" {
#endif

/**
* Render all dynlights in projection list @a listIdx according to @a paramaters
* writing them to the renderering lists for the current frame.
Expand All @@ -51,10 +53,6 @@ extern "C" {
*
* @return Number of lights rendered.
*/
uint Rend_RenderLightProjections(uint listIdx, renderlightprojectionparams_t *paramaters);

#ifdef __cplusplus
} // extern "C"
#endif
uint Rend_RenderLightProjections(uint listIdx, renderlightprojectionparams_t &parameters);

#endif /* LIBDENG_RENDER_DYNLIGHT_H */
#endif // DENG_RENDER_DYNLIGHT_H
34 changes: 16 additions & 18 deletions doomsday/client/include/render/rend_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG_RENDER_MOBJ_SHADOW_H
#define LIBDENG_RENDER_MOBJ_SHADOW_H
#ifndef DENG_RENDER_MOBJ_SHADOW_H
#define DENG_RENDER_MOBJ_SHADOW_H

#ifdef __cplusplus
extern "C" {
#endif
#include <de/Vector>

#include "render/rendpoly.h"
#include "render/walldiv.h"

/**
* This value defines the offset from the shadowed surface applied to
Expand All @@ -33,28 +34,29 @@ extern "C" {
#define SHADOW_ZOFFSET (.8f)

/// @return @c true if rendering of mobj shadows is currently enabled.
boolean Rend_MobjShadowsEnabled(void);
bool Rend_MobjShadowsEnabled();

/**
* Use the simple, drop-to-highest-floor algorithm for rendering mobj shadows
* selected for this method. Rendering lists are not used.
*/
void Rend_RenderMobjShadows(void);
void Rend_RenderMobjShadows();

/// Parameters for Rend_RenderShadowProjections (POD).
typedef struct {
uint lastIdx;
const rvertex_t* rvertices;
rvertex_t const *rvertices;
uint numVertices, realNumVertices;
const coord_t* texTL, *texBR;
boolean isWall;
de::Vector3d const *texTL;
de::Vector3d const *texBR;
bool isWall;
struct {
struct {
walldivnode_t* firstDiv;
walldivnode_t *firstDiv;
uint divCount;
} left;
struct {
walldivnode_t* firstDiv;
walldivnode_t *firstDiv;
uint divCount;
} right;
} wall;
Expand All @@ -64,10 +66,6 @@ typedef struct {
* Render all shadows in projection list @a listIdx according to @a parameters
* writing them to the renderering lists for the current frame.
*/
void Rend_RenderShadowProjections(uint listIdx, rendershadowprojectionparams_t* paramaters);

#ifdef __cplusplus
} // extern "C"
#endif
void Rend_RenderShadowProjections(uint listIdx, rendershadowprojectionparams_t &parameters);

#endif /* LIBDENG_RENDER_MOBJ_SHADOW_H */
#endif // DENG_RENDER_MOBJ_SHADOW_H
5 changes: 3 additions & 2 deletions doomsday/client/src/r_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ void R_ScaleAmbientRGB(float *out, const float *in, float mul)
}
}

boolean R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point, float xScale, float yScale,
const_pvec3d_t v1, const_pvec3d_t v2, const_pvec3f_t tangent, const_pvec3f_t bitangent)
bool R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point,
float xScale, float yScale, const_pvec3d_t v1, const_pvec3d_t v2,
const_pvec3f_t tangent, const_pvec3f_t bitangent)
{
vec3d_t vToPoint;

Expand Down
Loading

0 comments on commit 56d7517

Please sign in to comment.