Module |
|
Header |
/Engine/Source/Runtime/Navmesh/Public/DetourCrowd/DetourPathCorridor.h |
Include |
#include "DetourCrowd/DetourPathCorridor.h" |
class dtPathCorridor
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.
Name | Description | |
---|---|---|
|
dtPathCorridor() |
Name | Description | |
---|---|---|
|
~dtPathCorridor() |
Name | Description | ||
---|---|---|---|
|
canMoveOverOffmeshConnection ( |
[UE4] check if offmesh connection can be traversed, but don't modify corridor yet |
|
|
int |
findCorners ( |
Finds the corners in the corridor from the position toward the target. |
|
fixPathStart ( |
||
|
getFirstPoly() |
The polygon reference id of the first polygon in the corridor, the polygon containing the position. |
|
|
getLastPoly() |
The polygon reference id of the last polygon in the corridor, the polygon containing the target. |
|
|
const float ... |
getNextFixedCorner() |
|
|
const float ... |
getNextFixedCorner2() |
|
|
const dtPoly... |
getPath() |
The corridor's path. |
|
int |
getPathCount() |
The number of polygons in the current corridor path. |
|
const float ... |
getPos() |
Gets the current position within the corridor. (In the first polygon.) |
|
float |
getSegmentAngle() |
|
|
const float ... |
getTarget() |
Gets the current target within the corridor. (In the last polygon.) |
|
hasNextFixedCorner() |
||
|
hasNextFixedCorner2() |
||
|
init ( |
Allocates the corridor's path buffer. Cannot be called more than once. |
|
|
isValid ( |
Checks the current corridor path to see if its polygon references remain valid. |
|
|
moveOverOffmeshConnection ( |
||
|
movePosition ( |
Moves the position from the current location to the desired location, adjusting the corridor as needed to reflect the change. |
|
|
moveTargetPosition ( |
Moves the target from the curent location to the desired location, adjusting the corridor as needed to reflect the change. |
|
|
optimizePathTopology ( |
Attempts to optimize the path using a local area search. |
|
|
optimizePathVisibility ( |
Attempts to optimize the path if the specified point is visible from the current position. |
|
|
pruneOffmeshConenction ( |
[UE4] remove offmesh connection from corridor |
|
|
reset ( |
Resets the path corridor to the specified position. |
|
|
setCorridor ( |
Loads a new path and target into the corridor. |
|
|
setEarlyReachTest ( |
||
|
trimInvalidPath ( |