From e71512b36e8827110b006529f78c68974b89c3cc Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 7 Jan 2022 11:03:10 -0500 Subject: [PATCH] Core/PathFinding: Return raycast hitpoint when specifying straightLine Port From (https://github.com/TrinityCore/TrinityCore/commit/313b9d2531830e6470132beb3c131527a50b9d50) --- .../Game/Movement/Generators/PathGenerator.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/Game/Movement/Generators/PathGenerator.cs b/Source/Game/Movement/Generators/PathGenerator.cs index caf0ff6e4..b9fe4a354 100644 --- a/Source/Game/Movement/Generators/PathGenerator.cs +++ b/Source/Game/Movement/Generators/PathGenerator.cs @@ -359,7 +359,15 @@ namespace Game.Movement if (hit != float.MaxValue) { // the ray hit something, return no path instead of the incomplete one - pathType = PathType.NoPath; + Clear(); + _polyLength = 2; + Array.Resize(ref _pathPoints, 2); + _pathPoints[0] = GetStartPosition(); + float[] hitPos = new float[3]; + Detour.dtVlerp(hitPos, startPoint, endPoint, hit); + _pathPoints[1] = new Vector3(hitPos[2], hitPos[0], hitPos[1]); + + pathType = PathType.Incomplete; return; } } @@ -424,7 +432,15 @@ namespace Game.Movement if (hit != float.MaxValue) { // the ray hit something, return no path instead of the incomplete one - pathType = PathType.NoPath; + Clear(); + _polyLength = 2; + Array.Resize(ref _pathPoints, 2); + _pathPoints[0] = GetStartPosition(); + float[] hitPos = new float[3]; + Detour.dtVlerp(hitPos, startPoint, endPoint, hit); + _pathPoints[1] = new Vector3(hitPos[2], hitPos[0], hitPos[1]); + + pathType = PathType.Incomplete; return; } }