Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Map Renderer: Redesigned mechanism for applying geometry wall divisions
This new interface is rather more flexible, allowing for further
improvements to the map geometry construction.

Note that the walldivs_t structure in its present form is an interim
measure only and will soon be replaced entirely.
  • Loading branch information
danij-deng committed May 23, 2012
1 parent 8a0880c commit 006ebd5
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 211 deletions.
17 changes: 14 additions & 3 deletions doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -20,18 +20,29 @@ typedef struct lineowner_s {
shadowvert_t shadowOffsets;
} lineowner_t;

/// Maximum number of walldivnode_ts in a walldivs_t dataset.
#define WALLDIVS_MAX_NODES 64
struct walldivs_s;

typedef struct walldivnode_s {
struct walldivs_s* divs;
coord_t height;
} walldivnode_t;

coord_t WallDivNode_Height(walldivnode_t* node);
walldivnode_t* WallDivNode_Next(walldivnode_t* node);
walldivnode_t* WallDivNode_Prev(walldivnode_t* node);

/// Maximum number of walldivnode_ts in a walldivs_t dataset.
#define WALLDIVS_MAX_NODES 64

typedef struct walldivs_s {
uint num;
walldivnode_t nodes[WALLDIVS_MAX_NODES];
struct walldivnode_s nodes[WALLDIVS_MAX_NODES];
} walldivs_t;

uint WallDivs_Size(const walldivs_t* wallDivs);
walldivnode_t* WallDivs_First(walldivs_t* wallDivs);
walldivnode_t* WallDivs_Last(walldivs_t* wallDivs);

typedef struct mvertex_s {
// Vertex index. Always valid after loading and pruning of unused
// vertices has occurred.
Expand Down
14 changes: 8 additions & 6 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -292,14 +292,16 @@ void R_FreeRendColors(ColorRawf* rcolors);
void R_FreeRendTexCoords(rtexcoord_t* rtexcoords);
void R_InfoRendVerticesPool(void);

void R_DivVerts(rvertex_t* dst, const rvertex_t* src, const walldivs_t* leftDivs,
const walldivs_t* rightDivs);
void R_DivVerts(rvertex_t* dst, const rvertex_t* src,
walldivnode_t* leftDivFirst, uint leftDivCount, walldivnode_t* rightDivFirst, uint rightDivCount);

void R_DivVertColors(ColorRawf* dst, const ColorRawf* src, const walldivs_t* leftDivs,
const walldivs_t* rightDivs, float bL, float tL, float bR, float tR);
void R_DivTexCoords(rtexcoord_t* dst, const rtexcoord_t* src,
walldivnode_t* leftDivFirst, uint leftDivCount, walldivnode_t* rightDivFirst, uint rightDivCount,
float bL, float tL, float bR, float tR);

void R_DivTexCoords(rtexcoord_t* dst, const rtexcoord_t* src, const walldivs_t* leftDivs,
const walldivs_t* rightDivs, float bL, float tL, float bR, float tR);
void R_DivVertColors(ColorRawf* dst, const ColorRawf* src,
walldivnode_t* leftDivFirst, uint leftDivCount, walldivnode_t* rightDivFirst, uint rightDivCount,
float bL, float tL, float bR, float tR);

void R_InitTranslationTables(void);
void R_UpdateTranslationTables(void);
Expand Down
12 changes: 10 additions & 2 deletions doomsday/engine/portable/include/rend_dynlight.h
Expand Up @@ -32,8 +32,16 @@ typedef struct {
uint numVertices, realNumVertices;
const coord_t* texTL, *texBR;
boolean isWall;
const walldivs_t* leftWallDivs;
const walldivs_t* rightWallDivs;
struct {
struct {
walldivnode_t* firstDiv;
uint divCount;
} left;
struct {
walldivnode_t* firstDiv;
uint divCount;
} right;
} wall;
} renderlightprojectionparams_t;

/**
Expand Down
14 changes: 11 additions & 3 deletions doomsday/engine/portable/include/rend_fakeradio.h
Expand Up @@ -38,6 +38,16 @@ typedef struct {
const coord_t* segLength;
const coord_t* linedefLength;
const Sector* frontSec, *backSec;
struct {
struct {
walldivnode_t* firstDiv;
uint divCount;
} left;
struct {
walldivnode_t* firstDiv;
uint divCount;
} right;
} wall;
} rendsegradio_params_t;

/// Register the console commands, variables, etc..., of this module.
Expand All @@ -54,9 +64,7 @@ void Rend_RadioUpdateLinedef(LineDef* line, boolean backSide);
/**
* Render FakeRadio for the given hedge section.
*/
void Rend_RadioSegSection(const rvertex_t* rvertices,
const walldivs_t* leftWallDivs, const walldivs_t* rightWallDivs,
const rendsegradio_params_t* params);
void Rend_RadioSegSection(const rvertex_t* rvertices, const rendsegradio_params_t* params);

/**
* Render FakeRadio for the given BSP leaf.
Expand Down
16 changes: 12 additions & 4 deletions doomsday/engine/portable/include/rend_shadow.h
Expand Up @@ -42,19 +42,27 @@ boolean Rend_MobjShadowsEnabled(void);
*/
void Rend_RenderMobjShadows(void);

/// Paramaters for Rend_RenderShadowProjections (POD).
/// Parameters for Rend_RenderShadowProjections (POD).
typedef struct {
uint lastIdx;
const rvertex_t* rvertices;
uint numVertices, realNumVertices;
const coord_t* texTL, *texBR;
boolean isWall;
const walldivs_t* leftWallDivs;
const walldivs_t* rightWallDivs;
struct {
struct {
walldivnode_t* firstDiv;
uint divCount;
} left;
struct {
walldivnode_t* firstDiv;
uint divCount;
} right;
} wall;
} rendershadowprojectionparams_t;

/**
* Render all shadows in projection list @a listIdx according to @a paramaters
* 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);
Expand Down
63 changes: 56 additions & 7 deletions doomsday/engine/portable/src/hedge.cpp
Expand Up @@ -25,6 +25,46 @@
#include "de_play.h"
#include "de_refresh.h"

coord_t WallDivNode_Height(walldivnode_t* node)
{
assert(node);
return node->height;
}

walldivnode_t* WallDivNode_Next(walldivnode_t* node)
{
assert(node);
uint idx = node - node->divs->nodes;
if(idx+1 >= node->divs->num) return 0;
return &node->divs->nodes[idx+1];
}

walldivnode_t* WallDivNode_Prev(walldivnode_t* node)
{
assert(node);
uint idx = node - node->divs->nodes;
if(idx == 0) return 0;
return &node->divs->nodes[idx-1];
}

uint WallDivs_Size(const walldivs_t* wd)
{
assert(wd);
return wd->num;
}

walldivnode_t* WallDivs_First(walldivs_t* wd)
{
assert(wd);
return &wd->nodes[0];
}

walldivnode_t* WallDivs_Last(walldivs_t* wd)
{
assert(wd);
return &wd->nodes[wd->num-1];
}

static int C_DECL sortWallDivNode(const void* e1, const void* e2)
{
const coord_t h1 = ((walldivnode_t*)e1)->height;
Expand All @@ -34,7 +74,15 @@ static int C_DECL sortWallDivNode(const void* e1, const void* e2)
return 0;
}

static walldivnode_t* findWallDivNodeByZOrigin(walldivs_t* wallDivs, float height)
static void addWallDivNode(walldivs_t* wd, coord_t height)
{
assert(wd);
struct walldivnode_s* node = &wd->nodes[wd->num++];
node->divs = wd;
node->height = height;
}

static walldivnode_t* findWallDivNodeByZOrigin(walldivs_t* wallDivs, coord_t height)
{
Q_ASSERT(wallDivs);
for(uint i = 0; i < wallDivs->num; ++i)
Expand Down Expand Up @@ -110,7 +158,7 @@ static void addWallDivNodesForPlaneIntercepts(HEdge* hedge, walldivs_t* wallDivs
{
if(!findWallDivNodeByZOrigin(wallDivs, pln->visHeight))
{
wallDivs->nodes[wallDivs->num++].height = pln->visHeight;
addWallDivNode(wallDivs, pln->visHeight);

// Have we reached the div limit?
if(wallDivs->num == WALLDIVS_MAX_NODES)
Expand Down Expand Up @@ -147,7 +195,7 @@ static void addWallDivNodesForPlaneIntercepts(HEdge* hedge, walldivs_t* wallDivs
{
if(!findWallDivNodeByZOrigin(wallDivs, z))
{
wallDivs->nodes[wallDivs->num++].height = z;
addWallDivNode(wallDivs, z);

// Have we reached the div limit?
if(wallDivs->num == WALLDIVS_MAX_NODES)
Expand All @@ -170,14 +218,15 @@ static void buildWallDiv(walldivs_t* wallDivs, HEdge* hedge,
{
wallDivs->num = 0;

// Add the first node.
wallDivs->nodes[wallDivs->num++].height = bottomZ;
// Nodes are arranged according to their Z axis height in ascending order.
// The first node is the bottom.
addWallDivNode(wallDivs, bottomZ);

// Add nodes for intercepts.
addWallDivNodesForPlaneIntercepts(hedge, wallDivs, section, bottomZ, topZ, doRight);

// Add the last node.
wallDivs->nodes[wallDivs->num++].height = topZ;
// The last node is the top.
addWallDivNode(wallDivs, topZ);

if(!(wallDivs->num > 2)) return;

Expand Down

0 comments on commit 006ebd5

Please sign in to comment.