mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Core/Objects: merged new changes from undermap issue fixup PR
This commit is contained in:
@@ -1655,11 +1655,16 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
z = new_z + (isType(TYPEMASK_UNIT) ? static_cast<Unit const*>(this)->GetHoverOffset() : 0.0f);
|
||||
}
|
||||
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z, float* groundZ) const
|
||||
{
|
||||
// TODO: Allow transports to be part of dynamic vmap tree
|
||||
if (GetTransport())
|
||||
{
|
||||
if (groundZ)
|
||||
*groundZ = z;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Unit const* unit = ToUnit())
|
||||
{
|
||||
@@ -1685,12 +1690,18 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
|
||||
if (groundZ)
|
||||
*groundZ = ground_z;
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMapHeight(x, y, z) + unit->GetHoverOffset();
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
|
||||
if (groundZ)
|
||||
*groundZ = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1698,6 +1709,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
float ground_z = GetMapHeight(x, y, z);
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
|
||||
if (groundZ)
|
||||
*groundZ = ground_z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2596,10 +2610,28 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
}
|
||||
}
|
||||
|
||||
float groundZ = VMAP_INVALID_HEIGHT_VALUE;
|
||||
Trinity::NormalizeMapCoord(pos.m_positionX);
|
||||
Trinity::NormalizeMapCoord(pos.m_positionY);
|
||||
UpdateAllowedPositionZ(destx, desty, pos.m_positionZ);
|
||||
UpdateAllowedPositionZ(destx, desty, pos.m_positionZ, &groundZ);
|
||||
pos.SetOrientation(GetOrientation());
|
||||
|
||||
// position has no ground under it (or is too far away)
|
||||
if (groundZ <= INVALID_HEIGHT)
|
||||
{
|
||||
if (Unit const* unit = ToUnit())
|
||||
{
|
||||
// flying, ignore.
|
||||
if (unit->IsFlying())
|
||||
return;
|
||||
|
||||
// fall back to gridHeight if any
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap(), pos.m_positionX, pos.m_positionY);
|
||||
float gridHeight = GetMap()->GetGridHeight(terrainMapId, pos.m_positionX, pos.m_positionY);
|
||||
if (gridHeight > INVALID_HEIGHT)
|
||||
pos.m_positionZ = gridHeight + unit->GetHoverOffset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
|
||||
@@ -294,7 +294,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
virtual float GetCombatReach() const { return 0.0f; } // overridden (only) in Unit
|
||||
void UpdateGroundPositionZ(float x, float y, float &z) const;
|
||||
void UpdateAllowedPositionZ(float x, float y, float &z) const;
|
||||
void UpdateAllowedPositionZ(float x, float y, float &z, float* groundZ = nullptr) const;
|
||||
|
||||
void GetRandomPoint(Position const& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const;
|
||||
Position GetRandomPoint(Position const& srcPos, float distance) const;
|
||||
|
||||
@@ -2535,7 +2535,10 @@ float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float
|
||||
{
|
||||
// find raw .map surface under Z coordinates
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
|
||||
float const mapHeight = GetGridHeight(terrainMapId, x, y);
|
||||
float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
|
||||
float gridHeight = GetGridHeight(terrainMapId, x, y);
|
||||
if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
|
||||
mapHeight = gridHeight;
|
||||
|
||||
float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
|
||||
if (checkVMap)
|
||||
|
||||
Reference in New Issue
Block a user