From 5de5e576e5037d7617e8f6ffed43954a338609d9 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 17 Feb 2024 09:07:37 +0100 Subject: [PATCH] Rename `Navigation.ProjectPoint` into `Navigation.FindClosestPoint` to have consistent API naming #2034 --- Source/Engine/AI/BehaviorTreeNodes.cpp | 4 ++-- Source/Engine/Navigation/NavMeshRuntime.cpp | 2 +- Source/Engine/Navigation/NavMeshRuntime.h | 16 ++++++++++++++-- Source/Engine/Navigation/Navigation.cpp | 4 ++-- Source/Engine/Navigation/Navigation.h | 16 ++++++++++++++-- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Source/Engine/AI/BehaviorTreeNodes.cpp b/Source/Engine/AI/BehaviorTreeNodes.cpp index 42b12d911..34d0c7295 100644 --- a/Source/Engine/AI/BehaviorTreeNodes.cpp +++ b/Source/Engine/AI/BehaviorTreeNodes.cpp @@ -474,8 +474,8 @@ BehaviorUpdateResult BehaviorTreeMoveToNode::Update(const BehaviorUpdateContext& state->NavAgentRadius = navMesh->Properties.Agent.Radius; // Place start and end on navmesh - navMesh->ProjectPoint(state->Path.First(), state->Path.First()); - navMesh->ProjectPoint(state->Path.Last(), state->Path.Last()); + navMesh->FindClosestPoint(state->Path.First(), state->Path.First()); + navMesh->FindClosestPoint(state->Path.Last(), state->Path.Last()); // Calculate offset between path and the agent (aka feet offset) state->AgentOffset = state->Path.First() - agentLocation; diff --git a/Source/Engine/Navigation/NavMeshRuntime.cpp b/Source/Engine/Navigation/NavMeshRuntime.cpp index 4fcf0e038..21c42dc5a 100644 --- a/Source/Engine/Navigation/NavMeshRuntime.cpp +++ b/Source/Engine/Navigation/NavMeshRuntime.cpp @@ -194,7 +194,7 @@ bool NavMeshRuntime::TestPath(const Vector3& startPosition, const Vector3& endPo return true; } -bool NavMeshRuntime::ProjectPoint(const Vector3& point, Vector3& result) const +bool NavMeshRuntime::FindClosestPoint(const Vector3& point, Vector3& result) const { ScopeLock lock(Locker); const auto query = GetNavMeshQuery(); diff --git a/Source/Engine/Navigation/NavMeshRuntime.h b/Source/Engine/Navigation/NavMeshRuntime.h index 612cba285..ec8b7dbae 100644 --- a/Source/Engine/Navigation/NavMeshRuntime.h +++ b/Source/Engine/Navigation/NavMeshRuntime.h @@ -146,12 +146,24 @@ public: API_FUNCTION() bool TestPath(const Vector3& startPosition, const Vector3& endPosition) const; /// - /// Projects the point to nav mesh surface (finds the nearest polygon). + /// Finds the nearest point on a nav mesh surface. /// /// The source point. /// The result position on the navmesh (valid only if method returns true). /// True if found valid location on the navmesh, otherwise false. - API_FUNCTION() bool ProjectPoint(const Vector3& point, API_PARAM(Out) Vector3& result) const; + API_FUNCTION() bool FindClosestPoint(const Vector3& point, API_PARAM(Out) Vector3& result) const; + + /// + /// Projects the point to nav mesh surface (finds the nearest polygon). + /// [Deprecated in v1.8] + /// + /// The source point. + /// The result position on the navmesh (valid only if method returns true). + /// True if found valid location on the navmesh, otherwise false. + API_FUNCTION() bool ProjectPoint(const Vector3& point, API_PARAM(Out) Vector3& result) const + { + return FindClosestPoint(point, result); + } /// /// Finds random location on nav mesh. diff --git a/Source/Engine/Navigation/Navigation.cpp b/Source/Engine/Navigation/Navigation.cpp index 73e11e630..2f1e6f989 100644 --- a/Source/Engine/Navigation/Navigation.cpp +++ b/Source/Engine/Navigation/Navigation.cpp @@ -325,11 +325,11 @@ bool Navigation::TestPath(const Vector3& startPosition, const Vector3& endPositi return NavMeshes.First()->TestPath(startPosition, endPosition); } -bool Navigation::ProjectPoint(const Vector3& point, Vector3& result) +bool Navigation::FindClosestPoint(const Vector3& point, Vector3& result) { if (NavMeshes.IsEmpty()) return false; - return NavMeshes.First()->ProjectPoint(point, result); + return NavMeshes.First()->FindClosestPoint(point, result); } bool Navigation::FindRandomPoint(Vector3& result) diff --git a/Source/Engine/Navigation/Navigation.h b/Source/Engine/Navigation/Navigation.h index 4ca6aa470..8d4ee1a21 100644 --- a/Source/Engine/Navigation/Navigation.h +++ b/Source/Engine/Navigation/Navigation.h @@ -40,12 +40,24 @@ public: API_FUNCTION() static bool TestPath(const Vector3& startPosition, const Vector3& endPosition); /// - /// Projects the point to nav mesh surface (finds the nearest polygon). + /// Finds the nearest point on a nav mesh surface. /// /// The source point. /// The result position on the navmesh (valid only if method returns true). /// True if found valid location on the navmesh, otherwise false. - API_FUNCTION() static bool ProjectPoint(const Vector3& point, API_PARAM(Out) Vector3& result); + API_FUNCTION() static bool FindClosestPoint(const Vector3& point, API_PARAM(Out) Vector3& result); + + /// + /// Projects the point to nav mesh surface (finds the nearest polygon). + /// [Deprecated in v1.8] + /// + /// The source point. + /// The result position on the navmesh (valid only if method returns true). + /// True if found valid location on the navmesh, otherwise false. + API_FUNCTION() DEPRECATED static bool ProjectPoint(const Vector3& point, API_PARAM(Out) Vector3& result) + { + return FindClosestPoint(point, result); + } /// /// Finds random location on nav mesh.