Skip to content

Commit

Permalink
Server|Map: Server does not animate plane heights or surface material…
Browse files Browse the repository at this point in the history
… origins

Storage for the plane height and material origin tracking buffers is
no longer allocated and the logic for which is excluded from server
builds.

On server side we only care about "sharp" change notification.
  • Loading branch information
danij-deng committed Jun 12, 2013
1 parent 04aabea commit 2e7b034
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 111 deletions.
4 changes: 4 additions & 0 deletions doomsday/client/include/world/bspleaf.h
Expand Up @@ -181,6 +181,8 @@ class BspLeaf : public de::MapElement
*/
void setSector(Sector *newSector);

#ifdef __CLIENT__

/**
* Determines whether the BSP leaf has a positive world volume. For this
* to be true the following criteria must be met:
Expand All @@ -195,6 +197,8 @@ class BspLeaf : public de::MapElement
*/
bool hasWorldVolume(bool useVisualHeights = true) const;

#endif // __CLIENT__

/**
* Returns @c true iff at least one polyobj is linked to the BSP leaf.
*/
Expand Down
36 changes: 19 additions & 17 deletions doomsday/client/include/world/map.h
Expand Up @@ -99,8 +99,10 @@ class Map
typedef QList<BspLeaf *> BspLeafs;
typedef QList<Segment *> Segments;

#ifdef __CLIENT__
typedef QSet<Plane *> PlaneSet;
typedef QSet<Surface *> SurfaceSet;
#endif

public: /// @todo make private:
Uri _uri;
Expand Down Expand Up @@ -406,20 +408,6 @@ class Map
return pathTraverse(from, to, flags, callback, parameters);
}

coord_t skyFix(bool ceiling) const;

inline coord_t skyFixFloor() const { return skyFix(false /*the floor*/); }
inline coord_t skyFixCeiling() const { return skyFix(true /*the ceiling*/); }

void setSkyFix(bool ceiling, coord_t newHeight);

inline void setSkyFixFloor(coord_t newHeight) {
setSkyFix(false /*the floor*/, newHeight);
}
inline void setSkyFixCeiling(coord_t newHeight) {
setSkyFix(true /*the ceiling*/, newHeight);
}

/**
* Link the specified @a bspLeaf in internal data structures for
* bookkeeping purposes.
Expand Down Expand Up @@ -479,6 +467,20 @@ class Map
EntityDatabase &entityDatabase() const;

#ifdef __CLIENT__
coord_t skyFix(bool ceiling) const;

inline coord_t skyFixFloor() const { return skyFix(false /*the floor*/); }
inline coord_t skyFixCeiling() const { return skyFix(true /*the ceiling*/); }

void setSkyFix(bool ceiling, coord_t newHeight);

inline void setSkyFixFloor(coord_t newHeight) {
setSkyFix(false /*the floor*/, newHeight);
}
inline void setSkyFixCeiling(coord_t newHeight) {
setSkyFix(true /*the ceiling*/, newHeight);
}

/**
* Retrieve a pointer to the Generators collection for the map. If no collection
* has yet been constructed a new empty collection will be initialized.
Expand Down Expand Up @@ -560,8 +562,6 @@ class Map
*/
SurfaceSet /*const*/ &glowingSurfaces();

#endif // __CLIENT__

/**
* $smoothmatoffset: interpolate the visual offset.
*/
Expand Down Expand Up @@ -592,6 +592,8 @@ class Map
*/
PlaneSet /*const*/ &trackedPlanes();

#endif // __CLIENT__

/**
* Helper function for returning the relevant line side index for @a lineIndex
* and @a backSide.
Expand Down Expand Up @@ -692,14 +694,14 @@ class Map
*/
void initPolyobjs();

#ifdef __CLIENT__
/**
* Fixing the sky means that for adjacent sky sectors the lower sky
* ceiling is lifted to match the upper sky. The raising only affects
* rendering, it has no bearing on gameplay.
*/
void initSkyFix();

#ifdef __CLIENT__
void buildSurfaceLists();

/**
Expand Down
4 changes: 4 additions & 0 deletions doomsday/client/include/world/plane.h
Expand Up @@ -146,6 +146,8 @@ class Plane : public de::MapElement
*/
coord_t speed() const;

#ifdef __CLIENT__

/**
* Returns the current interpolated visual height of the plane in the map
* coordinate space.
Expand Down Expand Up @@ -183,6 +185,8 @@ class Plane : public de::MapElement
*/
void updateHeightTracking();

#endif // __CLIENT__

/**
* Change the normal of the plane to @a newNormal (which if necessary will
* be normalized before being assigned to the plane).
Expand Down
10 changes: 7 additions & 3 deletions doomsday/client/include/world/r_world.h
@@ -1,4 +1,4 @@
/** @file world/r_world.h World Setup.
/** @file world/r_world.h World map utilities.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
Expand Down Expand Up @@ -31,6 +31,8 @@
void R_SetRelativeHeights(Sector const *front, Sector const *back, int planeIndex,
coord_t *fz = 0, coord_t *bz = 0, coord_t *bhz = 0);

#ifdef __CLIENT__

/**
* Determine the map space Z coordinates of a wall section.
*
Expand All @@ -45,6 +47,8 @@ void R_SetRelativeHeights(Sector const *front, Sector const *back, int planeInde
void R_SideSectionCoords(Line::Side const &side, int section, bool skyClip = true,
coord_t *bottom = 0, coord_t *top = 0, de::Vector2f *materialOrigin = 0);

#endif // __CLIENT__

/**
* Find the "sharp" Z coordinate range of the opening between sectors @a frontSec
* and @a backSec. The open range is defined as the gap between foor and ceiling on
Expand Down Expand Up @@ -72,6 +76,8 @@ inline coord_t R_OpenRange(Line::Side const &side, coord_t *bottom = 0, coord_t
return R_OpenRange(side, side.sectorPtr(), side.back().sectorPtr(), bottom, top);
}

#ifdef __CLIENT__

/**
* Same as @ref R_OpenRange() but works with the "visual" (i.e., smoothed) plane
* height coordinates rather than the "sharp" coordinates.
Expand All @@ -98,8 +104,6 @@ inline coord_t R_VisOpenRange(Line::Side const &side, coord_t *bottom = 0, coord
return R_VisOpenRange(side, side.sectorPtr(), side.back().sectorPtr(), bottom, top);
}

#ifdef __CLIENT__

/**
* @param side Line::Side instance.
* @param ignoreOpacity @c true= do not consider Material opacity.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/src/render/r_main.cpp
Expand Up @@ -784,11 +784,13 @@ void R_NewSharpWorld()
R_CheckViewerLimits(vd->lastSharp, &sharpView);
}

#ifdef __CLIENT__
if(App_World().hasMap())
{
App_World().map().updateTrackedPlanes();
App_World().map().updateScrollingSurfaces();
}
#endif
}

void R_CreateMobjLinks()
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/r_things.cpp
Expand Up @@ -774,6 +774,8 @@ float R_MovementXYZPitch(float momx, float momy, float momz)
return R_MovementPitch(mom);
}

#ifdef __CLIENT__

typedef struct {
vissprite_t *vis;
mobj_t const *mo;
Expand Down Expand Up @@ -804,8 +806,6 @@ int RIT_VisMobjZ(Sector *sector, void *parameters)
return false; // Continue iteration.
}

#ifdef __CLIENT__

static void setupSpriteParamsForVisSprite(rendspriteparams_t *params,
float x, float y, float z, float distance, float visOffX, float visOffY, float visOffZ,
float /*secFloor*/, float /*secCeil*/, float /*floorClip*/, float /*top*/,
Expand Down
22 changes: 11 additions & 11 deletions doomsday/client/src/world/bspleaf.cpp
Expand Up @@ -413,17 +413,6 @@ void BspLeaf::setSector(Sector *newSector)
d->sector = newSector;
}

bool BspLeaf::hasWorldVolume(bool useVisualHeights) const
{
if(isDegenerate()) return false;
if(!hasSector()) return false;

coord_t const floorHeight = useVisualHeights? d->sector->floor().visHeight() : d->sector->floor().height();
coord_t const ceilHeight = useVisualHeights? d->sector->ceiling().visHeight() : d->sector->ceiling().height();

return (ceilHeight - floorHeight > 0);
}

Polyobj *BspLeaf::firstPolyobj() const
{
return d->polyobj;
Expand All @@ -446,6 +435,17 @@ void BspLeaf::setValidCount(int newValidCount)

#ifdef __CLIENT__

bool BspLeaf::hasWorldVolume(bool useVisualHeights) const
{
if(isDegenerate()) return false;
if(!hasSector()) return false;

coord_t const floorHeight = useVisualHeights? d->sector->floor().visHeight() : d->sector->floor().height();
coord_t const ceilHeight = useVisualHeights? d->sector->ceiling().visHeight() : d->sector->ceiling().height();

return (ceilHeight - floorHeight > 0);
}

HEdge *BspLeaf::fanBase() const
{
if(d->needUpdateFanBase)
Expand Down
93 changes: 48 additions & 45 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -114,18 +114,19 @@ DENG2_PIMPL(Map)
QScopedPointer<Blockmap> lineBlockmap;
QScopedPointer<Blockmap> bspLeafBlockmap;

#ifdef __CLIENT__
PlaneSet trackedPlanes;
SurfaceSet scrollingSurfaces;
#ifdef __CLIENT__

SurfaceSet decoratedSurfaces;
SurfaceSet glowingSurfaces;

QScopedPointer<Generators> generators;
QScopedPointer<LightGrid> lightGrid;
#endif

coord_t skyFloorHeight;
coord_t skyCeilingHeight;
#endif

// Current LOS trace state.
/// @todo Does not belong here.
Expand All @@ -135,9 +136,11 @@ DENG2_PIMPL(Map)
Instance(Public *i)
: Base (i),
editingEnabled (true),
bspRoot (0),
skyFloorHeight (DDMAXFLOAT),
bspRoot (0)
#ifdef __CLIENT__
, skyFloorHeight(DDMAXFLOAT),
skyCeilingHeight(DDMINFLOAT)
#endif
{
zap(traceOpening);
zap(traceLine);
Expand Down Expand Up @@ -515,8 +518,6 @@ DENG2_PIMPL(Map)
}
}

#endif // __CLIENT__

void updateMapSkyFixForSector(Sector const &sector)
{
if(!sector.sideCount()) return;
Expand Down Expand Up @@ -586,6 +587,8 @@ DENG2_PIMPL(Map)
}
}

#endif // __CLIENT__

/**
* Locate a polyobj in the map by sound emitter.
*
Expand Down Expand Up @@ -884,35 +887,6 @@ int Map::ambientLightLevel() const
return _ambientLightLevel;
}

void Map::initSkyFix()
{
Time begunAt;

LOG_AS("Map::initSkyFix");

d->skyFloorHeight = DDMAXFLOAT;
d->skyCeilingHeight = DDMINFLOAT;

// Update for sector plane heights and mobjs which intersect the ceiling.
foreach(Sector *sector, d->sectors)
{
d->updateMapSkyFixForSector(*sector);
}

LOG_INFO(String("Completed in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
}

coord_t Map::skyFix(bool ceiling) const
{
return ceiling? d->skyCeilingHeight : d->skyFloorHeight;
}

void Map::setSkyFix(bool ceiling, coord_t newHeight)
{
if(ceiling) d->skyCeilingHeight = newHeight;
else d->skyFloorHeight = newHeight;
}

int Map::toSideIndex(int lineIndex, int backSide) // static
{
DENG_ASSERT(lineIndex >= 0);
Expand Down Expand Up @@ -1735,6 +1709,23 @@ BspLeaf *Map::bspLeafAtPoint_FixedPrecision(Vector2d const &point) const
return bspElement->castTo<BspLeaf>();
}

void Map::updateSurfacesOnMaterialChange(Material &material)
{
if(ddMapSetup) return;

#ifdef __CLIENT__
foreach(Surface *surface, d->decoratedSurfaces)
{
if(&material == surface->materialPtr())
{
surface->markAsNeedingDecorationUpdate();
}
}
#endif
}

#ifdef __CLIENT__

void Map::lerpScrollingSurfaces(bool resetNextViewer)
{
if(resetNextViewer)
Expand Down Expand Up @@ -1829,22 +1820,34 @@ Map::PlaneSet &Map::trackedPlanes()
return d->trackedPlanes;
}

void Map::updateSurfacesOnMaterialChange(Material &material)
void Map::initSkyFix()
{
if(ddMapSetup) return;
Time begunAt;

#ifdef __CLIENT__
foreach(Surface *surface, d->decoratedSurfaces)
LOG_AS("Map::initSkyFix");

d->skyFloorHeight = DDMAXFLOAT;
d->skyCeilingHeight = DDMINFLOAT;

// Update for sector plane heights and mobjs which intersect the ceiling.
foreach(Sector *sector, d->sectors)
{
if(&material == surface->materialPtr())
{
surface->markAsNeedingDecorationUpdate();
}
d->updateMapSkyFixForSector(*sector);
}
#endif

LOG_INFO(String("Completed in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
}

#ifdef __CLIENT__
coord_t Map::skyFix(bool ceiling) const
{
return ceiling? d->skyCeilingHeight : d->skyFloorHeight;
}

void Map::setSkyFix(bool ceiling, coord_t newHeight)
{
if(ceiling) d->skyCeilingHeight = newHeight;
else d->skyFloorHeight = newHeight;
}

Generators &Map::generators()
{
Expand Down

0 comments on commit 2e7b034

Please sign in to comment.