diff --git a/doomsday/client/include/world/bspleaf.h b/doomsday/client/include/world/bspleaf.h index ddfe31c045..01e98a14c2 100644 --- a/doomsday/client/include/world/bspleaf.h +++ b/doomsday/client/include/world/bspleaf.h @@ -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 @@ -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. diff --git a/doomsday/client/src/world/bspleaf.cpp b/doomsday/client/src/world/bspleaf.cpp index c7fc119ec2..4dfed4d7db 100644 --- a/doomsday/client/src/world/bspleaf.cpp +++ b/doomsday/client/src/world/bspleaf.cpp @@ -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()); diff --git a/doomsday/client/src/world/map.cpp b/doomsday/client/src/world/map.cpp index 3a7cc65fec..4dd08adb98 100644 --- a/doomsday/client/src/world/map.cpp +++ b/doomsday/client/src/world/map.cpp @@ -2046,20 +2046,24 @@ void Map::link(mobj_t &mo, byte flags) if(mo.dPlayer && mo.dPlayer->mo) { ddplayer_t *player = mo.dPlayer; - Sector §or = 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; + } } } } diff --git a/doomsday/client/src/world/p_players.cpp b/doomsday/client/src/world/p_players.cpp index 43e370060d..60741f2ce9 100644 --- a/doomsday/client/src/world/p_players.cpp +++ b/doomsday/client/src/world/p_players.cpp @@ -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; diff --git a/doomsday/client/src/world/world.cpp b/doomsday/client/src/world/world.cpp index 228cc0b3a2..1481e865e3 100644 --- a/doomsday/client/src/world/world.cpp +++ b/doomsday/client/src/world/world.cpp @@ -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;