Skip to content

Commit

Permalink
Refactor|Client|Map Renderer: Specify position coordinates to the ren…
Browse files Browse the repository at this point in the history
…der lists with de::VectorN<>
  • Loading branch information
danij-deng committed Aug 7, 2013
1 parent c2e4275 commit 5866e11
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 331 deletions.
10 changes: 5 additions & 5 deletions doomsday/client/include/render/biassurface.h
Expand Up @@ -43,12 +43,12 @@ class BiasSurface
* Perform lighting for the supplied geometry. The derived class wil define
* how these vertices map to bias illumination points.
*
* @param geomGroup Geometry group identifier.
* @param positions World coordinates for each vertex.
* @param colors Final lighting values will be written here.
* @param group Geometry group identifier.
* @param posCoords World coordinates for each vertex.
* @param colorCoords Final lighting values will be written here.
*/
virtual void lightBiasPoly(int geomGroup, rvertex_t const *positions,
de::Vector4f *colors) = 0;
virtual void lightBiasPoly(int group, de::Vector3f const *posCoords,
de::Vector4f *colorCoords) = 0;

/**
* Schedule a lighting update to a geometry group following a move of some
Expand Down
4 changes: 1 addition & 3 deletions doomsday/client/include/render/rend_dynlight.h
Expand Up @@ -24,12 +24,10 @@

#include "WallEdge"

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

/// Paramaters for Rend_RenderLightProjections (POD).
typedef struct {
uint lastIdx;
rvertex_t const *rvertices;
de::Vector3f const *rvertices;
uint numVertices, realNumVertices;
de::Vector3d const *texTL;
de::Vector3d const *texBR;
Expand Down
10 changes: 5 additions & 5 deletions doomsday/client/include/render/rend_list.h
Expand Up @@ -146,7 +146,7 @@ void RL_Rtu_SetTextureUnmanaged(uint idx, DGLuint glName, int wrapS, int wrapT);
* vertices of the primitive.
*/
void RL_AddPolyWithCoordsModulationReflection(primtype_t primType, int flags,
uint numElements, const rvertex_t* vertices, const de::Vector4f* colors,
uint numElements, const de::Vector3f* vertices, const de::Vector4f* colors,
const de::Vector2f* primaryCoords, const de::Vector2f* interCoords,
DGLuint modTex, const de::Vector4f* modColor, const de::Vector2f* modCoords,
const de::Vector4f* reflectionColors, const de::Vector2f* reflectionCoords,
Expand All @@ -160,7 +160,7 @@ void RL_AddPolyWithCoordsModulationReflection(primtype_t primType, int flags,
* vertices of the primitive.
*/
void RL_AddPolyWithCoordsModulation(primtype_t primType, int flags,
uint numElements, const rvertex_t* vertices, const de::Vector4f* colors,
uint numElements, const de::Vector3f* vertices, const de::Vector4f* colors,
const de::Vector2f* primaryCoords, const de::Vector2f* interCoords,
DGLuint modTex, const de::Vector4f* modColor, const de::Vector2f* modCoords);

Expand All @@ -172,7 +172,7 @@ void RL_AddPolyWithCoordsModulation(primtype_t primType, int flags,
* vertices of the primitive.
*/
void RL_AddPolyWithCoords(primtype_t primType, int flags, uint numElements,
const rvertex_t* vertices, const de::Vector4f* colors,
const de::Vector3f* vertices, const de::Vector4f* colors,
const de::Vector2f* primaryCoords, const de::Vector2f* interCoords);

/**
Expand All @@ -183,7 +183,7 @@ void RL_AddPolyWithCoords(primtype_t primType, int flags, uint numElements,
* vertices of the primitive.
*/
void RL_AddPolyWithModulation(primtype_t primType, int flags, uint numElements,
const rvertex_t* vertices, const de::Vector4f* colors,
const de::Vector3f* vertices, const de::Vector4f* colors,
DGLuint modTex, const de::Vector4f* modColor, const de::Vector2f* modCoords);

/**
Expand All @@ -194,7 +194,7 @@ void RL_AddPolyWithModulation(primtype_t primType, int flags, uint numElements,
* vertices of the primitive.
*/
void RL_AddPoly(primtype_t primType, int flags, uint numElements,
const rvertex_t* vertices, const de::Vector4f* colors);
const de::Vector3f* vertices, const de::Vector4f* colors);

void RL_RenderAllLists(void);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/render/rend_main.h
Expand Up @@ -166,7 +166,7 @@ texturevariantspecification_t &Rend_MapSurfaceShinyTextureSpec();

texturevariantspecification_t &Rend_MapSurfaceShinyMaskTextureSpec();

void R_DivVerts(rvertex_t *dst, rvertex_t const *src,
void R_DivVerts(de::Vector3f *dst, de::Vector3f const *src,
de::WorldEdge const &leftEdge, de::WorldEdge const &rightEdge);

void R_DivTexCoords(de::Vector2f *dst, de::Vector2f const *src,
Expand Down
4 changes: 1 addition & 3 deletions doomsday/client/include/render/rend_shadow.h
Expand Up @@ -24,8 +24,6 @@

#include "WallEdge"

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

/**
* This value defines the offset from the shadowed surface applied to
* shadows rendered with the simple drop-to-highest-floor method.
Expand All @@ -46,7 +44,7 @@ void Rend_RenderMobjShadows();
/// Parameters for Rend_RenderShadowProjections (POD).
typedef struct {
uint lastIdx;
rvertex_t const *rvertices;
de::Vector3f const *rvertices;
uint numVertices, realNumVertices;
de::Vector3d const *texTL;
de::Vector3d const *texBR;
Expand Down
47 changes: 19 additions & 28 deletions doomsday/client/include/render/rendpoly.h
Expand Up @@ -141,58 +141,49 @@ void R_PrintRendPoolInfo(void);
void R_InitRendPolyPools(void);

/**
* Retrieves a batch of rvertex_t.
* Possibly allocates new if necessary.
* Allocate a new contiguous range of position coordinates from the specialized
* write-geometry pool
*
* @param num The number of verts required.
*
* @return Ptr to array of rvertex_t
* @param num The number of coordinate sets required.
*/
rvertex_t *R_AllocRendVertices(uint num);
de::Vector3f *R_AllocRendVertices(uint num);

/**
* Retrieves a batch of ColorRawf.
* Possibly allocates new if necessary.
*
* @param num The number of verts required.
* Allocate a new contiguous range of color coordinates from the specialized
* write-geometry pool
*
* @return Ptr to array of ColorRawf
* @param num The number of coordinate sets required.
*/
de::Vector4f *R_AllocRendColors(uint num);

/**
* Retrieves a batch of rtexcoord_t.
* Possibly allocates new if necessary.
*
* @param num The number required.
* Allocate a new contiguous range of texture coordinates from the specialized
* write-geometry pool
*
* @return Ptr to array of rtexcoord_t
* @param num The number of coordinate sets required.
*/
de::Vector2f *R_AllocRendTexCoords(uint num);

/**
* Doesn't actually free anything. Instead, mark them as unused ready for
* the next time a batch of rendvertex_t is needed.
* @note Doesn't actually free anything (storage is pooled for reuse).
*
* @param rvertices Ptr to array of rvertex_t to mark unused.
* @param posCoords Position coordinates to mark unused.
*/
void R_FreeRendVertices(rvertex_t *rvertices);
void R_FreeRendVertices(de::Vector3f *posCoords);

/**
* Doesn't actually free anything. Instead, mark them as unused ready for
* the next time a batch of rendvertex_t is needed.
* @note Doesn't actually free anything (storage is pooled for reuse).
*
* @param rcolors Ptr to array of ColorRawf to mark unused.
* @param colorCoords Color coordinates to mark unused.
*/
void R_FreeRendColors(de::Vector4f *rcolors);
void R_FreeRendColors(de::Vector4f *colorCoords);

/**
* Doesn't actually free anything. Instead, mark them as unused ready for
* the next time a batch of rendvertex_t is needed.
* @note Doesn't actually free anything (storage is pooled for reuse).
*
* @param rtexcoords Ptr to array of rtexcoord_t to mark unused.
* @param texCoords Texture coordinates to mark unused.
*/
void R_FreeRendTexCoords(de::Vector2f *rtexcoords);
void R_FreeRendTexCoords(de::Vector2f *texCoords);

/// Manipulators, for convenience.
void Rtu_Init(rtexmapunit_t *rtu);
Expand Down
8 changes: 3 additions & 5 deletions doomsday/client/include/render/trianglestripbuilder.h
Expand Up @@ -25,8 +25,6 @@
#include <de/libdeng2.h>
#include <de/Vector>

#include "render/rendpoly.h" /// @todo Remove me

namespace de {

/**
Expand Down Expand Up @@ -112,7 +110,7 @@ class WorldEdge : public AbstractEdge

virtual Vector3d origin() const = 0;

inline coord_t z() const { return origin().z; }
inline double z() const { return origin().z; }
};

public:
Expand Down Expand Up @@ -146,7 +144,7 @@ class WorldEdge : public AbstractEdge

namespace de {

typedef QVarLengthArray<rvertex_t, 24> PositionBuffer;
typedef QVarLengthArray<Vector3f, 24> PositionBuffer;
typedef QVarLengthArray<Vector2f, 24> TexCoordBuffer;

/**
Expand All @@ -158,7 +156,7 @@ typedef QVarLengthArray<Vector2f, 24> TexCoordBuffer;
*
* @todo Separate the backing store with an external allocator mechanism.
* (Geometry should not be owned by the builder.)
* @todo Support custom vertex types/do not depend on rvertex_t (etc...).
* @todo Support custom vertex types.
* (Once implemented move this component to libgui.)
* @todo Support building strips by adding single vertices.
*/
Expand Down
9 changes: 5 additions & 4 deletions doomsday/client/include/world/bspleaf.h
Expand Up @@ -280,11 +280,12 @@ class BspLeaf : public de::MapElement
*
* @important It is assumed there are least @ref numFanVertices() elements!
*
* @param group Geometry group identifier.
* @param positions World coordinates for each vertex.
* @param colors Final lighting values will be written here.
* @param group Geometry group identifier.
* @param posCoords World coordinates for each vertex.
* @param colorCoords Final lighting values will be written here.
*/
void lightBiasPoly(int group, rvertex_t const *positions, de::Vector4f *colors);
void lightBiasPoly(int group, de::Vector3f const *posCoords,
de::Vector4f *colorCoords);

void updateBiasAfterGeometryMove(int group);

Expand Down
9 changes: 5 additions & 4 deletions doomsday/client/include/world/segment.h
Expand Up @@ -245,11 +245,12 @@ class Segment : public de::MapElement
*
* @important It is assumed there are least @em four elements!
*
* @param group Geometry group identifier.
* @param positions World coordinates for each vertex.
* @param colors Final lighting values will be written here.
* @param group Geometry group identifier.
* @param posCoords World coordinates for each vertex.
* @param colorCoords Final lighting values will be written here.
*/
void lightBiasPoly(int group, rvertex_t const *positions, de::Vector4f *colors);
void lightBiasPoly(int group, de::Vector3f const *posCoords,
de::Vector4f *colorCoords);

void updateBiasAfterGeometryMove(int group);

Expand Down
18 changes: 9 additions & 9 deletions doomsday/client/src/render/rend_dynlight.cpp
Expand Up @@ -34,9 +34,9 @@ static void drawDynlight(dynlight_t const &dyn, renderlightprojectionparams_t &p
if(!(RL_IsMTexLights() && parm.lastIdx == 0))
{
// Allocate enough for the divisions too.
rvertex_t *rvertices = R_AllocRendVertices(parm.realNumVertices);
Vector3f *rvertices = R_AllocRendVertices(parm.realNumVertices);
Vector2f *rtexcoords = R_AllocRendTexCoords(parm.realNumVertices);
Vector4f *rcolors = R_AllocRendColors(parm.realNumVertices);
Vector4f *rcolors = R_AllocRendColors(parm.realNumVertices);
bool const mustSubdivide = (parm.isWall && (parm.wall.leftEdge->divisionCount() || parm.wall.rightEdge->divisionCount() ));

for(uint i = 0; i < parm.numVertices; ++i)
Expand All @@ -62,7 +62,7 @@ static void drawDynlight(dynlight_t const &dyn, renderlightprojectionparams_t &p
* color.
*/

rvertex_t origVerts[4]; std::memcpy(origVerts, parm.rvertices, sizeof(rvertex_t) * 4);
Vector3f origVerts[4]; std::memcpy(origVerts, parm.rvertices, sizeof(Vector3f) * 4);
Vector2f origTexCoords[4]; std::memcpy(origTexCoords, rtexcoords, sizeof(Vector2f) * 4);
Vector4f origColors[4]; std::memcpy(origColors, rcolors, sizeof(Vector4f) * 4);

Expand All @@ -72,7 +72,7 @@ static void drawDynlight(dynlight_t const &dyn, renderlightprojectionparams_t &p
}
else
{
std::memcpy(rvertices, parm.rvertices, sizeof(rvertex_t) * parm.numVertices);
std::memcpy(rvertices, parm.rvertices, sizeof(Vector3f) * parm.numVertices);
}
}
else
Expand All @@ -83,14 +83,14 @@ static void drawDynlight(dynlight_t const &dyn, renderlightprojectionparams_t &p

for(uint i = 0; i < parm.numVertices; ++i)
{
rtexcoords[i].x = ((parm.texBR->x - parm.rvertices[i].pos[VX]) / width * dyn.s[0]) +
((parm.rvertices[i].pos[VX] - parm.texTL->x) / width * dyn.s[1]);
rtexcoords[i].x = ((parm.texBR->x - parm.rvertices[i].x) / width * dyn.s[0]) +
((parm.rvertices[i].x - parm.texTL->x) / width * dyn.s[1]);

rtexcoords[i].y = ((parm.texBR->y - parm.rvertices[i].pos[VY]) / height * dyn.t[0]) +
((parm.rvertices[i].pos[VY] - parm.texTL->y) / height * dyn.t[1]);
rtexcoords[i].y = ((parm.texBR->y - parm.rvertices[i].y) / height * dyn.t[0]) +
((parm.rvertices[i].y - parm.texTL->y) / height * dyn.t[1]);
}

std::memcpy(rvertices, parm.rvertices, sizeof(rvertex_t) * parm.numVertices);
std::memcpy(rvertices, parm.rvertices, sizeof(Vector3f) * parm.numVertices);
}

RL_LoadDefaultRtus();
Expand Down

0 comments on commit 5866e11

Please sign in to comment.