diff options
| author | Shauren <shauren.trinity@gmail.com> | 2018-04-07 00:25:00 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2018-04-07 21:36:14 +0200 |
| commit | 2dadbda24ac1c2e6ff3dad650c7e25f4b3322342 (patch) | |
| tree | 654ad62aaa66d12710a346e27d4ffd236bee4a27 /src/server/game/Maps | |
| parent | 5f897589f9b3d5677dc5d2382fcb7dd35696aaa7 (diff) | |
Revert "Core/Entities: Reduce the probability of units dropping under the map (#21322)"
This reverts commit 9e0faace9a5114fc2324c2c601ba943272e0d6ff.
Diffstat (limited to 'src/server/game/Maps')
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 50 | ||||
| -rw-r--r-- | src/server/game/Maps/Map.h | 57 |
2 files changed, 27 insertions, 80 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 609426e1b11..afe5e8d6727 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2365,12 +2365,12 @@ inline GridMap* Map::GetGrid(float x, float y) return GridMaps[gx][gy]; } -float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const +float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/) const { if (const_cast<Map*>(this)->GetGrid(x, y)) { // we need ground level (including grid height version) for proper return water level in point - float ground_z = GetHeight(phasemask, x, y, z, true, maxSearchDist, collisionHeight); + float ground_z = GetHeight(phasemask, x, y, z + collisionHeight, true, 50.0f); if (ground) *ground = ground_z; @@ -2391,22 +2391,30 @@ float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, fl return VMAP_INVALID_HEIGHT_VALUE; } -float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/, float collisionHeight) const +float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const { // find raw .map surface under Z coordinates - float const gridHeight = GetGridMapHeight(x, y); - float mapHeight = z + collisionHeight > gridHeight ? gridHeight : VMAP_INVALID_HEIGHT_VALUE; + float mapHeight = VMAP_INVALID_HEIGHT_VALUE; + if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) + { + float gridHeight = gmap->getHeight(x, y); + if (z > gridHeight) + mapHeight = gridHeight; + } float vmapHeight = VMAP_INVALID_HEIGHT_VALUE; if (checkVMap) - vmapHeight = GetVMapFloor(x, y, z, maxSearchDist, collisionHeight); - - bool const hasVmapFloor = vmapHeight > INVALID_HEIGHT; - bool const hasMapFloor = mapHeight > INVALID_HEIGHT; + { + VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); + if (vmgr->isHeightCalcEnabled()) + vmapHeight = vmgr->getHeight(GetId(), x, y, z, maxSearchDist); + } - if (hasVmapFloor) + // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT + // vmapheight set for any under Z value or <= INVALID_HEIGHT + if (vmapHeight > INVALID_HEIGHT) { - if (hasMapFloor) + if (mapHeight > INVALID_HEIGHT) { // we have mapheight and vmapheight and must select more appropriate @@ -2421,7 +2429,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float return vmapHeight; // we have only vmapHeight (if have) } - return gridHeight; // explicitly use map data + return mapHeight; // explicitly use map data } float Map::GetMinHeight(float x, float y) const @@ -2432,19 +2440,6 @@ float Map::GetMinHeight(float x, float y) const return -500.0f; } -float Map::GetGridMapHeight(float x, float y) const -{ - if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) - return gmap->getHeight(x, y); - - return VMAP_INVALID_HEIGHT_VALUE; -} - -float Map::GetVMapFloor(float x, float y, float z, float maxSearchDist, float collisionHeight) const -{ - return VMAP::VMapFactory::createOrGetVMapManager()->getHeight(GetId(), x, y, z + collisionHeight, maxSearchDist); -} - inline bool IsOutdoorWMO(uint32 mogpFlags, WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry) { if (wmoEntry && atEntry) @@ -2772,11 +2767,6 @@ float Map::GetWaterLevel(float x, float y) const return 0; } -float Map::GetCeil(float x, float y, float z, float maxSearchDist, float collisionHeight) const -{ - return VMAP::VMapFactory::createOrGetVMapManager()->getCeil(GetId(), x, y, z + collisionHeight, maxSearchDist); -} - bool Map::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const { if ((checks & LINEOFSIGHT_CHECK_VMAP) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 8021cf440c2..4cfa53252fc 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -540,63 +540,20 @@ class TC_GAME_API Map : public GridRefManager<NGridType> BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return nullptr; } BattlegroundMap const* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; } - // FLOOR, CEIL AND HEIGHT - float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 0.0f, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const; + float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 2.03128f) const; // DEFAULT_COLLISION_HEIGHT in Object.h float GetMinHeight(float x, float y) const; - float GetGridMapHeight(float x, float y) const; - float GetVMapFloor(float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const; - float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const; - float GetHeight(Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return GetHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist, collisionHeight); - } - - float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist, collisionHeight), GetGameObjectFloor(phasemask, x, y, z, maxSearchDist, collisionHeight)); - } - - float GetHeight(uint32 phasemask, Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return GetHeight(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist, collisionHeight); - } - - float GetCeil(uint32 phasemask, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return std::min<float>(GetCeil(x, y, z, maxSearchDist, collisionHeight), GetGameObjectCeil(phasemask, x, y, z, maxSearchDist, collisionHeight)); - } - - float GetCeil(uint32 phasemask, Position const& pos, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return GetCeil(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), maxSearchDist, collisionHeight); - } - - float GetCeil(Position const& pos, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return GetCeil(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), maxSearchDist, collisionHeight); - } - - float GetCeil(float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const; - - float GetGameObjectCeil(uint32 phasemask, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return _dynamicTree.getCeil(x, y, z + collisionHeight, maxSearchDist, phasemask); - } - - float GetGameObjectCeil(uint32 phasemask, Position const& pos, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const - { - return GetGameObjectCeil(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + collisionHeight, maxSearchDist, phasemask); - } - - // + float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const; + float GetHeight(Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return GetHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); } + float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phasemask, x, y, z, maxSearchDist)); } + float GetHeight(uint32 phasemask, Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return GetHeight(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); } bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const; void Balance() { _dynamicTree.balance(); } void RemoveGameObjectModel(GameObjectModel const& model) { _dynamicTree.remove(model); } void InsertGameObjectModel(GameObjectModel const& model) { _dynamicTree.insert(model); } bool ContainsGameObjectModel(GameObjectModel const& model) const { return _dynamicTree.contains(model);} - float GetGameObjectFloor(uint32 phasemask, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH, float collisionHeight = 0.0f) const + float GetGameObjectFloor(uint32 phasemask, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { - return _dynamicTree.getHeight(x, y, z + collisionHeight, maxSearchDist, phasemask); + return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask); } bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist); |
