Skip to content

Commit

Permalink
Map Renderer|Client: Use sector clusters when determining if a player…
Browse files Browse the repository at this point in the history
… is in the void
  • Loading branch information
danij-deng committed Aug 25, 2013
1 parent 6b465ef commit d660c05
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
27 changes: 26 additions & 1 deletion doomsday/client/include/world/bspleaf.h
Expand Up @@ -217,6 +217,32 @@ class BspLeaf : public de::MapElement
*/
inline Plane &ceiling() const { return plane(Sector::Ceiling); }

/**
* Convenient method of accessing the physical height of the identified sector plane.
*
* @param planeIndex Index of the plane to return.
*
* @see plane(), Plane::height()
*/
inline coord_t planeHeight(int planeIndex) const {
return plane(planeIndex).height();
}

/**
* Convenient method of accessing the physical height of the sector floor plane.
*
* @see planeHeight()
*/
inline coord_t floorHeight() const { return planeHeight(Sector::Floor); }

/**
* Convenient method of accessing the physical height of the sector ceiling plane.
*
* @see planeHeight()
*/
inline coord_t ceilingHeight() const { return planeHeight(Sector::Ceiling); }

#ifdef __CLIENT__
/**
* Returns the identified @em visual sector plane for the BSP leaf (which may
* or may not be the same as the physical plane). Note that a sector must be
Expand All @@ -240,7 +266,6 @@ class BspLeaf : public de::MapElement
*/
inline Plane &visCeiling() const { return visPlane(Sector::Ceiling); }

#ifdef __CLIENT__
/**
* Convenient method of accessing the visual (i.e., smoothed) height of the
* identified @em visual sector plane.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/world/bspleaf.cpp
Expand Up @@ -251,7 +251,7 @@ DENG2_PIMPL(BspLeaf)

geomGroup.biasTracker.clearContributors();

Plane const &plane = cluster->plane(planeIndex);
Plane const &plane = cluster->visPlane(planeIndex);
Surface const &surface = plane.surface();

Vector3d surfacePoint(poly->center(), plane.visHeight());
Expand Down
20 changes: 12 additions & 8 deletions doomsday/client/src/world/map.cpp
Expand Up @@ -2046,20 +2046,24 @@ void Map::link(mobj_t &mo, byte flags)
if(mo.dPlayer && mo.dPlayer->mo)
{
ddplayer_t *player = mo.dPlayer;
Sector &sector = player->mo->bspLeaf->sector();

player->inVoid = true;
if(sector.pointInside(player->mo->origin))

if(player->mo->bspLeaf && player->mo->bspLeaf->hasSector())
{
BspLeaf &bspLeaf = *player->mo->bspLeaf;
if(bspLeaf.pointInside(player->mo->origin))
{
#ifdef __CLIENT__
if(player->mo->origin[VZ] < sector.ceiling().visHeight() + 4 &&
player->mo->origin[VZ] >= sector.floor().visHeight())
if(player->mo->origin[VZ] < bspLeaf.visCeilingHeight() + 4 &&
player->mo->origin[VZ] >= bspLeaf.visFloorHeight())
#else
if(player->mo->origin[VZ] < sector.ceiling().height() + 4 &&
player->mo->origin[VZ] >= sector.floor().height())
if(player->mo->origin[VZ] < bspLeaf.ceilingHeight() + 4 &&
player->mo->origin[VZ] >= bspLeaf.floorHeight())
#endif
{
player->inVoid = false;
{
player->inVoid = false;
}
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions doomsday/client/src/world/p_players.cpp
Expand Up @@ -126,34 +126,34 @@ boolean P_IsInVoid(player_t *player)
return true;

BspLeaf *bspLeaf = ddpl->mo->bspLeaf;
if(!bspLeaf->hasSector())
if(!bspLeaf->hasSector() || bspLeaf->isDegenerate())
return true;

#ifdef __CLIENT__
if(bspLeaf->ceiling().surface().hasSkyMaskedMaterial())
if(bspLeaf->visCeiling().surface().hasSkyMaskedMaterial())
{
coord_t const skyCeil = bspLeaf->map().skyFixCeiling();
if(skyCeil < DDMAXFLOAT && ddpl->mo->origin[VZ] > skyCeil - 4)
return true;
}
else if(ddpl->mo->origin[VZ] > bspLeaf->ceiling().visHeight() - 4)
else if(ddpl->mo->origin[VZ] > bspLeaf->visCeilingHeight() - 4)
#else
if(ddpl->mo->origin[VZ] > bspLeaf->ceiling().height() - 4)
if(ddpl->mo->origin[VZ] > bspLeaf->ceilingHeight() - 4)
#endif
{
return true;
}

#ifdef __CLIENT__
if(bspLeaf->floor().surface().hasSkyMaskedMaterial())
if(bspLeaf->visFloor().surface().hasSkyMaskedMaterial())
{
coord_t const skyFloor = bspLeaf->map().skyFixFloor();
if(skyFloor > DDMINFLOAT && ddpl->mo->origin[VZ] < skyFloor + 4)
return true;
}
else if(ddpl->mo->origin[VZ] < bspLeaf->floor().visHeight() + 4)
else if(ddpl->mo->origin[VZ] < bspLeaf->visFloorHeight() + 4)
#else
if(ddpl->mo->origin[VZ] < bspLeaf->floor().height() + 4)
if(ddpl->mo->origin[VZ] < bspLeaf->floorHeight() + 4)
#endif
{
return true;
Expand Down
11 changes: 6 additions & 5 deletions doomsday/client/src/world/world.cpp
Expand Up @@ -589,14 +589,15 @@ DENG2_PIMPL(World)

if(mobj_t *mo = ddpl.mo)
{
if(Sector *sector = map->bspLeafAt(mo->origin).sectorPtr())
BspLeaf &bspLeaf = map->bspLeafAt(mo->origin);
if(bspLeaf.hasSector() && !bspLeaf.isDegenerate())
{
#ifdef __CLIENT__
if(mo->origin[VZ] >= sector->floor().visHeight() &&
mo->origin[VZ] < sector->ceiling().visHeight() - 4)
if(mo->origin[VZ] >= bspLeaf.visFloorHeight() &&
mo->origin[VZ] < bspLeaf.visCeilingHeight() - 4)
#else
if(mo->origin[VZ] >= sector->floor().height() &&
mo->origin[VZ] < sector->ceiling().height() - 4)
if(mo->origin[VZ] >= bspLeaf.floorHeight() &&
mo->origin[VZ] < bspLeaf.ceilingHeight() - 4)
#endif
{
ddpl.inVoid = false;
Expand Down

0 comments on commit d660c05

Please sign in to comment.