Skip to content

Commit

Permalink
Continued clean up of rend_main.c and the render lists interface. Shi…
Browse files Browse the repository at this point in the history
…ny polys are now added to the render lists using RL_AddPoly().
  • Loading branch information
danij committed Jan 20, 2009
1 parent e504bd1 commit ccab18a
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 329 deletions.
20 changes: 9 additions & 11 deletions doomsday/engine/portable/include/rend_list.h
Expand Up @@ -76,17 +76,15 @@ boolean RL_IsMTexDetails(void);
void RL_ClearLists(void);
void RL_DeleteLists(void);

void RL_AddPoly(primtype_t type, rendpolytype_t polyType,
const rvertex_t* vertices,
const rtexcoord_t* rtexcoords,
const rtexcoord_t* rtexcoords1,
const rtexcoord_t* rtexcoords2,
const rtexcoord_t* srtexcoords,
const rtexcoord_t* srtexcoords1,
const rcolor_t* colors, const rcolor_t* scolors,
uint numVertices,
uint numLights, DGLuint modTex, float modColor[3],
const rtexmapunit_t tu[NUM_TEXMAP_UNITS]);
void RL_AddPoly(primtype_t type, rendpolytype_t polyType,
const rvertex_t* rvertices,
const rtexcoord_t* rtexcoords, const rtexcoord_t* rtexcoords1,
const rtexcoord_t* rtexcoords2,
const rcolor_t* rcolors,
uint numVertices, uint numLights,
DGLuint modTex, float modColor[3],
const rtexmapunit_t rTU[NUM_TEXMAP_UNITS],
blendmode_t blendMode /*temp*/);
void RL_RenderAllLists(void);

#endif
36 changes: 18 additions & 18 deletions doomsday/engine/portable/src/rend_fakeradio.c
Expand Up @@ -1051,16 +1051,16 @@ static void renderShadowSeg(const rvertex_t* origVertices,
float texOrigin[2][3];
rcolor_t* rcolors;
rtexcoord_t* rtexcoords;
rtexmapunit_t pTU[NUM_TEXMAP_UNITS];
rtexmapunit_t rTU[NUM_TEXMAP_UNITS];
uint realNumVertices = 4;

if(divs)
realNumVertices = 3 + divs[0].num + 3 + divs[1].num;

memset(pTU, 0, sizeof(pTU));
pTU[TU_PRIMARY].tex = curTex = GL_PrepareLSTexture(p->texture);
pTU[TU_PRIMARY].magMode = DGL_LINEAR;
pTU[TU_PRIMARY].blend = 1;
memset(rTU, 0, sizeof(rTU));
rTU[TU_PRIMARY].tex = curTex = GL_PrepareLSTexture(p->texture);
rTU[TU_PRIMARY].magMode = DGL_LINEAR;
rTU[TU_PRIMARY].blend = 1;

// Top left.
texOrigin[0][VX] = origVertices[1].pos[VX];
Expand Down Expand Up @@ -1113,19 +1113,19 @@ static void renderShadowSeg(const rvertex_t* origVertices,
R_DivVertColors(rcolors, origColors, divs, bL, tL, bR, tR);

RL_AddPoly(PT_FAN, RPT_SHADOW, rvertices + 3 + divs[0].num,
rtexcoords + 3 + divs[0].num, NULL, NULL, NULL, NULL,
rcolors + 3 + divs[0].num, NULL, 3 + divs[1].num,
0, 0, NULL, pTU);
RL_AddPoly(PT_FAN, RPT_SHADOW, rvertices, rtexcoords, NULL, NULL, NULL, NULL,
rcolors, NULL,
3 + divs[0].num, 0, 0, NULL, pTU);
rtexcoords + 3 + divs[0].num, NULL, NULL,
rcolors + 3 + divs[0].num, 3 + divs[1].num,
0, 0, NULL, rTU, rTU[TU_PRIMARY].blendMode);
RL_AddPoly(PT_FAN, RPT_SHADOW, rvertices, rtexcoords, NULL, NULL,
rcolors, 3 + divs[0].num, 0, 0, NULL, rTU, rTU[TU_PRIMARY].blendMode);

R_FreeRendVertices(rvertices);
}
else
{
RL_AddPoly(PT_TRIANGLE_STRIP, RPT_SHADOW, origVertices, rtexcoords, NULL, NULL, NULL, NULL,
rcolors, NULL, 4, 0, 0, NULL, pTU);
RL_AddPoly(PT_TRIANGLE_STRIP, RPT_SHADOW, origVertices,
rtexcoords, NULL, NULL,
rcolors, 4, 0, 0, NULL, rTU, rTU[TU_PRIMARY].blendMode);
}
}

Expand Down Expand Up @@ -1363,7 +1363,7 @@ static void radioAddShadowEdge(const linedef_t* line, byte side,
const uint* idx;
rvertex_t rvertices[4];
rcolor_t rcolors[4];
rtexmapunit_t pTU[NUM_TEXMAP_UNITS];
rtexmapunit_t rTU[NUM_TEXMAP_UNITS];
float shadowAlpha;
vertex_t* vtx0, *vtx1;

Expand All @@ -1380,8 +1380,8 @@ static void radioAddShadowEdge(const linedef_t* line, byte side,
wind = (V2_Distance(inner[1], vtx1->V_pos) >
V2_Distance(inner[0], vtx0->V_pos)? 1 : 0);

memset(pTU, 0, sizeof(pTU));
pTU[TU_PRIMARY].blend = 1;
memset(rTU, 0, sizeof(rTU));
rTU[TU_PRIMARY].blend = 1;

idx = (normal[VZ] > 0 ? floorIndices[wind] : ceilIndices[wind]);

Expand Down Expand Up @@ -1427,8 +1427,8 @@ static void radioAddShadowEdge(const linedef_t* line, byte side,

if(rendFakeRadio != 2)
RL_AddPoly(PT_FAN, (renderWireframe? RPT_NORMAL : RPT_SHADOW),
rvertices, NULL, NULL, NULL, NULL, NULL,
rcolors, NULL, 4, 0, 0, NULL, pTU);
rvertices, NULL, NULL, NULL,
rcolors, 4, 0, 0, NULL, rTU, rTU[TU_PRIMARY].blendMode);
}

/**
Expand Down
100 changes: 47 additions & 53 deletions doomsday/engine/portable/src/rend_list.c
Expand Up @@ -503,26 +503,26 @@ static rendlist_t* createList(listhash_t* hash)
}

static __inline void copyTU(rendlist_texmapunit_t* lTU,
const rtexmapunit_t* pTU)
const rtexmapunit_t* rTU)
{
lTU->tex = pTU->tex;
lTU->magMode = pTU->magMode;
lTU->blendMode = pTU->blendMode;
lTU->blend = pTU->blend;
lTU->tex = rTU->tex;
lTU->magMode = rTU->magMode;
lTU->blendMode = rTU->blendMode;
lTU->blend = rTU->blend;
}

static __inline boolean compareTU(const rendlist_texmapunit_t* lTU,
const rtexmapunit_t* pTU)
const rtexmapunit_t* rTU)
{
if(lTU->tex == pTU->tex && lTU->magMode == pTU->magMode &&
lTU->blend == pTU->blend)
if(lTU->tex == rTU->tex && lTU->magMode == rTU->magMode &&
lTU->blend == rTU->blend)
return true;

return false;
}

static rendlist_t* getListFor(rendpolytype_t polyType,
const rtexmapunit_t pTU[NUM_TEXMAP_UNITS],
const rtexmapunit_t rTU[NUM_TEXMAP_UNITS],
boolean useLights)
{
listhash_t* hash, *table;
Expand All @@ -546,39 +546,39 @@ static rendlist_t* getListFor(rendpolytype_t polyType,
}

// Find/create a list in the hash.
hash = &table[(polyType == RPT_SHINY? pTU[TU_SHINY].tex :
pTU[TU_PRIMARY].tex) % RL_HASH_SIZE];
hash = &table[(polyType == RPT_SHINY? rTU[TU_SHINY].tex :
rTU[TU_PRIMARY].tex) % RL_HASH_SIZE];
for(dest = hash->first; dest; dest = dest->next)
{
if((polyType == RPT_SHINY &&
compareTU(TU(dest, TU_PRIMARY), &pTU[TU_SHINY])) ||
compareTU(TU(dest, TU_PRIMARY), &rTU[TU_SHINY])) ||
(polyType != RPT_SHINY &&
compareTU(TU(dest, TU_PRIMARY), &pTU[TU_PRIMARY]) &&
compareTU(TU(dest, TU_PRIMARY_DETAIL), &pTU[TU_PRIMARY_DETAIL])))
compareTU(TU(dest, TU_PRIMARY), &rTU[TU_PRIMARY]) &&
compareTU(TU(dest, TU_PRIMARY_DETAIL), &rTU[TU_PRIMARY_DETAIL])))
{
if(!TU(dest, TU_INTER)->tex &&
((polyType == RPT_SHINY && !pTU[TU_SHINY_MASK].tex) ||
(polyType != RPT_SHINY && !pTU[TU_INTER].tex)))
((polyType == RPT_SHINY && !rTU[TU_SHINY_MASK].tex) ||
(polyType != RPT_SHINY && !rTU[TU_INTER].tex)))
{
// This will do great.
return dest;
}

// Is this eligible for conversion to a blended list?
if(!dest->last && !convertable &&
((polyType == RPT_SHINY && pTU[TU_SHINY_MASK].tex) ||
(polyType != RPT_SHINY && pTU[TU_INTER].tex)))
((polyType == RPT_SHINY && rTU[TU_SHINY_MASK].tex) ||
(polyType != RPT_SHINY && rTU[TU_INTER].tex)))
{
// If necessary, this empty list will be selected.
convertable = dest;
}

// Possibly an exact match?
if((polyType == RPT_SHINY &&
compareTU(TU(dest, TU_INTER), &pTU[TU_SHINY_MASK])) ||
compareTU(TU(dest, TU_INTER), &rTU[TU_SHINY_MASK])) ||
(polyType != RPT_SHINY &&
compareTU(TU(dest, TU_INTER), &pTU[TU_INTER]) &&
compareTU(TU(dest, TU_INTER_DETAIL), &pTU[TU_INTER_DETAIL])))
compareTU(TU(dest, TU_INTER), &rTU[TU_INTER]) &&
compareTU(TU(dest, TU_INTER_DETAIL), &rTU[TU_INTER_DETAIL])))
{
return dest;
}
Expand All @@ -590,12 +590,12 @@ static rendlist_t* getListFor(rendpolytype_t polyType,
{ // This list is currently empty.
if(polyType == RPT_SHINY)
{
copyTU(TU(convertable, TU_INTER), &pTU[TU_SHINY_MASK]);
copyTU(TU(convertable, TU_INTER), &rTU[TU_SHINY_MASK]);
}
else
{
copyTU(TU(convertable, TU_INTER), &pTU[TU_INTER]);
copyTU(TU(convertable, TU_INTER_DETAIL), &pTU[TU_INTER_DETAIL]);
copyTU(TU(convertable, TU_INTER), &rTU[TU_INTER]);
copyTU(TU(convertable, TU_INTER_DETAIL), &rTU[TU_INTER_DETAIL]);
}

return convertable;
Expand All @@ -607,19 +607,19 @@ static rendlist_t* getListFor(rendpolytype_t polyType,
// Init the info.
if(polyType == RPT_SHINY)
{
copyTU(TU(dest, TU_PRIMARY), &pTU[TU_SHINY]);
if(pTU[TU_SHINY_MASK].tex)
copyTU(TU(dest, TU_INTER), &pTU[TU_SHINY_MASK]);
copyTU(TU(dest, TU_PRIMARY), &rTU[TU_SHINY]);
if(rTU[TU_SHINY_MASK].tex)
copyTU(TU(dest, TU_INTER), &rTU[TU_SHINY_MASK]);
}
else
{
copyTU(TU(dest, TU_PRIMARY), &pTU[TU_PRIMARY]);
copyTU(TU(dest, TU_PRIMARY_DETAIL), &pTU[TU_PRIMARY_DETAIL]);
copyTU(TU(dest, TU_PRIMARY), &rTU[TU_PRIMARY]);
copyTU(TU(dest, TU_PRIMARY_DETAIL), &rTU[TU_PRIMARY_DETAIL]);

if(pTU[TU_INTER].tex)
if(rTU[TU_INTER].tex)
{
copyTU(TU(dest, TU_INTER), &pTU[TU_INTER]);
copyTU(TU(dest, TU_INTER_DETAIL), &pTU[TU_INTER_DETAIL]);
copyTU(TU(dest, TU_INTER), &rTU[TU_INTER]);
copyTU(TU(dest, TU_INTER_DETAIL), &rTU[TU_INTER_DETAIL]);
}
}

Expand Down Expand Up @@ -803,7 +803,7 @@ static void addPoly(primtype_t type, rendpolytype_t polyType,
uint numVertices, blendmode_t blendMode,
uint numLights,
DGLuint modTex, float modColor[3],
const rtexmapunit_t pTU[NUM_TEXMAP_UNITS])
const rtexmapunit_t rTU[NUM_TEXMAP_UNITS])
{
uint i, base, primSize, numIndices;
rendlist_t* li;
Expand All @@ -816,7 +816,7 @@ BEGIN_PROF( PROF_RL_ADD_POLY );
BEGIN_PROF( PROF_RL_GET_LIST );

// Find/create a rendering list for the polygon's texture.
li = getListFor(polyType, pTU, useLights);
li = getListFor(polyType, rTU, useLights);

END_PROF( PROF_RL_GET_LIST );

Expand All @@ -843,20 +843,20 @@ END_PROF( PROF_RL_GET_LIST );
hdr->modColor[CG] = modColor? modColor[CG] : 0;
hdr->modColor[CB] = modColor? modColor[CB] : 0;

if(pTU[TU_PRIMARY].tex || pTU[TU_SHINY_MASK].tex)
if(rTU[TU_PRIMARY].tex || rTU[TU_SHINY_MASK].tex)
{
hdr->ptexScale[0] = pTU[TU_PRIMARY].scale[0];
hdr->ptexScale[1] = pTU[TU_PRIMARY].scale[1];
hdr->ptexOffset[0] = pTU[TU_PRIMARY].offset[0];
hdr->ptexOffset[1] = pTU[TU_PRIMARY].offset[1];
hdr->ptexScale[0] = rTU[TU_PRIMARY].scale[0];
hdr->ptexScale[1] = rTU[TU_PRIMARY].scale[1];
hdr->ptexOffset[0] = rTU[TU_PRIMARY].offset[0];
hdr->ptexOffset[1] = rTU[TU_PRIMARY].offset[1];
}

if(pTU[TU_PRIMARY_DETAIL].tex)
if(rTU[TU_PRIMARY_DETAIL].tex)
{
hdr->texScale[0] = pTU[TU_PRIMARY_DETAIL].scale[0];
hdr->texScale[1] = pTU[TU_PRIMARY_DETAIL].scale[1];
hdr->texOffset[0] = pTU[TU_PRIMARY_DETAIL].offset[0];
hdr->texOffset[1] = pTU[TU_PRIMARY_DETAIL].offset[1];
hdr->texScale[0] = rTU[TU_PRIMARY_DETAIL].scale[0];
hdr->texScale[1] = rTU[TU_PRIMARY_DETAIL].scale[1];
hdr->texOffset[0] = rTU[TU_PRIMARY_DETAIL].offset[0];
hdr->texOffset[1] = rTU[TU_PRIMARY_DETAIL].offset[1];
}
else
{
Expand All @@ -882,12 +882,11 @@ void RL_AddPoly(primtype_t type, rendpolytype_t polyType,
const rvertex_t* rvertices,
const rtexcoord_t* rtexcoords, const rtexcoord_t* rtexcoords1,
const rtexcoord_t* rtexcoords2,
const rtexcoord_t* srtexcoords, const rtexcoord_t* srtexcoords1,
const rcolor_t* rcolors,
const rcolor_t* srcolors,
uint numVertices, uint numLights,
DGLuint modTex, float modColor[3],
const rtexmapunit_t pTU[NUM_TEXMAP_UNITS])
const rtexmapunit_t rTU[NUM_TEXMAP_UNITS],
blendmode_t blendMode /* temp */)
{
if(numVertices < 3)
return; // huh?
Expand All @@ -896,12 +895,7 @@ void RL_AddPoly(primtype_t type, rendpolytype_t polyType,
Con_Error("RL_AddPoly: Unknown primtype %i.", type);

addPoly(type, polyType, rvertices, rtexcoords, rtexcoords1, rtexcoords2,
rcolors, numVertices, BM_NORMAL, numLights, modTex, modColor, pTU);

if(pTU[TU_SHINY].tex && polyType != RPT_SKY_MASK)
addPoly(type, RPT_SHINY, rvertices, srtexcoords, srtexcoords1,
NULL, srcolors, numVertices, pTU[TU_SHINY].blendMode,
0, 0, NULL, pTU);
rcolors, numVertices, blendMode, numLights, modTex, modColor, rTU);
}

/**
Expand Down

0 comments on commit ccab18a

Please sign in to comment.