Skip to content

Commit

Permalink
WallEdge: Minor API improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed May 23, 2013
1 parent 7a859d0 commit eddca70
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/include/render/walledge.h
Expand Up @@ -96,9 +96,9 @@ class WallEdge

de::Vector2d const &origin() const;

coord_t lineOffset() const;
coord_t mapLineOffset() const;

Line::Side &lineSide() const;
Line::Side &mapSide() const;

Surface &surface() const;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1081,13 +1081,13 @@ void Rend_RadioWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge,

if(shadowSize <= 0) return;

Line::Side &side = leftEdge.lineSide();
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.section() != Line::Side::Middle? hedge->twin().bspLeaf().sectorPtr() : 0;

coord_t const lineLength = side.line().length();
coord_t const sectionOffset = leftEdge.lineOffset();
coord_t const sectionOffset = leftEdge.mapLineOffset();
coord_t const sectionWidth = de::abs(Vector2d(rightEdge.origin() - leftEdge.origin()).length());

LineSideRadioData &frData = Rend_RadioDataForLineSide(side);
Expand Down
10 changes: 5 additions & 5 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -1259,8 +1259,8 @@ static void wallSectionLightLevelDeltas(WallEdge const &leftEdge, WallEdge const

// Linearly interpolate to find the light level delta values for the
// vertical edges of this wall section.
coord_t const lineLength = leftEdge.lineSide().line().length();
coord_t const sectionOffset = leftEdge.lineOffset();
coord_t const lineLength = leftEdge.mapSide().line().length();
coord_t const sectionOffset = leftEdge.mapLineOffset();
coord_t const sectionWidth = de::abs(Vector2d(rightEdge.origin() - leftEdge.origin()).length());

float deltaDiff = rightDelta - leftDelta;
Expand Down Expand Up @@ -1361,7 +1361,7 @@ static bool writeWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge
DENG_ASSERT(!isNullLeaf(bspLeaf));
DENG_ASSERT(rightEdge.top().distance() > leftEdge.bottom().distance());

Line::Side &side = leftEdge.lineSide();
Line::Side &side = leftEdge.mapSide();
Line &line = side.line();
int const section = leftEdge.section();
Surface &surface = leftEdge.surface();
Expand Down Expand Up @@ -2179,8 +2179,8 @@ static bool useWallSectionLightLevelDeltas(Line::Side &side, int section)
if(rendLightWallAngle <= 0)
return false;

// ...always if the surface's material was chosen as a HOM fix (lighting
// must be consistent with that applied to the relative back sector plane).
// Never if the surface's material was chosen as a HOM fix (lighting must
// be consistent with that applied to the relative back sector plane).
if(side.hasSector() && side.back().hasSector() && side.surface(section).hasFixMaterial())
return false;

Expand Down
45 changes: 22 additions & 23 deletions doomsday/client/src/render/walledge.cpp
Expand Up @@ -50,7 +50,7 @@ Vector3d WallEdge::Intercept::origin() const

DENG2_PIMPL(WallEdge), public IHPlane
{
Line::Side *lineSide;
Line::Side *mapSide;
int section;
int edge;
Flags flags;
Expand Down Expand Up @@ -83,10 +83,10 @@ DENG2_PIMPL(WallEdge), public IHPlane
{}
} hplane;

Instance(Public *i, Line::Side *lineSide, int section, int edge,
Instance(Public *i, Line::Side *mapSide, int section, int edge,
Flags flags, coord_t lineOffset, Vertex *lineVertex)
: Base(i),
lineSide(lineSide),
mapSide(mapSide),
section(section),
edge(edge),
flags(flags),
Expand All @@ -97,7 +97,7 @@ DENG2_PIMPL(WallEdge), public IHPlane

Instance(Public *i, Instance const &other)
: Base(i),
lineSide (other.lineSide),
mapSide (other.mapSide),
section (other.section),
edge (other.edge),
flags (other.flags),
Expand Down Expand Up @@ -224,14 +224,14 @@ DENG2_PIMPL(WallEdge), public IHPlane
DENG_ASSERT(top > bottom);

// Retrieve the start owner node.
LineOwner *base = lineSide->line().vertexOwner(*lineVertex);
LineOwner *base = mapSide->line().vertexOwner(*lineVertex);
if(!base) return;

// Check for neighborhood division?
if(section == Line::Side::Middle && lineSide->back().hasSector())
if(section == Line::Side::Middle && mapSide->back().hasSector())
return;

Sector const *frontSec = lineSide->sectorPtr();
Sector const *frontSec = mapSide->sectorPtr();
LineOwner *own = base;
bool stopScan = false;
do
Expand Down Expand Up @@ -323,33 +323,32 @@ DENG2_PIMPL(WallEdge), public IHPlane

/**
* Find the neighbor surface for the edge which we will use to calculate the
* smoothed normal.
* "blend" properties (e.g., smoothed edge normal).
*
* @todo: Use the half-edge rings instead of LineOwners.
*/
Surface *findBlendNeighbor(binangle_t &diff)
{
diff = 0;

// Disabled?
// Are we not blending?
if(!(flags & SmoothNormal))
return 0;

// Polyobj lines have no owner rings.
if(lineSide->line().definesPolyobj())
if(mapSide->line().definesPolyobj())
return 0;

LineOwner const *farVertOwner = lineSide->line().vertexOwner(lineSide->lineSideId() ^ edge);

LineOwner const *farVertOwner = mapSide->line().vertexOwner(mapSide->lineSideId() ^ edge);
Line *neighbor;
if(R_SideBackClosed(*lineSide))
if(R_SideBackClosed(*mapSide))
{
neighbor = R_FindSolidLineNeighbor(lineSide->sectorPtr(), &lineSide->line(),
neighbor = R_FindSolidLineNeighbor(mapSide->sectorPtr(), &mapSide->line(),
farVertOwner, edge, &diff);
}
else
{
neighbor = R_FindLineNeighbor(lineSide->sectorPtr(), &lineSide->line(),
neighbor = R_FindLineNeighbor(mapSide->sectorPtr(), &mapSide->line(),
farVertOwner, edge, &diff);
}

Expand All @@ -358,12 +357,12 @@ DENG2_PIMPL(WallEdge), public IHPlane

// Choose the correct side of the neighbor (determined by which vertex is shared).
Line::Side *otherSide;
if(&neighbor->vertex(edge ^ 1) == &lineSide->vertex(edge))
if(&neighbor->vertex(edge ^ 1) == &mapSide->vertex(edge))
otherSide = &neighbor->front();
else
otherSide = &neighbor->back();

// We can only smooth if the neighbor has a surface.
// We can only blend if the neighbor has a surface.
if(!otherSide->hasSections()) return 0;

/// @todo Do not assume the neighbor is the middle section of @var otherSide.
Expand Down Expand Up @@ -391,14 +390,14 @@ bool WallEdge::isValid() const
return d->isValid;
}

Line::Side &WallEdge::lineSide() const
Line::Side &WallEdge::mapSide() const
{
return *d->lineSide;
return *d->mapSide;
}

Surface &WallEdge::surface() const
{
return d->lineSide->surface(d->section);
return d->mapSide->surface(d->section);
}

int WallEdge::section() const
Expand All @@ -411,7 +410,7 @@ Vector2d const &WallEdge::origin() const
return d->partition().origin;
}

coord_t WallEdge::lineOffset() const
coord_t WallEdge::mapLineOffset() const
{
return d->lineOffset;
}
Expand Down Expand Up @@ -478,7 +477,7 @@ static bool shouldSmoothNormals(Surface &sufA, Surface &sufB, binangle_t angleDi
void WallEdge::prepare()
{
coord_t bottom, top;
R_SideSectionCoords(*d->lineSide, d->section, &bottom, &top, &d->materialOrigin);
R_SideSectionCoords(*d->mapSide, d->section, &bottom, &top, &d->materialOrigin);

d->isValid = (top >= bottom);
if(!d->isValid) return;
Expand Down Expand Up @@ -513,7 +512,7 @@ void WallEdge::prepare()

// Determine the edge normal.
/// @todo Cache the smoothed normal value somewhere.
Surface &surface = d->lineSide->surface(d->section);
Surface &surface = d->mapSide->surface(d->section);
binangle_t angleDiff;
Surface *blendSurface = d->findBlendNeighbor(angleDiff);

Expand Down

0 comments on commit eddca70

Please sign in to comment.