Skip to content

Commit

Permalink
Refactor|World|Plane|Surface: Disambiguate "visual height" wrt planes
Browse files Browse the repository at this point in the history
Since the introduction of mapped sector planes the "visual height"
of a plane could be interpreted with two very different meanings
depending on the context.

Sector cluster allows mapping of planes for visual effect only and
so the term "visual" is now overloaded (previously this identified
the interpolated "smooth" height of a plane).

To disambiguate, Plane's API now uses the term "smoothed" and for
uniformity, Surface applies the same terminology when identifying
the smoothed material origin.
  • Loading branch information
danij-deng committed Sep 11, 2013
1 parent 2ece2ee commit d1e9ded
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 290 deletions.
37 changes: 20 additions & 17 deletions doomsday/client/include/world/bspleaf.h
Expand Up @@ -283,33 +283,36 @@ class BspLeaf : public de::MapElement
inline Plane &visCeiling() const { return visPlane(Sector::Ceiling); }

/**
* Convenient method of accessing the visual (i.e., smoothed) height of the
* identified @em visual sector plane.
* Convenient method of accessing the @em smoothed height of the identified
* @em visual sector plane.
*
* @param planeIndex Index of the plane to return.
*
* @see visPlane(), Plane::visHeight()
* @see visPlane(), Plane::heightSmoothed()
*/
inline coord_t visPlaneHeight(int planeIndex) const {
return visPlane(planeIndex).visHeight();
inline coord_t visPlaneHeightSmoothed(int planeIndex) const {
return visPlane(planeIndex).heightSmoothed();
}

/**
* Convenient method of accessing the visual (i.e., smoothed) height of the
* @em visual floor plane.
* Convenient method of accessing the @em smoothed height of the @em visual
* floor plane.
*
* @see visPlaneHeight()
* @see visPlaneHeightSmoothed()
*/
inline coord_t visFloorHeight() const { return visPlaneHeight(Sector::Floor); }
inline coord_t visFloorHeightSmoothed() const {
return visPlaneHeightSmoothed(Sector::Floor);
}

/**
* Convenient method of accessing the visual (i.e., smoothed) height of the
* @em visual ceiling plane.
* Convenient method of accessing the @em smoothed height of the @em visual
* ceiling plane.
*
* @see visPlaneHeight()
* @see visPlaneHeightSmoothed()
*/
inline coord_t visCeilingHeight() const { return visPlaneHeight(Sector::Ceiling); }

inline coord_t visCeilingHeightSmoothed() const {
return visPlaneHeightSmoothed(Sector::Ceiling);
}
#endif // __CLIENT__

/**
Expand Down Expand Up @@ -367,10 +370,10 @@ class BspLeaf : public de::MapElement
* - The height of floor is lower than that of the ceiling plane for the
* attributed sector.
*
* @param useVisualHeights @c true= use the visual (i.e., smoothed) plane
* heights instead of the @em sharp heights.
* @param useSmoothedHeights @c true= use the @em smoothed plane heights
* instead of the @em sharp heights.
*/
bool hasWorldVolume(bool useVisualHeights = true) const;
bool hasWorldVolume(bool useSmoothedHeights = true) const;

/**
* Returns a pointer to the face geometry half-edge which has been chosen
Expand Down
31 changes: 18 additions & 13 deletions doomsday/client/include/world/plane.h
Expand Up @@ -52,6 +52,11 @@ class Plane : public de::MapElement
*/
DENG2_DEFINE_AUDIENCE(HeightChange, void planeHeightChanged(Plane &plane, coord_t oldHeight))

/*
* Notified whenever a @em smoothed height change occurs.
*/
DENG2_DEFINE_AUDIENCE(SmoothedHeightChange, void planeSmoothedHeightChanged(Plane &plane, coord_t oldHeight))

// Constants:
static int const MAX_SMOOTH_MOVE = 64; ///< $smoothplane: Maximum speed for a smoothed plane.

Expand Down Expand Up @@ -157,34 +162,34 @@ class Plane : public de::MapElement
#ifdef __CLIENT__

/**
* Returns the current interpolated visual height of the plane in the map
* coordinate space.
* Returns the current smoothed height of the plane (interpolated) in the
* map coordinate space.
*
* @see targetHeight(), height()
*/
coord_t visHeight() const;
coord_t heightSmoothed() const;

/**
* Returns the delta between current height and the interpolated visual
* height of the plane in the map coordinate space.
* Returns the delta between current height and the smoothed height of the
* plane in the map coordinate space.
*
* @see targetHeight()
* @see heightSmoothed(), targetHeight()
*/
coord_t visHeightDelta() const;
coord_t heightSmoothedDelta() const;

/**
* Set the visible offsets.
* Perform smoothed height interpolation.
*
* @see visHeight(), targetHeight()
* @see heightSmoothed(), targetHeight()
*/
void lerpVisHeight();
void lerpSmoothedHeight();

/**
* Reset the plane's height tracking.
* Reset the plane's height tracking buffer (for smoothing).
*
* @see visHeight(), targetHeight()
* @see heightSmoothed(), targetHeight()
*/
void resetVisHeight();
void resetSmoothedHeight();

/**
* Roll the plane's height tracking buffer.
Expand Down
22 changes: 11 additions & 11 deletions doomsday/client/include/world/surface.h
Expand Up @@ -408,34 +408,34 @@ class Surface : public de::MapElement
#ifdef __CLIENT__

/**
* Returns the current interpolated visual material origin of the surface
* Returns the current smoothed (interpolated) material origin for the plane
* in the map coordinate space.
*
* @see setMaterialOrigin()
*/
de::Vector2f const &visMaterialOrigin() const;
de::Vector2f const &materialOriginSmoothed() const;

/**
* Returns the delta between current material origin and the interpolated
* visual origin of the material in the map coordinate space.
* Returns the delta between current and the smoothed material origin for
* the surface in the map coordinate space.
*
* @see setMaterialOrigin(), visMaterialOrigin()
* @see setMaterialOrigin(), smoothMaterialOrigin()
*/
de::Vector2f const &visMaterialOriginDelta() const;
de::Vector2f const &materialOriginSmoothedDelta() const;

/**
* Interpolate the visible material origin.
* Perform smoothed material origin interpolation.
*
* @see visMaterialOrigin()
* @see materialOriginSmoothed()
*/
void lerpVisMaterialOrigin();
void lerpSmoothedMaterialOrigin();

/**
* Reset the surface's material origin tracking.
*
* @see visMaterialOrigin()
* @see materialOriginSmoothed()
*/
void resetVisMaterialOrigin();
void resetSmoothedMaterialOrigin();

/**
* Roll the surface's material origin tracking buffer.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/biasillum.cpp
Expand Up @@ -166,9 +166,9 @@ DENG2_PIMPL_NOREF(BiasIllum)
/// @todo LineSightTest should (optionally) perform this test.
BspLeaf &leaf = source.bspLeafAtOrigin();
if((!leaf.visFloor().surface().hasSkyMaskedMaterial() &&
source.origin().z < leaf.visFloorHeight()) ||
source.origin().z < leaf.visFloorHeightSmoothed()) ||
(!leaf.visCeiling().surface().hasSkyMaskedMaterial() &&
source.origin().z > leaf.visCeilingHeight()))
source.origin().z > leaf.visCeilingHeightSmoothed()))
{
// This affecting source does not contribute any light.
casted = Vector3f();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/projector.cpp
Expand Up @@ -385,7 +385,7 @@ void Rend_ProjectPlaneGlows(BspLeaf *bspLeaf, Vector3d const &topLeft,
for(int i = 0; i < bspLeaf->sector().planeCount(); ++i)
{
Plane &plane = bspLeaf->visPlane(i);
Vector3d pointOnPlane(bspLeaf->cluster().center(), plane.visHeight());
Vector3d pointOnPlane(bspLeaf->cluster().center(), plane.heightSmoothed());

projectGlow(plane.surface(), pointOnPlane, parm);
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/r_main.cpp
Expand Up @@ -1017,8 +1017,8 @@ void R_SetupPlayerSprites()
spr->data.model.flags = 0;
// 32 is the raised weapon height.
spr->data.model.gzt = viewData->current.origin[VZ];
spr->data.model.secFloor = ddpl->mo->bspLeaf->visFloorHeight();
spr->data.model.secCeil = ddpl->mo->bspLeaf->visCeilingHeight();
spr->data.model.secFloor = ddpl->mo->bspLeaf->visFloorHeightSmoothed();
spr->data.model.secCeil = ddpl->mo->bspLeaf->visCeilingHeightSmoothed();
spr->data.model.pClass = 0;
spr->data.model.floorClip = 0;

Expand Down
18 changes: 9 additions & 9 deletions doomsday/client/src/render/r_things.cpp
Expand Up @@ -136,12 +136,12 @@ static int findMobjZOriginWorker(Sector *sector, void *parameters)

if(p->floorAdjust && p->mo->origin[VZ] == sector->floor().height())
{
p->vis->origin.z = sector->floor().visHeight();
p->vis->origin.z = sector->floor().heightSmoothed();
}

if(p->mo->origin[VZ] + p->mo->height == sector->ceiling().height())
{
p->vis->origin.z = sector->ceiling().visHeight() - p->mo->height;
p->vis->origin.z = sector->ceiling().heightSmoothed() - p->mo->height;
}

return false; // Continue iteration.
Expand Down Expand Up @@ -275,7 +275,7 @@ void R_ProjectSprite(mobj_t *mo)
bool floorAdjust = false;
if(!Mobj_OriginBehindVisPlane(mo))
{
floorAdjust = de::abs(floor.visHeight() - floor.height()) < 8;
floorAdjust = de::abs(floor.heightSmoothed() - floor.height()) < 8;
findMobjZOrigin(mo, floorAdjust, vis);
}

Expand Down Expand Up @@ -380,14 +380,14 @@ void R_ProjectSprite(mobj_t *mo)

// We must find the correct positioning using the sector floor
// and ceiling heights as an aid.
if(ms.height() < ceiling.visHeight() - floor.visHeight())
if(ms.height() < ceiling.heightSmoothed() - floor.heightSmoothed())
{
// Sprite fits in, adjustment possible?
if(fitTop && gzt > ceiling.visHeight())
gzt = ceiling.visHeight();
if(fitTop && gzt > ceiling.heightSmoothed())
gzt = ceiling.heightSmoothed();

if(floorAdjust && fitBottom && gzt - ms.height() < floor.visHeight())
gzt = floor.visHeight() + ms.height();
if(floorAdjust && fitBottom && gzt - ms.height() < floor.heightSmoothed())
gzt = floor.heightSmoothed() + ms.height();
}
// Adjust by the floor clip.
gzt -= floorClip;
Expand All @@ -401,7 +401,7 @@ void R_ProjectSprite(mobj_t *mo)
ambientColor.w = alpha;

VisSprite_SetupSprite(vis->data.sprite, origin, vis->distance, visOff,
floor.visHeight(), ceiling.visHeight(),
floor.heightSmoothed(), ceiling.heightSmoothed(),
floorClip, gzt, *mat, matFlipS, matFlipT, blendMode,
ambientColor, vLightListIdx,
mo->tclass, mo->tmap,
Expand Down
56 changes: 28 additions & 28 deletions doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -180,8 +180,8 @@ static void scanNeighbor(bool scanTop, LineSide const &side, edge_t *edge,
bool stopScan = false;
bool closed;

coord_t fFloor = startSector->floor().visHeight();
coord_t fCeil = startSector->ceiling().visHeight();
coord_t fFloor = startSector->floor().heightSmoothed();
coord_t fCeil = startSector->ceiling().heightSmoothed();

// Retrieve the start owner node.
LineOwner *own = side.line().vertexOwner(side.vertex((int)!toLeft));
Expand Down Expand Up @@ -214,13 +214,13 @@ static void scanNeighbor(bool scanTop, LineSide const &side, edge_t *edge,
// Pick plane heights for relative offset comparison.
if(!stopScan)
{
iFFloor = iter->frontSector().floor().visHeight();
iFCeil = iter->frontSector().ceiling().visHeight();
iFFloor = iter->frontSector().floor().heightSmoothed();
iFCeil = iter->frontSector().ceiling().heightSmoothed();

if(iter->hasBackSector())
{
iBFloor = iter->backSector().floor().visHeight();
iBCeil = iter->backSector().ceiling().visHeight();
iBFloor = iter->backSector().floor().heightSmoothed();
iBCeil = iter->backSector().ceiling().heightSmoothed();
}
else
iBFloor = iBCeil = 0;
Expand Down Expand Up @@ -316,16 +316,16 @@ static void scanNeighbor(bool scanTop, LineSide const &side, edge_t *edge,
// A height difference from the start sector?
if(scanTop)
{
if(scanSector->ceiling().visHeight() != fCeil &&
scanSector->floor().visHeight() <
startSector->ceiling().visHeight())
if(scanSector->ceiling().heightSmoothed() != fCeil &&
scanSector->floor().heightSmoothed() <
startSector->ceiling().heightSmoothed())
stopScan = true;
}
else
{
if(scanSector->floor().visHeight() != fFloor &&
scanSector->ceiling().visHeight() >
startSector->floor().visHeight())
if(scanSector->floor().heightSmoothed() != fFloor &&
scanSector->ceiling().heightSmoothed() >
startSector->floor().heightSmoothed())
stopScan = true;
}
}
Expand All @@ -345,10 +345,10 @@ static void scanNeighbor(bool scanTop, LineSide const &side, edge_t *edge,
// heights are within accepted range.
if(scanSector && side.back().hasSector() &&
scanSector != side.back().sectorPtr() &&
((scanTop && scanSector->ceiling().visHeight() ==
startSector->ceiling().visHeight()) ||
(!scanTop && scanSector->floor().visHeight() ==
startSector->floor().visHeight())))
((scanTop && scanSector->ceiling().heightSmoothed() ==
startSector->ceiling().heightSmoothed()) ||
(!scanTop && scanSector->floor().heightSmoothed() ==
startSector->floor().heightSmoothed())))
{
// If the map is formed correctly, we should find a back
// neighbor attached to this line. However, if this is not
Expand Down Expand Up @@ -389,8 +389,8 @@ static void scanNeighbors(shadowcorner_t top[2], shadowcorner_t bottom[2],
{
if(side.line().isSelfReferencing()) return;

coord_t fFloor = side.sector().floor().visHeight();
coord_t fCeil = side.sector().ceiling().visHeight();
coord_t fFloor = side.sector().floor().heightSmoothed();
coord_t fCeil = side.sector().ceiling().heightSmoothed();

edge_t edges[2]; // {bottom, top}
std::memset(edges, 0, sizeof(edges));
Expand Down Expand Up @@ -450,13 +450,13 @@ static void scanNeighbors(shadowcorner_t top[2], shadowcorner_t bottom[2],
corner->proximity = edge->sector;
if(i == 0) // Floor.
{
corner->pOffset = corner->proximity->floor().visHeight() - fFloor;
corner->pHeight = corner->proximity->floor().visHeight();
corner->pOffset = corner->proximity->floor().heightSmoothed() - fFloor;
corner->pHeight = corner->proximity->floor().heightSmoothed();
}
else // Ceiling.
{
corner->pOffset = corner->proximity->ceiling().visHeight() - fCeil;
corner->pHeight = corner->proximity->ceiling().visHeight();
corner->pOffset = corner->proximity->ceiling().heightSmoothed() - fCeil;
corner->pHeight = corner->proximity->ceiling().heightSmoothed();
}
}
else
Expand Down Expand Up @@ -1108,10 +1108,10 @@ void Rend_RadioWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge,

LineSideRadioData &frData = Rend_RadioDataForLineSide(side);

coord_t const fFloor = leaf->visFloorHeight();
coord_t const fCeil = leaf->visCeilingHeight();
coord_t const bFloor = (backLeaf? backLeaf->visFloorHeight() : 0);
coord_t const bCeil = (backLeaf? backLeaf->visCeilingHeight() : 0);
coord_t const fFloor = leaf->visFloorHeightSmoothed();
coord_t const fCeil = leaf->visCeilingHeightSmoothed();
coord_t const bFloor = (backLeaf? backLeaf->visFloorHeightSmoothed() : 0);
coord_t const bCeil = (backLeaf? backLeaf->visCeilingHeightSmoothed() : 0);

Vector3f rvertices[4] = {
leftEdge.bottom().origin(),
Expand Down Expand Up @@ -1324,7 +1324,7 @@ void Rend_RadioBspLeafEdges(BspLeaf &bspLeaf)
{
Plane const &plane = bspLeaf.visPlane(pln);

eyeToSurface.z = vOrigin[VY] - plane.visHeight();
eyeToSurface.z = vOrigin[VY] - plane.heightSmoothed();

// Don't bother with planes facing away from the camera.
if(eyeToSurface.dot(plane.surface().normal()) < 0) continue;
Expand Down Expand Up @@ -1435,7 +1435,7 @@ void Rend_DrawShadowOffsetVerts()
do
{
Vector2d xy = vtx.origin() + own->extendedShadowOffset();
coord_t z = own->line().frontSector().floor().visHeight();
coord_t z = own->line().frontSector().floor().heightSmoothed();
drawPoint(Vector3d(xy.x, xy.y, z), 1, yellow);

xy = vtx.origin() + own->innerShadowOffset();
Expand Down

0 comments on commit d1e9ded

Please sign in to comment.