Skip to content

Commit 4bc9c07

Browse files
committed
Core/Objects: MovePositionToFirstCollision will now always use detour raycasts to get the first collision point
1 parent a378f23 commit 4bc9c07

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

src/server/game/Entities/Object/Object.cpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,34 +2575,10 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
25752575
dist = std::sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
25762576
}
25772577

2578-
if (Unit const* unit = ToUnit())
2579-
{
2580-
PathGenerator path(unit);
2581-
path.CalculatePath(destx, desty, destz, false, true);
2582-
pos.Relocate(Vector3ToPosition(path.GetPath().back()));
2583-
}
2584-
else
2585-
{
2586-
// To-do: move non-unit cases to detour raycasts as well
2587-
float step = dist / 10.0f;
2588-
2589-
for (uint8 j = 0; j < 10; ++j)
2590-
{
2591-
// do not allow too big z changes
2592-
if (std::fabs(pos.m_positionZ - destz) > 6.0f)
2593-
{
2594-
destx -= step * std::cos(angle);
2595-
desty -= step * std::sin(angle);
2596-
UpdateAllowedPositionZ(destx, desty, destz);
2597-
}
2598-
// we have correct destz now
2599-
else
2600-
{
2601-
pos.Relocate(destx, desty, destz);
2602-
break;
2603-
}
2604-
}
2605-
}
2578+
// Use a detour raycast to get our first collision point
2579+
PathGenerator path(this);
2580+
path.CalculatePath(destx, desty, destz, false, true);
2581+
pos.Relocate(Vector3ToPosition(path.GetPath().back()));
26062582

26072583
float groundZ = VMAP_INVALID_HEIGHT_VALUE;
26082584
Trinity::NormalizeMapCoord(pos.m_positionX);

0 commit comments

Comments
 (0)