fix(Core/Movement): Fixed collision calculation returning wrong position. (#4879)

This commit is contained in:
UltraNix
2021-03-20 17:55:59 +01:00
committed by GitHub
parent 7c620fb7f0
commit b2f6a36c6c
2 changed files with 8 additions and 10 deletions

View File

@@ -3483,11 +3483,6 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, PathGener
return true;
}
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
{
return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
}
/**
* @brief validate the new destination and set reachable coords
* Check if a given unit can reach a specific point on a segment
@@ -3500,16 +3495,19 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float &de
* @return true if the destination is valid, false otherwise
*
**/
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float& destX, float& destY, float& destZ, bool failOnCollision, bool failOnSlopes) const
{
return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
}
bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
{
float tempX=destX, tempY=destY, tempZ=destZ;
if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
{
return false;
}
destX = tempX, destY = tempY, destZ = tempZ;
const Unit* unit = source->ToUnit();
// if it's not an unit (Object) then we do not have to continue
// with walkable checks
@@ -3614,7 +3612,7 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start
source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
// position has no ground under it (or is too far away)
if (groundZ <= INVALID_HEIGHT && unit && unit->CanFly())
if (groundZ <= INVALID_HEIGHT && unit && !unit->CanFly())
{
// fall back to gridHeight if any
float gridHeight = GetGridHeight(destX, destY);