Add NavMeshPathFlags to navmesh for partial paths info
This commit is contained in:
@@ -78,9 +78,10 @@ bool NavMeshRuntime::FindDistanceToWall(const Vector3& startPosition, NavMeshHit
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NavMeshRuntime::FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath) const
|
||||
bool NavMeshRuntime::FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath, NavMeshPathFlags& resultFlags) const
|
||||
{
|
||||
resultPath.Clear();
|
||||
resultFlags = NavMeshPathFlags::None;
|
||||
ScopeLock lock(Locker);
|
||||
const auto query = GetNavMeshQuery();
|
||||
if (!query || !_navMesh)
|
||||
@@ -120,6 +121,7 @@ bool NavMeshRuntime::FindPath(const Vector3& startPosition, const Vector3& endPo
|
||||
|
||||
if (pathSize == 1 && dtStatusDetail(findPathStatus, DT_PARTIAL_RESULT))
|
||||
{
|
||||
resultFlags |= NavMeshPathFlags::PartialPath;
|
||||
// TODO: skip adding 2nd end point if it's not reachable (use navmesh raycast check? or physics check? or local Z distance check?)
|
||||
resultPath.Resize(2);
|
||||
resultPath[0] = startPosition;
|
||||
|
||||
@@ -24,6 +24,19 @@ public:
|
||||
BytesContainer Data;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The navigation mesh path flags.
|
||||
/// </summary>
|
||||
enum class NavMeshPathFlags
|
||||
{
|
||||
// Nothing.
|
||||
None = 0,
|
||||
// Path is only partially generated, goal is unreachable so path represents the best guess.
|
||||
PartialPath = 1,
|
||||
};
|
||||
|
||||
DECLARE_ENUM_OPERATORS(NavMeshPathFlags);
|
||||
|
||||
/// <summary>
|
||||
/// The navigation mesh runtime object that builds the navmesh from all loaded scenes.
|
||||
/// </summary>
|
||||
@@ -106,7 +119,21 @@ public:
|
||||
/// <param name="endPosition">The end position.</param>
|
||||
/// <param name="resultPath">The result path.</param>
|
||||
/// <returns>True if found valid path between given two points (it may be partial), otherwise false if failed.</returns>
|
||||
bool FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath) const;
|
||||
bool FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath) const
|
||||
{
|
||||
NavMeshPathFlags flags;
|
||||
return FindPath(startPosition, endPosition, resultPath, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the path between the two positions presented as a list of waypoints stored in the corners array.
|
||||
/// </summary>
|
||||
/// <param name="startPosition">The start position.</param>
|
||||
/// <param name="endPosition">The end position.</param>
|
||||
/// <param name="resultPath">The result path.</param>
|
||||
/// <param name="resultPath">The result path flags.</param>
|
||||
/// <returns>True if found valid path between given two points (it may be partial), otherwise false if failed.</returns>
|
||||
bool FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath, NavMeshPathFlags& resultFlags) const;
|
||||
|
||||
/// <summary>
|
||||
/// Tests the path between the two positions (non-partial).
|
||||
|
||||
Reference in New Issue
Block a user