Dungeon Architect  17.0.0
SharpNav.NavMeshQuery Class Reference

Do pathfinding calculations on the TiledNavMesh More...

Classes

struct  SegInterval
 

Public Member Functions

 NavMeshQuery (TiledNavMesh nav, int maxNodes)
 Initializes a new instance of the NavMeshQuery class. More...
 
 NavMeshQuery (TiledNavMesh nav, int maxNodes, Random rand)
 Initializes a new instance of the NavMeshQuery class. More...
 
float GetCost (Vector3 pa, Vector3 pb, Poly curPoly)
 The cost between two points may vary depending on the type of polygon. More...
 
Vector3 FindRandomPointOnPoly (MeshTile tile, Poly poly, int polyRef)
 Finds a random point on a polygon. More...
 
void FindRandomPointOnPoly (MeshTile tile, Poly poly, int polyRef, out Vector3 randomPt)
 Finds a random point on a polygon. More...
 
NavPoint FindRandomPoint ()
 Finds a random point somewhere in the navigation mesh. More...
 
void FindRandomPoint (out NavPoint randomPoint)
 Finds a random point somewhere in the navigation mesh. More...
 
NavPoint FindRandomPointAroundCircle (NavPoint center, float radius)
 Finds a random point in a NavMesh within a specified circle. More...
 
void FindRandomPointAroundCircle (NavPoint center, float radius, out NavPoint randomPoint)
 Finds a random point in a NavMesh within a specified circle. More...
 
bool FindPath (ref NavPoint startPt, ref NavPoint endPt, List< int > path)
 Find a path from the start polygon to the end polygon. -If the end polygon can't be reached, the last polygon will be nearest the end polygon -If the path array is too small, it will be filled as far as possible -start and end positions are used to calculate traversal costs More...
 
bool FindStraightPath (Vector3 startPos, Vector3 endPos, int[] path, int pathSize, Vector3[] straightPath, int[] straightPathFlags, int[] straightPathRefs, ref int straightPathCount, int maxStraightPath, PathBuildFlags options)
 Add vertices and portals to a regular path computed from the method FindPath(). More...
 
bool MoveAlongSurface (NavPoint startPoint, Vector3 endPos, ref Vector3 resultPos, List< int > visited)
 This method is optimized for small delta movement and a small number of polygons. If movement distance is too large, the result will form an incomplete path. More...
 
bool InitSlicedFindPath (NavPoint startPoint, NavPoint endPoint)
 Initialize a sliced path, which is used mostly for crowd pathfinding. More...
 
bool UpdateSlicedFindPath (int maxIter, ref int doneIters)
 Update the sliced path as agents move across the path. More...
 
bool FinalizeSlicedFindPath (int[] path, ref int pathCount, int maxPath)
 Save the sliced path More...
 
bool FinalizedSlicedPathPartial (int[] existing, int existingSize, int[] path, ref int pathCount, int maxPath)
 Save a partial path More...
 
bool Raycast (NavPoint startPoint, Vector3 endPos, ref float t, ref Vector3 hitNormal, int[] path, ref int pathCount, int maxPath)
 
bool FindLocalNeighbourhood (NavPoint centerPoint, float radius, int[] resultRef, int[] resultParent, ref int resultCount, int maxResult)
 Store polygons that are within a certain range from the current polygon More...
 
bool GetPolyWallSegments (int reference, Crowds.LocalBoundary.Segment[] segmentVerts, int[] segmentRefs, ref int segmentCount, int maxSegments)
 Collect all the edges from a polygon. More...
 
void InsertInterval (SegInterval[] ints, ref int nints, int maxInts, int tmin, int tmax, int reference)
 Insert a segment into the array More...
 
bool GetEdgeMidPoint (int from, Poly fromPoly, MeshTile fromTile, int to, Poly toPoly, MeshTile toTile, ref Vector3 mid)
 Get edge midpoint between two prolygons More...
 
bool GetPortalPoints (int from, int to, ref Vector3 left, ref Vector3 right, ref PolygonType fromType, ref PolygonType toType)
 Find points on the left and right side. More...
 
bool GetPortalPoints (int from, Poly fromPoly, MeshTile fromTile, int to, Poly toPoly, MeshTile toTile, ref Vector3 left, ref Vector3 right)
 Find points on the left and right side. More...
 
bool ClosestPointOnPoly (int reference, Vector3 pos, ref Vector3 closest)
 Given a point on the polygon, find the closest point More...
 
bool ClosestPointOnPoly (int reference, Vector3 pos, out Vector3 closest, out bool posOverPoly)
 Given a point on the polygon, find the closest point More...
 
bool ClosestPointOnPolyBoundary (int reference, Vector3 pos, ref Vector3 closest)
 Given a point on a polygon, find the closest point which lies on the polygon boundary. More...
 
bool AppendVertex (Vector3 pos, int flags, int reference, Vector3[] straightPath, int[] straightPathFlags, int[] straightPathRefs, ref int straightPathCount, int maxStraightPath)
 Add a vertex to the straight path. More...
 
bool AppendPortals (int startIdx, int endIdx, Vector3 endPos, int[] path, Vector3[] straightPath, int[] straightPathFlags, int[] straightPathRefs, ref int straightPathCount, int maxStraightPath, PathBuildFlags options)
 Update the vertices on the straight path More...
 
bool GetPolyHeight (int reference, Vector3 pos, ref float height)
 Return false if the provided position is outside the xz-bounds. More...
 
NavPoint FindNearestPoly (Vector3 center, Vector3 extents)
 Find the nearest poly within a certain range. More...
 
void FindNearestPoly (ref Vector3 center, ref Vector3 extents, out NavPoint nearestPt)
 Find the nearest poly within a certain range. More...
 
bool QueryPolygons (ref Vector3 center, ref Vector3 extent, List< int > polys)
 Finds nearby polygons within a certain range. More...
 
bool IsValidPolyRef (int reference)
 
bool IsInOpenList (Node node)
 
bool IsInClosedList (Node node)
 
void SetNodeFlagOpen (ref Node node)
 
void SetNodeFlagClosed (ref Node node)
 
NodeFlags RemoveNodeFlagClosed (Node node)
 

Properties

TiledNavMesh NavMesh [get]
 

Detailed Description

Do pathfinding calculations on the TiledNavMesh

Definition at line 24 of file NavMeshQuery.cs.

Constructor & Destructor Documentation

◆ NavMeshQuery() [1/2]

SharpNav.NavMeshQuery.NavMeshQuery ( TiledNavMesh  nav,
int  maxNodes 
)

Initializes a new instance of the NavMeshQuery class.

Parameters
navThe navigation mesh to query.
maxNodesThe maximum number of nodes that can be queued in a query.

Definition at line 41 of file NavMeshQuery.cs.

◆ NavMeshQuery() [2/2]

SharpNav.NavMeshQuery.NavMeshQuery ( TiledNavMesh  nav,
int  maxNodes,
Random  rand 
)

Initializes a new instance of the NavMeshQuery class.

Parameters
navThe navigation mesh to query.
maxNodesThe maximum number of nodes that can be queued in a query.
randA random number generator for use in methods like NavMeshQuery.FindRandomPoint()

Definition at line 52 of file NavMeshQuery.cs.

Member Function Documentation

◆ AppendPortals()

bool SharpNav.NavMeshQuery.AppendPortals ( int  startIdx,
int  endIdx,
Vector3  endPos,
int[]  path,
Vector3[]  straightPath,
int[]  straightPathFlags,
int[]  straightPathRefs,
ref int  straightPathCount,
int  maxStraightPath,
PathBuildFlags  options 
)

Update the vertices on the straight path

Parameters
startIdxOriginal path's starting index
endIdxOriginal path's end index
endPosThe end position
pathThe original path of polygon references
straightPathAn array of points on the straight path
straightPathFlagsAn array of flags
straightPathRefsAn array of polygon references
straightPathCountThe number of points on the path
maxStraightPathThe maximum length allowed for the straight path
optionsOptions flag
Returns

Definition at line 2154 of file NavMeshQuery.cs.

◆ AppendVertex()

bool SharpNav.NavMeshQuery.AppendVertex ( Vector3  pos,
int  flags,
int  reference,
Vector3[]  straightPath,
int[]  straightPathFlags,
int[]  straightPathRefs,
ref int  straightPathCount,
int  maxStraightPath 
)

Add a vertex to the straight path.

Parameters
pos
flags
reference
straightPathAn array of points on the straight path
straightPathFlagsAn array of flags
straightPathRefsAn array of polygon references
straightPathCountThe number of points on the path
maxStraightPathThe maximum length allowed for the straight path
Returns
True, if end of path hasn't been reached yet and path isn't full. False, if otherwise.

Definition at line 2106 of file NavMeshQuery.cs.

◆ ClosestPointOnPoly() [1/2]

bool SharpNav.NavMeshQuery.ClosestPointOnPoly ( int  reference,
Vector3  pos,
out Vector3  closest,
out bool  posOverPoly 
)

Given a point on the polygon, find the closest point

Parameters
referencePolygon reference
posCurrent position
closestResulting closest position
posOverPolyDetermines whether the position can be found on the polygon
Returns
True, if the closest point is found. False, if otherwise.

Definition at line 1976 of file NavMeshQuery.cs.

◆ ClosestPointOnPoly() [2/2]

bool SharpNav.NavMeshQuery.ClosestPointOnPoly ( int  reference,
Vector3  pos,
ref Vector3  closest 
)

Given a point on the polygon, find the closest point

Parameters
referencePolygon reference
posGiven point
closestResulting closest point
Returns
True, if point found. False, if otherwise.

Definition at line 1950 of file NavMeshQuery.cs.

◆ ClosestPointOnPolyBoundary()

bool SharpNav.NavMeshQuery.ClosestPointOnPolyBoundary ( int  reference,
Vector3  pos,
ref Vector3  closest 
)

Given a point on a polygon, find the closest point which lies on the polygon boundary.

Parameters
referencePolygon reference
posCurrent position
closestResulting closest point
Returns
True, if the closest point is found. False, if otherwise.

Definition at line 2083 of file NavMeshQuery.cs.

◆ FinalizedSlicedPathPartial()

bool SharpNav.NavMeshQuery.FinalizedSlicedPathPartial ( int[]  existing,
int  existingSize,
int[]  path,
ref int  pathCount,
int  maxPath 
)

Save a partial path

Parameters
existingExisting path
existingSizeExisting path's length
pathNew path
pathCountNew path's length
maxPathMaximum path length allowed
Returns
True if path saved, false if not

Definition at line 1238 of file NavMeshQuery.cs.

◆ FinalizeSlicedFindPath()

bool SharpNav.NavMeshQuery.FinalizeSlicedFindPath ( int[]  path,
ref int  pathCount,
int  maxPath 
)

Save the sliced path

Parameters
pathThe path in terms of polygon references
pathCountThe path length
maxPathThe maximum path length allowed
Returns
True if the path is saved, false if not

Definition at line 1176 of file NavMeshQuery.cs.

◆ FindLocalNeighbourhood()

bool SharpNav.NavMeshQuery.FindLocalNeighbourhood ( NavPoint  centerPoint,
float  radius,
int[]  resultRef,
int[]  resultParent,
ref int  resultCount,
int  maxResult 
)

Store polygons that are within a certain range from the current polygon

Parameters
centerPointStarting position
radiusRange to search within
resultRefAll the polygons within range
resultParentPolygon's parents
resultCountNumber of polygons stored
maxResultMaximum number of polygons allowed
Returns
True, unless input is invalid

Definition at line 1494 of file NavMeshQuery.cs.

◆ FindNearestPoly() [1/2]

void SharpNav.NavMeshQuery.FindNearestPoly ( ref Vector3  center,
ref Vector3  extents,
out NavPoint  nearestPt 
)

Find the nearest poly within a certain range.

Parameters
centerCenter.
extentsExtents.
nearestPtThe neareast point.

Definition at line 2270 of file NavMeshQuery.cs.

◆ FindNearestPoly() [2/2]

NavPoint SharpNav.NavMeshQuery.FindNearestPoly ( Vector3  center,
Vector3  extents 
)

Find the nearest poly within a certain range.

Parameters
centerCenter.
extentsExtents.
Returns
The neareast point.

Definition at line 2257 of file NavMeshQuery.cs.

◆ FindPath()

bool SharpNav.NavMeshQuery.FindPath ( ref NavPoint  startPt,
ref NavPoint  endPt,
List< int >  path 
)

Find a path from the start polygon to the end polygon. -If the end polygon can't be reached, the last polygon will be nearest the end polygon -If the path array is too small, it will be filled as far as possible -start and end positions are used to calculate traversal costs

Parameters
startPtThe start point.
endPtThe end point.
pathThe path of polygon references
Returns
True, if path found. False, if otherwise.

Definition at line 397 of file NavMeshQuery.cs.

◆ FindRandomPoint() [1/2]

NavPoint SharpNav.NavMeshQuery.FindRandomPoint ( )

Finds a random point somewhere in the navigation mesh.

Returns
Resulting random point.

Definition at line 132 of file NavMeshQuery.cs.

◆ FindRandomPoint() [2/2]

void SharpNav.NavMeshQuery.FindRandomPoint ( out NavPoint  randomPoint)

Finds a random point somewhere in the navigation mesh.

Parameters
randomPointResulting random point.

Definition at line 143 of file NavMeshQuery.cs.

◆ FindRandomPointAroundCircle() [1/2]

NavPoint SharpNav.NavMeshQuery.FindRandomPointAroundCircle ( NavPoint  center,
float  radius 
)

Finds a random point in a NavMesh within a specified circle.

Parameters
centerThe center point.
radiusThe maximum distance away from the center that the random point can be.
Returns
A random point within the specified circle.

Definition at line 225 of file NavMeshQuery.cs.

◆ FindRandomPointAroundCircle() [2/2]

void SharpNav.NavMeshQuery.FindRandomPointAroundCircle ( NavPoint  center,
float  radius,
out NavPoint  randomPoint 
)

Finds a random point in a NavMesh within a specified circle.

Parameters
centerThe center point.
radiusThe maximum distance away from the center that the random point can be.
randomPointA random point within the specified circle.

Definition at line 238 of file NavMeshQuery.cs.

◆ FindRandomPointOnPoly() [1/2]

Vector3 SharpNav.NavMeshQuery.FindRandomPointOnPoly ( MeshTile  tile,
Poly  poly,
int  polyRef 
)

Finds a random point on a polygon.

Parameters
tileThe current mesh tile
polyThe current polygon
polyRefPolygon reference
Returns
Resulting random point

Definition at line 94 of file NavMeshQuery.cs.

◆ FindRandomPointOnPoly() [2/2]

void SharpNav.NavMeshQuery.FindRandomPointOnPoly ( MeshTile  tile,
Poly  poly,
int  polyRef,
out Vector3  randomPt 
)

Finds a random point on a polygon.

Parameters
tileThe current mesh tile
polyThe current polygon
polyRefPolygon reference
randomPtResulting random point

Definition at line 108 of file NavMeshQuery.cs.

◆ FindStraightPath()

bool SharpNav.NavMeshQuery.FindStraightPath ( Vector3  startPos,
Vector3  endPos,
int[]  path,
int  pathSize,
Vector3[]  straightPath,
int[]  straightPathFlags,
int[]  straightPathRefs,
ref int  straightPathCount,
int  maxStraightPath,
PathBuildFlags  options 
)

Add vertices and portals to a regular path computed from the method FindPath().

Parameters
startPosStarting position
endPosEnding position
pathPath of polygon references
pathSizeLength of path
straightPathAn array of points on the straight path
straightPathFlagsAn array of flags
straightPathRefsAn array of polygon references
straightPathCountThe number of points on the path
maxStraightPathThe maximum length allowed for the straight path
optionsOptions flag
Returns
True, if path found. False, if otherwise.

Definition at line 586 of file NavMeshQuery.cs.

◆ GetCost()

float SharpNav.NavMeshQuery.GetCost ( Vector3  pa,
Vector3  pb,
Poly  curPoly 
)

The cost between two points may vary depending on the type of polygon.

Parameters
paPoint A
pbPoint B
curPolyCurrent polygon
Returns
Cost

Definition at line 74 of file NavMeshQuery.cs.

◆ GetEdgeMidPoint()

bool SharpNav.NavMeshQuery.GetEdgeMidPoint ( int  from,
Poly  fromPoly,
MeshTile  fromTile,
int  to,
Poly  toPoly,
MeshTile  toTile,
ref Vector3  mid 
)

Get edge midpoint between two prolygons

Parameters
from"From" polygon reference
fromPoly"From" polygon data
fromTile"From" mesh tile
to"To" polygon reference
toPoly"To" polygon data
toTile"To" mesh tile
midEdge midpoint
Returns
True, if midpoint found. False, if otherwise.

Definition at line 1818 of file NavMeshQuery.cs.

◆ GetPolyHeight()

bool SharpNav.NavMeshQuery.GetPolyHeight ( int  reference,
Vector3  pos,
ref float  height 
)

Return false if the provided position is outside the xz-bounds.

Parameters
referencePolygon reference
posCurrent position
heightResulting polygon height
Returns
True, if height found. False, if otherwise.

Definition at line 2210 of file NavMeshQuery.cs.

◆ GetPolyWallSegments()

bool SharpNav.NavMeshQuery.GetPolyWallSegments ( int  reference,
Crowds.LocalBoundary.Segment[]  segmentVerts,
int[]  segmentRefs,
ref int  segmentCount,
int  maxSegments 
)

Collect all the edges from a polygon.

Parameters
referenceThe polygon reference
segmentVertsSegment vertices
segmentRefsThe polygon reference containing the segment
segmentCountThe number of segments stored
maxSegmentsThe maximum number of segments allowed
Returns
True, unless the polygon reference is invalid

Definition at line 1659 of file NavMeshQuery.cs.

◆ GetPortalPoints() [1/2]

bool SharpNav.NavMeshQuery.GetPortalPoints ( int  from,
int  to,
ref Vector3  left,
ref Vector3  right,
ref PolygonType  fromType,
ref PolygonType  toType 
)

Find points on the left and right side.

Parameters
from"From" polygon reference
to"To" polygon reference
leftPoint on the left side
rightPoint on the right side
fromTypePolygon type of "From" polygon
toTypePolygon type of "To" polygon
Returns
True, if points found. False, if otherwise.

Definition at line 1840 of file NavMeshQuery.cs.

◆ GetPortalPoints() [2/2]

bool SharpNav.NavMeshQuery.GetPortalPoints ( int  from,
Poly  fromPoly,
MeshTile  fromTile,
int  to,
Poly  toPoly,
MeshTile  toTile,
ref Vector3  left,
ref Vector3  right 
)

Find points on the left and right side.

Parameters
from"From" polygon reference
fromPoly"From" polygon data
fromTile"From" mesh tile
to"To" polygon reference
toPoly"To" polygon data
toTile"To" mesh tile
leftResulting point on the left side
rightResulting point on the right side
Returns
True, if points found. False, if otherwise.

Definition at line 1869 of file NavMeshQuery.cs.

◆ InitSlicedFindPath()

bool SharpNav.NavMeshQuery.InitSlicedFindPath ( NavPoint  startPoint,
NavPoint  endPoint 
)

Initialize a sliced path, which is used mostly for crowd pathfinding.

Parameters
startPointThe start point.
endPointThe end point.
Returns
True if path initialized, false otherwise

Definition at line 968 of file NavMeshQuery.cs.

◆ InsertInterval()

void SharpNav.NavMeshQuery.InsertInterval ( SegInterval[]  ints,
ref int  nints,
int  maxInts,
int  tmin,
int  tmax,
int  reference 
)

Insert a segment into the array

Parameters
intsThe array of segments
nintsThe number of segments
maxIntsThe maximium number of segments allowed
tminParameter t minimum
tmaxParameter t maximum
referencePolygon reference

Definition at line 1779 of file NavMeshQuery.cs.

◆ MoveAlongSurface()

bool SharpNav.NavMeshQuery.MoveAlongSurface ( NavPoint  startPoint,
Vector3  endPos,
ref Vector3  resultPos,
List< int >  visited 
)

This method is optimized for small delta movement and a small number of polygons. If movement distance is too large, the result will form an incomplete path.

Parameters
startPointThe start point.
endPosEnd position
resultPosIntermediate point
visitedVisited polygon references
Returns
True, if point found. False, if otherwise.

Definition at line 797 of file NavMeshQuery.cs.

◆ QueryPolygons()

bool SharpNav.NavMeshQuery.QueryPolygons ( ref Vector3  center,
ref Vector3  extent,
List< int >  polys 
)

Finds nearby polygons within a certain range.

Parameters
centerThe starting point
extentThe range to search within
polysA list of polygons
Returns
True, if successful. False, if otherwise.

Definition at line 2321 of file NavMeshQuery.cs.

◆ UpdateSlicedFindPath()

bool SharpNav.NavMeshQuery.UpdateSlicedFindPath ( int  maxIter,
ref int  doneIters 
)

Update the sliced path as agents move across the path.

Parameters
maxIterMaximum iterations
doneItersNumber of times iterated through
Returns
True if updated, false if not

Definition at line 1016 of file NavMeshQuery.cs.


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