2 Debian patches touch this file
| 1 | // |
| 2 | // Copyright (c) 2009-2010 Mikko Mononen [email protected] |
| 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 DETOURNAVMESHBUILDER_H |
| 20 | #define DETOURNAVMESHBUILDER_H |
| 21 | |
| 22 | #include "DetourAlloc.h" |
| 23 | |
| 24 | /// Represents the source data used to build an navigation mesh tile. |
| 25 | /// @ingroup detour |
| 26 | struct dtNavMeshCreateParams |
| 27 | { |
| 28 | |
| 29 | /// @name Polygon Mesh Attributes |
| 30 | /// Used to create the base navigation graph. |
| 31 | /// See #rcPolyMesh for details related to these attributes. |
| 32 | /// @{ |
| 33 | |
| 34 | const unsigned short* verts; ///< The polygon mesh vertices. [(x, y, z) * #vertCount] [Unit: vx] |
| 35 | int vertCount; ///< The number vertices in the polygon mesh. [Limit: >= 3] |
| 36 | const unsigned short* polys; ///< The polygon data. [Size: #polyCount * 2 * #nvp] |
| 37 | const unsigned short* polyFlags; ///< The user defined flags assigned to each polygon. [Size: #polyCount] |
| 38 | const unsigned char* polyAreas; ///< The user defined area ids assigned to each polygon. [Size: #polyCount] |
| 39 | int polyCount; ///< Number of polygons in the mesh. [Limit: >= 1] |
| 40 | int nvp; ///< Number maximum number of vertices per polygon. [Limit: >= 3] |
| 41 | |
| 42 | /// @} |
| 43 | /// @name Height Detail Attributes (Optional) |
| 44 | /// See #rcPolyMeshDetail for details related to these attributes. |
| 45 | /// @{ |
| 46 | |
| 47 | const unsigned int* detailMeshes; ///< The height detail sub-mesh data. [Size: 4 * #polyCount] |
| 48 | const float* detailVerts; ///< The detail mesh vertices. [Size: 3 * #detailVertsCount] [Unit: wu] |
| 49 | int detailVertsCount; ///< The number of vertices in the detail mesh. |
| 50 | const unsigned char* detailTris; ///< The detail mesh triangles. [Size: 4 * #detailTriCount] |
| 51 | int detailTriCount; ///< The number of triangles in the detail mesh. |
| 52 | |
| 53 | /// @} |
| 54 | /// @name Off-Mesh Connections Attributes (Optional) |
| 55 | /// Used to define a custom point-to-point edge within the navigation graph, an |
| 56 | /// off-mesh connection is a user defined traversable connection made up to two vertices, |
| 57 | /// at least one of which resides within a navigation mesh polygon. |
| 58 | /// @{ |
| 59 | |
| 60 | /// Off-mesh connection vertices. [(ax, ay, az, bx, by, bz) * #offMeshConCount] [Unit: wu] |
| 61 | const float* offMeshConVerts; |
| 62 | /// Off-mesh connection radii. [Size: #offMeshConCount] [Unit: wu] |
| 63 | const float* offMeshConRad; |
| 64 | /// User defined flags assigned to the off-mesh connections. [Size: #offMeshConCount] |
| 65 | const unsigned short* offMeshConFlags; |
| 66 | /// User defined area ids assigned to the off-mesh connections. [Size: #offMeshConCount] |
| 67 | const unsigned char* offMeshConAreas; |
| 68 | /// The permitted travel direction of the off-mesh connections. [Size: #offMeshConCount] |
| 69 | /// |
| 70 | /// 0 = Travel only from endpoint A to endpoint B.<br/> |
| 71 | /// #DT_OFFMESH_CON_BIDIR = Bidirectional travel. |
| 72 | const unsigned char* offMeshConDir; |
| 73 | /// The user defined ids of the off-mesh connection. [Size: #offMeshConCount] |
| 74 | const unsigned int* offMeshConUserID; |
| 75 | /// The number of off-mesh connections. [Limit: >= 0] |
| 76 | int offMeshConCount; |
| 77 | |
| 78 | /// @} |
| 79 | /// @name Tile Attributes |
| 80 | /// @note The tile grid/layer data can be left at zero if the destination is a single tile mesh. |
| 81 | /// @{ |
| 82 | |
| 83 | unsigned int userId; ///< The user defined id of the tile. |
| 84 | int tileX; ///< The tile's x-grid location within the multi-tile destination mesh. (Along the x-axis.) |
| •85 | int tileY; ///< The tile's y-grid location within the multi-tile destination mesh. (Along the z-axis.) |
| 86 | int tileLayer; ///< The tile's layer within the layered destination mesh. [Limit: >= 0] (Along the y-axis.) |
| 87 | float bmin[3]; ///< The minimum bounds of the tile. [(x, y, z)] [Unit: wu] |
| 88 | float bmax[3]; ///< The maximum bounds of the tile. [(x, y, z)] [Unit: wu] |
| 89 | |
| 90 | /// @} |
| 91 | /// @name General Configuration Attributes |
| 92 | /// @{ |
| 93 | |
| 94 | float walkableHeight; ///< The agent height. [Unit: wu] |
| 95 | float walkableRadius; ///< The agent radius. [Unit: wu] |
| 96 | float walkableClimb; ///< The agent maximum traversable ledge. (Up/Down) [Unit: wu] |
| 97 | float cs; ///< The xz-plane cell size of the polygon mesh. [Limit: > 0] [Unit: wu] |
| 98 | float ch; ///< The y-axis cell height of the polygon mesh. [Limit: > 0] [Unit: wu] |
| 99 | |
| 100 | /// True if a bounding volume tree should be built for the tile. |
| 101 | /// @note The BVTree is not normally needed for layered navigation meshes. |
| 102 | bool buildBvTree; |
| 103 | |
| 104 | /// @} |
| 105 | }; |
| 106 | |
| 107 | /// Builds navigation mesh tile data from the provided tile creation data. |
| 108 | /// @ingroup detour |
| 109 | /// @param[in] params Tile creation data. |
| 110 | /// @param[out] outData The resulting tile data. |
| 111 | /// @param[out] outDataSize The size of the tile data array. |
| 112 | /// @return True if the tile data was successfully created. |
| 113 | bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, int* outDataSize); |
| 114 | |
| •115 | /// Swaps the endianness of the tile data's header (#dtMeshHeader). |
| 116 | /// @param[in,out] data The tile data array. |
| 117 | /// @param[in] dataSize The size of the data array. |
| 118 | bool dtNavMeshHeaderSwapEndian(unsigned char* data, const int dataSize); |
| 119 | |
| •120 | /// Swaps endianness of the tile data. |
| 121 | /// @param[in,out] data The tile data array. |
| 122 | /// @param[in] dataSize The size of the data array. |
| 123 | bool dtNavMeshDataSwapEndian(unsigned char* data, const int dataSize); |
| 124 | |
| 125 | #endif // DETOURNAVMESHBUILDER_H |
| 126 | |
| 127 | // This section contains detailed documentation for members that don't have |
| 128 | // a source file. It reduces clutter in the main section of the header. |
| 129 | |
| 130 | /** |
| 131 | |
| 132 | @struct dtNavMeshCreateParams |
| 133 | @par |
| 134 | |
| 135 | This structure is used to marshal data between the Recast mesh generation pipeline and Detour navigation components. |
| 136 | |
| 137 | See the rcPolyMesh and rcPolyMeshDetail documentation for detailed information related to mesh structure. |
| 138 | |
| 139 | Units are usually in voxels (vx) or world units (wu). The units for voxels, grid size, and cell size |
| 140 | are all based on the values of #cs and #ch. |
| 141 | |
| 142 | The standard navigation mesh build process is to create tile data using dtCreateNavMeshData, then add the tile |
| 143 | to a navigation mesh using either the dtNavMesh single tile <tt>init()</tt> function or the dtNavMesh::addTile() |
| 144 | function. |
| 145 | |
| 146 | @see dtCreateNavMeshData |
| 147 | |
| 148 | */ |
| 149 |