From 7739a6c9093ab1669ba6450c3e5cda65a38f952b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:42:58 +0200 Subject: [PATCH] Recast: minor improvement to traverse link selection algorithm Slight optimization to skip unsupported ones out before computing anything, and also improves the generation results as we try to get the best one out of the supported ones, instead of taking one from supported and unsupported and then later check if its unsupported. (if the best type is 9, and 9 isn't supported while 8 is, and 8 would've been the candidate after 9, then this patch will still give the link a chance for 8 while the previous implementation would've skipped it entirely and returned DT_NULL_TRAVERSE_TYPE, ultimately resulting in no link whatsoever. --- src/naveditor/Editor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 5796af9a..88ce9828 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -498,6 +498,9 @@ unsigned char GetBestTraverseType(void* userData, const float traverseDist, cons continue; } + if (!traverseTypeSupported(userData, (unsigned char)i)) + continue; + if (traverseDist < traverseType.minDist || traverseDist > traverseType.maxDist) { @@ -543,9 +546,6 @@ unsigned char GetBestTraverseType(void* userData, const float traverseDist, cons } } - if (!traverseTypeSupported(userData, (unsigned char)bestTraverseType)) - return DT_NULL_TRAVERSE_TYPE; - return (unsigned char)bestTraverseType; }