Dungeon Architect  17.0.0
SharpNav.TiledNavMesh Class Reference

A TiledNavMesh is a continuous region, which is used for pathfinding. More...

Inheritance diagram for SharpNav.TiledNavMesh:
SharpNav.NavMesh

Classes

struct  TiledNavMeshParams
 The settings for the TiledNavMesh More...
 

Public Member Functions

 TiledNavMesh (NavMeshBuilder data)
 Initializes a new instance of the TiledNavMesh class. More...
 
bool InitTileNavMesh (TiledNavMeshParams parameters)
 Initialize the Tiled Navigation Mesh variables and arrays. More...
 
void AddTile (NavMeshBuilder data, int lastRef, ref int result)
 Build a tile and link all the polygons togther, both internally and externally. Make sure to link off-mesh connections as well. More...
 
void ConnectIntLinks (ref MeshTile tile)
 Allocate links for each of the tile's polygons' vertices More...
 
void BaseOffMeshLinks (ref MeshTile tile)
 Begin creating off-mesh links between the tile polygons. More...
 
void ConnectExtLinks (ref MeshTile tile, ref MeshTile target, BoundarySide side)
 Connect polygons from two different tiles. More...
 
void ConnectExtOffMeshLinks (ref MeshTile tile, ref MeshTile target, BoundarySide side)
 Connect Off-Mesh links between polygons from two different tiles. More...
 
bool GetOffMeshConnectionPolyEndPoints (int prevRef, int polyRef, ref Vector3 startPos, ref Vector3 endPos)
 Retrieve the endpoints of the offmesh connection at the specified polygon More...
 
void FindConnectingPolys (Vector3 va, Vector3 vb, MeshTile tile, BoundarySide side, List< int > con, List< float > conarea)
 Search for neighbor polygons in the tile. More...
 
void CalcSlabEndPoints (Vector3 va, Vector3 vb, Vector2 bmin, Vector2 bmax, BoundarySide side)
 Find the slab endpoints based off of the 'side' value. More...
 
float GetSlabCoord (Vector3 va, BoundarySide side)
 Return the proper slab coordinate value depending on the 'side' value. More...
 
bool OverlapSlabs (Vector2 amin, Vector2 amax, Vector2 bmin, Vector2 bmax, float px, float py)
 Check if two slabs overlap. More...
 
int FindNearestPolyInTile (MeshTile tile, Vector3 center, Vector3 extents, ref Vector3 nearestPt)
 Find the closest polygon possible in the tile under certain constraints. More...
 
int QueryPolygonsInTile (MeshTile tile, BBox3 qbounds, List< int > polys)
 Find all the polygons within a certain bounding box. More...
 
int AllocLink (MeshTile tile)
 Allocate a new link if possible. More...
 
int GetTileRef (MeshTile tile)
 Get the tile reference More...
 
MeshTile GetTileAt (int x, int y, int layer)
 Find the tile at a specific location More...
 
int GetTilesAt (int x, int y, MeshTile[] tiles)
 Find and add a tile if it is found More...
 
int GetNeighbourTilesAt (int x, int y, BoundarySide side, MeshTile[] tiles)
 Gets the neighboring tile at that position More...
 
int ComputeTileHash (int x, int y, int mask)
 Computes the tile hash code, which can be used in a hash table for quick lookup. More...
 
int GetReference (int polyBase, int poly)
 Get the actual polygon reference More...
 
bool IsLinkAllocated (int index)
 Determines whether a link exists for that index More...
 
bool IsExternalLink (int neighbor)
 Determines whether the two polygons are externally linked or not More...
 
int GetPolyRefBase (MeshTile tile)
 Get the base reference for the polygons in a tile. More...
 
bool TryGetTileAndPolyByRef (int reference, out MeshTile tile, out Poly poly)
 Retrieve the tile and poly based off of a polygon reference More...
 
void TryGetTileAndPolyByRefUnsafe (int reference, out MeshTile tile, out Poly poly)
 Only use this function if it is known that the provided polygon reference is valid. More...
 
bool IsValidPolyRef (int reference)
 Check if polygon reference is valid. More...
 
void DecodePolyId (int reference, ref int salt, ref int indexTile, ref int indexPoly)
 Decode a standard polygon reference More...
 
int DecodePolyIdSalt (int reference)
 Extract a tile's salt value from the specified polygon reference More...
 
int DecodePolyIdTile (int reference)
 Extract a tile's index from the specified polygon reference More...
 
int DecodePolyIdPoly (int reference)
 Extract a polygon's index (within its tile) from the specified polygon reference More...
 
int EncodePolyId (int salt, int indexTile, int indexPoly)
 Derive a standard polygon reference, which compresses salt, tile index, and poly index together More...
 
void CalcTileLoc (ref Vector3 pos, out int tx, out int ty)
 Calculates the tile location. More...
 

Properties

int TileCount [get]
 Gets the maximum number of tiles that can be stored More...
 
MeshTile this[int index] [get]
 Gets the mesh tile at a specified index. More...
 
object Tag [get, set]
 Gets or sets user data for this navmesh. More...
 

Detailed Description

A TiledNavMesh is a continuous region, which is used for pathfinding.

Definition at line 27 of file TiledNavMesh.cs.

Constructor & Destructor Documentation

◆ TiledNavMesh()

SharpNav.TiledNavMesh.TiledNavMesh ( NavMeshBuilder  data)

Initializes a new instance of the TiledNavMesh class.

Parameters
dataThe Navigation Mesh data

Definition at line 60 of file TiledNavMesh.cs.

Member Function Documentation

◆ AddTile()

void SharpNav.TiledNavMesh.AddTile ( NavMeshBuilder  data,
int  lastRef,
ref int  result 
)

Build a tile and link all the polygons togther, both internally and externally. Make sure to link off-mesh connections as well.

Parameters
dataNavigation Mesh data
lastRefLast polygon reference
resultLast tile reference

Definition at line 159 of file TiledNavMesh.cs.

◆ AllocLink()

int SharpNav.TiledNavMesh.AllocLink ( MeshTile  tile)

Allocate a new link if possible.

Parameters
tileCurrent tile
Returns
New link number

Definition at line 931 of file TiledNavMesh.cs.

◆ BaseOffMeshLinks()

void SharpNav.TiledNavMesh.BaseOffMeshLinks ( ref MeshTile  tile)

Begin creating off-mesh links between the tile polygons.

Parameters
tileCurrent Tile

Definition at line 336 of file TiledNavMesh.cs.

◆ CalcSlabEndPoints()

void SharpNav.TiledNavMesh.CalcSlabEndPoints ( Vector3  va,
Vector3  vb,
Vector2  bmin,
Vector2  bmax,
BoundarySide  side 
)

Find the slab endpoints based off of the 'side' value.

Parameters
vaVertex A
vbVertex B
bminMinimum bounds
bmaxMaximum bounds
sideThe side

Definition at line 688 of file TiledNavMesh.cs.

◆ CalcTileLoc()

void SharpNav.TiledNavMesh.CalcTileLoc ( ref Vector3  pos,
out int  tx,
out int  ty 
)

Calculates the tile location.

Parameters
posThe position
txThe tile's x-coordinate
tyThe tile's y-coordinate

Definition at line 1287 of file TiledNavMesh.cs.

◆ ComputeTileHash()

int SharpNav.TiledNavMesh.ComputeTileHash ( int  x,
int  y,
int  mask 
)

Computes the tile hash code, which can be used in a hash table for quick lookup.

Parameters
xThe x-coordinate
yThe y-coordinate
maskThe mask
Returns
Tile hash code

Definition at line 1082 of file TiledNavMesh.cs.

◆ ConnectExtLinks()

void SharpNav.TiledNavMesh.ConnectExtLinks ( ref MeshTile  tile,
ref MeshTile  target,
BoundarySide  side 
)

Connect polygons from two different tiles.

Parameters
tileCurrent Tile
targetTarget Tile
sidePolygon edge

Definition at line 405 of file TiledNavMesh.cs.

◆ ConnectExtOffMeshLinks()

void SharpNav.TiledNavMesh.ConnectExtOffMeshLinks ( ref MeshTile  tile,
ref MeshTile  target,
BoundarySide  side 
)

Connect Off-Mesh links between polygons from two different tiles.

Parameters
tileCurrent Tile
targetTarget Tile
sidePolygon edge

Definition at line 490 of file TiledNavMesh.cs.

◆ ConnectIntLinks()

void SharpNav.TiledNavMesh.ConnectIntLinks ( ref MeshTile  tile)

Allocate links for each of the tile's polygons' vertices

Parameters
tileA tile contains a set of polygons, which are linked to each other

Definition at line 288 of file TiledNavMesh.cs.

◆ DecodePolyId()

void SharpNav.TiledNavMesh.DecodePolyId ( int  reference,
ref int  salt,
ref int  indexTile,
ref int  indexPoly 
)

Decode a standard polygon reference

Parameters
referencePolygon reference
saltResulting salt value
indexTileResulting tile index
indexPolyResulting poly index

Definition at line 1226 of file TiledNavMesh.cs.

◆ DecodePolyIdPoly()

int SharpNav.TiledNavMesh.DecodePolyIdPoly ( int  reference)

Extract a polygon's index (within its tile) from the specified polygon reference

Parameters
referencePolygon reference
Returns
Poly index

Definition at line 1263 of file TiledNavMesh.cs.

◆ DecodePolyIdSalt()

int SharpNav.TiledNavMesh.DecodePolyIdSalt ( int  reference)

Extract a tile's salt value from the specified polygon reference

Parameters
referencePolygon reference
Returns
Salt value

Definition at line 1241 of file TiledNavMesh.cs.

◆ DecodePolyIdTile()

int SharpNav.TiledNavMesh.DecodePolyIdTile ( int  reference)

Extract a tile's index from the specified polygon reference

Parameters
referencePolygon reference
Returns
Tile index

Definition at line 1252 of file TiledNavMesh.cs.

◆ EncodePolyId()

int SharpNav.TiledNavMesh.EncodePolyId ( int  salt,
int  indexTile,
int  indexPoly 
)

Derive a standard polygon reference, which compresses salt, tile index, and poly index together

Parameters
saltSalt value
indexTileTile index
indexPolyPoly index
Returns
Polygon reference

Definition at line 1276 of file TiledNavMesh.cs.

◆ FindConnectingPolys()

void SharpNav.TiledNavMesh.FindConnectingPolys ( Vector3  va,
Vector3  vb,
MeshTile  tile,
BoundarySide  side,
List< int >  con,
List< float >  conarea 
)

Search for neighbor polygons in the tile.

Parameters
vaVertex A
vbVertex B
tileCurrent tile
sidePolygon edge
conResulting Connection polygon
conareaResulting Connection area

Definition at line 623 of file TiledNavMesh.cs.

◆ FindNearestPolyInTile()

int SharpNav.TiledNavMesh.FindNearestPolyInTile ( MeshTile  tile,
Vector3  center,
Vector3  extents,
ref Vector3  nearestPt 
)

Find the closest polygon possible in the tile under certain constraints.

Parameters
tileCurrent tile
centerCenter starting point
extentsRange of search
nearestPtResulting nearest point
Returns
Polygon Reference which contains nearest point

Definition at line 797 of file TiledNavMesh.cs.

◆ GetNeighbourTilesAt()

int SharpNav.TiledNavMesh.GetNeighbourTilesAt ( int  x,
int  y,
BoundarySide  side,
MeshTile[]  tiles 
)

Gets the neighboring tile at that position

Parameters
xThe x-coordinate
yThe y-coordinate
sideThe side value
tilesAn array of MeshTiles
Returns
The number of tiles satisfying the condition

Definition at line 1030 of file TiledNavMesh.cs.

◆ GetOffMeshConnectionPolyEndPoints()

bool SharpNav.TiledNavMesh.GetOffMeshConnectionPolyEndPoints ( int  prevRef,
int  polyRef,
ref Vector3  startPos,
ref Vector3  endPos 
)

Retrieve the endpoints of the offmesh connection at the specified polygon

Parameters
prevRefThe previous polygon reference
polyRefThe current polygon reference
startPosThe starting position
endPosThe ending position
Returns
True if endpoints found, false if not

Definition at line 570 of file TiledNavMesh.cs.

◆ GetPolyRefBase()

int SharpNav.TiledNavMesh.GetPolyRefBase ( MeshTile  tile)

Get the base reference for the polygons in a tile.

Parameters
tileCurrent Tile
Returns
Base poly reference

Definition at line 1127 of file TiledNavMesh.cs.

◆ GetReference()

int SharpNav.TiledNavMesh.GetReference ( int  polyBase,
int  poly 
)

Get the actual polygon reference

Parameters
polyBaseThe base value
polyThe offset
Returns
The polygon reference

Definition at line 1097 of file TiledNavMesh.cs.

◆ GetSlabCoord()

float SharpNav.TiledNavMesh.GetSlabCoord ( Vector3  va,
BoundarySide  side 
)

Return the proper slab coordinate value depending on the 'side' value.

Parameters
vaVertex A
sideThe side
Returns
Slab coordinate value

Definition at line 736 of file TiledNavMesh.cs.

◆ GetTileAt()

MeshTile SharpNav.TiledNavMesh.GetTileAt ( int  x,
int  y,
int  layer 
)

Find the tile at a specific location

Parameters
xThe x-coordinate
yThe y-coordinate
layerThe layer number
Returns
The MeshTile at that location

Definition at line 971 of file TiledNavMesh.cs.

◆ GetTileRef()

int SharpNav.TiledNavMesh.GetTileRef ( MeshTile  tile)

Get the tile reference

Parameters
tileTile to look for
Returns
Tile reference

Definition at line 946 of file TiledNavMesh.cs.

◆ GetTilesAt()

int SharpNav.TiledNavMesh.GetTilesAt ( int  x,
int  y,
MeshTile[]  tiles 
)

Find and add a tile if it is found

Parameters
xThe x-coordinate
yThe y-coordinate
tilesTile array
Returns
Number of tiles satisfying condition

Definition at line 997 of file TiledNavMesh.cs.

◆ InitTileNavMesh()

bool SharpNav.TiledNavMesh.InitTileNavMesh ( TiledNavMeshParams  parameters)

Initialize the Tiled Navigation Mesh variables and arrays.

Parameters
parametersTiled Navigation Mesh attributes
Returns
True if initialization is successful

Definition at line 110 of file TiledNavMesh.cs.

◆ IsExternalLink()

bool SharpNav.TiledNavMesh.IsExternalLink ( int  neighbor)

Determines whether the two polygons are externally linked or not

Parameters
neighborThe neighboring polygon
Returns
True if externally linked, false if not

Definition at line 1117 of file TiledNavMesh.cs.

◆ IsLinkAllocated()

bool SharpNav.TiledNavMesh.IsLinkAllocated ( int  index)

Determines whether a link exists for that index

Parameters
indexThe index
Returns
True if allocated, false if not

Definition at line 1107 of file TiledNavMesh.cs.

◆ IsValidPolyRef()

bool SharpNav.TiledNavMesh.IsValidPolyRef ( int  reference)

Check if polygon reference is valid.

Parameters
referencePolygon reference
Returns
True if valid

Definition at line 1199 of file TiledNavMesh.cs.

◆ OverlapSlabs()

bool SharpNav.TiledNavMesh.OverlapSlabs ( Vector2  amin,
Vector2  amax,
Vector2  bmin,
Vector2  bmax,
float  px,
float  py 
)

Check if two slabs overlap.

Parameters
aminMinimum bounds A
amaxMaximum bounds A
bminMinimum bounds B
bmaxMaximum bounds B
pxPoint's x
pyPoint's y
Returns
True if slabs overlap

Definition at line 756 of file TiledNavMesh.cs.

◆ QueryPolygonsInTile()

int SharpNav.TiledNavMesh.QueryPolygonsInTile ( MeshTile  tile,
BBox3  qbounds,
List< int >  polys 
)

Find all the polygons within a certain bounding box.

Parameters
tileCurrent tile
qboundsThe bounds
polysList of polygons
Returns
Number of polygons found

Definition at line 836 of file TiledNavMesh.cs.

◆ TryGetTileAndPolyByRef()

bool SharpNav.TiledNavMesh.TryGetTileAndPolyByRef ( int  reference,
out MeshTile  tile,
out Poly  poly 
)

Retrieve the tile and poly based off of a polygon reference

Parameters
referencePolygon reference
tileResulting tile
polyResulting poly
Returns
True if tile and poly successfully retrieved

Definition at line 1152 of file TiledNavMesh.cs.

◆ TryGetTileAndPolyByRefUnsafe()

void SharpNav.TiledNavMesh.TryGetTileAndPolyByRefUnsafe ( int  reference,
out MeshTile  tile,
out Poly  poly 
)

Only use this function if it is known that the provided polygon reference is valid.

Parameters
referencePolygon reference
tileResulting tile
polyResulting poly

Definition at line 1186 of file TiledNavMesh.cs.

Property Documentation

◆ Tag

object SharpNav.TiledNavMesh.Tag
getset

Gets or sets user data for this navmesh.

Definition at line 103 of file TiledNavMesh.cs.

◆ this[int index]

MeshTile SharpNav.TiledNavMesh.this[int index]
get

Gets the mesh tile at a specified index.

Parameters
indexThe index referencing a tile.
Returns
The tile at the index.

Definition at line 92 of file TiledNavMesh.cs.

◆ TileCount

int SharpNav.TiledNavMesh.TileCount
get

Gets the maximum number of tiles that can be stored

Definition at line 79 of file TiledNavMesh.cs.


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