A* Pathfinding Project  3.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
TileHandler Class Reference

Classes

class  TileType
 

Public Types

enum  CutMode { CutAll = 1, CutDual = 2, CutExtra = 4 }
 

Public Member Functions

 TileHandler (RecastGraph graph)
 
void ClearTile (int x, int z)
 
void CreateTileTypesFromGraph ()
 
void CutShapeWithTile (int x, int z, Int3[] shape, ref Int3[] verts, ref int[] tris, out int vCount, out int tCount)
 
void EndBatchLoad ()
 
int GetActiveRotation (Int2 p)
 
TileType GetTileType (int index)
 
int GetTileTypeCount ()
 
void LoadTile (TileType tile, int x, int z, int rotation, int yoffset)
 Load a tile id at tile coordinate x, z.
 
TileType RegisterTileType (Mesh source, Int3 centerOffset, int width=1, int depth=1)
 Register that a tile can be loaded from source.
 
void ReloadInBounds (Bounds b)
 Reloads all tiles intersecting with the specified bounds.
 
void ReloadTile (int x, int z)
 Reload tile at tile coordinate.
 
bool StartBatchLoad ()
 Start batch loading.
 

Static Protected Member Functions

static T[] ShrinkArray< T > (T[] arr, int newLength)
 Returns a new array with at most length newLength.
 

Properties

RecastGraph graph [get]
 

Private Member Functions

void CutPoly (Int3[] verts, int[] tris, ref Int3[] outVertsArr, ref int[] outTrisArr, out int outVCount, out int outTCount, Int3[] extraShape, Int3 cuttingOffset, Bounds realBounds, CutMode mode=CutMode.CutAll|CutMode.CutDual, int perturbate=0)
 
void DelaunayRefinement (Int3[] verts, int[] tris, ref int vCount, ref int tCount, bool delaunay, bool colinear, Int3 worldOffset)
 Refine a mesh using delaunay refinement.
 
Int3 IntPoint2Int3 (IntPoint p)
 
Vector3 Point2D2V3 (Poly2Tri.TriangulationPoint p)
 

Private Attributes

RecastGraph _graph
 
int[] activeTileOffsets
 
int[] activeTileRotations
 
TileType[] activeTileTypes
 
Dictionary< Int2, int > cached_Int2_int_dict = new Dictionary<Int2, int>()
 
Dictionary< Int3, int > cached_Int3_int_dict = new Dictionary<Int3, int>()
 
int[] cached_int_array = new int[32]
 
Clipper clipper
 
const int CUT_ALL = 0
 
const int CUT_BREAK = CUT_DUAL+1
 
const int CUT_DUAL = CUT_ALL+1
 
bool isBatching = false
 
bool[] reloadedInBatch
 
List< TileTypetileTypes = new List<TileType>()
 

Member Enumeration Documentation

enum CutMode
Enumerator:
CutAll 
CutDual 
CutExtra 

Constructor & Destructor Documentation

Member Function Documentation

void ClearTile ( int  x,
int  z 
)
void CreateTileTypesFromGraph ( )
void CutPoly ( Int3[]  verts,
int[]  tris,
ref Int3[]  outVertsArr,
ref int[]  outTrisArr,
out int  outVCount,
out int  outTCount,
Int3[]  extraShape,
Int3  cuttingOffset,
Bounds  realBounds,
CutMode  mode = CutMode.CutAll | CutMode.CutDual,
int  perturbate = 0 
)
private
void CutShapeWithTile ( int  x,
int  z,
Int3[]  shape,
ref Int3[]  verts,
ref int[]  tris,
out int  vCount,
out int  tCount 
)
void DelaunayRefinement ( Int3[]  verts,
int[]  tris,
ref int  vCount,
ref int  tCount,
bool  delaunay,
bool  colinear,
Int3  worldOffset 
)
private

Refine a mesh using delaunay refinement.

Loops through all pairs of neighbouring triangles and check if it would be better to flip the diagonal joining them using the delaunay criteria.

Does not require triangles to be clockwise, triangles will be checked for if they are clockwise and made clockwise if not. The resulting mesh will have all triangles clockwise.

void EndBatchLoad ( )
int GetActiveRotation ( Int2  p)
TileType GetTileType ( int  index)
int GetTileTypeCount ( )
Int3 IntPoint2Int3 ( IntPoint  p)
private
void LoadTile ( TileType  tile,
int  x,
int  z,
int  rotation,
int  yoffset 
)

Load a tile id at tile coordinate x, z.

Parameters
idTile id as got from RegisterTile
xTile x coordinate (first tile is at (0,0), second at (1,0) etc.. ).
zTile z coordinate.
rotationRotate tile by 90 degrees * value.
yoffsetOffset Y coordinates by this amount. In Int3 space, so if you have a world space offset, multiply by Int3.Precision and round to the nearest integer before calling this function.
Vector3 Point2D2V3 ( Poly2Tri.TriangulationPoint  p)
private
TileType RegisterTileType ( Mesh  source,
Int3  centerOffset,
int  width = 1,
int  depth = 1 
)

Register that a tile can be loaded from source.

Parameters
centerOffsetAssumes that the mesh has its pivot point at the center of the tile. If it has not, you can supply a non-zero centerOffset to offset all vertices.
widthwidth of the tile. In base tiles, not world units.
depthdepth of the tile. In base tiles, not world units.
sourceSource mesh, must be readable.
Returns
Identifier for loading that tile type
void ReloadInBounds ( Bounds  b)

Reloads all tiles intersecting with the specified bounds.

void ReloadTile ( int  x,
int  z 
)

Reload tile at tile coordinate.

The last tile loaded at that position will be reloaded (e.g to account for moved navmesh cut components)

static T [] ShrinkArray< T > ( T[]  arr,
int  newLength 
)
staticprotected

Returns a new array with at most length newLength.

The array will a copy of all elements of arr.

bool StartBatchLoad ( )

Start batch loading.

Returns
True if batching wasn't started yet, and thus EndBatchLoad should be called, False if batching was already started by some other part of the code and you should not call EndBatchLoad

Member Data Documentation

RecastGraph _graph
private
int [] activeTileOffsets
private
int [] activeTileRotations
private
TileType [] activeTileTypes
private
Dictionary<Int2, int> cached_Int2_int_dict = new Dictionary<Int2, int>()
private
Dictionary<Int3, int> cached_Int3_int_dict = new Dictionary<Int3, int>()
private
int [] cached_int_array = new int[32]
private
Clipper clipper
private
const int CUT_ALL = 0
private
const int CUT_BREAK = CUT_DUAL+1
private
const int CUT_DUAL = CUT_ALL+1
private
bool isBatching = false
private
bool [] reloadedInBatch
private
List<TileType> tileTypes = new List<TileType>()
private

Property Documentation

RecastGraph graph
get

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