Core/Maps: Use a fixed offset instead of full collision height when retrieving floor Z

This commit is contained in:
Giacomo Pozzoni
2021-02-21 20:26:21 +01:00
committed by Ovahlord
parent 4343dd6d55
commit c12531b023
3 changed files with 4 additions and 3 deletions

View File

@@ -2784,7 +2784,7 @@ float WorldObject::GetFloorZ() const
{
if (!IsInWorld())
return m_staticFloorZ;
return std::max<float>(m_staticFloorZ, GetMap()->GetGameObjectFloor(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight()));
return std::max<float>(m_staticFloorZ, GetMap()->GetGameObjectFloor(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ() + Z_OFFSET_FIND_HEIGHT));
}
float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* ground/* = nullptr*/) const
@@ -2797,7 +2797,7 @@ float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* gr
float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const
{
if (z != MAX_HEIGHT)
z += GetCollisionHeight();
z += Z_OFFSET_FIND_HEIGHT;
return GetMap()->GetHeight(GetPhaseShift(), x, y, z, vmap, distanceToSearch);
}

View File

@@ -2543,7 +2543,7 @@ float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y,
if (GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
{
// we need ground level (including grid height version) for proper return water level in point
float ground_z = GetHeight(phaseShift, x, y, z + collisionHeight);
float ground_z = GetHeight(phaseShift, x, y, z + Z_OFFSET_FIND_HEIGHT);
if (ground)
*ground = ground_z;

View File

@@ -22,6 +22,7 @@
#include "DetourNavMesh.h"
float const GROUND_HEIGHT_TOLERANCE = 0.05f; // Extra tolerance to z position to check if it is in air or on ground.
constexpr float Z_OFFSET_FIND_HEIGHT = 0.5f;
enum SpellEffIndex : uint8
{