Skip to content

Commit

Permalink
Client|Map Renderer: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed May 25, 2013
1 parent 9c98378 commit 6bd775a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
4 changes: 1 addition & 3 deletions doomsday/client/include/render/walledge.h
Expand Up @@ -93,9 +93,7 @@ class WallEdge : public WorldEdge

coord_t mapSideOffset() const;

int mapSideSection() const;

inline Surface &surface() const { return mapSide().surface(mapSideSection()); }
inline Surface &surface() const { return mapSide().surface(spec().section); }

/// Implement IEdge.
bool isValid() const;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1084,7 +1084,7 @@ void Rend_RadioWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge,
Line::Side &side = leftEdge.mapSide();
HEdge const *hedge = side.leftHEdge();
Sector const *frontSec = hedge->sectorPtr();
Sector const *backSec = hedge->twin().hasBspLeaf() && !hedge->twin().bspLeaf().isDegenerate() && leftEdge.mapSideSection() != Line::Side::Middle? hedge->twin().bspLeaf().sectorPtr() : 0;
Sector const *backSec = hedge->twin().hasBspLeaf() && !hedge->twin().bspLeaf().isDegenerate() && leftEdge.spec().section != Line::Side::Middle? hedge->twin().bspLeaf().sectorPtr() : 0;

coord_t const lineLength = side.line().length();
coord_t const sectionOffset = leftEdge.mapSideOffset();
Expand Down
33 changes: 15 additions & 18 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -1341,7 +1341,6 @@ static bool writeWallGeometry(WallEdge **edges, BiasSurface &biasSurface,

WallEdge const &leftEdge = *edges[0];
WallEdge const &rightEdge = *edges[1];
WallSpec const &spec = leftEdge.spec();

if(!leftEdge.isValid() || !rightEdge.isValid() ||
de::fequal(leftEdge.bottom().distance(), rightEdge.top().distance()))
Expand All @@ -1350,27 +1349,26 @@ static bool writeWallGeometry(WallEdge **edges, BiasSurface &biasSurface,
if(bottomZ) *bottomZ = leftEdge.bottom().distance();
if(topZ) *topZ = rightEdge.top().distance();

///
Line::Side &side = leftEdge.mapSide();
Line &line = side.line();
int const section = leftEdge.mapSideSection();
Surface &surface = leftEdge.surface();
WallSpec const &wallSpec = leftEdge.spec();
Line::Side &side = leftEdge.mapSide();
Surface &surface = leftEdge.surface();

bool const isTwoSidedMiddle = (section == Line::Side::Middle &&
side.hasSections() && side.back().hasSections());
bool const isTwoSidedMiddle =
(wallSpec.section == Line::Side::Middle && !side.considerOneSided());

float opacity = surface.opacity();

// Apply a fade out when the viewer is near to this geometry?
bool didNearFade = false;
if(isTwoSidedMiddle &&
((viewPlayer->shared.flags & (DDPF_NOCLIP|DDPF_CAMERA)) ||
!(line.isFlagged(DDLF_BLOCKING))) &&
!(side.line().isFlagged(DDLF_BLOCKING))) &&
(vOrigin[VY] > leftEdge.bottom().distance() &&
vOrigin[VY] < rightEdge.top().distance()))
{
mobj_t const *mo = viewPlayer->shared.mo;

Line const &line = side.line();
coord_t linePoint[2] = { line.fromOrigin().x, line.fromOrigin().y };
coord_t lineDirection[2] = { line.direction().x, line.direction().y };
vec2d_t result;
Expand Down Expand Up @@ -1420,18 +1418,18 @@ static bool writeWallGeometry(WallEdge **edges, BiasSurface &biasSurface,

// Calculate the light level deltas for this wall section?
float leftLightLevelDelta = 0, rightLightLevelDelta = 0;
if(!spec.flags.testFlag(WallSpec::NoLightDeltas))
if(!wallSpec.flags.testFlag(WallSpec::NoLightDeltas))
{
wallSectionLightLevelDeltas(leftEdge, rightEdge, leftLightLevelDelta, rightLightLevelDelta);
}

rendworldpoly_params_t parm; zap(parm);

parm.flags = RPF_DEFAULT;
parm.forceOpaque = spec.flags.testFlag(WallSpec::ForceOpaque);
parm.forceOpaque = wallSpec.flags.testFlag(WallSpec::ForceOpaque);
parm.alpha = parm.forceOpaque? 1 : opacity;
parm.mapElement = &mapElement;
parm.elmIdx = section;
parm.elmIdx = wallSpec.section;
parm.bsuf = &biasSurface;
parm.normal = &surface.normal();
parm.texTL = &texTL;
Expand Down Expand Up @@ -1481,19 +1479,19 @@ static bool writeWallGeometry(WallEdge **edges, BiasSurface &biasSurface,
parm.glowing *= glowFactor; // Global scale factor.
}

side.chooseSurfaceTintColors(section, &parm.surfaceColor, &parm.wall.surfaceColor2);
side.chooseSurfaceTintColors(wallSpec.section, &parm.surfaceColor, &parm.wall.surfaceColor2);
}

// Project dynamic Lights?
if(!spec.flags.testFlag(WallSpec::NoDynLights) &&
if(!wallSpec.flags.testFlag(WallSpec::NoDynLights) &&
!(parm.flags & RPF_SKYMASK))
{
parm.lightListIdx = projectSurfaceLights(surface, parm.glowing, texTL, texBR,
isTwoSidedMiddle);
}

// Project dynamic shadows?
if(!spec.flags.testFlag(WallSpec::NoDynShadows) &&
if(!wallSpec.flags.testFlag(WallSpec::NoDynShadows) &&
!(parm.flags & RPF_SKYMASK))
{
parm.shadowListIdx = projectSurfaceShadows(surface, parm.glowing, texTL, texBR);
Expand Down Expand Up @@ -1547,10 +1545,9 @@ static bool writeWallGeometry(WallEdge **edges, BiasSurface &biasSurface,
if(opaque)
{
// Render FakeRadio for this section?
if(!spec.flags.testFlag(WallSpec::NoFakeRadio) &&
if(!wallSpec.flags.testFlag(WallSpec::NoFakeRadio) &&
!(parm.flags & RPF_SKYMASK) &&
!(parm.glowing > 0) && currentSectorLightLevel > 0 &&
!line.definesPolyobj())
!(parm.glowing > 0) && currentSectorLightLevel > 0)
{
Rend_RadioUpdateForLineSide(side);

Expand Down
7 changes: 1 addition & 6 deletions doomsday/client/src/render/walledge.cpp
Expand Up @@ -166,7 +166,7 @@ DENG2_PIMPL(WallEdge), public IHPlane
if(de::fequal(icpt->distance(), distance))
return i;
}
return WorldEdge::InvalidIndex;
return WallEdge::InvalidIndex;
}

inline bool haveEvent(double distance) {
Expand Down Expand Up @@ -497,11 +497,6 @@ Line::Side &WallEdge::mapSide() const
return *d->mapSide;
}

int WallEdge::mapSideSection() const
{
return d->spec.section;
}

coord_t WallEdge::mapSideOffset() const
{
return d->mapSideOffset;
Expand Down

0 comments on commit 6bd775a

Please sign in to comment.