From 6443e518cfa110434617c26f949b6783fe4d10d3 Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Fri, 28 Feb 2020 19:29:58 +0100 Subject: Core/PathFinding: Return raycast hitpoint when specifying straightLine (#24206) --- src/server/game/Movement/PathGenerator.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index 6318f952d5d..66b93de4820 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -369,7 +369,15 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con if (hit != FLT_MAX) { // the ray hit something, return no path instead of the incomplete one - _type = PATHFIND_NOPATH; + Clear(); + _polyLength = 2; + _pathPoints.resize(2); + _pathPoints[0] = GetStartPosition(); + float hitPos[3]; + dtVlerp(hitPos, startPoint, endPoint, hit); + _pathPoints[1] = G3D::Vector3(hitPos[2], hitPos[0], hitPos[1]); + + _type = PATHFIND_INCOMPLETE; return; } } @@ -432,7 +440,15 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con if (hit != FLT_MAX) { // the ray hit something, return no path instead of the incomplete one - _type = PATHFIND_NOPATH; + Clear(); + _polyLength = 2; + _pathPoints.resize(2); + _pathPoints[0] = GetStartPosition(); + float hitPos[3]; + dtVlerp(hitPos, startPoint, endPoint, hit); + _pathPoints[1] = G3D::Vector3(hitPos[2], hitPos[0], hitPos[1]); + + _type = PATHFIND_INCOMPLETE; return; } } -- cgit v1.2.3