Skip to content

Commit

Permalink
Client: Improving SoC in the edge components
Browse files Browse the repository at this point in the history
Moved map coordinate space origin from EdgeAttribs to implementors
of WorldEdge, added flag WallSpec::NoEdgeDivisions.
  • Loading branch information
danij-deng committed May 25, 2013
1 parent f2eaeee commit ff6356d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
5 changes: 5 additions & 0 deletions doomsday/client/include/render/skyfixedge.h
Expand Up @@ -67,6 +67,11 @@ class SkyFixEdge : public WorldEdge
*/
SkyFixEdge(HEdge &hedge, FixType fixType, int edge, float materialOffsetS = 0);

/**
* Returns the origin of the edge in the map coordinate space.
*/
Vector2d const &origin() const;

/// Implement IEdge.
bool isValid() const;

Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/include/render/walledge.h
Expand Up @@ -86,6 +86,11 @@ class WallEdge : public WorldEdge
return at(index);
}

/**
* Returns the origin of the edge in the map coordinate space.
*/
Vector2d const &origin() const;

WallSpec const &spec() const;

Line::Side &mapSide() const;
Expand Down
5 changes: 4 additions & 1 deletion doomsday/client/include/render/wallspec.h
Expand Up @@ -62,8 +62,11 @@ class WallSpec
/// Do not apply angle based light level deltas.
NoLightDeltas = 0x080,

/// Do not intercept edges with neighboring geometries.
NoEdgeDivisions = 0x100,

/// Do not smooth edge normals.
NoEdgeNormalSmoothing = 0x100,
NoEdgeNormalSmoothing = 0x200,

DefaultFlags = ForceOpaque | SkyClip
};
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1088,7 +1088,7 @@ void Rend_RadioWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge,

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

LineSideRadioData &frData = Rend_RadioDataForLineSide(side);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -1301,7 +1301,7 @@ static void wallSectionLightLevelDeltas(WallEdge const &leftEdge, WallEdge const
// vertical edges of this wall section.
coord_t const lineLength = leftEdge.mapSide().line().length();
coord_t const sectionOffset = leftEdge.mapSideOffset();
coord_t const sectionWidth = de::abs(Vector2d(rightEdge.origin - leftEdge.origin).length());
coord_t const sectionWidth = de::abs(Vector2d(rightEdge.origin() - leftEdge.origin()).length());

float deltaDiff = rightDelta - leftDelta;
rightDelta = leftDelta + ((sectionOffset + sectionWidth) / lineLength) * deltaDiff;
Expand Down Expand Up @@ -1455,7 +1455,7 @@ static void writeWallSection(HEdge &hedge, int section,
parm.materialScale = &materialScale;

parm.isWall = true;
parm.wall.sectionWidth = de::abs(Vector2d(rightEdge.origin - leftEdge.origin).length());
parm.wall.sectionWidth = de::abs(Vector2d(rightEdge.origin() - leftEdge.origin()).length());
parm.wall.leftEdge = &leftEdge;
parm.wall.rightEdge = &rightEdge;

Expand Down
10 changes: 7 additions & 3 deletions doomsday/client/src/render/skyfixedge.cpp
Expand Up @@ -79,7 +79,7 @@ void SkyFixEdge::Event::setDistance(coord_t distance)

Vector3d SkyFixEdge::Event::origin() const
{
return Vector3d(d->owner.origin, d->distance);
return Vector3d(d->owner.origin(), d->distance);
}

DENG2_PIMPL(SkyFixEdge)
Expand Down Expand Up @@ -190,14 +190,18 @@ DENG2_PIMPL(SkyFixEdge)
};

SkyFixEdge::SkyFixEdge(HEdge &hedge, FixType fixType, int edge, float materialOffsetS)
: WorldEdge(EdgeAttribs(edge? hedge.twin().origin() : hedge.origin(),
Vector2f(materialOffsetS, 0))),
: WorldEdge(EdgeAttribs(Vector2f(materialOffsetS, 0))),
d(new Instance(this, hedge, fixType, edge))
{
/// @todo Defer until necessary.
d->prepare();
}

Vector2d const &SkyFixEdge::origin() const
{
return (d->edge? d->hedge->twin() : *d->hedge).origin();
}

bool SkyFixEdge::isValid() const
{
return d->isValid;
Expand Down
24 changes: 12 additions & 12 deletions doomsday/client/src/render/walledge.cpp
Expand Up @@ -76,7 +76,7 @@ void WallEdge::Event::setDistance(double newDistance)

Vector3d WallEdge::Event::origin() const
{
return Vector3d(d->owner.origin, distance());
return Vector3d(d->owner.origin(), distance());
}

static bool eventSorter(WorldEdge::Event *a, WorldEdge::Event *b)
Expand Down Expand Up @@ -207,7 +207,7 @@ DENG2_PIMPL(WallEdge), public IHPlane
// Any work to do?
if(!needSortEvents) return;

qSort(events.begin(), events.top(), eventSorter);
qSort(events.begin(), events.end(), eventSorter);
needSortEvents = false;
}

Expand Down Expand Up @@ -273,14 +273,10 @@ DENG2_PIMPL(WallEdge), public IHPlane
{
DENG_ASSERT(top > bottom);

// Retrieve the bottom owner node.
// Retrieve the vertex owner node.
LineOwner *base = mapSide->line().vertexOwner(*mapVertex);
if(!base) return;

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

Sector const *frontSec = mapSide->sectorPtr();
LineOwner *own = base;
bool stopScan = false;
Expand Down Expand Up @@ -433,7 +429,7 @@ DENG2_PIMPL(WallEdge), public IHPlane
coord_t const hi = top.distance();

// Add intecepts for neighbor planes?
if(!de::fequal(hi, lo))
if(!spec.flags.testFlag(WallSpec::NoEdgeDivisions) && !de::fequal(hi, lo))
{
configure(Partition(mapVertex->origin(), Vector2d(0, hi - lo)));

Expand Down Expand Up @@ -467,8 +463,7 @@ DENG2_PIMPL(WallEdge), public IHPlane
};

WallEdge::WallEdge(WallSpec const &spec, HEdge &hedge, int edge)
: WorldEdge(EdgeAttribs((edge? hedge.twin() : hedge.vertex()).origin(),
Vector2f(hedge.lineOffset() + (edge? hedge.length() : 0), 0))),
: WorldEdge(EdgeAttribs(Vector2f(hedge.lineOffset() + (edge? hedge.length() : 0), 0))),
d(new Instance(this, spec, &hedge.lineSide(), edge,
hedge.lineOffset() + (edge? hedge.length() : 0),
edge? &hedge.twin().vertex() : &hedge.vertex()))
Expand All @@ -479,9 +474,9 @@ WallEdge::WallEdge(WallSpec const &spec, HEdge &hedge, int edge)
d->prepare();
}

bool WallEdge::isValid() const
Vector2d const &WallEdge::origin() const
{
return d->isValid;
return d->mapVertex->origin();
}

WallSpec const &WallEdge::spec() const
Expand Down Expand Up @@ -525,6 +520,11 @@ WallEdge::Event const &WallEdge::at(EventIndex index) const
return *events().at(index);
}

bool WallEdge::isValid() const
{
return d->isValid;
}

WallEdge::Event const &WallEdge::first() const
{
return at(0);
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/src/render/wallspec.cpp
Expand Up @@ -50,7 +50,10 @@ WallSpec WallSpec::fromMapSide(Line::Side const &side, int section) // static
WallSpec spec(section);

if(side.line().definesPolyobj() || isTwoSidedMiddle)
{
spec.flags &= ~WallSpec::ForceOpaque;
spec.flags |= WallSpec::NoEdgeDivisions;
}

if(isTwoSidedMiddle)
{
Expand Down

0 comments on commit ff6356d

Please sign in to comment.