Recast Navigation
Navigation-mesh Toolset for Games
DetourTileCacheBuilder.cpp File Reference
#include "DetourCommon.h"
#include "DetourMath.h"
#include "DetourStatus.h"
#include "DetourAssert.h"
#include "DetourTileCacheBuilder.h"
#include <string.h>

Classes

class  dtFixedArray< T >
 
struct  dtLayerSweepSpan
 
struct  dtLayerMonotoneRegion
 
struct  dtTempContour
 
struct  rcEdge
 

Functions

int getDirOffsetX (int dir)
 
int getDirOffsetY (int dir)
 
dtTileCacheContourSetdtAllocTileCacheContourSet (dtTileCacheAlloc *alloc)
 
void dtFreeTileCacheContourSet (dtTileCacheAlloc *alloc, dtTileCacheContourSet *cset)
 
dtTileCachePolyMeshdtAllocTileCachePolyMesh (dtTileCacheAlloc *alloc)
 
void dtFreeTileCachePolyMesh (dtTileCacheAlloc *alloc, dtTileCachePolyMesh *lmesh)
 
bool overlapRangeExl (const unsigned short amin, const unsigned short amax, const unsigned short bmin, const unsigned short bmax)
 
static void addUniqueLast (unsigned char *a, unsigned char &an, unsigned char v)
 
bool isConnected (const dtTileCacheLayer &layer, const int ia, const int ib, const int walkableClimb)
 
static bool canMerge (unsigned char oldRegId, unsigned char newRegId, const dtLayerMonotoneRegion *regs, const int nregs)
 
dtStatus dtBuildTileCacheRegions (dtTileCacheAlloc *alloc, dtTileCacheLayer &layer, const int walkableClimb)
 
static bool appendVertex (dtTempContour &cont, const int x, const int y, const int z, const int r)
 
static unsigned char getNeighbourReg (dtTileCacheLayer &layer, const int ax, const int ay, const int dir)
 
static bool walkContour (dtTileCacheLayer &layer, int x, int y, dtTempContour &cont)
 
static float distancePtSeg (const int x, const int z, const int px, const int pz, const int qx, const int qz)
 
static void simplifyContour (dtTempContour &cont, const float maxError)
 
static unsigned char getCornerHeight (dtTileCacheLayer &layer, const int x, const int y, const int z, const int walkableClimb, bool &shouldRemove)
 
dtStatus dtBuildTileCacheContours (dtTileCacheAlloc *alloc, dtTileCacheLayer &layer, const int walkableClimb, const float maxError, dtTileCacheContourSet &lcset)
 
int computeVertexHash2 (int x, int y, int z)
 
static unsigned short addVertex (unsigned short x, unsigned short y, unsigned short z, unsigned short *verts, unsigned short *firstVert, unsigned short *nextVert, int &nv)
 
static bool buildMeshAdjacency (dtTileCacheAlloc *alloc, unsigned short *polys, const int npolys, const unsigned short *verts, const int nverts, const dtTileCacheContourSet &lcset)
 
int prev (int i, int n)
 
int next (int i, int n)
 
int area2 (const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
bool xorb (bool x, bool y)
 
bool left (const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
bool leftOn (const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
bool collinear (const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
static bool intersectProp (const unsigned char *a, const unsigned char *b, const unsigned char *c, const unsigned char *d)
 
static bool between (const unsigned char *a, const unsigned char *b, const unsigned char *c)
 
static bool intersect (const unsigned char *a, const unsigned char *b, const unsigned char *c, const unsigned char *d)
 
static bool vequal (const unsigned char *a, const unsigned char *b)
 
static bool diagonalie (int i, int j, int n, const unsigned char *verts, const unsigned short *indices)
 
static bool inCone (int i, int j, int n, const unsigned char *verts, const unsigned short *indices)
 
static bool diagonal (int i, int j, int n, const unsigned char *verts, const unsigned short *indices)
 
static int triangulate (int n, const unsigned char *verts, unsigned short *indices, unsigned short *tris)
 
static int countPolyVerts (const unsigned short *p)
 
bool uleft (const unsigned short *a, const unsigned short *b, const unsigned short *c)
 
static int getPolyMergeValue (unsigned short *pa, unsigned short *pb, const unsigned short *verts, int &ea, int &eb)
 
static void mergePolys (unsigned short *pa, unsigned short *pb, int ea, int eb)
 
static void pushFront (unsigned short v, unsigned short *arr, int &an)
 
static void pushBack (unsigned short v, unsigned short *arr, int &an)
 
static bool canRemoveVertex (dtTileCachePolyMesh &mesh, const unsigned short rem)
 
static dtStatus removeVertex (dtTileCachePolyMesh &mesh, const unsigned short rem, const int maxTris)
 
dtStatus dtBuildTileCachePolyMesh (dtTileCacheAlloc *alloc, dtTileCacheContourSet &lcset, dtTileCachePolyMesh &mesh)
 
dtStatus dtMarkCylinderArea (dtTileCacheLayer &layer, const float *orig, const float cs, const float ch, const float *pos, const float radius, const float height, const unsigned char areaId)
 
dtStatus dtMarkBoxArea (dtTileCacheLayer &layer, const float *orig, const float cs, const float ch, const float *bmin, const float *bmax, const unsigned char areaId)
 
dtStatus dtMarkBoxArea (dtTileCacheLayer &layer, const float *orig, const float cs, const float ch, const float *center, const float *halfExtents, const float *rotAux, const unsigned char areaId)
 
dtStatus dtBuildTileCacheLayer (dtTileCacheCompressor *comp, dtTileCacheLayerHeader *header, const unsigned char *heights, const unsigned char *areas, const unsigned char *cons, unsigned char **outData, int *outDataSize)
 
void dtFreeTileCacheLayer (dtTileCacheAlloc *alloc, dtTileCacheLayer *layer)
 
dtStatus dtDecompressTileCacheLayer (dtTileCacheAlloc *alloc, dtTileCacheCompressor *comp, unsigned char *compressed, const int compressedSize, dtTileCacheLayer **layerOut)
 
bool dtTileCacheHeaderSwapEndian (unsigned char *data, const int dataSize)
 Swaps the endianness of the compressed tile data's header (dtTileCacheLayerHeader). More...
 

Variables

static const int MAX_VERTS_PER_POLY = 6
 
static const int MAX_REM_EDGES = 48
 
static const int DT_LAYER_MAX_NEIS = 16
 
static const int VERTEX_BUCKET_COUNT2 = (1<<8)
 

Function Documentation

◆ addUniqueLast()

static void addUniqueLast ( unsigned char *  a,
unsigned char &  an,
unsigned char  v 
)
static

◆ addVertex()

static unsigned short addVertex ( unsigned short  x,
unsigned short  y,
unsigned short  z,
unsigned short *  verts,
unsigned short *  firstVert,
unsigned short *  nextVert,
int &  nv 
)
static

◆ appendVertex()

static bool appendVertex ( dtTempContour cont,
const int  x,
const int  y,
const int  z,
const int  r 
)
static

◆ area2()

int area2 ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)
inline

◆ between()

static bool between ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)
static

◆ buildMeshAdjacency()

static bool buildMeshAdjacency ( dtTileCacheAlloc alloc,
unsigned short *  polys,
const int  npolys,
const unsigned short *  verts,
const int  nverts,
const dtTileCacheContourSet lcset 
)
static

◆ canMerge()

static bool canMerge ( unsigned char  oldRegId,
unsigned char  newRegId,
const dtLayerMonotoneRegion regs,
const int  nregs 
)
static

◆ canRemoveVertex()

static bool canRemoveVertex ( dtTileCachePolyMesh mesh,
const unsigned short  rem 
)
static

◆ collinear()

bool collinear ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)
inline

◆ computeVertexHash2()

int computeVertexHash2 ( int  x,
int  y,
int  z 
)
inline

◆ countPolyVerts()

static int countPolyVerts ( const unsigned short *  p)
static

◆ diagonal()

static bool diagonal ( int  i,
int  j,
int  n,
const unsigned char *  verts,
const unsigned short *  indices 
)
static

◆ diagonalie()

static bool diagonalie ( int  i,
int  j,
int  n,
const unsigned char *  verts,
const unsigned short *  indices 
)
static

◆ distancePtSeg()

static float distancePtSeg ( const int  x,
const int  z,
const int  px,
const int  pz,
const int  qx,
const int  qz 
)
static

◆ dtAllocTileCacheContourSet()

dtTileCacheContourSet* dtAllocTileCacheContourSet ( dtTileCacheAlloc alloc)

◆ dtAllocTileCachePolyMesh()

dtTileCachePolyMesh* dtAllocTileCachePolyMesh ( dtTileCacheAlloc alloc)

◆ dtBuildTileCacheContours()

dtStatus dtBuildTileCacheContours ( dtTileCacheAlloc alloc,
dtTileCacheLayer layer,
const int  walkableClimb,
const float  maxError,
dtTileCacheContourSet lcset 
)

◆ dtBuildTileCacheLayer()

dtStatus dtBuildTileCacheLayer ( dtTileCacheCompressor comp,
dtTileCacheLayerHeader header,
const unsigned char *  heights,
const unsigned char *  areas,
const unsigned char *  cons,
unsigned char **  outData,
int *  outDataSize 
)

◆ dtBuildTileCachePolyMesh()

dtStatus dtBuildTileCachePolyMesh ( dtTileCacheAlloc alloc,
dtTileCacheContourSet lcset,
dtTileCachePolyMesh mesh 
)

◆ dtBuildTileCacheRegions()

dtStatus dtBuildTileCacheRegions ( dtTileCacheAlloc alloc,
dtTileCacheLayer layer,
const int  walkableClimb 
)

◆ dtDecompressTileCacheLayer()

dtStatus dtDecompressTileCacheLayer ( dtTileCacheAlloc alloc,
dtTileCacheCompressor comp,
unsigned char *  compressed,
const int  compressedSize,
dtTileCacheLayer **  layerOut 
)

◆ dtFreeTileCacheContourSet()

void dtFreeTileCacheContourSet ( dtTileCacheAlloc alloc,
dtTileCacheContourSet cset 
)

◆ dtFreeTileCacheLayer()

void dtFreeTileCacheLayer ( dtTileCacheAlloc alloc,
dtTileCacheLayer layer 
)

◆ dtFreeTileCachePolyMesh()

void dtFreeTileCachePolyMesh ( dtTileCacheAlloc alloc,
dtTileCachePolyMesh lmesh 
)

◆ dtMarkBoxArea() [1/2]

dtStatus dtMarkBoxArea ( dtTileCacheLayer layer,
const float *  orig,
const float  cs,
const float  ch,
const float *  bmin,
const float *  bmax,
const unsigned char  areaId 
)

◆ dtMarkBoxArea() [2/2]

dtStatus dtMarkBoxArea ( dtTileCacheLayer layer,
const float *  orig,
const float  cs,
const float  ch,
const float *  center,
const float *  halfExtents,
const float *  rotAux,
const unsigned char  areaId 
)

◆ dtMarkCylinderArea()

dtStatus dtMarkCylinderArea ( dtTileCacheLayer layer,
const float *  orig,
const float  cs,
const float  ch,
const float *  pos,
const float  radius,
const float  height,
const unsigned char  areaId 
)

◆ dtTileCacheHeaderSwapEndian()

bool dtTileCacheHeaderSwapEndian ( unsigned char *  data,
const int  dataSize 
)

Swaps the endianness of the compressed tile data's header (dtTileCacheLayerHeader).

Tile layer data does not need endian swapping as it consist only of bytes.

Parameters
[in,out]dataThe tile data array.
[in]dataSizeThe size of the data array.

◆ getCornerHeight()

static unsigned char getCornerHeight ( dtTileCacheLayer layer,
const int  x,
const int  y,
const int  z,
const int  walkableClimb,
bool &  shouldRemove 
)
static

◆ getDirOffsetX()

int getDirOffsetX ( int  dir)
inline

◆ getDirOffsetY()

int getDirOffsetY ( int  dir)
inline

◆ getNeighbourReg()

static unsigned char getNeighbourReg ( dtTileCacheLayer layer,
const int  ax,
const int  ay,
const int  dir 
)
static

◆ getPolyMergeValue()

static int getPolyMergeValue ( unsigned short *  pa,
unsigned short *  pb,
const unsigned short *  verts,
int &  ea,
int &  eb 
)
static

◆ inCone()

static bool inCone ( int  i,
int  j,
int  n,
const unsigned char *  verts,
const unsigned short *  indices 
)
static

◆ intersect()

static bool intersect ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c,
const unsigned char *  d 
)
static

◆ intersectProp()

static bool intersectProp ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c,
const unsigned char *  d 
)
static

◆ isConnected()

bool isConnected ( const dtTileCacheLayer layer,
const int  ia,
const int  ib,
const int  walkableClimb 
)
inline

◆ left()

bool left ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)
inline

◆ leftOn()

bool leftOn ( const unsigned char *  a,
const unsigned char *  b,
const unsigned char *  c 
)
inline

◆ mergePolys()

static void mergePolys ( unsigned short *  pa,
unsigned short *  pb,
int  ea,
int  eb 
)
static

◆ next()

int next ( int  i,
int  n 
)
inline

◆ overlapRangeExl()

bool overlapRangeExl ( const unsigned short  amin,
const unsigned short  amax,
const unsigned short  bmin,
const unsigned short  bmax 
)
inline

◆ prev()

int prev ( int  i,
int  n 
)
inline

◆ pushBack()

static void pushBack ( unsigned short  v,
unsigned short *  arr,
int &  an 
)
static

◆ pushFront()

static void pushFront ( unsigned short  v,
unsigned short *  arr,
int &  an 
)
static

◆ removeVertex()

static dtStatus removeVertex ( dtTileCachePolyMesh mesh,
const unsigned short  rem,
const int  maxTris 
)
static

◆ simplifyContour()

static void simplifyContour ( dtTempContour cont,
const float  maxError 
)
static

◆ triangulate()

static int triangulate ( int  n,
const unsigned char *  verts,
unsigned short *  indices,
unsigned short *  tris 
)
static

◆ uleft()

bool uleft ( const unsigned short *  a,
const unsigned short *  b,
const unsigned short *  c 
)
inline

◆ vequal()

static bool vequal ( const unsigned char *  a,
const unsigned char *  b 
)
static

◆ walkContour()

static bool walkContour ( dtTileCacheLayer layer,
int  x,
int  y,
dtTempContour cont 
)
static

◆ xorb()

bool xorb ( bool  x,
bool  y 
)
inline

Variable Documentation

◆ DT_LAYER_MAX_NEIS

const int DT_LAYER_MAX_NEIS = 16
static

◆ MAX_REM_EDGES

const int MAX_REM_EDGES = 48
static

◆ MAX_VERTS_PER_POLY

const int MAX_VERTS_PER_POLY = 6
static

◆ VERTEX_BUCKET_COUNT2

const int VERTEX_BUCKET_COUNT2 = (1<<8)
static