3 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
19 * The Original Code is Copyright (C) 2011 Blender Foundation.
20 * All rights reserved.
22 * Contributor(s): Sergey Sharybin
24 * ***** END GPL LICENSE BLOCK *****
27 #ifndef RECAST_C_API_H
28 #define RECAST_C_API_H
37 struct recast_polyMesh;
38 struct recast_polyMeshDetail;
39 struct recast_heightfield;
40 struct recast_compactHeightfield;
41 struct recast_contourSet;
45 RECAST_WALKABLE = 0x01,
46 RECAST_REACHABLE = 0x02
49 int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,
50 const int nverts, const int vertsPerPoly);
52 void recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax);
54 void recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h);
56 struct recast_heightfield *recast_newHeightfield(void);
58 void recast_destroyHeightfield(struct recast_heightfield *heightfield);
60 int recast_createHeightfield(struct recast_heightfield *hf, int width, int height,
61 const float *bmin, const float* bmax, float cs, float ch);
63 void recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,
64 const int *tris, int nt, unsigned char *flags);
66 void recast_rasterizeTriangles(const float *verts, int nv, const int *tris,
67 const unsigned char *flags, int nt, struct recast_heightfield *solid);
69 void recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,
70 struct recast_heightfield *solid);
72 void recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid);
74 void recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid);
76 struct recast_compactHeightfield *recast_newCompactHeightfield(void);
78 void recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield);
80 int recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,
81 struct recast_heightfield *hf, struct recast_compactHeightfield *chf);
83 int recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf);
85 int recast_buildDistanceField(struct recast_compactHeightfield *chf);
87 int recast_buildRegions(struct recast_compactHeightfield *chf, int borderSize,
88 int minRegionSize, int mergeRegionSize);
92 struct recast_contourSet *recast_newContourSet(void);
94 void recast_destroyContourSet(struct recast_contourSet *contourSet);
96 int recast_buildContours(struct recast_compactHeightfield *chf,
97 const float maxError, const int maxEdgeLen, struct recast_contourSet *cset);
101 struct recast_polyMesh *recast_newPolyMesh(void);
103 void recast_destroyPolyMesh(struct recast_polyMesh *polyMesh);
105 int recast_buildPolyMesh(struct recast_contourSet *cset, int nvp, struct recast_polyMesh *mesh);
107 unsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts);
109 void recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax);
111 void recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch);
113 unsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp);
115 /* Poly mesh detail */
117 struct recast_polyMeshDetail *recast_newPolyMeshDetail(void);
119 void recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail);
121 int recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,
122 const float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh);
124 float *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts);
126 unsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris);
128 unsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes);
130 /* utility function: quick sort reentrant */
131 typedef int recast_cmp_t(void *ctx, const void *a, const void *b);
133 void recast_qsort(void *a, size_t n, size_t es, void *thunk, recast_cmp_t *cmp);
139 #endif // RECAST_C_API_H