mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 05:43:12 +01:00
Core/Objects: MovePositionToFirstCollision will now always use detour raycasts to get the first collision point
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user