Navigation
Unreal Engine C++ API Reference > Runtime > Navmesh > DetourCrowd
References
Module | Navmesh |
Header | /Engine/Source/Runtime/Navmesh/Public/DetourCrowd/DetourPathCorridor.h |
Include | #include "DetourCrowd/DetourPathCorridor.h" |
Syntax
class dtPathCorridor
Remarks
Represents a dynamic polygon corridor used to plan agent movement. ,
The corridor is loaded with a path, usually obtained from a dtNavMeshQuery::findPath() query. The corridor is then used to plan local movement, with the corridor automatically updating as needed to deal with inaccurate agent locomotion.
Example of a common use case:
Construct the corridor object and call init() to allocate its path buffer.
Obtain a path from a dtNavMeshQuery object.
Use reset() to set the agent's current position. (At the beginning of the path.)
Use setCorridor() to load the path and target.
Use findCorners() to plan movement. (This handles dynamic path straightening.)
Use movePosition() to feed agent movement back into the corridor. (The corridor will automatically adjust as needed.)
If the target is moving, use moveTargetPosition() to update the end of the corridor. (The corridor will automatically adjust as needed.)
Repeat the previous 3 steps to continue to move the agent.
The corridor position and target are always constrained to the navigation mesh.
One of the difficulties in maintaining a path is that floating point errors, locomotion inaccuracies, and/or local steering can result in the agent crossing the boundary of the path corridor, temporarily invalidating the path. This class uses local mesh queries to detect and update the corridor as needed to handle these types of issues.
The fact that local mesh queries are used to move the position and target locations results in two beahviors that need to be considered:
Every time a move function is used there is a chance that the path will become non-optimial. Basically, the further the target is moved from its original location, and the further the position is moved outside the original corridor, the more likely the path will become non-optimal. This issue can be addressed by periodically running the optimizePathTopology() and optimizePathVisibility() methods.
All local mesh queries have distance limitations. (Review the dtNavMeshQuery methods for details.) So the most accurate use case is to move the position and target in small increments. If a large increment is used, then the corridor may not be able to accurately find the new location. Because of this limiation, if a position is moved in a large increment, then compare the desired and resulting polygon references. If the two do not match, then path replanning may be needed. E.g. If you move the target, check getLastPoly() to see if it is the expected polygon.
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
bool | canMoveOverOffmeshConnection
(
dtPolyRef offMeshConRef, |
[UE] check if offmesh connection can be traversed, but don't modify corridor yet |
![]() |
int | findCorners
(
dtReal* cornerVerts, |
Finds the corners in the corridor from the position toward the target. |
![]() |
bool | fixPathStart
(
dtPolyRef safeRef, |
|
![]() ![]() |
dtPolyRef | getFirstPoly () |
The polygon reference id of the first polygon in the corridor, the polygon containing the position. |
![]() ![]() |
dtPolyRef | getLastPoly () |
The polygon reference id of the last polygon in the corridor, the polygon containing the target. |
![]() ![]() |
const dtReal * | ||
![]() ![]() |
const dtReal * | ||
![]() ![]() |
const dtPolyRef * | getPath () |
The corridor's path. |
![]() ![]() |
int | getPathCount () |
The number of polygons in the current corridor path. |
![]() ![]() |
const dtReal * | getPos () |
Gets the current position within the corridor. (In the first polygon.) |
![]() ![]() |
dtReal | ||
![]() ![]() |
const dtReal * | getTarget () |
Gets the current target within the corridor. (In the last polygon.) |
![]() ![]() |
bool | ||
![]() ![]() |
bool | ||
![]() |
bool | init
(
const int maxPath |
Allocates the corridor's path buffer. Cannot be called more than once. |
![]() |
bool | isValid
(
const int maxLookAhead, |
Checks the current corridor path to see if its polygon references remain valid. |
![]() |
bool | moveOverOffmeshConnection
(
dtPolyRef offMeshConRef, |
|
![]() |
bool | movePosition
(
const dtReal* npos, |
Moves the position from the current location to the desired location, adjusting the corridor as needed to reflect the change. |
![]() |
void | moveTargetPosition
(
const dtReal* npos, |
Moves the target from the curent location to the desired location, adjusting the corridor as needed to reflect the change. |
![]() |
bool | optimizePathTopology
(
dtNavMeshQuery* navquery, |
Attempts to optimize the path using a local area search. |
![]() |
bool | optimizePathVisibility
(
const dtReal* next, |
Attempts to optimize the path if the specified point is visible from the current position. |
![]() |
void | pruneOffmeshConenction
(
dtPolyRef offMeshConRef |
[UE] remove offmesh connection from corridor |
![]() |
void | reset
(
dtPolyRef ref, |
Resets the path corridor to the specified position. |
![]() |
void | setCorridor
(
const dtReal* target, |
Loads a new path and target into the corridor. |
![]() |
void | setEarlyReachTest
(
bool enable |
|
![]() |
bool | trimInvalidPath
(
dtPolyRef safeRef, |