fix(Core/Movement): Fixed collision calculation returning wrong position. (#4879)
This commit is contained in:
@@ -3483,11 +3483,6 @@ bool Map::CanReachPositionAndGetValidCoords(const WorldObject* source, PathGener
|
|||||||
return true;
|
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
|
* @brief validate the new destination and set reachable coords
|
||||||
* Check if a given unit can reach a specific point on a segment
|
* 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
|
* @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
|
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))
|
if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
destX = tempX, destY = tempY, destZ = tempZ;
|
|
||||||
|
|
||||||
const Unit* unit = source->ToUnit();
|
const Unit* unit = source->ToUnit();
|
||||||
// if it's not an unit (Object) then we do not have to continue
|
// if it's not an unit (Object) then we do not have to continue
|
||||||
// with walkable checks
|
// with walkable checks
|
||||||
@@ -3614,7 +3612,7 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start
|
|||||||
source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
|
source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
|
||||||
|
|
||||||
// position has no ground under it (or is too far away)
|
// 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
|
// fall back to gridHeight if any
|
||||||
float gridHeight = GetGridHeight(destX, destY);
|
float gridHeight = GetGridHeight(destX, destY);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T* owner)
|
|||||||
owner->AddUnitState(UNIT_STATE_FLEEING_MOVE);
|
owner->AddUnitState(UNIT_STATE_FLEEING_MOVE);
|
||||||
|
|
||||||
Movement::MoveSplineInit init(owner);
|
Movement::MoveSplineInit init(owner);
|
||||||
init.MoveTo(x, y, z);
|
init.MoveTo(x, y, z, true);
|
||||||
init.SetWalk(false);
|
init.SetWalk(false);
|
||||||
init.Launch();
|
init.Launch();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user