Planeshift
Recast.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 // 1. The origin of this software must not be misrepresented; you must not
11 // claim that you wrote the original software. If you use this software
12 // in a product, an acknowledgment in the product documentation would be
13 // appreciated but is not required.
14 // 2. Altered source versions must be plainly marked as such, and must not be
15 // misrepresented as being the original software.
16 // 3. This notice may not be removed or altered from any source distribution.
17 //
18 
19 #ifndef RECAST_H
20 #define RECAST_H
21 
23 static const float RC_PI = 3.14159265f;
24 
28 {
32 };
33 
37 {
96 };
97 
102 {
103 public:
104 
107  inline rcContext(bool state = true) : m_logEnabled(state), m_timerEnabled(state) {}
108  virtual ~rcContext() {}
109 
112  inline void enableLog(bool state) { m_logEnabled = state; }
113 
115  inline void resetLog() { if (m_logEnabled) doResetLog(); }
116 
120  void log(const rcLogCategory category, const char* format, ...);
121 
124  inline void enableTimer(bool state) { m_timerEnabled = state; }
125 
127  inline void resetTimers() { if (m_timerEnabled) doResetTimers(); }
128 
131  inline void startTimer(const rcTimerLabel label) { if (m_timerEnabled) doStartTimer(label); }
132 
135  inline void stopTimer(const rcTimerLabel label) { if (m_timerEnabled) doStopTimer(label); }
136 
140  inline int getAccumulatedTime(const rcTimerLabel label) const { return m_timerEnabled ? doGetAccumulatedTime(label) : -1; }
141 
142 protected:
143 
145  virtual void doResetLog() {}
146 
151  virtual void doLog(const rcLogCategory /*category*/, const char* /*msg*/, const int /*len*/) {}
152 
154  virtual void doResetTimers() {}
155 
158  virtual void doStartTimer(const rcTimerLabel /*label*/) {}
159 
162  virtual void doStopTimer(const rcTimerLabel /*label*/) {}
163 
167  virtual int doGetAccumulatedTime(const rcTimerLabel /*label*/) const { return -1; }
168 
171 
174 };
175 
178 struct rcConfig
179 {
181  int width;
182 
184  int height;
185 
187  int tileSize;
188 
191 
193  float cs;
194 
196  float ch;
197 
199  float bmin[3];
200 
202  float bmax[3];
203 
206 
210 
213 
217 
220 
224 
227 
231 
235 
239 
243 };
244 
246 static const int RC_SPAN_HEIGHT_BITS = 13;
248 static const int RC_SPAN_MAX_HEIGHT = (1<<RC_SPAN_HEIGHT_BITS)-1;
249 
252 static const int RC_SPANS_PER_POOL = 2048;
253 
256 struct rcSpan
257 {
258  unsigned int smin : 13;
259  unsigned int smax : 13;
260  unsigned int area : 6;
262 };
263 
267 {
270 };
271 
275 {
276  int width;
277  int height;
278  float bmin[3];
279  float bmax[3];
280  float cs;
281  float ch;
285 };
286 
289 {
290  unsigned int index : 24;
291  unsigned int count : 8;
292 };
293 
296 {
297  unsigned short y;
298  unsigned short reg;
299  unsigned int con : 24;
300  unsigned int h : 8;
301 };
302 
306 {
307  int width;
308  int height;
309  int spanCount;
313  unsigned short maxDistance;
314  unsigned short maxRegions;
315  float bmin[3];
316  float bmax[3];
317  float cs;
318  float ch;
321  unsigned short* dist;
322  unsigned char* areas;
323 };
324 
328 {
329  float bmin[3];
330  float bmax[3];
331  float cs;
332  float ch;
333  int width;
334  int height;
335  int minx;
336  int maxx;
337  int miny;
338  int maxy;
339  int hmin;
340  int hmax;
341  unsigned char* heights;
342  unsigned char* areas;
343  unsigned char* cons;
344 };
345 
350 {
352  int nlayers;
353 };
354 
356 struct rcContour
357 {
358  int* verts;
359  int nverts;
360  int* rverts;
361  int nrverts;
362  unsigned short reg;
363  unsigned char area;
364 };
365 
369 {
371  int nconts;
372  float bmin[3];
373  float bmax[3];
374  float cs;
375  float ch;
376  int width;
377  int height;
379 };
380 
384 {
385  unsigned short* verts;
386  unsigned short* polys;
387  unsigned short* regs;
388  unsigned short* flags;
389  unsigned char* areas;
390  int nverts;
391  int npolys;
392  int maxpolys;
393  int nvp;
394  float bmin[3];
395  float bmax[3];
396  float cs;
397  float ch;
399 };
400 
405 {
406  unsigned int* meshes;
407  float* verts;
408  unsigned char* tris;
409  int nmeshes;
410  int nverts;
411  int ntris;
412 };
413 
418 
424 
430 
436 
442 
448 
454 
460 
465 void rcFreeContourSet(rcContourSet* cset);
466 
472 
477 void rcFreePolyMesh(rcPolyMesh* pmesh);
478 
484 
490 
492 
498 static const unsigned short RC_BORDER_REG = 0x8000;
499 
507 static const int RC_BORDER_VERTEX = 0x10000;
508 
514 static const int RC_AREA_BORDER = 0x20000;
515 
519 {
522 };
523 
528 static const int RC_CONTOUR_REG_MASK = 0xffff;
529 
533 static const unsigned short RC_MESH_NULL_IDX = 0xffff;
534 
538 static const unsigned char RC_NULL_AREA = 0;
539 
543 static const unsigned char RC_WALKABLE_AREA = 63;
544 
547 static const int RC_NOT_CONNECTED = 0x3f;
548 
551 
555 template<class T> inline void rcSwap(T& a, T& b) { T t = a; a = b; b = t; }
556 
561 template<class T> inline T rcMin(T a, T b) { return a < b ? a : b; }
562 
567 template<class T> inline T rcMax(T a, T b) { return a > b ? a : b; }
568 
572 template<class T> inline T rcAbs(T a) { return a < 0 ? -a : a; }
573 
577 template<class T> inline T rcSqr(T a) { return a*a; }
578 
584 template<class T> inline T rcClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
585 
589 float rcSqrt(float x);
590 
594 
599 inline void rcVcross(float* dest, const float* v1, const float* v2)
600 {
601  dest[0] = v1[1]*v2[2] - v1[2]*v2[1];
602  dest[1] = v1[2]*v2[0] - v1[0]*v2[2];
603  dest[2] = v1[0]*v2[1] - v1[1]*v2[0];
604 }
605 
610 inline float rcVdot(const float* v1, const float* v2)
611 {
612  return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
613 }
614 
620 inline void rcVmad(float* dest, const float* v1, const float* v2, const float s)
621 {
622  dest[0] = v1[0]+v2[0]*s;
623  dest[1] = v1[1]+v2[1]*s;
624  dest[2] = v1[2]+v2[2]*s;
625 }
626 
631 inline void rcVadd(float* dest, const float* v1, const float* v2)
632 {
633  dest[0] = v1[0]+v2[0];
634  dest[1] = v1[1]+v2[1];
635  dest[2] = v1[2]+v2[2];
636 }
637 
642 inline void rcVsub(float* dest, const float* v1, const float* v2)
643 {
644  dest[0] = v1[0]-v2[0];
645  dest[1] = v1[1]-v2[1];
646  dest[2] = v1[2]-v2[2];
647 }
648 
652 inline void rcVmin(float* mn, const float* v)
653 {
654  mn[0] = rcMin(mn[0], v[0]);
655  mn[1] = rcMin(mn[1], v[1]);
656  mn[2] = rcMin(mn[2], v[2]);
657 }
658 
662 inline void rcVmax(float* mx, const float* v)
663 {
664  mx[0] = rcMax(mx[0], v[0]);
665  mx[1] = rcMax(mx[1], v[1]);
666  mx[2] = rcMax(mx[2], v[2]);
667 }
668 
672 inline void rcVcopy(float* dest, const float* v)
673 {
674  dest[0] = v[0];
675  dest[1] = v[1];
676  dest[2] = v[2];
677 }
678 
683 inline float rcVdist(const float* v1, const float* v2)
684 {
685  float dx = v2[0] - v1[0];
686  float dy = v2[1] - v1[1];
687  float dz = v2[2] - v1[2];
688  return rcSqrt(dx*dx + dy*dy + dz*dz);
689 }
690 
695 inline float rcVdistSqr(const float* v1, const float* v2)
696 {
697  float dx = v2[0] - v1[0];
698  float dy = v2[1] - v1[1];
699  float dz = v2[2] - v1[2];
700  return dx*dx + dy*dy + dz*dz;
701 }
702 
705 inline void rcVnormalize(float* v)
706 {
707  float d = 1.0f / rcSqrt(rcSqr(v[0]) + rcSqr(v[1]) + rcSqr(v[2]));
708  v[0] *= d;
709  v[1] *= d;
710  v[2] *= d;
711 }
712 
717 
724 void rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax);
725 
733 void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h);
734 
745 bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,
746  const float* bmin, const float* bmax,
747  float cs, float ch);
748 
760 void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,
761  const int* tris, int nt, unsigned char* areas);
762 
773 void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,
774  const int* tris, int nt, unsigned char* areas);
775 
788 void rcAddSpan(rcContext* ctx, rcHeightfield& hf, const int x, const int y,
789  const unsigned short smin, const unsigned short smax,
790  const unsigned char area, const int flagMergeThr);
791 
802 void rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,
803  const unsigned char area, rcHeightfield& solid,
804  const int flagMergeThr = 1);
805 
817 void rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
818  const int* tris, const unsigned char* areas, const int nt,
819  rcHeightfield& solid, const int flagMergeThr = 1);
820 
832 void rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
833  const unsigned short* tris, const unsigned char* areas, const int nt,
834  rcHeightfield& solid, const int flagMergeThr = 1);
835 
845 void rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,
846  rcHeightfield& solid, const int flagMergeThr = 1);
847 
854 void rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid);
855 
864 void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight,
865  const int walkableClimb, rcHeightfield& solid);
866 
873 void rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid);
874 
881 
886 
897 bool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const int walkableClimb,
899 
906 bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf);
907 
914 
922 void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,
923  rcCompactHeightfield& chf);
924 
934 void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
935  const float hmin, const float hmax, unsigned char areaId,
936  rcCompactHeightfield& chf);
937 
945 int rcOffsetPoly(const float* verts, const int nverts, const float offset,
946  float* outVerts, const int maxOutVerts);
947 
956 void rcMarkCylinderArea(rcContext* ctx, const float* pos,
957  const float r, const float h, unsigned char areaId,
958  rcCompactHeightfield& chf);
959 
966 
979  const int borderSize, const int minRegionArea, const int mergeRegionArea);
980 
993  const int borderSize, const int minRegionArea, const int mergeRegionArea);
994 
995 
1000 inline void rcSetCon(rcCompactSpan& s, int dir, int i)
1001 {
1002  const unsigned int shift = (unsigned int)dir*6;
1003  unsigned int con = s.con;
1004  s.con = (con & ~(0x3f << shift)) | (((unsigned int)i & 0x3f) << shift);
1005 }
1006 
1012 inline int rcGetCon(const rcCompactSpan& s, int dir)
1013 {
1014  const unsigned int shift = (unsigned int)dir*6;
1015  return (s.con >> shift) & 0x3f;
1016 }
1017 
1022 inline int rcGetDirOffsetX(int dir)
1023 {
1024  const int offset[4] = { -1, 0, 1, 0, };
1025  return offset[dir&0x03];
1026 }
1027 
1032 inline int rcGetDirOffsetY(int dir)
1033 {
1034  const int offset[4] = { 0, 1, 0, -1 };
1035  return offset[dir&0x03];
1036 }
1037 
1042 
1054  const int borderSize, const int walkableHeight,
1055  rcHeightfieldLayerSet& lset);
1056 
1069  const float maxError, const int maxEdgeLen,
1070  rcContourSet& cset, const int flags = RC_CONTOUR_TESS_WALL_EDGES);
1071 
1080 bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh);
1081 
1089 bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh);
1090 
1101 bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,
1102  const float sampleDist, const float sampleMaxError,
1103  rcPolyMeshDetail& dmesh);
1104 
1111 bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst);
1112 
1120 bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh);
1121 
1123 
1124 #endif // RECAST_H
1125 
1127 
1128 // Due to the large amount of detail documentation for this file,
1129 // the content normally located at the end of the header file has been separated
1130 // out to a file in /Docs/Extern.
float rcSqrt(float x)
Returns the square root of the value.
bool rcBuildPolyMeshDetail(rcContext *ctx, const rcPolyMesh &mesh, const rcCompactHeightfield &chf, const float sampleDist, const float sampleMaxError, rcPolyMeshDetail &dmesh)
Builds a detail mesh from the provided polygon mesh.
int getAccumulatedTime(const rcTimerLabel label) const
Returns the total accumulated time of the specified performance timer.
Definition: Recast.h:140
float rcVdistSqr(const float *v1, const float *v2)
Returns the square of the distance between two points.
Definition: Recast.h:695
unsigned char * areas
The area id assigned to each polygon. [Length: maxpolys].
Definition: Recast.h:389
The maximum number of timers. (Used for iterating timers.)
Definition: Recast.h:95
A dynamic heightfield representing obstructed space.
Definition: Recast.h:274
rcHeightfieldLayer * layers
The layers in the set. [Size: nlayers].
Definition: Recast.h:351
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:308
rcCompactHeightfield * rcAllocCompactHeightfield()
Allocates a compact heightfield object using the Recast allocator.
The total time to build the contours. (See: rcBuildContours)
Definition: Recast.h:47
float detailSampleMaxError
The maximum distance the detail mesh surface should deviate from heightfield data. (For height detail only.) [Limit: >=0] [Units: wu].
Definition: Recast.h:242
void rcFreeCompactHeightfield(rcCompactHeightfield *chf)
Frees the specified compact heightfield object using the Recast allocator.
int nverts
The number of vertices.
Definition: Recast.h:390
bool m_logEnabled
True if logging is enabled.
Definition: Recast.h:170
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:276
Represents a set of heightfield layers.
Definition: Recast.h:349
int borderSize
The AABB border size used during the build of the field. (See: rcConfig::borderSize) ...
Definition: Recast.h:312
T rcAbs(T a)
Returns the absolute value.
Definition: Recast.h:572
Tessellate edges between areas during contour simplification.
Definition: Recast.h:521
int walkableRadius
The distance to erode/shrink the walkable area of the heightfield away from obstructions. [Limit: >=0] [Units: vx].
Definition: Recast.h:216
unsigned short maxRegions
The maximum region id of any span within the field.
Definition: Recast.h:314
Represents a span of unobstructed space within a compact heightfield.
Definition: Recast.h:295
void rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet *lset)
Frees the specified heightfield layer set using the Recast allocator.
int nrverts
The number of vertices in the raw contour.
Definition: Recast.h:361
rcLogCategory
Recast log categories.
Definition: Recast.h:27
The time to build the distances of the distance field. (See: rcBuildDistanceField) ...
Definition: Recast.h:75
int hmax
The maximum height bounds of usable data. (Along the y-axis.)
Definition: Recast.h:340
Tessellate solid (impassable) edges during contour simplification.
Definition: Recast.h:520
void resetTimers()
Clears all peformance timers. (Resets all to unused.)
Definition: Recast.h:127
void enableLog(bool state)
Enables or disables logging.
Definition: Recast.h:112
Provides an interface for optional logging and performance tracking of the Recast build process...
Definition: Recast.h:101
unsigned short * dist
Array containing border distance data. [Size: spanCount].
Definition: Recast.h:321
void rcSwap(T &a, T &b)
Swaps the values of the two parameters.
Definition: Recast.h:555
static const int RC_NOT_CONNECTED
The value returned by rcGetCon if the specified direction is not connected to another span...
Definition: Recast.h:547
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:281
The user defined total time of the build.
Definition: Recast.h:39
bool rcCreateHeightfield(rcContext *ctx, rcHeightfield &hf, int width, int height, const float *bmin, const float *bmax, float cs, float ch)
Initializes a new heightfield.
int tileSize
The width/height size of tile&#39;s on the xz-plane. [Limit: >= 0] [Units: vx].
Definition: Recast.h:187
unsigned short reg
The id of the region the span belongs to. (Or zero if not in a region.)
Definition: Recast.h:298
int ntris
The number of triangles in tris.
Definition: Recast.h:411
The time to rasterize the triangles. (See: rcRasterizeTriangle)
Definition: Recast.h:43
int nverts
The number of vertices in the simplified contour.
Definition: Recast.h:359
void rcVnormalize(float *v)
Normalizes the vector.
Definition: Recast.h:705
unsigned char * heights
The heightfield. [Size: (width - borderSize*2) * (h - borderSize*2)].
Definition: Recast.h:341
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
rcCompactCell * cells
Array of cells. [Size: width*height].
Definition: Recast.h:319
int rcGetHeightFieldSpanCount(rcContext *ctx, rcHeightfield &hf)
Returns the number of spans contained in the specified heightfield.
int rcGetDirOffsetY(int dir)
Gets the standard height (z-axis) offset for the specified direction.
Definition: Recast.h:1032
int walkableClimb
Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]...
Definition: Recast.h:212
The time to merge polygon meshes. (See: rcMergePolyMeshes)
Definition: Recast.h:63
void rcVadd(float *dest, const float *v1, const float *v2)
Performs a vector addition. (v1 + v2)
Definition: Recast.h:631
unsigned short y
The lower extent of the span. (Measured from the heightfield&#39;s base.)
Definition: Recast.h:297
void rcAddSpan(rcContext *ctx, rcHeightfield &hf, const int x, const int y, const unsigned short smin, const unsigned short smax, const unsigned char area, const int flagMergeThr)
Adds a span to the specified heightfield.
rcCompactSpan * spans
Array of spans. [Size: spanCount].
Definition: Recast.h:320
Specifies a configuration to use when performing Recast builds.
Definition: Recast.h:178
void resetLog()
Clears all log entries.
Definition: Recast.h:115
unsigned short * verts
The mesh vertices. [Form: (x, y, z) * nverts].
Definition: Recast.h:385
float * verts
The mesh vertices. [Size: 3*nverts].
Definition: Recast.h:407
int * rverts
Raw contour vertex and connection data. [Size: 4 * nrverts].
Definition: Recast.h:360
T rcMin(T a, T b)
Returns the minimum of two values.
Definition: Recast.h:561
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:397
int rcGetCon(const rcCompactSpan &s, int dir)
Gets neighbor connection data for the specified direction.
Definition: Recast.h:1012
Represents a span in a heightfield.
Definition: Recast.h:256
void rcVmin(float *mn, const float *v)
Selects the minimum value of each element from the specified vectors.
Definition: Recast.h:652
rcContour * conts
An array of the contours in the set. [Size: nconts].
Definition: Recast.h:370
virtual void doStopTimer(const rcTimerLabel)
Stops the specified performance timer.
Definition: Recast.h:162
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:396
int height
The height of the set. (Along the z-axis in cell units.)
Definition: Recast.h:377
Provides information on the content of a cell column in a compact heightfield.
Definition: Recast.h:288
void rcRasterizeTriangle(rcContext *ctx, const float *v0, const float *v1, const float *v2, const unsigned char area, rcHeightfield &solid, const int flagMergeThr=1)
Rasterizes a triangle into the specified heightfield.
void rcSetCon(rcCompactSpan &s, int dir, int i)
Sets the neighbor connection data for the specified direction.
Definition: Recast.h:1000
int mergeRegionArea
Any regions with a span count smaller than this value will, if possible, be merged with larger region...
Definition: Recast.h:230
bool rcMergePolyMeshes(rcContext *ctx, rcPolyMesh **meshes, const int nmeshes, rcPolyMesh &mesh)
Merges multiple polygon meshes into a single mesh.
The time to build the polygon mesh detail. (See: rcBuildPolyMeshDetail)
Definition: Recast.h:91
void rcFreeHeightField(rcHeightfield *hf)
Frees the specified heightfield object using the Recast allocator.
The time to trace the boundaries of the contours. (See: rcBuildContours)
Definition: Recast.h:49
int nconts
The number of contours in the set.
Definition: Recast.h:371
int * verts
Simplified contour vertex and connection data. [Size: 4 * nverts].
Definition: Recast.h:358
int nmeshes
The number of sub-meshes defined by meshes.
Definition: Recast.h:409
int borderSize
The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]...
Definition: Recast.h:190
void rcFilterLedgeSpans(rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &solid)
Marks spans that are ledges as not-walkable.
float detailSampleDist
Sets the sampling distance to use when generating the detail mesh. (For height detail only...
Definition: Recast.h:238
void rcCalcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h)
Calculates the grid size based on the bounding box and grid cell size.
Represents a simple, non-overlapping contour in field space.
Definition: Recast.h:356
unsigned char * areas
Area ids. [Size: Same as heights].
Definition: Recast.h:342
int maxEdgeLen
The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]...
Definition: Recast.h:219
bool rcCopyPolyMesh(rcContext *ctx, const rcPolyMesh &src, rcPolyMesh &dst)
Copies the poly mesh data from src to dst.
An error log entry.
Definition: Recast.h:31
A progress log entry.
Definition: Recast.h:29
void rcFilterLowHangingWalkableObstacles(rcContext *ctx, const int walkableClimb, rcHeightfield &solid)
Marks non-walkable spans as walkable if their maximum is within walkableClimp of a walkable neihbor...
void rcFilterWalkableLowHeightSpans(rcContext *ctx, int walkableHeight, rcHeightfield &solid)
Marks walkable spans as not walkable if the clearence above the span is less than the specified heigh...
rcSpan * freelist
The next free span.
Definition: Recast.h:284
static const int RC_SPANS_PER_POOL
The number of spans allocated per span spool.
Definition: Recast.h:252
int walkableHeight
Minimum floor to &#39;ceiling&#39; height that will still allow the floor area to be considered walkable...
Definition: Recast.h:209
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:334
void rcMarkWalkableTriangles(rcContext *ctx, const float walkableSlopeAngle, const float *verts, int nv, const int *tris, int nt, unsigned char *areas)
Sets the area id of all triangles with a slope below the specified value to RC_WALKABLE_AREA.
static const int RC_SPAN_HEIGHT_BITS
Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
Definition: Recast.h:246
The time to mark a box area. (See: rcMarkBoxArea)
Definition: Recast.h:67
rcContourSet * rcAllocContourSet()
Allocates a contour set object using the Recast allocator.
static const int RC_SPAN_MAX_HEIGHT
Defines the maximum value for rcSpan::smin and rcSpan::smax.
Definition: Recast.h:248
A compact, static heightfield representing unobstructed space.
Definition: Recast.h:305
unsigned int con
Packed neighbor connection data.
Definition: Recast.h:299
The time to blur the distance field. (See: rcBuildDistanceField)
Definition: Recast.h:77
virtual int doGetAccumulatedTime(const rcTimerLabel) const
Returns the total accumulated time of the specified performance timer.
Definition: Recast.h:167
Represents a group of related contours.
Definition: Recast.h:368
The time to build heightfield layers. (See: rcBuildHeightfieldLayers)
Definition: Recast.h:89
unsigned char * tris
The mesh triangles. [Size: 4*ntris].
Definition: Recast.h:408
float rcVdist(const float *v1, const float *v2)
Returns the distance between two points.
Definition: Recast.h:683
int maxx
The maximum x-bounds of usable data.
Definition: Recast.h:336
unsigned char area
The area id of the contour.
Definition: Recast.h:363
float maxSimplificationError
The maximum distance a simplfied contour&#39;s border edges should deviate the original raw contour...
Definition: Recast.h:223
bool rcMedianFilterWalkableArea(rcContext *ctx, rcCompactHeightfield &chf)
Applies a median filter to walkable area types (based on area id), removing noise.
int rcGetDirOffsetX(int dir)
Gets the standard width (x-axis) offset for the specified direction.
Definition: Recast.h:1022
void rcMarkBoxArea(rcContext *ctx, const float *bmin, const float *bmax, unsigned char areaId, rcCompactHeightfield &chf)
Applies an area id to all spans within the specified bounding box. (AABB)
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:280
A memory pool used for quick allocation of spans within a heightfield.
Definition: Recast.h:266
static const unsigned short RC_MESH_NULL_IDX
An value which indicates an invalid index within a mesh.
Definition: Recast.h:533
float ch
The y-axis cell size to use for fields. [Limit: > 0] [Units: wu].
Definition: Recast.h:196
The total time to apply the watershed algorithm. (See: rcBuildRegions)
Definition: Recast.h:81
Represents a polygon mesh suitable for use in building a navigation mesh.
Definition: Recast.h:383
The total time to build the distance field. (See: rcBuildDistanceField)
Definition: Recast.h:73
rcPolyMeshDetail * rcAllocPolyMeshDetail()
Allocates a detail mesh object using the Recast allocator.
static const int RC_BORDER_VERTEX
Border vertex flag. If a region ID has this bit set, then the associated element lies on a tile borde...
Definition: Recast.h:507
virtual void doStartTimer(const rcTimerLabel)
Starts the specified performance timer.
Definition: Recast.h:158
void rcCalcBounds(const float *verts, int nv, float *bmin, float *bmax)
Calculates the bounding box of an array of vertices.
rcHeightfield * rcAllocHeightfield()
Allocates a heightfield object using the Recast allocator.
int minx
The minimum x-bounds of usable data.
Definition: Recast.h:335
The time to filter low height spans. (See: rcFilterWalkableLowHeightSpans)
Definition: Recast.h:55
void rcVmad(float *dest, const float *v1, const float *v2, const float s)
Performs a scaled vector addition. (v1 + (v2 * s))
Definition: Recast.h:620
The time to erode the walkable area. (See: rcErodeWalkableArea)
Definition: Recast.h:65
unsigned char * areas
Array containing area id data. [Size: spanCount].
Definition: Recast.h:322
static const unsigned char RC_WALKABLE_AREA
The default area id used to indicate a walkable polygon. This is also the maximum allowed area id...
Definition: Recast.h:543
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:332
rcTimerLabel
Recast performance timer categories.
Definition: Recast.h:36
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:307
The time to build the compact heightfield. (See: rcBuildCompactHeightfield)
Definition: Recast.h:45
int maxVertsPerPoly
The maximum number of vertices allowed for polygons generated during the contour to polygon conversio...
Definition: Recast.h:234
unsigned short reg
The region id of the contour.
Definition: Recast.h:362
static const int RC_CONTOUR_REG_MASK
Applied to the region id field of contour vertices in order to extract the region id...
Definition: Recast.h:528
virtual ~rcContext()
Definition: Recast.h:108
rcContext(bool state=true)
Contructor.
Definition: Recast.h:107
void rcClearUnwalkableTriangles(rcContext *ctx, const float walkableSlopeAngle, const float *verts, int nv, const int *tris, int nt, unsigned char *areas)
Sets the area id of all triangles with a slope greater than or equal to the specified value to RC_NUL...
bool rcBuildHeightfieldLayers(rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int walkableHeight, rcHeightfieldLayerSet &lset)
Builds a layer set from the specified compact heightfield.
The total time to build the regions. (See: rcBuildRegions, rcBuildRegionsMonotone) ...
Definition: Recast.h:79
void rcVcopy(float *dest, const float *v)
Performs a vector copy.
Definition: Recast.h:672
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:374
void startTimer(const rcTimerLabel label)
Starts the specified performance timer.
Definition: Recast.h:131
void rcMarkCylinderArea(rcContext *ctx, const float *pos, const float r, const float h, unsigned char areaId, rcCompactHeightfield &chf)
Applies the area id to all spans within the specified cylinder.
void rcVsub(float *dest, const float *v1, const float *v2)
Performs a vector subtraction. (v1 - v2)
Definition: Recast.h:642
float walkableSlopeAngle
The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees].
Definition: Recast.h:205
rcPolyMesh * rcAllocPolyMesh()
Allocates a polygon mesh object using the Recast allocator.
int spanCount
The number of spans in the heightfield.
Definition: Recast.h:309
int walkableHeight
The walkable height used during the build of the field. (See: rcConfig::walkableHeight) ...
Definition: Recast.h:310
bool rcErodeWalkableArea(rcContext *ctx, int radius, rcCompactHeightfield &chf)
Erodes the walkable area within the heightfield by the specified radius.
unsigned char * cons
Packed neighbor connection information. [Size: Same as heights].
Definition: Recast.h:343
virtual void doResetTimers()
Clears all timers. (Resets all to unused.)
Definition: Recast.h:154
T rcSqr(T a)
Returns the square of the value.
Definition: Recast.h:577
int maxy
The maximum y-bounds of usable data. (Along the z-axis.)
Definition: Recast.h:338
T rcClamp(T v, T mn, T mx)
Clamps the value to the specified range.
Definition: Recast.h:584
int rcOffsetPoly(const float *verts, const int nverts, const float offset, float *outVerts, const int maxOutVerts)
Helper function to offset voncex polygons for rcMarkConvexPolyArea.
rcHeightfieldLayerSet * rcAllocHeightfieldLayerSet()
Allocates a heightfield layer set using the Recast allocator.
The time to flood regions while applying the watershed algorithm. (See: rcBuildRegions) ...
Definition: Recast.h:85
A user defined build time.
Definition: Recast.h:41
The time to expand regions while applying the watershed algorithm. (See: rcBuildRegions) ...
Definition: Recast.h:83
void rcFreePolyMeshDetail(rcPolyMeshDetail *dmesh)
Frees the specified detail mesh using the Recast allocator.
unsigned short * flags
The user defined flags for each polygon. [Length: maxpolys].
Definition: Recast.h:388
virtual void doResetLog()
Clears all log entries.
Definition: Recast.h:145
void enableTimer(bool state)
Enables or disables the performance timers.
Definition: Recast.h:124
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:317
The time to merge polygon mesh details. (See: rcMergePolyMeshDetails)
Definition: Recast.h:93
unsigned short maxDistance
The maximum distance value of any span within the field.
Definition: Recast.h:313
int height
The height of the field along the z-axis. [Limit: >= 0] [Units: vx].
Definition: Recast.h:184
static const int RC_AREA_BORDER
Area border flag. If a region ID has this bit set, then the associated element lies on the border of ...
Definition: Recast.h:514
static const float RC_PI
The value of PI used by Recast.
Definition: Recast.h:23
int width
The width of the set. (Along the x-axis in cell units.)
Definition: Recast.h:376
float cs
The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu].
Definition: Recast.h:193
The time to build the polygon mesh. (See: rcBuildPolyMesh)
Definition: Recast.h:61
bool rcBuildDistanceField(rcContext *ctx, rcCompactHeightfield &chf)
Builds the distance field for the specified compact heightfield.
bool rcBuildRegions(rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea)
Builds region data for the heightfield using watershed partitioning.
void rcRasterizeTriangles(rcContext *ctx, const float *verts, const int nv, const int *tris, const unsigned char *areas, const int nt, rcHeightfield &solid, const int flagMergeThr=1)
Rasterizes an indexed triangle mesh into the specified heightfield.
rcSpan * next
The next span higher up in column.
Definition: Recast.h:261
int borderSize
The AABB border size used to generate the source data from which the mesh was derived.
Definition: Recast.h:398
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:318
static const unsigned char RC_NULL_AREA
Represents the null area. When a data element is given this value it is considered to no longer be as...
Definition: Recast.h:538
void rcVcross(float *dest, const float *v1, const float *v2)
Derives the cross product of two vectors. (v1 x v2)
Definition: Recast.h:599
int nlayers
The number of layers in the set.
Definition: Recast.h:352
T rcMax(T a, T b)
Returns the maximum of two values.
Definition: Recast.h:567
rcSpanPool * next
The next span pool.
Definition: Recast.h:268
void log(const rcLogCategory category, const char *format,...)
Logs a message.
bool rcBuildContours(rcContext *ctx, rcCompactHeightfield &chf, const float maxError, const int maxEdgeLen, rcContourSet &cset, const int flags=RC_CONTOUR_TESS_WALL_EDGES)
Builds a contour set from the region outlines in the provided compact heightfield.
int borderSize
The AABB border size used to generate the source data from which the contours were derived...
Definition: Recast.h:378
The time to apply the median filter. (See: rcMedianFilterWalkableArea)
Definition: Recast.h:57
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:375
unsigned int * meshes
The sub-mesh data. [Size: 4*nmeshes].
Definition: Recast.h:406
int npolys
The number of polygons.
Definition: Recast.h:391
bool rcBuildRegionsMonotone(rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea)
Builds region data for the heightfield using simple monotone partitioning.
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:277
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:333
virtual void doLog(const rcLogCategory, const char *, const int)
Logs a message.
Definition: Recast.h:151
float rcVdot(const float *v1, const float *v2)
Derives the dot product of two vectors. (v1 . v2)
Definition: Recast.h:610
The time to mark a cylinder area. (See: rcMarkCylinderArea)
Definition: Recast.h:69
void stopTimer(const rcTimerLabel label)
Stops the specified performance timer.
Definition: Recast.h:135
int walkableClimb
The walkable climb used during the build of the field. (See: rcConfig::walkableClimb) ...
Definition: Recast.h:311
int minRegionArea
The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]...
Definition: Recast.h:226
int maxpolys
The number of allocated polygons.
Definition: Recast.h:392
rcBuildContoursFlags
Contour build flags.
Definition: Recast.h:518
unsigned short * regs
The region id assigned to each polygon. [Length: maxpolys].
Definition: Recast.h:387
rcSpanPool * pools
Linked list of span pools.
Definition: Recast.h:283
The time to filter ledge spans. (See: rcFilterLedgeSpans)
Definition: Recast.h:53
The time to mark a convex polygon area. (See: rcMarkConvexPolyArea)
Definition: Recast.h:71
int nverts
The number of vertices in verts.
Definition: Recast.h:410
void rcFreePolyMesh(rcPolyMesh *pmesh)
Frees the specified polygon mesh using the Recast allocator.
static const unsigned short RC_BORDER_REG
Heighfield border flag. If a heightfield region ID has this bit set, then the region is a border regi...
Definition: Recast.h:498
A warning log entry.
Definition: Recast.h:30
bool rcBuildPolyMesh(rcContext *ctx, rcContourSet &cset, const int nvp, rcPolyMesh &mesh)
Builds a polygon mesh from the provided contours.
int width
The width of the field along the x-axis. [Limit: >= 0] [Units: vx].
Definition: Recast.h:181
int hmin
The minimum height bounds of usable data. (Along the y-axis.)
Definition: Recast.h:339
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:331
Contains triangle meshes that represent detailed height data associated with the polygons in its asso...
Definition: Recast.h:404
The time to filter out small regions. (See: rcBuildRegions, rcBuildRegionsMonotone) ...
Definition: Recast.h:87
rcSpan ** spans
Heightfield of spans (width*height).
Definition: Recast.h:282
int nvp
The maximum number of vertices per polygon.
Definition: Recast.h:393
The time to simplify the contours. (See: rcBuildContours)
Definition: Recast.h:51
void rcMarkConvexPolyArea(rcContext *ctx, const float *verts, const int nverts, const float hmin, const float hmax, unsigned char areaId, rcCompactHeightfield &chf)
Applies the area id to the all spans within the specified convex polygon.
bool rcMergePolyMeshDetails(rcContext *ctx, rcPolyMeshDetail **meshes, const int nmeshes, rcPolyMeshDetail &mesh)
Merges multiple detail meshes into a single detail mesh.
void rcVmax(float *mx, const float *v)
Selects the maximum value of each element from the specified vectors.
Definition: Recast.h:662
unsigned short * polys
Polygon and neighbor data. [Length: maxpolys * 2 * nvp].
Definition: Recast.h:386
Represents a heightfield layer within a layer set.
Definition: Recast.h:327
The time to filter low obstacles. (See: rcFilterLowHangingWalkableObstacles)
Definition: Recast.h:59
void rcFreeContourSet(rcContourSet *cset)
Frees the specified contour set using the Recast allocator.
bool rcBuildCompactHeightfield(rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &hf, rcCompactHeightfield &chf)
Builds a compact heightfield representing open space, from a heightfield representing solid space...
int miny
The minimum y-bounds of usable data. (Along the z-axis.)
Definition: Recast.h:337