recast-capi.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. *
  3. * ***** BEGIN GPL LICENSE BLOCK *****
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software Foundation,
  17. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. *
  19. * The Original Code is Copyright (C) 2011 Blender Foundation.
  20. * All rights reserved.
  21. *
  22. * Contributor(s): Sergey Sharybin
  23. *
  24. * ***** END GPL LICENSE BLOCK *****
  25. */
  26. #ifndef RECAST_C_API_H
  27. #define RECAST_C_API_H
  28. // for size_t
  29. #include <stddef.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. struct recast_polyMesh;
  34. struct recast_polyMeshDetail;
  35. struct recast_heightfield;
  36. struct recast_compactHeightfield;
  37. struct recast_heightfieldLayerSet;
  38. struct recast_contourSet;
  39. enum recast_BuildContoursFlags
  40. {
  41. RECAST_CONTOUR_TESS_WALL_EDGES = 0x01,
  42. RECAST_CONTOUR_TESS_AREA_EDGES = 0x02,
  43. };
  44. int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,
  45. const int nverts, const int vertsPerPoly);
  46. void recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax);
  47. void recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h);
  48. struct recast_heightfield *recast_newHeightfield(void);
  49. void recast_destroyHeightfield(struct recast_heightfield *heightfield);
  50. int recast_createHeightfield(struct recast_heightfield *hf, int width, int height,
  51. const float *bmin, const float* bmax, float cs, float ch);
  52. void recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,
  53. const int *tris, int nt, unsigned char *areas);
  54. void recast_clearUnwalkableTriangles(const float walkableSlopeAngle, const float* verts, int nv,
  55. const int* tris, int nt, unsigned char* areas);
  56. int recast_addSpan(struct recast_heightfield *hf, const int x, const int y,
  57. const unsigned short smin, const unsigned short smax,
  58. const unsigned char area, const int flagMergeThr);
  59. int recast_rasterizeTriangle(const float* v0, const float* v1, const float* v2,
  60. const unsigned char area, struct recast_heightfield *solid,
  61. const int flagMergeThr);
  62. int recast_rasterizeTriangles(const float *verts, const int nv, const int *tris,
  63. const unsigned char *areas, const int nt, struct recast_heightfield *solid,
  64. const int flagMergeThr);
  65. void recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,
  66. struct recast_heightfield *solid);
  67. void recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid);
  68. void recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid);
  69. int recast_getHeightFieldSpanCount(struct recast_heightfield *hf);
  70. struct recast_heightfieldLayerSet *recast_newHeightfieldLayerSet(void);
  71. void recast_destroyHeightfieldLayerSet(struct recast_heightfieldLayerSet *lset);
  72. struct recast_compactHeightfield *recast_newCompactHeightfield(void);
  73. void recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield);
  74. int recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,
  75. struct recast_heightfield *hf, struct recast_compactHeightfield *chf);
  76. int recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf);
  77. int recast_medianFilterWalkableArea(struct recast_compactHeightfield *chf);
  78. void recast_markBoxArea(const float *bmin, const float *bmax, unsigned char areaId,
  79. struct recast_compactHeightfield *chf);
  80. void recast_markConvexPolyArea(const float* verts, const int nverts,
  81. const float hmin, const float hmax, unsigned char areaId,
  82. struct recast_compactHeightfield *chf);
  83. int recast_offsetPoly(const float* verts, const int nverts,
  84. const float offset, float *outVerts, const int maxOutVerts);
  85. void recast_markCylinderArea(const float* pos, const float r, const float h,
  86. unsigned char areaId, struct recast_compactHeightfield *chf);
  87. int recast_buildDistanceField(struct recast_compactHeightfield *chf);
  88. int recast_buildRegions(struct recast_compactHeightfield *chf,
  89. const int borderSize, const int minRegionArea, const int mergeRegionArea);
  90. int recast_buildLayerRegions(struct recast_compactHeightfield *chf,
  91. const int borderSize, const int minRegionArea);
  92. int recast_buildRegionsMonotone(struct recast_compactHeightfield *chf,
  93. const int borderSize, const int minRegionArea, const int mergeRegionArea);
  94. /* Contour set */
  95. struct recast_contourSet *recast_newContourSet(void);
  96. void recast_destroyContourSet(struct recast_contourSet *contourSet);
  97. int recast_buildContours(struct recast_compactHeightfield *chf,
  98. const float maxError, const int maxEdgeLen, struct recast_contourSet *cset,
  99. const int buildFlags);
  100. /* Poly mesh */
  101. struct recast_polyMesh *recast_newPolyMesh(void);
  102. void recast_destroyPolyMesh(struct recast_polyMesh *polyMesh);
  103. int recast_buildPolyMesh(struct recast_contourSet *cset, const int nvp, struct recast_polyMesh *mesh);
  104. int recast_mergePolyMeshes(struct recast_polyMesh **meshes, const int nmeshes, struct recast_polyMesh *mesh);
  105. int recast_copyPolyMesh(const struct recast_polyMesh *src, struct recast_polyMesh *dst);
  106. unsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts);
  107. void recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax);
  108. void recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch);
  109. unsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp);
  110. /* Poly mesh detail */
  111. struct recast_polyMeshDetail *recast_newPolyMeshDetail(void);
  112. void recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail);
  113. int recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,
  114. const float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh);
  115. int recast_mergePolyMeshDetails(struct recast_polyMeshDetail **meshes, const int nmeshes, struct recast_polyMeshDetail *mesh);
  116. float *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts);
  117. unsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris);
  118. unsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif // RECAST_C_API_H