Infohazard.HyperNav 1.1.5
3D Navigation for Flying Characters
Loading...
Searching...
No Matches
Infohazard.HyperNav.NavPathfinder Class Reference

A script used to calculate HyperNav paths. More...

Classes

class  PropNames
 This is used to refer to the names of private fields in this class from a custom Editor. More...
 

Public Member Functions

long FindPath (Vector3 start, Vector3 end, HyperNavPathCallback receiver, float sampleRadius=0)
 Find a path between two positions, and invoke the receiver when it is completed. More...
 
long FindPath (NavHit startHit, NavHit endHit, Vector3 startPos, Vector3 endPos, HyperNavPathCallback receiver)
 Find a path between two already-calculated nav query results, and invoke the receiver when it is completed. More...
 
void CancelPath (long id, bool logError=true)
 Cancel a pending path with the given ID. More...
 

Protected Member Functions

virtual void OnEnable ()
 If IsMainInstance is true, set MainInstance or log an error if it is already set. More...
 
virtual void OnDisable ()
 Dispose the pools of pending paths and completed paths, and all memory allocated for pathfinding jobs. More...
 
virtual void Update ()
 If mode is JobThread, check job completion. If mode is MainThreadAsynchronous, perform pathfinding work. More...
 

Package Functions

void DisposePath (NavPath path)
 Called by NavPath.Dispose. More...
 

Properties

bool IsMainInstance [get, set]
 Whether to set NavPathfinder.Instance to this instance. More...
 
NavPathfindingMode PathfindingMode [get, set]
 The mode to use for calculating paths. More...
 
int MaxExecutingRequests [get, set]
 (MainThreadAsynchronous Mode ONLY) If greater than zero, limit on the number of requests actively being worked on. More...
 
int MaxPathOpsPerFrame [get, set]
 (MainThreadAsynchronous Mode ONLY) Maximum total number of pathfinding steps that can be performed per frame by this instance. More...
 
int MaxConcurrentJobs [get, set]
 (JobThread Mode ONLY) Maximum number of pathfinding jobs that can be actively running at once. More...
 
int MaxCompletionFrames [get, set]
 (JobThread Mode ONLY) Maximum number of frames a job can take before the main thread must wait for it. More...
 
static NavPathfinder MainInstance [get, private set]
 The main instance, which should be used in most situations. More...
 

Private Member Functions

void LateUpdate ()
 Move paths from the pending queue and start executing them. More...
 

Private Attributes

bool _isMainInstance = true
 (Serialized) Whether to set NavPathfinder.Instance to this instance. More...
 
NavPathfindingMode _pathfindingMode = NavPathfindingMode.JobThread
 (Serialized) The mode to use for calculating paths. More...
 
int _maxExecutingRequests = 0
 (Serialized) If greater than zero, limit on the number of requests actively being worked on. More...
 
int _maxPathOpsPerFrame = 100
 (Serialized) Maximum total number of pathfinding steps that can be performed per frame by this instance. More...
 
int _maxConcurrentJobs = 1
 (Serialized) Maximum number of pathfinding jobs that can be actively running at once. More...
 
int _maxCompletionFrames = 3
 (Serialized) Maximum number of frames a job can take before the main thread must wait for it. More...
 

Detailed Description

A script used to calculate HyperNav paths.

Can be used as a singleton, or you can have more than one if needed.

Member Function Documentation

◆ CancelPath()

void Infohazard.HyperNav.NavPathfinder.CancelPath ( long  id,
bool  logError = true 
)

Cancel a pending path with the given ID.

If the mode is set to JobThread and the requested path is already executing, the actual work thread cannot be cancelled. However, this will still remove the receiver, so no matter what that will not be called for the path.

Parameters
idThe path ID to cancel.
logErrorWhether to log an error if the path is not running.

◆ DisposePath()

void Infohazard.HyperNav.NavPathfinder.DisposePath ( NavPath  path)
package

Called by NavPath.Dispose.

Parameters
pathThe path to dispose.

◆ FindPath() [1/2]

long Infohazard.HyperNav.NavPathfinder.FindPath ( NavHit  startHit,
NavHit  endHit,
Vector3  startPos,
Vector3  endPos,
HyperNavPathCallback  receiver 
)

Find a path between two already-calculated nav query results, and invoke the receiver when it is completed.

If pathfinding cannot occur, for example because there are no volumes, this method will return -1 and the receiver will not be invoked. If no path can be found, the receiver will be invoked with a null Path argument.

Parameters
startHitQuery result for the start of the path.
endHitQuery result for the end of the path.
startPosStart position for the path.
endPosDestination for the path.
receiverCallback to receive the path when it has been calculated.
Returns
The ID of the pending path, or -1 if pathfinding cannot occur.

◆ FindPath() [2/2]

long Infohazard.HyperNav.NavPathfinder.FindPath ( Vector3  start,
Vector3  end,
HyperNavPathCallback  receiver,
float  sampleRadius = 0 
)

Find a path between two positions, and invoke the receiver when it is completed.

If pathfinding cannot occur, for example because there are no volumes, or because a query at start or end fails, this method will return -1 and the receiver will not be invoked. If no path can be found, the receiver will be invoked with a null Path argument.

Parameters
startStart position for the path.
endDestination for the path.
receiverCallback to receive the path when it has been calculated.
sampleRadiusRadius to search for volumes at the start and end locations./>
Returns
The ID of the pending path, or -1 if pathfinding cannot occur.

◆ LateUpdate()

void Infohazard.HyperNav.NavPathfinder.LateUpdate ( )
private

Move paths from the pending queue and start executing them.

◆ OnDisable()

virtual void Infohazard.HyperNav.NavPathfinder.OnDisable ( )
protectedvirtual

Dispose the pools of pending paths and completed paths, and all memory allocated for pathfinding jobs.

◆ OnEnable()

virtual void Infohazard.HyperNav.NavPathfinder.OnEnable ( )
protectedvirtual

If IsMainInstance is true, set MainInstance or log an error if it is already set.

◆ Update()

virtual void Infohazard.HyperNav.NavPathfinder.Update ( )
protectedvirtual

If mode is JobThread, check job completion. If mode is MainThreadAsynchronous, perform pathfinding work.

Member Data Documentation

◆ _isMainInstance

bool Infohazard.HyperNav.NavPathfinder._isMainInstance = true
private

(Serialized) Whether to set NavPathfinder.Instance to this instance.

◆ _maxCompletionFrames

int Infohazard.HyperNav.NavPathfinder._maxCompletionFrames = 3
private

(Serialized) Maximum number of frames a job can take before the main thread must wait for it.

◆ _maxConcurrentJobs

int Infohazard.HyperNav.NavPathfinder._maxConcurrentJobs = 1
private

(Serialized) Maximum number of pathfinding jobs that can be actively running at once.

◆ _maxExecutingRequests

int Infohazard.HyperNav.NavPathfinder._maxExecutingRequests = 0
private

(Serialized) If greater than zero, limit on the number of requests actively being worked on.

◆ _maxPathOpsPerFrame

int Infohazard.HyperNav.NavPathfinder._maxPathOpsPerFrame = 100
private

(Serialized) Maximum total number of pathfinding steps that can be performed per frame by this instance.

◆ _pathfindingMode

NavPathfindingMode Infohazard.HyperNav.NavPathfinder._pathfindingMode = NavPathfindingMode.JobThread
private

(Serialized) The mode to use for calculating paths.

Property Documentation

◆ IsMainInstance

bool Infohazard.HyperNav.NavPathfinder.IsMainInstance
getset

Whether to set NavPathfinder.Instance to this instance.

This cannot be set while the game is running.

◆ MainInstance

NavPathfinder Infohazard.HyperNav.NavPathfinder.MainInstance
staticgetprivate set

The main instance, which should be used in most situations.

If you need more than one NavPathfinder, you can use direct references to other instances with IsMainInstance set to false.

◆ MaxCompletionFrames

int Infohazard.HyperNav.NavPathfinder.MaxCompletionFrames
getset

(JobThread Mode ONLY) Maximum number of frames a job can take before the main thread must wait for it.

Unity imposes a limit of 3 frames for faster TempJob allocations, so increasing this beyond 3 will slightly decrease memory performance. If a job takes longer than this and is forced to block the main thread, a warning will be logged showing you how long it blocked the main thread for. This cannot be set while any paths are executing.

◆ MaxConcurrentJobs

int Infohazard.HyperNav.NavPathfinder.MaxConcurrentJobs
getset

(JobThread Mode ONLY) Maximum number of pathfinding jobs that can be actively running at once.

Requests beyond this number are queued. You should keep this number fairly low, as each job has the potential to take up a CPU thread.

◆ MaxExecutingRequests

int Infohazard.HyperNav.NavPathfinder.MaxExecutingRequests
getset

(MainThreadAsynchronous Mode ONLY) If greater than zero, limit on the number of requests actively being worked on.

◆ MaxPathOpsPerFrame

int Infohazard.HyperNav.NavPathfinder.MaxPathOpsPerFrame
getset

(MainThreadAsynchronous Mode ONLY) Maximum total number of pathfinding steps that can be performed per frame by this instance.

This limit is shared by all executing paths in this instance.

◆ PathfindingMode

NavPathfindingMode Infohazard.HyperNav.NavPathfinder.PathfindingMode
getset

The mode to use for calculating paths.

This cannot be set while the game is running.


The documentation for this class was generated from the following file: