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.
This commit is contained in:
Kawe Mazidjatari 2024-09-04 00:42:58 +02:00
parent 0814efe613
commit 7739a6c909

View File

@ -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;
}