TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DetourNavMesh.cpp File Reference
#include <float.h>
#include <string.h>
#include <stdio.h>
#include "DetourNavMesh.h"
#include "DetourNode.h"
#include "DetourCommon.h"
#include "DetourMath.h"
#include "DetourAlloc.h"
#include "DetourAssert.h"
#include <new>
+ Include dependency graph for DetourNavMesh.cpp:

Classes

struct  dtTileState
 
struct  dtPolyState
 

Functions

bool overlapSlabs (const float *amin, const float *amax, const float *bmin, const float *bmax, const float px, const float py)
 
static float getSlabCoord (const float *va, const int side)
 
static void calcSlabEndPoints (const float *va, const float *vb, float *bmin, float *bmax, const int side)
 
int computeTileHash (int x, int y, const int mask)
 
unsigned int allocLink (dtMeshTile *tile)
 
void freeLink (dtMeshTile *tile, unsigned int link)
 
dtNavMeshdtAllocNavMesh ()
 
void dtFreeNavMesh (dtNavMesh *navmesh)
 

Function Documentation

unsigned int allocLink ( dtMeshTile tile)
inline
123 {
124  if (tile->linksFreeList == DT_NULL_LINK)
125  return DT_NULL_LINK;
126  unsigned int link = tile->linksFreeList;
127  tile->linksFreeList = tile->links[link].next;
128  return link;
129 }
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:283
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the caller graph for this function:

static void calcSlabEndPoints ( const float *  va,
const float *  vb,
float *  bmin,
float *  bmax,
const int  side 
)
static
77 {
78  if (side == 0 || side == 4)
79  {
80  if (va[2] < vb[2])
81  {
82  bmin[0] = va[2];
83  bmin[1] = va[1];
84  bmax[0] = vb[2];
85  bmax[1] = vb[1];
86  }
87  else
88  {
89  bmin[0] = vb[2];
90  bmin[1] = vb[1];
91  bmax[0] = va[2];
92  bmax[1] = va[1];
93  }
94  }
95  else if (side == 2 || side == 6)
96  {
97  if (va[0] < vb[0])
98  {
99  bmin[0] = va[0];
100  bmin[1] = va[1];
101  bmax[0] = vb[0];
102  bmax[1] = vb[1];
103  }
104  else
105  {
106  bmin[0] = vb[0];
107  bmin[1] = vb[1];
108  bmax[0] = va[0];
109  bmax[1] = va[1];
110  }
111  }
112 }

+ Here is the caller graph for this function:

int computeTileHash ( int  x,
int  y,
const int  mask 
)
inline
115 {
116  const unsigned int h1 = 0x8da6b343; // Large multiplicative constants;
117  const unsigned int h2 = 0xd8163841; // here arbitrarily chosen primes
118  unsigned int n = h1 * x + h2 * y;
119  return (int)(n & mask);
120 }
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void freeLink ( dtMeshTile tile,
unsigned int  link 
)
inline
132 {
133  tile->links[link].next = tile->linksFreeList;
134  tile->linksFreeList = link;
135 }
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:283
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287

+ Here is the caller graph for this function:

static float getSlabCoord ( const float *  va,
const int  side 
)
static
68 {
69  if (side == 0 || side == 4)
70  return va[0];
71  else if (side == 2 || side == 6)
72  return va[2];
73  return 0;
74 }

+ Here is the caller graph for this function:

bool overlapSlabs ( const float *  amin,
const float *  amax,
const float *  bmin,
const float *  bmax,
const float  px,
const float  py 
)
inline
34 {
35  // Check for horizontal overlap.
36  // The segment is shrunken a little so that slabs which touch
37  // at end points are not connected.
38  const float minx = dtMax(amin[0]+px,bmin[0]+px);
39  const float maxx = dtMin(amax[0]-px,bmax[0]-px);
40  if (minx > maxx)
41  return false;
42 
43  // Check vertical overlap.
44  const float ad = (amax[1]-amin[1]) / (amax[0]-amin[0]);
45  const float ak = amin[1] - ad*amin[0];
46  const float bd = (bmax[1]-bmin[1]) / (bmax[0]-bmin[0]);
47  const float bk = bmin[1] - bd*bmin[0];
48  const float aminy = ad*minx + ak;
49  const float amaxy = ad*maxx + ak;
50  const float bminy = bd*minx + bk;
51  const float bmaxy = bd*maxx + bk;
52  const float dmin = bminy - aminy;
53  const float dmax = bmaxy - amaxy;
54 
55  // Crossing segments always overlap.
56  if (dmin*dmax < 0)
57  return true;
58 
59  // Check for overlap at endpoints.
60  const float thr = dtSqr(py*2);
61  if (dmin*dmin <= thr || dmax*dmax <= thr)
62  return true;
63 
64  return false;
65 }
T dtMax(T a, T b)
Definition: DetourCommon.h:57
T dtMin(T a, T b)
Definition: DetourCommon.h:51
T dtSqr(T a)
Definition: DetourCommon.h:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function: