From 4bc9c07407705d4bc3549a495dc5cacf838e15a6 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 20 Feb 2020 21:49:18 +0100 Subject: [PATCH] Core/Objects: MovePositionToFirstCollision will now always use detour raycasts to get the first collision point --- src/server/game/Entities/Object/Object.cpp | 32 +++------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 1fd0a89399f..90a1b53004b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2575,34 +2575,10 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float dist = std::sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty)); } - if (Unit const* unit = ToUnit()) - { - PathGenerator path(unit); - path.CalculatePath(destx, desty, destz, false, true); - pos.Relocate(Vector3ToPosition(path.GetPath().back())); - } - else - { - // To-do: move non-unit cases to detour raycasts as well - float step = dist / 10.0f; - - for (uint8 j = 0; j < 10; ++j) - { - // do not allow too big z changes - if (std::fabs(pos.m_positionZ - destz) > 6.0f) - { - destx -= step * std::cos(angle); - desty -= step * std::sin(angle); - UpdateAllowedPositionZ(destx, desty, destz); - } - // we have correct destz now - else - { - pos.Relocate(destx, desty, destz); - break; - } - } - } + // Use a detour raycast to get our first collision point + PathGenerator path(this); + path.CalculatePath(destx, desty, destz, false, true); + pos.Relocate(Vector3ToPosition(path.GetPath().back())); float groundZ = VMAP_INVALID_HEIGHT_VALUE; Trinity::NormalizeMapCoord(pos.m_positionX);