Skip to content

Commit

Permalink
Map Renderer: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed May 3, 2013
1 parent 6b24aa1 commit ab2041c
Showing 1 changed file with 35 additions and 56 deletions.
91 changes: 35 additions & 56 deletions doomsday/client/src/render/rendpoly.cpp
Expand Up @@ -389,31 +389,25 @@ void R_DivVerts(rvertex_t *dst, rvertex_t const *src,
COPYVERT(&dst[numL + 1], &src[3]);
COPYVERT(&dst[numL + numR - 1], &src[2]);

if(rightEdge.divisionCount())
for(int n = 0; n < rightEdge.divisionCount(); ++n)
{
for(int n = 0; n < numR - 3; ++n)
{
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
dst[numL + 2 + n].pos[VX] = src[2].pos[VX];
dst[numL + 2 + n].pos[VY] = src[2].pos[VY];
dst[numL + 2 + n].pos[VZ] = float( icpt.distance );
}
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
dst[numL + 2 + n].pos[VX] = src[2].pos[VX];
dst[numL + 2 + n].pos[VY] = src[2].pos[VY];
dst[numL + 2 + n].pos[VZ] = float( icpt.distance );
}

// Left fan:
COPYVERT(&dst[0], &src[3]);
COPYVERT(&dst[1], &src[0]);
COPYVERT(&dst[numL - 1], &src[1]);

if(leftEdge.divisionCount())
for(int n = 0; n < leftEdge.divisionCount(); ++n)
{
for(int n = 0; n < numL - 3; ++n)
{
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
dst[2 + n].pos[VX] = src[0].pos[VX];
dst[2 + n].pos[VY] = src[0].pos[VY];
dst[2 + n].pos[VZ] = float( icpt.distance );
}
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
dst[2 + n].pos[VX] = src[0].pos[VX];
dst[2 + n].pos[VY] = src[0].pos[VY];
dst[2 + n].pos[VZ] = float( icpt.distance );
}

#undef COPYVERT
Expand All @@ -436,36 +430,29 @@ void R_DivTexCoords(rtexcoord_t *dst, rtexcoord_t const *src,
COPYTEXCOORD(&dst[numL + 1], &src[3]);
COPYTEXCOORD(&dst[numL + numR-1], &src[2]);

if(rightEdge.divisionCount())
float const rightHeight = tR - bR;
for(int n = 0; n < rightEdge.divisionCount(); ++n)
{
float const height = tR - bR;
float inter;
for(int n = 0; n < numR - 3; ++n)
{
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
inter = (float( icpt.distance ) - bR) / height;
dst[numL + 2 + n].st[0] = src[3].st[0];
dst[numL + 2 + n].st[1] = src[2].st[1] + (src[3].st[1] - src[2].st[1]) * inter;
}
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
float inter = (float( icpt.distance ) - bR) / rightHeight;
dst[numL + 2 + n].st[0] = src[3].st[0];
dst[numL + 2 + n].st[1] = src[2].st[1] + (src[3].st[1] - src[2].st[1]) * inter;
}

// Left fan:
COPYTEXCOORD(&dst[0], &src[3]);
COPYTEXCOORD(&dst[1], &src[0]);
COPYTEXCOORD(&dst[numL - 1], &src[1]);

if(leftEdge.divisionCount())
float const leftHeight = tL - bL;
for(int n = 0; n < leftEdge.divisionCount(); ++n)
{
float const height = tL - bL;
float inter;
for(int n = 0; n < numL - 3; ++n)
{
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
inter = (float( icpt.distance ) - bL) / height;
dst[2 + n].st[0] = src[0].st[0];
dst[2 + n].st[1] = src[0].st[1] + (src[1].st[1] - src[0].st[1]) * inter;
}
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
float inter = (float( icpt.distance ) - bL) / leftHeight;
dst[2 + n].st[0] = src[0].st[0];
dst[2 + n].st[1] = src[0].st[1] + (src[1].st[1] - src[0].st[1]) * inter;
}

#undef COPYTEXCOORD
}

Expand All @@ -488,18 +475,14 @@ void R_DivVertColors(ColorRawf *dst, ColorRawf const *src,
COPYVCOLOR(&dst[numL + 1], &src[3]);
COPYVCOLOR(&dst[numL + numR-1], &src[2]);

if(rightEdge.divisionCount())
float const rightHeight = tR - bR;
for(int n = 0; n < rightEdge.divisionCount(); ++n)
{
float const height = tR - bR;
float inter;
for(int n = 0; n < numR - 3; ++n)
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
float inter = (float( icpt.distance ) - bR) / rightHeight;
for(int c = 0; c < 4; ++c)
{
SectionEdge::Intercept const &icpt = rightEdge.at(rightEdge.lastDivision() - n);
inter = (float( icpt.distance ) - bR) / height;
for(int c = 0; c < 4; ++c)
{
dst[numL + 2 + n].rgba[c] = src[2].rgba[c] + (src[3].rgba[c] - src[2].rgba[c]) * inter;
}
dst[numL + 2 + n].rgba[c] = src[2].rgba[c] + (src[3].rgba[c] - src[2].rgba[c]) * inter;
}
}

Expand All @@ -508,18 +491,14 @@ void R_DivVertColors(ColorRawf *dst, ColorRawf const *src,
COPYVCOLOR(&dst[1], &src[0]);
COPYVCOLOR(&dst[numL - 1], &src[1]);

if(leftEdge.divisionCount())
float const leftHeight = tL - bL;
for(int n = 0; n < leftEdge.divisionCount(); ++n)
{
float const height = tL - bL;
float inter;
for(int n = 0; n < numL - 3; ++n)
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
float inter = (float( icpt.distance ) - bL) / leftHeight;
for(int c = 0; c < 4; ++c)
{
SectionEdge::Intercept const &icpt = leftEdge.at(leftEdge.firstDivision() + n);
inter = (float( icpt.distance ) - bL) / height;
for(int c = 0; c < 4; ++c)
{
dst[2 + n].rgba[c] = src[0].rgba[c] + (src[1].rgba[c] - src[0].rgba[c]) * inter;
}
dst[2 + n].rgba[c] = src[0].rgba[c] + (src[1].rgba[c] - src[0].rgba[c]) * inter;
}
}

Expand Down

0 comments on commit ab2041c

Please sign in to comment.