nav: return to everything visible in finding the nearest node. (resolve previously solved problem #432)

nav: checks whether the robot is blocked in the direction of movement. (excluded in hostages)
This commit is contained in:
commandcobra7 2024-06-06 15:31:07 +03:00 committed by jeefo
commit ece83734a1
6 changed files with 113 additions and 85 deletions

View file

@ -493,12 +493,12 @@ int BotGraph::getForAnalyzer (const Vector &origin, const float maxRange) {
return index;
}
int BotGraph::getNearestNoBuckets (const Vector &origin, const float range, int flags) {
int BotGraph::getNearestNoBuckets (const Vector &origin, float nearestDistanceSq, int flags) {
// find the nearest node to that origin and return the index
// fallback and go thru wall the nodes...
int index = kInvalidNodeIndex;
float nearestDistanceSq = cr::sqrf (range);
nearestDistanceSq = cr::sqrf (nearestDistanceSq);
for (const auto &path : m_paths) {
if (flags != -1 && !(path.flags & flags)) {
@ -555,15 +555,15 @@ int BotGraph::getNearest (const Vector &origin, const float range, int flags) {
return index;
}
IntArray BotGraph::getNearestInRadius (float radius, const Vector &origin, int maxCount) {
IntArray BotGraph::getNearestInRadius (float radiusSq, const Vector &origin, int maxCount) {
// returns all nodes within radius from position
const float radiusSq = cr::sqrf (radius);
radiusSq = cr::sqrf (radiusSq);
IntArray result {};
const auto &bucket = getNodesInBucket (origin);
if (bucket.length () < kMaxNodeLinks || radius > cr::sqrf (256.0f)) {
if (bucket.length () < kMaxNodeLinks || radiusSq > cr::sqrf (256.0f)) {
for (const auto &path : m_paths) {
if (maxCount != -1 && static_cast <int> (result.length ()) > maxCount) {
break;