Skip to content

Commit

Permalink
Refactor|World|Client: Removed R_SetRelativeHeights()
Browse files Browse the repository at this point in the history
As a general purpose utility function this clearly isn't working as
the API undermines its usefulness.
  • Loading branch information
danij-deng committed Aug 29, 2013
1 parent eb4ca59 commit d1f70d6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 60 deletions.
3 changes: 0 additions & 3 deletions doomsday/client/include/world/maputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
class Sector;
class LineOwner;

void R_SetRelativeHeights(Sector const *front, Sector const *back, int planeIndex,
coord_t *fz = 0, coord_t *bz = 0, coord_t *bhz = 0);

/**
* Determine the map space Z coordinates of a wall section.
*
Expand Down
34 changes: 27 additions & 7 deletions doomsday/client/src/render/shadowedge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void ShadowEdge::prepare(int planeIndex)
BspLeaf const &leaf = hedge.face().mapElement()->as<BspLeaf>();
Plane const &plane = leaf.visPlane(planeIndex);

LineSide &lineSide = hedge.mapElement()->as<LineSideSegment>().lineSide();
LineSide &lineSide = hedge.mapElement()->as<LineSideSegment>().lineSide();

d->sectorOpenness = 0; // Default is fully closed.
d->openness = 0; // Default is fully closed.
Expand All @@ -156,15 +156,25 @@ void ShadowEdge::prepare(int planeIndex)
hedge.twin().face().mapElement()->as<BspLeaf>().hasSector())
{
BspLeaf const &backLeaf = hedge.twin().face().mapElement()->as<BspLeaf>();
Plane const &backPlane = backLeaf.visPlane(planeIndex);
Surface const &wallEdgeSurface =
lineSide.back().hasSector()? lineSide.surface(planeIndex == Sector::Ceiling? LineSide::Top : LineSide::Bottom)
: lineSide.middle();

coord_t fz = 0, bz = 0, bhz = 0;
R_SetRelativeHeights(&leaf.visPlane(planeIndex).sector(),
&backLeaf.visPlane(planeIndex).sector(),
planeIndex, &fz, &bz, &bhz);
// Figure out the relative plane heights.
coord_t fz = plane.visHeight();
if(planeIndex == Sector::Ceiling)
fz = -fz;

coord_t bz = backPlane.visHeight();
if(planeIndex == Sector::Ceiling)
bz = -bz;

coord_t bhz = backLeaf.plane(otherPlaneIndex).visHeight();
if(planeIndex == Sector::Ceiling)
bhz = -bhz;

// Determine openness.
if(fz < bz && !wallEdgeSurface.hasMaterial())
{
d->sectorOpenness = 2; // Consider it fully open.
Expand Down Expand Up @@ -229,8 +239,18 @@ void ShadowEdge::prepare(int planeIndex)
!((plane.isSectorFloor() && backSec->ceiling().visHeight() <= plane.visHeight()) ||
(plane.isSectorCeiling() && backSec->floor().height() >= plane.visHeight())))
{
coord_t fz = 0, bz = 0, bhz = 0;
R_SetRelativeHeights(leaf.sectorPtr(), backSec, planeIndex, &fz, &bz, &bhz);
// Figure out the relative plane heights.
coord_t fz = plane.visHeight();
if(planeIndex == Sector::Ceiling)
fz = -fz;

coord_t bz = backSec->plane(planeIndex).visHeight();
if(planeIndex == Sector::Ceiling)
bz = -bz;

coord_t bhz = backSec->plane(otherPlaneIndex).visHeight();
if(planeIndex == Sector::Ceiling)
bhz = -bhz;

d->openness = opennessFactor(fz, bz, bhz);
}
Expand Down
15 changes: 12 additions & 3 deletions doomsday/client/src/render/skyfixedge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ DENG2_PIMPL(SkyFixEdge)
return false;
}

coord_t fz, bz;
R_SetRelativeHeights(&front->sector(), back? &back->sector() : 0,
relPlane, &fz, &bz);
// Figure out the relative plane heights.
coord_t fz = front->visHeight();
if(relPlane == Sector::Ceiling)
fz = -fz;

coord_t bz = 0;
if(back)
{
bz = back->visHeight();
if(relPlane == Sector::Ceiling)
bz = -bz;
}

coord_t planeZ = (back && back->surface().hasSkyMaskedMaterial() &&
fz < bz? bz : fz);
Expand Down
47 changes: 0 additions & 47 deletions doomsday/client/src/world/maputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,6 @@

using namespace de;

/// @todo fixme: Should work at BspLeaf level and use the visual plane heights
/// of sector clusters.
void R_SetRelativeHeights(Sector const *front, Sector const *back, int planeIndex,
coord_t *fz, coord_t *bz, coord_t *bhz)
{
if(fz)
{
if(front)
{
*fz = front->plane(planeIndex).visHeight();
if(planeIndex != Sector::Floor)
*fz = -(*fz);
}
else
{
*fz = 0;
}
}
if(bz)
{
if(back)
{
*bz = back->plane(planeIndex).visHeight();
if(planeIndex != Sector::Floor)
*bz = -(*bz);
}
else
{
*bz = 0;
}
}
if(bhz)
{
if(back)
{
int otherPlaneIndex = planeIndex == Sector::Floor? Sector::Ceiling : Sector::Floor;
*bhz = back->plane(otherPlaneIndex).visHeight();
if(planeIndex != Sector::Floor)
*bhz = -(*bhz);
}
else
{
*bhz = 0;
}
}
}

/// @todo fixme: Should use the visual plane heights of sector clusters.
void R_SideSectionCoords(LineSide const &side, int section, bool skyClip,
coord_t *retBottom, coord_t *retTop, Vector2f *retMaterialOrigin)
Expand Down

0 comments on commit d1f70d6

Please sign in to comment.