Added dtNavMesh, which is combination of dtStatNavMesh and dtTiledNavMesh. Added Sample_DynMesh which is used for dtNavMesh testing for now.
This commit is contained in:
parent
3a8b259bd2
commit
ab023b1700
@ -113,7 +113,7 @@ inline bool vequal(const float* p0, const float* p1)
|
|||||||
return d < thr;
|
return d < thr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int nextPow2(int v)
|
inline unsigned int nextPow2(unsigned int v)
|
||||||
{
|
{
|
||||||
v--;
|
v--;
|
||||||
v |= v >> 1;
|
v |= v >> 1;
|
||||||
@ -125,6 +125,18 @@ inline int nextPow2(int v)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned int ilog2(unsigned int v)
|
||||||
|
{
|
||||||
|
unsigned int r;
|
||||||
|
unsigned int shift;
|
||||||
|
r = (v > 0xffff) << 4; v >>= r;
|
||||||
|
shift = (v > 0xff) << 3; v >>= shift; r |= shift;
|
||||||
|
shift = (v > 0xf) << 2; v >>= shift; r |= shift;
|
||||||
|
shift = (v > 0x3) << 1; v >>= shift; r |= shift;
|
||||||
|
r |= (v >> 1);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
inline int align4(int x) { return (x+3) & ~3; }
|
inline int align4(int x) { return (x+3) & ~3; }
|
||||||
|
|
||||||
inline float vdot2D(const float* u, const float* v)
|
inline float vdot2D(const float* u, const float* v)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "DetourStatNavMesh.h"
|
#include "DetourStatNavMesh.h"
|
||||||
#include "DetourTileNavMesh.h"
|
#include "DetourTileNavMesh.h"
|
||||||
|
#include "DetourNavMesh.h"
|
||||||
|
|
||||||
void dtDebugDrawStatNavMeshPoly(const dtStatNavMesh* mesh, dtStatPolyRef ref, const float* col);
|
void dtDebugDrawStatNavMeshPoly(const dtStatNavMesh* mesh, dtStatPolyRef ref, const float* col);
|
||||||
void dtDebugDrawStatNavMeshBVTree(const dtStatNavMesh* mesh);
|
void dtDebugDrawStatNavMeshBVTree(const dtStatNavMesh* mesh);
|
||||||
@ -29,4 +30,7 @@ void dtDebugDrawStatNavMesh(const dtStatNavMesh* mesh, bool drawClosedList = fal
|
|||||||
void dtDebugDrawTiledNavMesh(const dtTiledNavMesh* mesh);
|
void dtDebugDrawTiledNavMesh(const dtTiledNavMesh* mesh);
|
||||||
void dtDebugDrawTiledNavMeshPoly(const dtTiledNavMesh* mesh, dtTilePolyRef ref, const float* col);
|
void dtDebugDrawTiledNavMeshPoly(const dtTiledNavMesh* mesh, dtTilePolyRef ref, const float* col);
|
||||||
|
|
||||||
|
void dtDebugDrawNavMesh(const dtNavMesh* mesh);
|
||||||
|
void dtDebugDrawNavMeshPoly(const dtNavMesh* mesh, dtPolyRef ref, const float* col);
|
||||||
|
|
||||||
#endif // DETOURDEBUGDRAW_H
|
#endif // DETOURDEBUGDRAW_H
|
343
Detour/Include/DetourNavMesh.h
Normal file
343
Detour/Include/DetourNavMesh.h
Normal file
@ -0,0 +1,343 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DETOURNAVMESH_H
|
||||||
|
#define DETOURNAVMESH_H
|
||||||
|
|
||||||
|
// Reference to navigation polygon.
|
||||||
|
typedef unsigned int dtPolyRef;
|
||||||
|
|
||||||
|
// The bits used in the poly ref.
|
||||||
|
/*static const int DT_REF_SALT_BITS = 12;
|
||||||
|
static const int DT_REF_TILE_BITS = 12;
|
||||||
|
static const int DT_REF_POLY_BITS = 8;
|
||||||
|
static const int DT_REF_SALT_MASK = (1<<DT_REF_SALT_BITS)-1;
|
||||||
|
static const int DT_REF_TILE_MASK = (1<<DT_REF_TILE_BITS)-1;
|
||||||
|
static const int DT_REF_POLY_MASK = (1<<DT_REF_POLY_BITS)-1;*/
|
||||||
|
|
||||||
|
// Maximum number of vertices per navigation polygon.
|
||||||
|
static const int DT_VERTS_PER_POLYGON = 6;
|
||||||
|
|
||||||
|
/*
|
||||||
|
static const int DT_MAX_TILES = 1 << DT_REF_TILE_BITS;
|
||||||
|
static const int DT_MAX_POLYGONS = 1 << DT_REF_POLY_BITS;
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const int DT_NAVMESH_MAGIC = 'DNAV';
|
||||||
|
static const int DT_NAVMESH_VERSION = 1;
|
||||||
|
|
||||||
|
// Structure holding the navigation polygon data.
|
||||||
|
struct dtPoly
|
||||||
|
{
|
||||||
|
unsigned short v[DT_VERTS_PER_POLYGON]; // Indices to vertices of the poly.
|
||||||
|
unsigned short n[DT_VERTS_PER_POLYGON]; // Refs to neighbours of the poly.
|
||||||
|
unsigned short links; // Base index to header 'links' array.
|
||||||
|
unsigned char nlinks; // Number of links for
|
||||||
|
unsigned char nv; // Number of vertices.
|
||||||
|
unsigned char flags; // Flags (not used).
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dtPolyDetail
|
||||||
|
{
|
||||||
|
unsigned short vbase; // Offset to detail vertex array.
|
||||||
|
unsigned short nverts; // Number of vertices in the detail mesh.
|
||||||
|
unsigned short tbase; // Offset to detail triangle array.
|
||||||
|
unsigned short ntris; // Number of triangles.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Stucture holding a link to another polygon.
|
||||||
|
struct dtLink
|
||||||
|
{
|
||||||
|
dtPolyRef ref; // Neighbour reference.
|
||||||
|
unsigned short p; // Index to polygon which owns this link.
|
||||||
|
unsigned char e; // Index to polygon edge which owns this link.
|
||||||
|
unsigned char side; // If boundary link, defines on which side the link is.
|
||||||
|
unsigned char bmin, bmax; // If boundary link, defines the sub edge area.
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dtBVNode
|
||||||
|
{
|
||||||
|
unsigned short bmin[3], bmax[3];
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dtMeshHeader
|
||||||
|
{
|
||||||
|
int magic; // Magic number, used to identify the data.
|
||||||
|
int version; // Data version number.
|
||||||
|
int npolys; // Number of polygons in the tile.
|
||||||
|
int nverts; // Number of vertices in the tile.
|
||||||
|
int nlinks; // Number of links in the tile (will be updated when tile is added).
|
||||||
|
int maxlinks; // Number of allocated links.
|
||||||
|
int ndmeshes;
|
||||||
|
int ndverts;
|
||||||
|
int ndtris;
|
||||||
|
int nbvtree;
|
||||||
|
float bmin[3], bmax[3]; // Bounding box of the tile.
|
||||||
|
float bvquant;
|
||||||
|
dtPoly* polys; // Pointer to the polygons (will be updated when tile is added).
|
||||||
|
float* verts; // Pointer to the vertices (will be updated when tile added).
|
||||||
|
dtLink* links; // Pointer to the links (will be updated when tile added).
|
||||||
|
dtPolyDetail* dmeshes;
|
||||||
|
float* dverts;
|
||||||
|
unsigned char* dtris;
|
||||||
|
dtBVNode* bvtree;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dtMeshTile
|
||||||
|
{
|
||||||
|
int salt; // Counter describing modifications to the tile.
|
||||||
|
int x,y; // Grid location of the tile.
|
||||||
|
dtMeshHeader* header; // Pointer to tile header.
|
||||||
|
unsigned char* data; // Pointer to tile data.
|
||||||
|
int dataSize; // Size of the tile data.
|
||||||
|
bool ownsData; // Flag indicating of the navmesh should release the data.
|
||||||
|
dtMeshTile* next; // Next free tile or, next tile in spatial grid.
|
||||||
|
};
|
||||||
|
|
||||||
|
class dtNavMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
dtNavMesh();
|
||||||
|
~dtNavMesh();
|
||||||
|
|
||||||
|
// Initializes the nav mesh.
|
||||||
|
// Params:
|
||||||
|
// orig - (in) origin of the nav mesh tile space.
|
||||||
|
// tileSiz - (in) size of a tile.
|
||||||
|
// portalheight - (in) height of the portal region between tiles.
|
||||||
|
// Returns: True if succeed, else false.
|
||||||
|
bool init(const float* orig, float tileSize, float portalHeight,
|
||||||
|
int maxTiles, int maxPolys, int maxNodes);
|
||||||
|
|
||||||
|
// Adds new tile into the navmesh.
|
||||||
|
// The add will fail if the data is in wrong format,
|
||||||
|
// there is not enough tiles left, or if there is a tile already at the location.
|
||||||
|
// Params:
|
||||||
|
// x,y - (in) Location of the new tile.
|
||||||
|
// data - (in) Data of the new tile mesh.
|
||||||
|
// dataSize - (in) Data size of the new tile mesh.
|
||||||
|
// ownsData - (in) Flag indicating if the navmesh should own and delete the data.
|
||||||
|
// Returns: True if tile was added, else false.
|
||||||
|
bool addTileAt(int x, int y, unsigned char* data, int dataSize, bool ownsData);
|
||||||
|
|
||||||
|
// Removes tile at specified location.
|
||||||
|
// Params:
|
||||||
|
// x,y - (in) Location of the tile to remove.
|
||||||
|
// data - (out) Data associated with deleted tile.
|
||||||
|
// dataSize - (out) Size of the data associated with deleted tile.
|
||||||
|
// Returns: True if remove suceed, else false.
|
||||||
|
bool removeTileAt(int x, int y, unsigned char** data, int* dataSize);
|
||||||
|
|
||||||
|
// Returns pointer to tile at specified location.
|
||||||
|
// Params:
|
||||||
|
// x,y - (in) Location of the tile to get.
|
||||||
|
// Returns: pointer to tile if tile exists or 0 tile does not exists.
|
||||||
|
dtMeshTile* getTileAt(int x, int y);
|
||||||
|
|
||||||
|
// Returns max number of tiles.
|
||||||
|
int getMaxTiles() const;
|
||||||
|
|
||||||
|
// Returns pointer to tile in the tile array.
|
||||||
|
// Params:
|
||||||
|
// i - (in) Index to the tile to retrieve, max index is getMaxTiles()-1.
|
||||||
|
// Returns: Pointer to specified tile.
|
||||||
|
dtMeshTile* getTile(int i);
|
||||||
|
const dtMeshTile* getTile(int i) const;
|
||||||
|
|
||||||
|
// Returns pointer to tile in the tile array.
|
||||||
|
// Params:
|
||||||
|
// ref - (in) reference to a polygon inside the tile.
|
||||||
|
// plyIndex - (out,optional) pointer to value where polygon index within the tile is stored.
|
||||||
|
// Returns: Pointer to specified tile.
|
||||||
|
const dtMeshTile* getTileByRef(dtPolyRef ref, int* polyIndex) const;
|
||||||
|
|
||||||
|
// Finds the nearest navigation polygon around the center location.
|
||||||
|
// Params:
|
||||||
|
// center - (in) The center of the search box.
|
||||||
|
// extents - (in) The extents of the search box.
|
||||||
|
// Returns: Reference identifier for the polygon, or 0 if no polygons found.
|
||||||
|
dtPolyRef findNearestPoly(const float* center, const float* extents);
|
||||||
|
|
||||||
|
// Returns polygons which touch the query box.
|
||||||
|
// Params:
|
||||||
|
// center - (in) the center of the search box.
|
||||||
|
// extents - (in) the extents of the search box.
|
||||||
|
// polys - (out) array holding the search result.
|
||||||
|
// maxPolys - (in) The max number of polygons the polys array can hold.
|
||||||
|
// Returns: Number of polygons in search result array.
|
||||||
|
int queryPolygons(const float* center, const float* extents,
|
||||||
|
dtPolyRef* polys, const int maxPolys);
|
||||||
|
|
||||||
|
// Finds path from start polygon to end polygon.
|
||||||
|
// If target polygon canno be reached through the navigation graph,
|
||||||
|
// the last node on the array is nearest node to the end polygon.
|
||||||
|
// Params:
|
||||||
|
// startRef - (in) ref to path start polygon.
|
||||||
|
// endRef - (in) ref to path end polygon.
|
||||||
|
// path - (out) array holding the search result.
|
||||||
|
// maxPathSize - (in) The max number of polygons the path array can hold.
|
||||||
|
// Returns: Number of polygons in search result array.
|
||||||
|
int findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||||
|
const float* startPos, const float* endPos,
|
||||||
|
dtPolyRef* path, const int maxPathSize);
|
||||||
|
|
||||||
|
// Finds a straight path from start to end locations within the corridor
|
||||||
|
// described by the path polygons.
|
||||||
|
// Start and end locations will be clamped on the corridor.
|
||||||
|
// Params:
|
||||||
|
// startPos - (in) Path start location.
|
||||||
|
// endPos - (in) Path end location.
|
||||||
|
// path - (in) Array of connected polygons describing the corridor.
|
||||||
|
// pathSize - (in) Number of polygons in path array.
|
||||||
|
// straightPath - (out) Points describing the straight path.
|
||||||
|
// maxStraightPathSize - (in) The max number of points the straight path array can hold.
|
||||||
|
// Returns: Number of points in the path.
|
||||||
|
int findStraightPath(const float* startPos, const float* endPos,
|
||||||
|
const dtPolyRef* path, const int pathSize,
|
||||||
|
float* straightPath, const int maxStraightPathSize);
|
||||||
|
|
||||||
|
// Finds intersection againts walls starting from start pos.
|
||||||
|
// Params:
|
||||||
|
// startRef - (in) ref to the polygon where the start lies.
|
||||||
|
// startPos - (in) start position of the query.
|
||||||
|
// endPos - (in) end position of the query.
|
||||||
|
// t - (out) hit parameter along the segment, 0 if no hit.
|
||||||
|
// endRef - (out) ref to the last polygon which was processed.
|
||||||
|
// Returns: Number of polygons in path or 0 if failed.
|
||||||
|
int raycast(dtPolyRef startRef, const float* startPos, const float* endPos,
|
||||||
|
float& t, dtPolyRef* path, const int pathSize);
|
||||||
|
|
||||||
|
// Returns distance to nearest wall from the specified location.
|
||||||
|
// Params:
|
||||||
|
// centerRef - (in) ref to the polygon where the center lies.
|
||||||
|
// centerPos - (in) center if the query circle.
|
||||||
|
// maxRadius - (in) max search radius.
|
||||||
|
// hitPos - (out) location of the nearest hit.
|
||||||
|
// hitNormal - (out) normal of the nearest hit.
|
||||||
|
// Returns: Distance to nearest wall from the test location.
|
||||||
|
float findDistanceToWall(dtPolyRef centerRef, const float* centerPos, float maxRadius,
|
||||||
|
float* hitPos, float* hitNormal);
|
||||||
|
|
||||||
|
// Finds polygons found along the navigation graph which touch the specified circle.
|
||||||
|
// Params:
|
||||||
|
// centerRef - (in) ref to the polygon where the center lies.
|
||||||
|
// centerPos - (in) center if the query circle
|
||||||
|
// radius - (in) radius of the query circle
|
||||||
|
// resultRef - (out, opt) refs to the polygons touched by the circle.
|
||||||
|
// resultParent - (out, opt) parent of each result polygon.
|
||||||
|
// resultCost - (out, opt) search cost at each result polygon.
|
||||||
|
// maxResult - (int) maximum capacity of search results.
|
||||||
|
// Returns: Number of results.
|
||||||
|
int findPolysAround(dtPolyRef centerRef, const float* centerPos, float radius,
|
||||||
|
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||||
|
const int maxResult);
|
||||||
|
|
||||||
|
// Returns closest point on navigation polygon.
|
||||||
|
// Params:
|
||||||
|
// ref - (in) ref to the polygon.
|
||||||
|
// pos - (in) the point to check.
|
||||||
|
// closest - (out) closest point.
|
||||||
|
// Returns: true if closest point found.
|
||||||
|
bool closestPointToPoly(dtPolyRef ref, const float* pos, float* closest) const;
|
||||||
|
|
||||||
|
// Returns height of the polygon at specified location.
|
||||||
|
// Params:
|
||||||
|
// ref - (in) ref to the polygon.
|
||||||
|
// pos - (in) the point where to locate the height.
|
||||||
|
// height - (out) height at the location.
|
||||||
|
// Returns: true if over polygon.
|
||||||
|
bool getPolyHeight(dtPolyRef ref, const float* pos, float* height) const;
|
||||||
|
|
||||||
|
// Returns pointer to a polygon based on ref.
|
||||||
|
const dtPoly* getPolyByRef(dtPolyRef ref) const;
|
||||||
|
|
||||||
|
// Returns pointer to a polygon vertices based on ref.
|
||||||
|
const float* getPolyVertsByRef(dtPolyRef ref) const;
|
||||||
|
|
||||||
|
// Returns pointer to a polygon link based on ref.
|
||||||
|
const dtLink* getPolyLinksByRef(dtPolyRef ref) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Encodes a tile id.
|
||||||
|
inline dtPolyRef dtEncodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
|
||||||
|
{
|
||||||
|
return (salt << (m_polyBits+m_tileBits)) | ((it+1) << m_polyBits) | ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodes a tile id.
|
||||||
|
inline void dtDecodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
|
||||||
|
{
|
||||||
|
salt = (ref >> (m_polyBits+m_tileBits)) & ((1<<m_saltBits)-1);
|
||||||
|
it = ((ref >> m_polyBits) - 1) & ((1<<m_tileBits)-1);
|
||||||
|
ip = ref & ((1<<m_polyBits)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns base id for the tile.
|
||||||
|
dtPolyRef getTileId(dtMeshTile* tile);
|
||||||
|
// Returns neighbour tile based on side.
|
||||||
|
dtMeshTile* getNeighbourTileAt(int x, int y, int side);
|
||||||
|
// Returns all polygons in neighbour tile based on portal defined by the segment.
|
||||||
|
int findConnectingPolys(const float* va, const float* vb,
|
||||||
|
dtMeshTile* tile, int side,
|
||||||
|
dtPolyRef* con, float* conarea, int maxcon);
|
||||||
|
// Builds internal polygons links for a tile.
|
||||||
|
void buildIntLinks(dtMeshTile* tile);
|
||||||
|
// Builds external polygon links for a tile.
|
||||||
|
void buildExtLinks(dtMeshTile* tile, dtMeshTile* target, int side);
|
||||||
|
// Removes external links at specified side.
|
||||||
|
void removeExtLinks(dtMeshTile* tile, int side);
|
||||||
|
// Queries polygons within a tile.
|
||||||
|
int queryTilePolygons(dtMeshTile* tile, const float* qmin, const float* qmax,
|
||||||
|
dtPolyRef* polys, const int maxPolys);
|
||||||
|
|
||||||
|
float getCost(dtPolyRef prev, dtPolyRef from, dtPolyRef to) const;
|
||||||
|
float getFirstCost(const float* pos, dtPolyRef from, dtPolyRef to) const;
|
||||||
|
float getLastCost(dtPolyRef from, dtPolyRef to, const float* pos) const;
|
||||||
|
float getHeuristic(const float* from, const float* to) const;
|
||||||
|
|
||||||
|
// Returns portal points between two polygons.
|
||||||
|
bool getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right) const;
|
||||||
|
// Returns edge mid point between two polygons.
|
||||||
|
bool getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const;
|
||||||
|
|
||||||
|
float m_orig[3];
|
||||||
|
float m_tileSize;
|
||||||
|
float m_portalHeight;
|
||||||
|
int m_maxTiles;
|
||||||
|
int m_tileLutSize;
|
||||||
|
int m_tileLutMask;
|
||||||
|
|
||||||
|
dtMeshTile** m_posLookup; //[DT_TILE_LOOKUP_SIZE];
|
||||||
|
dtMeshTile* m_nextFree;
|
||||||
|
dtMeshTile* m_tiles; //[DT_MAX_TILES];
|
||||||
|
|
||||||
|
// TODO: dont grow!
|
||||||
|
dtLink* m_tmpLinks;
|
||||||
|
int m_ntmpLinks;
|
||||||
|
|
||||||
|
unsigned int m_saltBits;
|
||||||
|
unsigned int m_tileBits;
|
||||||
|
unsigned int m_polyBits;
|
||||||
|
|
||||||
|
class dtNodePool* m_nodePool;
|
||||||
|
class dtNodeQueue* m_openList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DETOURNAVMESH_H
|
29
Detour/Include/DetourNavMeshBuilder.h
Normal file
29
Detour/Include/DetourNavMeshBuilder.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DETOURNAVMESHBUILDER_H
|
||||||
|
#define DETOURNAVMESHBUILDER_H
|
||||||
|
|
||||||
|
bool dtCreateNavMeshData(const unsigned short* verts, const int nverts,
|
||||||
|
const unsigned short* polys, const int npolys, const int nvp,
|
||||||
|
const unsigned short* dmeshes, const float* dverts, const int ndverts,
|
||||||
|
const unsigned char* dtris, const int ndtris,
|
||||||
|
const float* bmin, const float* bmax, float cs, float ch, int tileSize, int walkableClimb,
|
||||||
|
unsigned char** outData, int* outDataSize);
|
||||||
|
|
||||||
|
#endif // DETOURNAVMESHBUILDER_H
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "DetourDebugDraw.h"
|
#include "DetourDebugDraw.h"
|
||||||
#include "DetourStatNavMesh.h"
|
#include "DetourStatNavMesh.h"
|
||||||
|
#include "DetourTileNavMesh.h"
|
||||||
|
#include "DetourNavMesh.h"
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_opengl.h"
|
#include "SDL_opengl.h"
|
||||||
|
|
||||||
@ -494,3 +496,270 @@ void dtDebugDrawTiledNavMeshPoly(const dtTiledNavMesh* mesh, dtTilePolyRef ref,
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void drawPolyBoundaries(const dtMeshHeader* header, bool inner)
|
||||||
|
{
|
||||||
|
static const float thr = 0.01f*0.01f;
|
||||||
|
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (int i = 0; i < header->npolys; ++i)
|
||||||
|
{
|
||||||
|
const dtPoly* p = &header->polys[i];
|
||||||
|
const dtPolyDetail* pd = &header->dmeshes[i];
|
||||||
|
|
||||||
|
for (int j = 0, nj = (int)p->nv; j < nj; ++j)
|
||||||
|
{
|
||||||
|
if (inner)
|
||||||
|
{
|
||||||
|
if (p->n[j] == 0) continue;
|
||||||
|
if (p->n[j] & 0x8000)
|
||||||
|
{
|
||||||
|
bool con = false;
|
||||||
|
for (int k = 0; k < p->nlinks; ++k)
|
||||||
|
{
|
||||||
|
if (header->links[p->links+k].e == j)
|
||||||
|
{
|
||||||
|
con = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (con)
|
||||||
|
glColor4ub(255,255,255,128);
|
||||||
|
else
|
||||||
|
glColor4ub(0,0,0,128);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
glColor4ub(0,48,64,32);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (p->n[j] != 0) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float* v0 = &header->verts[p->v[j]*3];
|
||||||
|
const float* v1 = &header->verts[p->v[(j+1)%nj]*3];
|
||||||
|
|
||||||
|
// Draw detail mesh edges which align with the actual poly edge.
|
||||||
|
// This is really slow.
|
||||||
|
for (int k = 0; k < pd->ntris; ++k)
|
||||||
|
{
|
||||||
|
const unsigned char* t = &header->dtris[(pd->tbase+k)*4];
|
||||||
|
const float* tv[3];
|
||||||
|
for (int m = 0; m < 3; ++m)
|
||||||
|
{
|
||||||
|
if (t[m] < p->nv)
|
||||||
|
tv[m] = &header->verts[p->v[t[m]]*3];
|
||||||
|
else
|
||||||
|
tv[m] = &header->dverts[(pd->vbase+(t[m]-p->nv))*3];
|
||||||
|
}
|
||||||
|
for (int m = 0, n = 2; m < 3; n=m++)
|
||||||
|
{
|
||||||
|
if (((t[3] >> (n*2)) & 0x3) == 0) continue; // Skip inner detail edges.
|
||||||
|
if (distancePtLine2d(tv[n],v0,v1) < thr &&
|
||||||
|
distancePtLine2d(tv[m],v0,v1) < thr)
|
||||||
|
{
|
||||||
|
glVertex3fv(tv[n]);
|
||||||
|
glVertex3fv(tv[m]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawMeshTile(const dtMeshHeader* header)
|
||||||
|
{
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
for (int i = 0; i < header->npolys; ++i)
|
||||||
|
{
|
||||||
|
const dtPoly* p = &header->polys[i];
|
||||||
|
const dtPolyDetail* pd = &header->dmeshes[i];
|
||||||
|
|
||||||
|
glColor4ub(0,196,255,64);
|
||||||
|
|
||||||
|
for (int j = 0; j < pd->ntris; ++j)
|
||||||
|
{
|
||||||
|
const unsigned char* t = &header->dtris[(pd->tbase+j)*4];
|
||||||
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
|
if (t[k] < p->nv)
|
||||||
|
glVertex3fv(&header->verts[p->v[t[k]]*3]);
|
||||||
|
else
|
||||||
|
glVertex3fv(&header->dverts[(pd->vbase+t[k]-p->nv)*3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Draw inter poly boundaries
|
||||||
|
glColor4ub(0,48,64,32);
|
||||||
|
glLineWidth(1.5f);
|
||||||
|
|
||||||
|
drawPolyBoundaries(header, true);
|
||||||
|
|
||||||
|
// Draw outer poly boundaries
|
||||||
|
glLineWidth(2.5f);
|
||||||
|
glColor4ub(0,48,64,220);
|
||||||
|
|
||||||
|
drawPolyBoundaries(header, false);
|
||||||
|
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
|
||||||
|
glPointSize(3.0f);
|
||||||
|
glColor4ub(0,0,0,196);
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
for (int i = 0; i < header->nverts; ++i)
|
||||||
|
{
|
||||||
|
const float* v = &header->verts[i*3];
|
||||||
|
glVertex3f(v[0], v[1], v[2]);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
glPointSize(1.0f);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Draw BV nodes.
|
||||||
|
const float col[] = { 1,1,1,0.5f };
|
||||||
|
const float cs = 1.0f / header->bvquant;
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (int i = 0; i < header->nbvtree; ++i)
|
||||||
|
{
|
||||||
|
const dtBVNode* n = &header->bvtree[i];
|
||||||
|
if (n->i < 0) // Leaf indices are positive.
|
||||||
|
continue;
|
||||||
|
drawBoxWire(header->bmin[0] + n->bmin[0]*cs,
|
||||||
|
header->bmin[1] + n->bmin[1]*cs,
|
||||||
|
header->bmin[2] + n->bmin[2]*cs,
|
||||||
|
header->bmin[0] + n->bmax[0]*cs,
|
||||||
|
header->bmin[1] + n->bmax[1]*cs,
|
||||||
|
header->bmin[2] + n->bmax[2]*cs, col);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Draw portals
|
||||||
|
/* glBegin(GL_LINES);
|
||||||
|
|
||||||
|
for (int i = 0; i < header->nportals[0]; ++i)
|
||||||
|
{
|
||||||
|
const dtTilePortal* p = &header->portals[0][i];
|
||||||
|
if (p->ncon)
|
||||||
|
glColor4ub(255,255,255,192);
|
||||||
|
else
|
||||||
|
glColor4ub(255,0,0,64);
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
|
||||||
|
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < header->nportals[1]; ++i)
|
||||||
|
{
|
||||||
|
const dtTilePortal* p = &header->portals[1][i];
|
||||||
|
if (p->ncon)
|
||||||
|
glColor4ub(255,255,255,192);
|
||||||
|
else
|
||||||
|
glColor4ub(255,0,0,64);
|
||||||
|
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
|
||||||
|
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
|
||||||
|
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
|
||||||
|
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
|
||||||
|
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < header->nportals[2]; ++i)
|
||||||
|
{
|
||||||
|
const dtTilePortal* p = &header->portals[2][i];
|
||||||
|
if (p->ncon)
|
||||||
|
glColor4ub(255,255,255,192);
|
||||||
|
else
|
||||||
|
glColor4ub(255,0,0,64);
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
|
||||||
|
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
|
||||||
|
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < header->nportals[3]; ++i)
|
||||||
|
{
|
||||||
|
const dtTilePortal* p = &header->portals[3][i];
|
||||||
|
if (p->ncon)
|
||||||
|
glColor4ub(255,255,255,192);
|
||||||
|
else
|
||||||
|
glColor4ub(255,0,0,64);
|
||||||
|
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
|
||||||
|
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
|
||||||
|
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
|
||||||
|
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
|
||||||
|
|
||||||
|
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
|
||||||
|
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
|
||||||
|
}
|
||||||
|
glEnd();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void dtDebugDrawNavMesh(const dtNavMesh* mesh)
|
||||||
|
{
|
||||||
|
if (!mesh) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < mesh->getMaxTiles(); ++i)
|
||||||
|
{
|
||||||
|
const dtMeshTile* tile = mesh->getTile(i);
|
||||||
|
if (!tile->header) continue;
|
||||||
|
drawMeshTile(tile->header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void dtDebugDrawNavMeshPoly(const dtNavMesh* mesh, dtPolyRef ref, const float* col)
|
||||||
|
{
|
||||||
|
int ip = 0;
|
||||||
|
const dtMeshTile* tile = mesh->getTileByRef(ref, &ip);
|
||||||
|
if (!tile)
|
||||||
|
return;
|
||||||
|
const dtMeshHeader* header = tile->header;
|
||||||
|
const dtPoly* p = &header->polys[ip];
|
||||||
|
const dtPolyDetail* pd = &header->dmeshes[ip];
|
||||||
|
|
||||||
|
glColor4f(col[0],col[1],col[2],0.25f);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
for (int i = 0; i < pd->ntris; ++i)
|
||||||
|
{
|
||||||
|
const unsigned char* t = &header->dtris[(pd->tbase+i)*4];
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
if (t[j] < p->nv)
|
||||||
|
glVertex3fv(&header->verts[p->v[t[j]]*3]);
|
||||||
|
else
|
||||||
|
glVertex3fv(&header->dverts[(pd->vbase+t[j]-p->nv)*3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
1530
Detour/Source/DetourNavMesh.cpp
Normal file
1530
Detour/Source/DetourNavMesh.cpp
Normal file
File diff suppressed because it is too large
Load Diff
408
Detour/Source/DetourNavMeshBuilder.cpp
Normal file
408
Detour/Source/DetourNavMeshBuilder.cpp
Normal file
@ -0,0 +1,408 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "DetourNavMesh.h"
|
||||||
|
#include "DetourCommon.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct BVItem
|
||||||
|
{
|
||||||
|
unsigned short bmin[3];
|
||||||
|
unsigned short bmax[3];
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int compareItemX(const void* va, const void* vb)
|
||||||
|
{
|
||||||
|
const BVItem* a = (const BVItem*)va;
|
||||||
|
const BVItem* b = (const BVItem*)vb;
|
||||||
|
if (a->bmin[0] < b->bmin[0])
|
||||||
|
return -1;
|
||||||
|
if (a->bmin[0] > b->bmin[0])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compareItemY(const void* va, const void* vb)
|
||||||
|
{
|
||||||
|
const BVItem* a = (const BVItem*)va;
|
||||||
|
const BVItem* b = (const BVItem*)vb;
|
||||||
|
if (a->bmin[1] < b->bmin[1])
|
||||||
|
return -1;
|
||||||
|
if (a->bmin[1] > b->bmin[1])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compareItemZ(const void* va, const void* vb)
|
||||||
|
{
|
||||||
|
const BVItem* a = (const BVItem*)va;
|
||||||
|
const BVItem* b = (const BVItem*)vb;
|
||||||
|
if (a->bmin[2] < b->bmin[2])
|
||||||
|
return -1;
|
||||||
|
if (a->bmin[2] > b->bmin[2])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void calcExtends(BVItem* items, int nitems, int imin, int imax,
|
||||||
|
unsigned short* bmin, unsigned short* bmax)
|
||||||
|
{
|
||||||
|
bmin[0] = items[imin].bmin[0];
|
||||||
|
bmin[1] = items[imin].bmin[1];
|
||||||
|
bmin[2] = items[imin].bmin[2];
|
||||||
|
|
||||||
|
bmax[0] = items[imin].bmax[0];
|
||||||
|
bmax[1] = items[imin].bmax[1];
|
||||||
|
bmax[2] = items[imin].bmax[2];
|
||||||
|
|
||||||
|
for (int i = imin+1; i < imax; ++i)
|
||||||
|
{
|
||||||
|
const BVItem& it = items[i];
|
||||||
|
if (it.bmin[0] < bmin[0]) bmin[0] = it.bmin[0];
|
||||||
|
if (it.bmin[1] < bmin[1]) bmin[1] = it.bmin[1];
|
||||||
|
if (it.bmin[2] < bmin[2]) bmin[2] = it.bmin[2];
|
||||||
|
|
||||||
|
if (it.bmax[0] > bmax[0]) bmax[0] = it.bmax[0];
|
||||||
|
if (it.bmax[1] > bmax[1]) bmax[1] = it.bmax[1];
|
||||||
|
if (it.bmax[2] > bmax[2]) bmax[2] = it.bmax[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int longestAxis(unsigned short x, unsigned short y, unsigned short z)
|
||||||
|
{
|
||||||
|
int axis = 0;
|
||||||
|
unsigned short maxVal = x;
|
||||||
|
if (y > maxVal)
|
||||||
|
{
|
||||||
|
axis = 1;
|
||||||
|
maxVal = y;
|
||||||
|
}
|
||||||
|
if (z > maxVal)
|
||||||
|
{
|
||||||
|
axis = 2;
|
||||||
|
maxVal = z;
|
||||||
|
}
|
||||||
|
return axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void subdivide(BVItem* items, int nitems, int imin, int imax, int& curNode, dtBVNode* nodes)
|
||||||
|
{
|
||||||
|
int inum = imax - imin;
|
||||||
|
int icur = curNode;
|
||||||
|
|
||||||
|
dtBVNode& node = nodes[curNode++];
|
||||||
|
|
||||||
|
if (inum == 1)
|
||||||
|
{
|
||||||
|
// Leaf
|
||||||
|
node.bmin[0] = items[imin].bmin[0];
|
||||||
|
node.bmin[1] = items[imin].bmin[1];
|
||||||
|
node.bmin[2] = items[imin].bmin[2];
|
||||||
|
|
||||||
|
node.bmax[0] = items[imin].bmax[0];
|
||||||
|
node.bmax[1] = items[imin].bmax[1];
|
||||||
|
node.bmax[2] = items[imin].bmax[2];
|
||||||
|
|
||||||
|
node.i = items[imin].i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Split
|
||||||
|
calcExtends(items, nitems, imin, imax, node.bmin, node.bmax);
|
||||||
|
|
||||||
|
int axis = longestAxis(node.bmax[0] - node.bmin[0],
|
||||||
|
node.bmax[1] - node.bmin[1],
|
||||||
|
node.bmax[2] - node.bmin[2]);
|
||||||
|
|
||||||
|
if (axis == 0)
|
||||||
|
{
|
||||||
|
// Sort along x-axis
|
||||||
|
qsort(items+imin, inum, sizeof(BVItem), compareItemX);
|
||||||
|
}
|
||||||
|
else if (axis == 1)
|
||||||
|
{
|
||||||
|
// Sort along y-axis
|
||||||
|
qsort(items+imin, inum, sizeof(BVItem), compareItemY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Sort along z-axis
|
||||||
|
qsort(items+imin, inum, sizeof(BVItem), compareItemZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
int isplit = imin+inum/2;
|
||||||
|
|
||||||
|
// Left
|
||||||
|
subdivide(items, nitems, imin, isplit, curNode, nodes);
|
||||||
|
// Right
|
||||||
|
subdivide(items, nitems, isplit, imax, curNode, nodes);
|
||||||
|
|
||||||
|
int iescape = curNode - icur;
|
||||||
|
// Negative index means escape.
|
||||||
|
node.i = -iescape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int createBVTree(const unsigned short* verts, const int nverts,
|
||||||
|
const unsigned short* polys, const int npolys, const int nvp,
|
||||||
|
float cs, float ch,
|
||||||
|
int nnodes, dtBVNode* nodes)
|
||||||
|
{
|
||||||
|
// Build tree
|
||||||
|
BVItem* items = new BVItem[npolys];
|
||||||
|
for (int i = 0; i < npolys; i++)
|
||||||
|
{
|
||||||
|
BVItem& it = items[i];
|
||||||
|
it.i = i;
|
||||||
|
// Calc polygon bounds.
|
||||||
|
const unsigned short* p = &polys[i*nvp*2];
|
||||||
|
it.bmin[0] = it.bmax[0] = verts[p[0]*3+0];
|
||||||
|
it.bmin[1] = it.bmax[1] = verts[p[0]*3+1];
|
||||||
|
it.bmin[2] = it.bmax[2] = verts[p[0]*3+2];
|
||||||
|
|
||||||
|
for (int j = 1; j < nvp; ++j)
|
||||||
|
{
|
||||||
|
if (p[j] == 0xffff) break;
|
||||||
|
unsigned short x = verts[p[j]*3+0];
|
||||||
|
unsigned short y = verts[p[j]*3+1];
|
||||||
|
unsigned short z = verts[p[j]*3+2];
|
||||||
|
|
||||||
|
if (x < it.bmin[0]) it.bmin[0] = x;
|
||||||
|
if (y < it.bmin[1]) it.bmin[1] = y;
|
||||||
|
if (z < it.bmin[2]) it.bmin[2] = z;
|
||||||
|
|
||||||
|
if (x > it.bmax[0]) it.bmax[0] = x;
|
||||||
|
if (y > it.bmax[1]) it.bmax[1] = y;
|
||||||
|
if (z > it.bmax[2]) it.bmax[2] = z;
|
||||||
|
}
|
||||||
|
// Remap y
|
||||||
|
it.bmin[1] = (unsigned short)floorf((float)it.bmin[1]*ch/cs);
|
||||||
|
it.bmax[1] = (unsigned short)ceilf((float)it.bmax[1]*ch/cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int curNode = 0;
|
||||||
|
subdivide(items, npolys, 0, npolys, curNode, nodes);
|
||||||
|
|
||||||
|
delete [] items;
|
||||||
|
|
||||||
|
return curNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dtCreateNavMeshData(const unsigned short* verts, const int nverts,
|
||||||
|
const unsigned short* polys, const int npolys, const int nvp,
|
||||||
|
const unsigned short* dmeshes, const float* dverts, const int ndverts,
|
||||||
|
const unsigned char* dtris, const int ndtris,
|
||||||
|
const float* bmin, const float* bmax, float cs, float ch, int tileSize, int walkableClimb,
|
||||||
|
unsigned char** outData, int* outDataSize)
|
||||||
|
{
|
||||||
|
if (nvp != DT_VERTS_PER_POLYGON)
|
||||||
|
return false;
|
||||||
|
if (nverts >= 0xffff)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!nverts)
|
||||||
|
return false;
|
||||||
|
if (!npolys)
|
||||||
|
return false;
|
||||||
|
if (!dmeshes || !dverts || ! dtris)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Find portal edges which are at tile borders.
|
||||||
|
int nedges = 0;
|
||||||
|
int nportals = 0;
|
||||||
|
for (int i = 0; i < npolys; ++i)
|
||||||
|
{
|
||||||
|
const unsigned short* p = &polys[i*2*nvp];
|
||||||
|
for (int j = 0; j < nvp; ++j)
|
||||||
|
{
|
||||||
|
if (p[j] == 0xffff) break;
|
||||||
|
int nj = j+1;
|
||||||
|
if (nj >= nvp || p[nj] == 0xffff) nj = 0;
|
||||||
|
const unsigned short* va = &verts[p[j]*3];
|
||||||
|
const unsigned short* vb = &verts[p[nj]*3];
|
||||||
|
|
||||||
|
nedges++;
|
||||||
|
|
||||||
|
if (va[0] == tileSize && vb[0] == tileSize)
|
||||||
|
nportals++; // x+
|
||||||
|
else if (va[2] == tileSize && vb[2] == tileSize)
|
||||||
|
nportals++; // z+
|
||||||
|
else if (va[0] == 0 && vb[0] == 0)
|
||||||
|
nportals++; // x-
|
||||||
|
else if (va[2] == 0 && vb[2] == 0)
|
||||||
|
nportals++; // z-
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int maxLinks = nedges + nportals*2;
|
||||||
|
|
||||||
|
|
||||||
|
// Find unique detail vertices.
|
||||||
|
int uniqueDetailVerts = 0;
|
||||||
|
if (dmeshes)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < npolys; ++i)
|
||||||
|
{
|
||||||
|
const unsigned short* p = &polys[i*nvp*2];
|
||||||
|
int ndv = dmeshes[i*4+1];
|
||||||
|
int nv = 0;
|
||||||
|
for (int j = 0; j < nvp; ++j)
|
||||||
|
{
|
||||||
|
if (p[j] == 0xffff) break;
|
||||||
|
nv++;
|
||||||
|
}
|
||||||
|
ndv -= nv;
|
||||||
|
uniqueDetailVerts += ndv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate data size
|
||||||
|
const int headerSize = align4(sizeof(dtMeshHeader));
|
||||||
|
const int vertsSize = align4(sizeof(float)*3*nverts);
|
||||||
|
const int polysSize = align4(sizeof(dtPoly)*npolys);
|
||||||
|
const int linksSize = align4(sizeof(dtLink)*maxLinks);
|
||||||
|
const int detailMeshesSize = align4(sizeof(dtPolyDetail)*npolys);
|
||||||
|
const int detailVertsSize = align4(sizeof(float)*3*uniqueDetailVerts);
|
||||||
|
const int detailTrisSize = align4(sizeof(unsigned char)*4*ndtris);
|
||||||
|
const int bvtreeSize = align4(sizeof(dtBVNode)*npolys*2);
|
||||||
|
|
||||||
|
const int dataSize = headerSize + vertsSize + polysSize + linksSize +
|
||||||
|
detailMeshesSize + detailVertsSize + detailTrisSize + bvtreeSize;
|
||||||
|
unsigned char* data = new unsigned char[dataSize];
|
||||||
|
if (!data)
|
||||||
|
return false;
|
||||||
|
memset(data, 0, dataSize);
|
||||||
|
|
||||||
|
unsigned char* d = data;
|
||||||
|
dtMeshHeader* header = (dtMeshHeader*)d; d += headerSize;
|
||||||
|
float* navVerts = (float*)d; d += vertsSize;
|
||||||
|
dtPoly* navPolys = (dtPoly*)d; d += polysSize;
|
||||||
|
d += linksSize;
|
||||||
|
dtPolyDetail* navDMeshes = (dtPolyDetail*)d; d += detailMeshesSize;
|
||||||
|
float* navDVerts = (float*)d; d += detailVertsSize;
|
||||||
|
unsigned char* navDTris = (unsigned char*)d; d += detailTrisSize;
|
||||||
|
dtBVNode* navBvtree = (dtBVNode*)d; d += bvtreeSize;
|
||||||
|
|
||||||
|
|
||||||
|
// Store header
|
||||||
|
header->magic = DT_NAVMESH_MAGIC;
|
||||||
|
header->version = DT_NAVMESH_VERSION;
|
||||||
|
header->npolys = npolys;
|
||||||
|
header->nverts = nverts;
|
||||||
|
header->maxlinks = maxLinks;
|
||||||
|
header->bmin[0] = bmin[0];
|
||||||
|
header->bmin[1] = bmin[1];
|
||||||
|
header->bmin[2] = bmin[2];
|
||||||
|
header->bmax[0] = bmax[0];
|
||||||
|
header->bmax[1] = bmax[1];
|
||||||
|
header->bmax[2] = bmax[2];
|
||||||
|
header->ndmeshes = npolys;
|
||||||
|
header->ndverts = uniqueDetailVerts;
|
||||||
|
header->ndtris = ndtris;
|
||||||
|
header->bvquant = 1.0f/cs;
|
||||||
|
|
||||||
|
// Store vertices
|
||||||
|
for (int i = 0; i < nverts; ++i)
|
||||||
|
{
|
||||||
|
const unsigned short* iv = &verts[i*3];
|
||||||
|
float* v = &navVerts[i*3];
|
||||||
|
v[0] = bmin[0] + iv[0] * cs;
|
||||||
|
v[1] = bmin[1] + iv[1] * ch;
|
||||||
|
v[2] = bmin[2] + iv[2] * cs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store polygons
|
||||||
|
const unsigned short* src = polys;
|
||||||
|
for (int i = 0; i < npolys; ++i)
|
||||||
|
{
|
||||||
|
dtPoly* p = &navPolys[i];
|
||||||
|
p->nv = 0;
|
||||||
|
for (int j = 0; j < nvp; ++j)
|
||||||
|
{
|
||||||
|
if (src[j] == 0xffff) break;
|
||||||
|
p->v[j] = src[j];
|
||||||
|
p->n[j] = (src[nvp+j]+1) & 0xffff;
|
||||||
|
p->nv++;
|
||||||
|
}
|
||||||
|
src += nvp*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store portal edges.
|
||||||
|
for (int i = 0; i < npolys; ++i)
|
||||||
|
{
|
||||||
|
dtPoly* poly = &navPolys[i];
|
||||||
|
for (int j = 0; j < poly->nv; ++j)
|
||||||
|
{
|
||||||
|
int nj = j+1;
|
||||||
|
if (nj >= poly->nv) nj = 0;
|
||||||
|
|
||||||
|
const unsigned short* va = &verts[poly->v[j]*3];
|
||||||
|
const unsigned short* vb = &verts[poly->v[nj]*3];
|
||||||
|
|
||||||
|
if (va[0] == tileSize && vb[0] == tileSize) // x+
|
||||||
|
poly->n[j] = 0x8000 | 0;
|
||||||
|
else if (va[2] == tileSize && vb[2] == tileSize) // z+
|
||||||
|
poly->n[j] = 0x8000 | 1;
|
||||||
|
else if (va[0] == 0 && vb[0] == 0) // x-
|
||||||
|
poly->n[j] = 0x8000 | 2;
|
||||||
|
else if (va[2] == 0 && vb[2] == 0) // z-
|
||||||
|
poly->n[j] = 0x8000 | 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store detail meshes and vertices.
|
||||||
|
// The nav polygon vertices are stored as the first vertices on each mesh.
|
||||||
|
// We compress the mesh data by skipping them and using the navmesh coordinates.
|
||||||
|
unsigned short vbase = 0;
|
||||||
|
for (int i = 0; i < npolys; ++i)
|
||||||
|
{
|
||||||
|
dtPolyDetail& dtl = navDMeshes[i];
|
||||||
|
const int vb = dmeshes[i*4+0];
|
||||||
|
const int ndv = dmeshes[i*4+1];
|
||||||
|
const int nv = navPolys[i].nv;
|
||||||
|
dtl.vbase = vbase;
|
||||||
|
dtl.nverts = ndv-nv;
|
||||||
|
dtl.tbase = dmeshes[i*4+2];
|
||||||
|
dtl.ntris = dmeshes[i*4+3];
|
||||||
|
// Copy vertices except the first 'nv' verts which are equal to nav poly verts.
|
||||||
|
if (ndv-nv)
|
||||||
|
{
|
||||||
|
memcpy(&navDVerts[vbase*3], &dverts[(vb+nv)*3], sizeof(float)*3*(ndv-nv));
|
||||||
|
vbase += ndv-nv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Store triangles.
|
||||||
|
memcpy(navDTris, dtris, sizeof(unsigned char)*4*ndtris);
|
||||||
|
|
||||||
|
// Store and create BVtree.
|
||||||
|
// TODO: take detail mesh into account! use byte per bbox extent?
|
||||||
|
header->nbvtree = createBVTree(verts, nverts, polys, npolys, nvp,
|
||||||
|
cs, ch, npolys*2, navBvtree);
|
||||||
|
|
||||||
|
*outData = data;
|
||||||
|
*outDataSize = dataSize;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -279,14 +279,14 @@
|
|||||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||||
<array>
|
<array>
|
||||||
<array>
|
<array>
|
||||||
<integer>11</integer>
|
<integer>9</integer>
|
||||||
<integer>3</integer>
|
<integer>3</integer>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</array>
|
</array>
|
||||||
</array>
|
</array>
|
||||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||||
<string>{{0, 35}, {282, 660}}</string>
|
<string>{{0, 39}, {282, 660}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>PBXTopSmartGroupGIDs</key>
|
<key>PBXTopSmartGroupGIDs</key>
|
||||||
<array/>
|
<array/>
|
||||||
@ -321,7 +321,7 @@
|
|||||||
<key>PBXProjectModuleGUID</key>
|
<key>PBXProjectModuleGUID</key>
|
||||||
<string>6B8632A30F78115100E2684A</string>
|
<string>6B8632A30F78115100E2684A</string>
|
||||||
<key>PBXProjectModuleLabel</key>
|
<key>PBXProjectModuleLabel</key>
|
||||||
<string>DetourTileNavMesh.cpp</string>
|
<string>DetourDebugDraw.cpp</string>
|
||||||
<key>PBXSplitModuleInNavigatorKey</key>
|
<key>PBXSplitModuleInNavigatorKey</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Split0</key>
|
<key>Split0</key>
|
||||||
@ -329,11 +329,11 @@
|
|||||||
<key>PBXProjectModuleGUID</key>
|
<key>PBXProjectModuleGUID</key>
|
||||||
<string>6B8632A40F78115100E2684A</string>
|
<string>6B8632A40F78115100E2684A</string>
|
||||||
<key>PBXProjectModuleLabel</key>
|
<key>PBXProjectModuleLabel</key>
|
||||||
<string>DetourTileNavMesh.cpp</string>
|
<string>DetourDebugDraw.cpp</string>
|
||||||
<key>_historyCapacity</key>
|
<key>_historyCapacity</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>bookmark</key>
|
<key>bookmark</key>
|
||||||
<string>6B8DE88110B68A7500DF20FB</string>
|
<string>6B8DEA7C10B6CFC900DF20FB</string>
|
||||||
<key>history</key>
|
<key>history</key>
|
||||||
<array>
|
<array>
|
||||||
<string>6B3BFADD107A80E1006284CD</string>
|
<string>6B3BFADD107A80E1006284CD</string>
|
||||||
@ -341,37 +341,45 @@
|
|||||||
<string>6B57D358108C66B200DDD053</string>
|
<string>6B57D358108C66B200DDD053</string>
|
||||||
<string>6B57D38F108C69E400DDD053</string>
|
<string>6B57D38F108C69E400DDD053</string>
|
||||||
<string>6B7FB74D1091EBDE001BA51A</string>
|
<string>6B7FB74D1091EBDE001BA51A</string>
|
||||||
<string>6B8DE6FE10B01BBF00DF20FB</string>
|
|
||||||
<string>6B8DE70110B01BBF00DF20FB</string>
|
<string>6B8DE70110B01BBF00DF20FB</string>
|
||||||
<string>6B8DE70310B01BBF00DF20FB</string>
|
|
||||||
<string>6B8DE70410B01BBF00DF20FB</string>
|
|
||||||
<string>6B8DE70710B01BBF00DF20FB</string>
|
|
||||||
<string>6B8DE70A10B01BBF00DF20FB</string>
|
<string>6B8DE70A10B01BBF00DF20FB</string>
|
||||||
<string>6B8DE70B10B01BBF00DF20FB</string>
|
<string>6B8DE70B10B01BBF00DF20FB</string>
|
||||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||||
<string>6B8DE76D10B0243500DF20FB</string>
|
<string>6B8DE76D10B0243500DF20FB</string>
|
||||||
<string>6B8DE7F110B0517A00DF20FB</string>
|
<string>6B8DE7F110B0517A00DF20FB</string>
|
||||||
<string>6B8DE7F310B0517A00DF20FB</string>
|
<string>6B8DE7F310B0517A00DF20FB</string>
|
||||||
<string>6B8DE7F410B0517A00DF20FB</string>
|
|
||||||
<string>6B8DE7F510B0517A00DF20FB</string>
|
|
||||||
<string>6B8DE7F610B0517A00DF20FB</string>
|
|
||||||
<string>6B8DE7F710B0517A00DF20FB</string>
|
<string>6B8DE7F710B0517A00DF20FB</string>
|
||||||
<string>6B8DE7F810B0517A00DF20FB</string>
|
<string>6B8DE7F810B0517A00DF20FB</string>
|
||||||
<string>6B8DE81F10B0528100DF20FB</string>
|
|
||||||
<string>6B8DE82010B0528100DF20FB</string>
|
|
||||||
<string>6B8DE84910B0584400DF20FB</string>
|
<string>6B8DE84910B0584400DF20FB</string>
|
||||||
<string>6B8DE84A10B0584400DF20FB</string>
|
<string>6B8DE84A10B0584400DF20FB</string>
|
||||||
<string>6B8DE85110B6873400DF20FB</string>
|
|
||||||
<string>6B8DE85210B6873400DF20FB</string>
|
<string>6B8DE85210B6873400DF20FB</string>
|
||||||
<string>6B8DE85C10B6899100DF20FB</string>
|
<string>6B8DE85C10B6899100DF20FB</string>
|
||||||
<string>6B8DE86B10B68A1300DF20FB</string>
|
<string>6B8DE89910B6B3F800DF20FB</string>
|
||||||
<string>6B8DE86C10B68A1300DF20FB</string>
|
<string>6B8DE89A10B6B3F800DF20FB</string>
|
||||||
<string>6B8DE86D10B68A1300DF20FB</string>
|
<string>6B8DE89B10B6B3F800DF20FB</string>
|
||||||
<string>6B8DE86E10B68A1300DF20FB</string>
|
<string>6B8DE8A110B6B3F800DF20FB</string>
|
||||||
<string>6B8DE87A10B68A7500DF20FB</string>
|
<string>6B8DE8E710B6B59A00DF20FB</string>
|
||||||
<string>6B8DE87B10B68A7500DF20FB</string>
|
<string>6B8DE8E910B6B59A00DF20FB</string>
|
||||||
<string>6B8DE87C10B68A7500DF20FB</string>
|
<string>6B8DE8EA10B6B59A00DF20FB</string>
|
||||||
<string>6B8DE87D10B68A7500DF20FB</string>
|
<string>6B8DE8FD10B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE92D10B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE98B10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE98C10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE98D10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE98E10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE98F10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DEA0110B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA0310B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA3610B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA3810B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA4010B6CC0400DF20FB</string>
|
||||||
|
<string>6B8DEA6410B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6510B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6610B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6710B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA7710B6CFC900DF20FB</string>
|
||||||
|
<string>6B8DEA7810B6CFC900DF20FB</string>
|
||||||
|
<string>6B8DEA7910B6CFC900DF20FB</string>
|
||||||
</array>
|
</array>
|
||||||
<key>prevStack</key>
|
<key>prevStack</key>
|
||||||
<array>
|
<array>
|
||||||
@ -506,6 +514,196 @@
|
|||||||
<string>6B8DE87E10B68A7500DF20FB</string>
|
<string>6B8DE87E10B68A7500DF20FB</string>
|
||||||
<string>6B8DE87F10B68A7500DF20FB</string>
|
<string>6B8DE87F10B68A7500DF20FB</string>
|
||||||
<string>6B8DE88010B68A7500DF20FB</string>
|
<string>6B8DE88010B68A7500DF20FB</string>
|
||||||
|
<string>6B8DE8A310B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A410B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A510B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A610B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A710B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A810B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8A910B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AA10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AB10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AC10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AD10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AE10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8AF10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B010B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B110B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B210B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B310B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B410B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B510B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B610B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B710B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B810B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8B910B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BA10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BB10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BC10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BD10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BE10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8BF10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C010B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C110B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C210B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C310B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C410B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C510B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C610B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C710B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C810B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8C910B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CA10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CB10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CC10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CD10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CE10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8CF10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D010B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D110B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D210B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D310B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D410B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D510B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D610B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D710B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8D810B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8EC10B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE8ED10B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE8EE10B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE8EF10B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE8F010B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE8F110B6B59A00DF20FB</string>
|
||||||
|
<string>6B8DE90010B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90110B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90210B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90310B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90410B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90510B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90610B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90710B6B76800DF20FB</string>
|
||||||
|
<string>6B8DE90D10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE90E10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE90F10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91010B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91110B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91210B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91310B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91410B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91510B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91610B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91710B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91810B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91910B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91A10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91B10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91C10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91D10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91E10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE91F10B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE92010B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE92110B6BAD500DF20FB</string>
|
||||||
|
<string>6B8DE93110B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93210B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93310B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93410B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93510B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93610B6BCDA00DF20FB</string>
|
||||||
|
<string>6B8DE93D10B6BD1E00DF20FB</string>
|
||||||
|
<string>6B8DE94A10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE94B10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE94C10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE94D10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE94E10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE94F10B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95010B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95110B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95210B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95310B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95410B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95F10B6BF0100DF20FB</string>
|
||||||
|
<string>6B8DE96010B6BF0100DF20FB</string>
|
||||||
|
<string>6B8DE96B10B6BF6100DF20FB</string>
|
||||||
|
<string>6B8DE97610B6C04900DF20FB</string>
|
||||||
|
<string>6B8DE97710B6C04900DF20FB</string>
|
||||||
|
<string>6B8DE97810B6C04900DF20FB</string>
|
||||||
|
<string>6B8DE99410B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99510B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99610B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99710B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99810B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99910B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99A10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99B10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99C10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99D10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99E10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE99F10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A010B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A110B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A210B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A310B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A410B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A510B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A610B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A710B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A810B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9A910B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AA10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AB10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AC10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AD10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AE10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9AF10B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B010B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B110B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B210B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B310B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B410B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B510B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9B610B6C53B00DF20FB</string>
|
||||||
|
<string>6B8DE9BD10B6C61D00DF20FB</string>
|
||||||
|
<string>6B8DE9C510B6C64100DF20FB</string>
|
||||||
|
<string>6B8DE9D010B6C75600DF20FB</string>
|
||||||
|
<string>6B8DE9D610B6C7DD00DF20FB</string>
|
||||||
|
<string>6B8DE9DB10B6C83E00DF20FB</string>
|
||||||
|
<string>6B8DE9E410B6C8BE00DF20FB</string>
|
||||||
|
<string>6B8DE9E510B6C8BE00DF20FB</string>
|
||||||
|
<string>6B8DE9EC10B6C97B00DF20FB</string>
|
||||||
|
<string>6B8DE9ED10B6C97B00DF20FB</string>
|
||||||
|
<string>6B8DE9EE10B6C97B00DF20FB</string>
|
||||||
|
<string>6B8DE9F710B6C9B700DF20FB</string>
|
||||||
|
<string>6B8DE9F810B6C9B700DF20FB</string>
|
||||||
|
<string>6B8DEA0510B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA0610B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA0710B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA0810B6CA1500DF20FB</string>
|
||||||
|
<string>6B8DEA1010B6CAAD00DF20FB</string>
|
||||||
|
<string>6B8DEA1710B6CAF600DF20FB</string>
|
||||||
|
<string>6B8DEA1810B6CAF600DF20FB</string>
|
||||||
|
<string>6B8DEA2310B6CB3000DF20FB</string>
|
||||||
|
<string>6B8DEA2D10B6CB8A00DF20FB</string>
|
||||||
|
<string>6B8DEA2E10B6CB8A00DF20FB</string>
|
||||||
|
<string>6B8DEA2F10B6CB8A00DF20FB</string>
|
||||||
|
<string>6B8DEA3A10B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA3B10B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA3C10B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA3D10B6CBC200DF20FB</string>
|
||||||
|
<string>6B8DEA4310B6CC0400DF20FB</string>
|
||||||
|
<string>6B8DEA4410B6CC0400DF20FB</string>
|
||||||
|
<string>6B8DEA4510B6CC0400DF20FB</string>
|
||||||
|
<string>6B8DEA4E10B6CC2600DF20FB</string>
|
||||||
|
<string>6B8DEA5210B6CC5500DF20FB</string>
|
||||||
|
<string>6B8DEA6910B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6A10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6B10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6C10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6D10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6E10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA6F10B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA7010B6CF6400DF20FB</string>
|
||||||
|
<string>6B8DEA7A10B6CFC900DF20FB</string>
|
||||||
|
<string>6B8DEA7B10B6CFC900DF20FB</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SplitCount</key>
|
<key>SplitCount</key>
|
||||||
@ -519,18 +717,18 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 0}, {976, 521}}</string>
|
<string>{{0, 0}, {976, 548}}</string>
|
||||||
<key>RubberWindowFrame</key>
|
<key>RubberWindowFrame</key>
|
||||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXNavigatorGroup</string>
|
<string>PBXNavigatorGroup</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>521pt</string>
|
<string>548pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>152pt</string>
|
<string>125pt</string>
|
||||||
<key>Tabs</key>
|
<key>Tabs</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
@ -544,7 +742,7 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{10, 27}, {976, -27}}</string>
|
<string>{{10, 27}, {976, 262}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>XCDetailModule</string>
|
<string>XCDetailModule</string>
|
||||||
@ -560,7 +758,9 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{10, 27}, {976, 175}}</string>
|
<string>{{10, 27}, {976, 98}}</string>
|
||||||
|
<key>RubberWindowFrame</key>
|
||||||
|
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXProjectFindModule</string>
|
<string>PBXProjectFindModule</string>
|
||||||
@ -598,9 +798,7 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{10, 27}, {976, 125}}</string>
|
<string>{{10, 27}, {976, 90}}</string>
|
||||||
<key>RubberWindowFrame</key>
|
|
||||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXBuildResultsModule</string>
|
<string>PBXBuildResultsModule</string>
|
||||||
@ -681,12 +879,12 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 0}, {1280, 305}}</string>
|
<string>{{0, 0}, {1280, 359}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXDebugCLIModule</string>
|
<string>PBXDebugCLIModule</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>305pt</string>
|
<string>359pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>ContentConfiguration</key>
|
<key>ContentConfiguration</key>
|
||||||
@ -705,8 +903,8 @@
|
|||||||
<string>yes</string>
|
<string>yes</string>
|
||||||
<key>sizes</key>
|
<key>sizes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>{{0, 0}, {620, 135}}</string>
|
<string>{{0, 0}, {620, 115}}</string>
|
||||||
<string>{{620, 0}, {660, 135}}</string>
|
<string>{{620, 0}, {660, 115}}</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<key>VerticalSplitView</key>
|
<key>VerticalSplitView</key>
|
||||||
@ -721,8 +919,8 @@
|
|||||||
<string>yes</string>
|
<string>yes</string>
|
||||||
<key>sizes</key>
|
<key>sizes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>{{0, 0}, {1280, 135}}</string>
|
<string>{{0, 0}, {1280, 115}}</string>
|
||||||
<string>{{0, 135}, {1280, 233}}</string>
|
<string>{{0, 115}, {1280, 199}}</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
@ -742,7 +940,7 @@
|
|||||||
<key>DebugSTDIOWindowFrame</key>
|
<key>DebugSTDIOWindowFrame</key>
|
||||||
<string>{{200, 200}, {500, 300}}</string>
|
<string>{{200, 200}, {500, 300}}</string>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 310}, {1280, 368}}</string>
|
<string>{{0, 364}, {1280, 314}}</string>
|
||||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>DebugVariablesTableConfiguration</key>
|
<key>DebugVariablesTableConfiguration</key>
|
||||||
@ -755,13 +953,13 @@
|
|||||||
<real>430</real>
|
<real>430</real>
|
||||||
</array>
|
</array>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{620, 0}, {660, 135}}</string>
|
<string>{{620, 0}, {660, 115}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXDebugSessionModule</string>
|
<string>PBXDebugSessionModule</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>368pt</string>
|
<string>314pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>Name</key>
|
<key>Name</key>
|
||||||
@ -816,6 +1014,9 @@
|
|||||||
<integer>5</integer>
|
<integer>5</integer>
|
||||||
<key>WindowOrderList</key>
|
<key>WindowOrderList</key>
|
||||||
<array>
|
<array>
|
||||||
|
<string>6B8DE95710B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE95810B6BEDB00DF20FB</string>
|
||||||
|
<string>6B8DE8DB10B6B3F800DF20FB</string>
|
||||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||||
</array>
|
</array>
|
||||||
<key>WindowString</key>
|
<key>WindowString</key>
|
||||||
@ -1465,22 +1666,40 @@
|
|||||||
<string>100 100 700 500 0 0 1280 1002 </string>
|
<string>100 100 700 500 0 0 1280 1002 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>FirstTimeWindowDisplayed</key>
|
||||||
|
<false/>
|
||||||
<key>Identifier</key>
|
<key>Identifier</key>
|
||||||
<string>windowTool.bookmarks</string>
|
<string>windowTool.bookmarks</string>
|
||||||
|
<key>IsVertical</key>
|
||||||
|
<true/>
|
||||||
<key>Layout</key>
|
<key>Layout</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Dock</key>
|
<key>Dock</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>ContentConfiguration</key>
|
||||||
|
<dict>
|
||||||
|
<key>PBXProjectModuleGUID</key>
|
||||||
|
<string>6B8DE8DA10B6B3F800DF20FB</string>
|
||||||
|
<key>PBXProjectModuleLabel</key>
|
||||||
|
<string>Bookmarks</string>
|
||||||
|
</dict>
|
||||||
|
<key>GeometryConfiguration</key>
|
||||||
|
<dict>
|
||||||
|
<key>Frame</key>
|
||||||
|
<string>{{0, 0}, {401, 202}}</string>
|
||||||
|
<key>RubberWindowFrame</key>
|
||||||
|
<string>21 533 401 222 0 0 1280 778 </string>
|
||||||
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXBookmarksModule</string>
|
<string>PBXBookmarksModule</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>166pt</string>
|
<string>202pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>166pt</string>
|
<string>202pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>Name</key>
|
<key>Name</key>
|
||||||
@ -1490,9 +1709,19 @@
|
|||||||
<string>PBXBookmarksModule</string>
|
<string>PBXBookmarksModule</string>
|
||||||
</array>
|
</array>
|
||||||
<key>StatusbarIsVisible</key>
|
<key>StatusbarIsVisible</key>
|
||||||
<integer>0</integer>
|
<false/>
|
||||||
|
<key>TableOfContents</key>
|
||||||
|
<array>
|
||||||
|
<string>6B8DE8DB10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8DC10B6B3F800DF20FB</string>
|
||||||
|
<string>6B8DE8DA10B6B3F800DF20FB</string>
|
||||||
|
</array>
|
||||||
<key>WindowString</key>
|
<key>WindowString</key>
|
||||||
<string>538 42 401 187 0 0 1280 1002 </string>
|
<string>21 533 401 222 0 0 1280 778 </string>
|
||||||
|
<key>WindowToolGUID</key>
|
||||||
|
<string>6B8DE8DB10B6B3F800DF20FB</string>
|
||||||
|
<key>WindowToolIsVisible</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Identifier</key>
|
<key>Identifier</key>
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B624169103434880002E346 /* RecastMeshDetail.cpp */; };
|
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B624169103434880002E346 /* RecastMeshDetail.cpp */; };
|
||||||
6B8632DA0F78122C00E2684A /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632D90F78122C00E2684A /* SDL.framework */; };
|
6B8632DA0F78122C00E2684A /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632D90F78122C00E2684A /* SDL.framework */; };
|
||||||
6B8632DC0F78123E00E2684A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632DB0F78123E00E2684A /* OpenGL.framework */; };
|
6B8632DC0F78123E00E2684A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632DB0F78123E00E2684A /* OpenGL.framework */; };
|
||||||
|
6B8DE88910B69E3E00DF20FB /* DetourNavMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */; };
|
||||||
|
6B8DE88A10B69E3E00DF20FB /* DetourNavMeshBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; };
|
||||||
|
6B8DE8F810B6B70E00DF20FB /* Sample_DynMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE8F710B6B70E00DF20FB /* Sample_DynMesh.cpp */; };
|
||||||
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */; };
|
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */; };
|
||||||
6BDD9E0A0F91113800904EEF /* DetourDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */; };
|
6BDD9E0A0F91113800904EEF /* DetourDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */; };
|
||||||
6BDD9E0B0F91113800904EEF /* DetourStatNavMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDD9E080F91113800904EEF /* DetourStatNavMesh.cpp */; };
|
6BDD9E0B0F91113800904EEF /* DetourStatNavMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDD9E080F91113800904EEF /* DetourStatNavMesh.cpp */; };
|
||||||
@ -96,6 +99,12 @@
|
|||||||
6B624169103434880002E346 /* RecastMeshDetail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastMeshDetail.cpp; path = ../../../Recast/Source/RecastMeshDetail.cpp; sourceTree = SOURCE_ROOT; };
|
6B624169103434880002E346 /* RecastMeshDetail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastMeshDetail.cpp; path = ../../../Recast/Source/RecastMeshDetail.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
6B8632D90F78122C00E2684A /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = Library/Frameworks/SDL.framework; sourceTree = SDKROOT; };
|
6B8632D90F78122C00E2684A /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = Library/Frameworks/SDL.framework; sourceTree = SDKROOT; };
|
||||||
6B8632DB0F78123E00E2684A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
6B8632DB0F78123E00E2684A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
||||||
|
6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourNavMesh.cpp; path = ../../../Detour/Source/DetourNavMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
|
6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourNavMeshBuilder.cpp; path = ../../../Detour/Source/DetourNavMeshBuilder.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
|
6B8DE88B10B69E4C00DF20FB /* DetourNavMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourNavMesh.h; path = ../../../Detour/Include/DetourNavMesh.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
6B8DE88C10B69E4C00DF20FB /* DetourNavMeshBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourNavMeshBuilder.h; path = ../../../Detour/Include/DetourNavMeshBuilder.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
6B8DE8F610B6B70100DF20FB /* Sample_DynMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_DynMesh.h; path = ../../Include/Sample_DynMesh.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
6B8DE8F710B6B70E00DF20FB /* Sample_DynMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_DynMesh.cpp; path = ../../Source/Sample_DynMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChunkyTriMesh.cpp; path = ../../Source/ChunkyTriMesh.cpp; sourceTree = SOURCE_ROOT; };
|
6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChunkyTriMesh.cpp; path = ../../Source/ChunkyTriMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
6BB788180FC04753003C24DB /* ChunkyTriMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChunkyTriMesh.h; path = ../../Include/ChunkyTriMesh.h; sourceTree = SOURCE_ROOT; };
|
6BB788180FC04753003C24DB /* ChunkyTriMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChunkyTriMesh.h; path = ../../Include/ChunkyTriMesh.h; sourceTree = SOURCE_ROOT; };
|
||||||
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourDebugDraw.h; path = ../../../Detour/Include/DetourDebugDraw.h; sourceTree = SOURCE_ROOT; };
|
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourDebugDraw.h; path = ../../../Detour/Include/DetourDebugDraw.h; sourceTree = SOURCE_ROOT; };
|
||||||
@ -238,6 +247,8 @@
|
|||||||
children = (
|
children = (
|
||||||
6B25B6100FFA62AD004F1BC4 /* Sample.h */,
|
6B25B6100FFA62AD004F1BC4 /* Sample.h */,
|
||||||
6B25B6140FFA62BE004F1BC4 /* Sample.cpp */,
|
6B25B6140FFA62BE004F1BC4 /* Sample.cpp */,
|
||||||
|
6B8DE8F610B6B70100DF20FB /* Sample_DynMesh.h */,
|
||||||
|
6B8DE8F710B6B70E00DF20FB /* Sample_DynMesh.cpp */,
|
||||||
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */,
|
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */,
|
||||||
6B2AEC520FFB8958005BE9CC /* Sample_TileMesh.cpp */,
|
6B2AEC520FFB8958005BE9CC /* Sample_TileMesh.cpp */,
|
||||||
6B2AEC570FFB89F4005BE9CC /* Sample_StatMeshTiled.h */,
|
6B2AEC570FFB89F4005BE9CC /* Sample_StatMeshTiled.h */,
|
||||||
@ -253,6 +264,10 @@
|
|||||||
6BDD9E030F91110C00904EEF /* Detour */ = {
|
6BDD9E030F91110C00904EEF /* Detour */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
6B8DE88B10B69E4C00DF20FB /* DetourNavMesh.h */,
|
||||||
|
6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */,
|
||||||
|
6B8DE88C10B69E4C00DF20FB /* DetourNavMeshBuilder.h */,
|
||||||
|
6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */,
|
||||||
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */,
|
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */,
|
||||||
6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */,
|
6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */,
|
||||||
6BDD9E050F91112200904EEF /* DetourStatNavMesh.h */,
|
6BDD9E050F91112200904EEF /* DetourStatNavMesh.h */,
|
||||||
@ -355,6 +370,9 @@
|
|||||||
6B1185FE10068B150018F96F /* DetourCommon.cpp in Sources */,
|
6B1185FE10068B150018F96F /* DetourCommon.cpp in Sources */,
|
||||||
6B555DB1100B212E00247EA3 /* imguiRenderGL.cpp in Sources */,
|
6B555DB1100B212E00247EA3 /* imguiRenderGL.cpp in Sources */,
|
||||||
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */,
|
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */,
|
||||||
|
6B8DE88910B69E3E00DF20FB /* DetourNavMesh.cpp in Sources */,
|
||||||
|
6B8DE88A10B69E3E00DF20FB /* DetourNavMeshBuilder.cpp in Sources */,
|
||||||
|
6B8DE8F810B6B70E00DF20FB /* Sample_DynMesh.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
114
RecastDemo/Include/Sample_DynMesh.h
Normal file
114
RecastDemo/Include/Sample_DynMesh.h
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef RECASTSAMPLEDYNMESH_H
|
||||||
|
#define RECASTSAMPLEDYNMESH_H
|
||||||
|
|
||||||
|
#include "Sample.h"
|
||||||
|
#include "DetourNavMesh.h"
|
||||||
|
#include "Recast.h"
|
||||||
|
#include "RecastLog.h"
|
||||||
|
#include "ChunkyTriMesh.h"
|
||||||
|
|
||||||
|
class Sample_DynMesh : public Sample
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool m_keepInterResults;
|
||||||
|
rcBuildTimes m_buildTimes;
|
||||||
|
|
||||||
|
dtNavMesh* m_navMesh;
|
||||||
|
rcChunkyTriMesh* m_chunkyMesh;
|
||||||
|
unsigned char* m_triflags;
|
||||||
|
rcHeightfield* m_solid;
|
||||||
|
rcCompactHeightfield* m_chf;
|
||||||
|
rcContourSet* m_cset;
|
||||||
|
rcPolyMesh* m_pmesh;
|
||||||
|
rcPolyMeshDetail* m_dmesh;
|
||||||
|
rcConfig m_cfg;
|
||||||
|
|
||||||
|
float m_tileSize;
|
||||||
|
|
||||||
|
float m_spos[3];
|
||||||
|
float m_epos[3];
|
||||||
|
bool m_sposSet;
|
||||||
|
bool m_eposSet;
|
||||||
|
|
||||||
|
float m_tileCol[4];
|
||||||
|
float m_tileBmin[3];
|
||||||
|
float m_tileBmax[3];
|
||||||
|
float m_tileBuildTime;
|
||||||
|
float m_tileMemUsage;
|
||||||
|
int m_tileTriCount;
|
||||||
|
|
||||||
|
enum ToolMode
|
||||||
|
{
|
||||||
|
TOOLMODE_CREATE_TILES,
|
||||||
|
TOOLMODE_PATHFIND,
|
||||||
|
TOOLMODE_RAYCAST,
|
||||||
|
TOOLMODE_DISTANCE_TO_WALL,
|
||||||
|
TOOLMODE_FIND_POLYS_AROUND,
|
||||||
|
};
|
||||||
|
|
||||||
|
dtPolyRef m_startRef;
|
||||||
|
dtPolyRef m_endRef;
|
||||||
|
float m_polyPickExt[3];
|
||||||
|
|
||||||
|
static const int MAX_POLYS = 256;
|
||||||
|
|
||||||
|
dtPolyRef m_polys[MAX_POLYS];
|
||||||
|
dtPolyRef m_parent[MAX_POLYS];
|
||||||
|
int m_npolys;
|
||||||
|
float m_straightPath[MAX_POLYS*3];
|
||||||
|
int m_nstraightPath;
|
||||||
|
float m_hitPos[3];
|
||||||
|
float m_hitNormal[3];
|
||||||
|
float m_distanceToWall;
|
||||||
|
|
||||||
|
ToolMode m_toolMode;
|
||||||
|
|
||||||
|
void toolRecalc();
|
||||||
|
|
||||||
|
void buildTile(const float* pos);
|
||||||
|
void removeTile(const float* pos);
|
||||||
|
|
||||||
|
unsigned char* buildTileMesh(const float* bmin, const float* bmax, int& dataSize);
|
||||||
|
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Sample_DynMesh();
|
||||||
|
virtual ~Sample_DynMesh();
|
||||||
|
|
||||||
|
virtual void handleSettings();
|
||||||
|
virtual void handleTools();
|
||||||
|
virtual void handleDebugMode();
|
||||||
|
|
||||||
|
virtual void setToolStartPos(const float* p);
|
||||||
|
virtual void setToolEndPos(const float* p);
|
||||||
|
|
||||||
|
virtual void handleRender();
|
||||||
|
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||||
|
virtual void handleMeshChanged(const float* verts, int nverts,
|
||||||
|
const int* tris, const float* trinorms, int ntris,
|
||||||
|
const float* bmin, const float* bmax);
|
||||||
|
virtual bool handleBuild();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // RECASTSAMPLEDYNMESH_H
|
931
RecastDemo/Source/Sample_DynMesh.cpp
Normal file
931
RecastDemo/Source/Sample_DynMesh.cpp
Normal file
@ -0,0 +1,931 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "SDL_opengl.h"
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "Sample.h"
|
||||||
|
#include "Sample_DynMesh.h"
|
||||||
|
#include "Recast.h"
|
||||||
|
#include "RecastTimer.h"
|
||||||
|
#include "RecastDebugDraw.h"
|
||||||
|
#include "DetourNavMesh.h"
|
||||||
|
#include "DetourNavMeshBuilder.h"
|
||||||
|
#include "DetourDebugDraw.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Sample_DynMesh::Sample_DynMesh() :
|
||||||
|
m_keepInterResults(false),
|
||||||
|
m_navMesh(0),
|
||||||
|
m_chunkyMesh(0),
|
||||||
|
m_triflags(0),
|
||||||
|
m_solid(0),
|
||||||
|
m_chf(0),
|
||||||
|
m_cset(0),
|
||||||
|
m_pmesh(0),
|
||||||
|
m_dmesh(0),
|
||||||
|
m_tileSize(32),
|
||||||
|
m_sposSet(false),
|
||||||
|
m_eposSet(false),
|
||||||
|
m_tileBuildTime(0),
|
||||||
|
m_tileMemUsage(0),
|
||||||
|
m_tileTriCount(0),
|
||||||
|
m_startRef(0),
|
||||||
|
m_endRef(0),
|
||||||
|
m_npolys(0),
|
||||||
|
m_nstraightPath(0),
|
||||||
|
m_distanceToWall(0),
|
||||||
|
m_toolMode(TOOLMODE_CREATE_TILES)
|
||||||
|
{
|
||||||
|
resetCommonSettings();
|
||||||
|
memset(m_tileBmin, 0, sizeof(m_tileBmin));
|
||||||
|
memset(m_tileBmax, 0, sizeof(m_tileBmax));
|
||||||
|
m_polyPickExt[0] = 2;
|
||||||
|
m_polyPickExt[1] = 4;
|
||||||
|
m_polyPickExt[2] = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample_DynMesh::~Sample_DynMesh()
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
delete m_navMesh;
|
||||||
|
delete m_chunkyMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::cleanup()
|
||||||
|
{
|
||||||
|
delete [] m_triflags;
|
||||||
|
m_triflags = 0;
|
||||||
|
delete m_solid;
|
||||||
|
m_solid = 0;
|
||||||
|
delete m_chf;
|
||||||
|
m_chf = 0;
|
||||||
|
delete m_cset;
|
||||||
|
m_cset = 0;
|
||||||
|
delete m_pmesh;
|
||||||
|
m_pmesh = 0;
|
||||||
|
delete m_dmesh;
|
||||||
|
m_dmesh = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleSettings()
|
||||||
|
{
|
||||||
|
Sample::handleCommonSettings();
|
||||||
|
|
||||||
|
imguiLabel("Tiling");
|
||||||
|
imguiSlider("TileSize", &m_tileSize, 16.0f, 1024.0f, 16.0f);
|
||||||
|
|
||||||
|
char text[64];
|
||||||
|
int gw = 0, gh = 0;
|
||||||
|
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||||
|
const int ts = (int)m_tileSize;
|
||||||
|
const int tw = (gw + ts-1) / ts;
|
||||||
|
const int th = (gh + ts-1) / ts;
|
||||||
|
snprintf(text, 64, "Tiles %d x %d", tw, th);
|
||||||
|
imguiValue(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::toolRecalc()
|
||||||
|
{
|
||||||
|
m_startRef = 0;
|
||||||
|
if (m_sposSet)
|
||||||
|
m_startRef = m_navMesh->findNearestPoly(m_spos, m_polyPickExt);
|
||||||
|
|
||||||
|
m_endRef = 0;
|
||||||
|
if (m_eposSet)
|
||||||
|
m_endRef = m_navMesh->findNearestPoly(m_epos, m_polyPickExt);
|
||||||
|
|
||||||
|
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||||
|
{
|
||||||
|
if (m_sposSet && m_eposSet && m_startRef && m_endRef)
|
||||||
|
{
|
||||||
|
m_npolys = m_navMesh->findPath(m_startRef, m_endRef, m_spos, m_epos, m_polys, MAX_POLYS);
|
||||||
|
if (m_npolys)
|
||||||
|
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys, m_straightPath, MAX_POLYS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_npolys = 0;
|
||||||
|
m_nstraightPath = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||||
|
{
|
||||||
|
m_nstraightPath = 0;
|
||||||
|
if (m_sposSet && m_eposSet && m_startRef)
|
||||||
|
{
|
||||||
|
float t = 0;
|
||||||
|
m_npolys = 0;
|
||||||
|
m_nstraightPath = 2;
|
||||||
|
m_straightPath[0] = m_spos[0];
|
||||||
|
m_straightPath[1] = m_spos[1];
|
||||||
|
m_straightPath[2] = m_spos[2];
|
||||||
|
m_npolys = m_navMesh->raycast(m_startRef, m_spos, m_epos, t, m_polys, MAX_POLYS);
|
||||||
|
if (m_npolys && t < 1)
|
||||||
|
{
|
||||||
|
m_straightPath[3] = m_spos[0] + (m_epos[0] - m_spos[0]) * t;
|
||||||
|
m_straightPath[4] = m_spos[1] + (m_epos[1] - m_spos[1]) * t;
|
||||||
|
m_straightPath[5] = m_spos[2] + (m_epos[2] - m_spos[2]) * t;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_straightPath[3] = m_epos[0];
|
||||||
|
m_straightPath[4] = m_epos[1];
|
||||||
|
m_straightPath[5] = m_epos[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||||
|
{
|
||||||
|
m_distanceToWall = 0;
|
||||||
|
if (m_sposSet && m_startRef)
|
||||||
|
m_distanceToWall = m_navMesh->findDistanceToWall(m_startRef, m_spos, 100.0f, m_hitPos, m_hitNormal);
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||||
|
{
|
||||||
|
if (m_sposSet && m_startRef && m_eposSet)
|
||||||
|
{
|
||||||
|
const float dx = m_epos[0] - m_spos[0];
|
||||||
|
const float dz = m_epos[2] - m_spos[2];
|
||||||
|
float dist = sqrtf(dx*dx + dz*dz);
|
||||||
|
m_npolys = m_navMesh->findPolysAround(m_startRef, m_spos, dist, m_polys, m_parent, 0, MAX_POLYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleTools()
|
||||||
|
{
|
||||||
|
if (imguiCheck("Create Tiles", m_toolMode == TOOLMODE_CREATE_TILES))
|
||||||
|
{
|
||||||
|
m_toolMode = TOOLMODE_CREATE_TILES;
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
if (imguiCheck("Pathfind", m_toolMode == TOOLMODE_PATHFIND))
|
||||||
|
{
|
||||||
|
m_toolMode = TOOLMODE_PATHFIND;
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
if (imguiCheck("Distance to Wall", m_toolMode == TOOLMODE_DISTANCE_TO_WALL))
|
||||||
|
{
|
||||||
|
m_toolMode = TOOLMODE_DISTANCE_TO_WALL;
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
if (imguiCheck("Raycast", m_toolMode == TOOLMODE_RAYCAST))
|
||||||
|
{
|
||||||
|
m_toolMode = TOOLMODE_RAYCAST;
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
if (imguiCheck("Find Polys Around", m_toolMode == TOOLMODE_FIND_POLYS_AROUND))
|
||||||
|
{
|
||||||
|
m_toolMode = TOOLMODE_FIND_POLYS_AROUND;
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
if (imguiButton("Create All"))
|
||||||
|
{
|
||||||
|
int gw = 0, gh = 0;
|
||||||
|
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||||
|
const int ts = (int)m_tileSize;
|
||||||
|
const int tw = (gw + ts-1) / ts;
|
||||||
|
const int th = (gh + ts-1) / ts;
|
||||||
|
const float tcs = m_tileSize*m_cellSize;
|
||||||
|
|
||||||
|
for (int y = 0; y < th; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < tw; ++x)
|
||||||
|
{
|
||||||
|
m_tileBmin[0] = m_bmin[0] + x*tcs;
|
||||||
|
m_tileBmin[1] = m_bmin[1];
|
||||||
|
m_tileBmin[2] = m_bmin[2] + y*tcs;
|
||||||
|
|
||||||
|
m_tileBmax[0] = m_bmin[0] + (x+1)*tcs;
|
||||||
|
m_tileBmax[1] = m_bmax[1];
|
||||||
|
m_tileBmax[2] = m_bmin[2] + (y+1)*tcs;
|
||||||
|
|
||||||
|
int dataSize = 0;
|
||||||
|
unsigned char* data = buildTileMesh(m_tileBmin, m_tileBmax, dataSize);
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
// Remove any previous data (navmesh owns and deletes the data).
|
||||||
|
m_navMesh->removeTileAt(x,y,0,0);
|
||||||
|
// Let the navmesh own the data.
|
||||||
|
if (!m_navMesh->addTileAt(x,y,data,dataSize,true))
|
||||||
|
delete [] data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleDebugMode()
|
||||||
|
{
|
||||||
|
if (m_navMesh)
|
||||||
|
{
|
||||||
|
imguiValue("Navmesh ready.");
|
||||||
|
imguiValue("Use 'Create Tiles' tool to experiment.");
|
||||||
|
imguiValue("LMB: (Re)Create tiles.");
|
||||||
|
imguiValue("LMB+SHIFT: Remove tiles.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||||
|
{
|
||||||
|
const dtPoly* p = navMesh->getPolyByRef(ref);
|
||||||
|
if (!p) return;
|
||||||
|
const float* verts = navMesh->getPolyVertsByRef(ref);
|
||||||
|
center[0] = 0;
|
||||||
|
center[1] = 0;
|
||||||
|
center[2] = 0;
|
||||||
|
for (int i = 0; i < (int)p->nv; ++i)
|
||||||
|
{
|
||||||
|
const float* v = &verts[p->v[i]*3];
|
||||||
|
center[0] += v[0];
|
||||||
|
center[1] += v[1];
|
||||||
|
center[2] += v[2];
|
||||||
|
}
|
||||||
|
const float s = 1.0f / p->nv;
|
||||||
|
center[0] *= s;
|
||||||
|
center[1] *= s;
|
||||||
|
center[2] *= s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleRender()
|
||||||
|
{
|
||||||
|
if (!m_verts || !m_tris || !m_trinorms)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DebugDrawGL dd;
|
||||||
|
|
||||||
|
// Draw mesh
|
||||||
|
if (m_navMesh)
|
||||||
|
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||||
|
else
|
||||||
|
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||||
|
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
// Draw bounds
|
||||||
|
float col[4] = {1,1,1,0.5f};
|
||||||
|
rcDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
|
||||||
|
|
||||||
|
// Tiling grid.
|
||||||
|
const int ts = (int)m_tileSize;
|
||||||
|
int gw = 0, gh = 0;
|
||||||
|
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||||
|
int tw = (gw + ts-1) / ts;
|
||||||
|
int th = (gh + ts-1) / ts;
|
||||||
|
const float s = ts*m_cellSize;
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glColor4ub(0,0,0,64);
|
||||||
|
for (int y = 0; y < th; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < tw; ++x)
|
||||||
|
{
|
||||||
|
float fx, fy, fz;
|
||||||
|
fx = m_bmin[0] + x*s;
|
||||||
|
fy = m_bmin[1];
|
||||||
|
fz = m_bmin[2] + y*s;
|
||||||
|
|
||||||
|
glVertex3f(fx,fy,fz);
|
||||||
|
glVertex3f(fx+s,fy,fz);
|
||||||
|
glVertex3f(fx,fy,fz);
|
||||||
|
glVertex3f(fx,fy,fz+s);
|
||||||
|
|
||||||
|
if (x+1 >= tw)
|
||||||
|
{
|
||||||
|
glVertex3f(fx+s,fy,fz);
|
||||||
|
glVertex3f(fx+s,fy,fz+s);
|
||||||
|
}
|
||||||
|
if (y+1 >= th)
|
||||||
|
{
|
||||||
|
glVertex3f(fx,fy,fz+s);
|
||||||
|
glVertex3f(fx+s,fy,fz+s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Draw active tile
|
||||||
|
rcDebugDrawBoxWire(&dd, m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol);
|
||||||
|
|
||||||
|
if (m_navMesh)
|
||||||
|
dtDebugDrawNavMesh(m_navMesh);
|
||||||
|
|
||||||
|
if (m_sposSet)
|
||||||
|
{
|
||||||
|
const float s = 0.5f;
|
||||||
|
glColor4ub(64,16,0,255);
|
||||||
|
glLineWidth(3.0f);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex3f(m_spos[0]-s,m_spos[1]+m_cellHeight,m_spos[2]);
|
||||||
|
glVertex3f(m_spos[0]+s,m_spos[1]+m_cellHeight,m_spos[2]);
|
||||||
|
glVertex3f(m_spos[0],m_spos[1]-s+m_cellHeight,m_spos[2]);
|
||||||
|
glVertex3f(m_spos[0],m_spos[1]+s+m_cellHeight,m_spos[2]);
|
||||||
|
glVertex3f(m_spos[0],m_spos[1]+m_cellHeight,m_spos[2]-s);
|
||||||
|
glVertex3f(m_spos[0],m_spos[1]+m_cellHeight,m_spos[2]+s);
|
||||||
|
glEnd();
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
}
|
||||||
|
if (m_eposSet)
|
||||||
|
{
|
||||||
|
const float s = 0.5f;
|
||||||
|
glColor4ub(16,64,0,255);
|
||||||
|
glLineWidth(3.0f);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex3f(m_epos[0]-s,m_epos[1]+m_cellHeight,m_epos[2]);
|
||||||
|
glVertex3f(m_epos[0]+s,m_epos[1]+m_cellHeight,m_epos[2]);
|
||||||
|
glVertex3f(m_epos[0],m_epos[1]-s+m_cellHeight,m_epos[2]);
|
||||||
|
glVertex3f(m_epos[0],m_epos[1]+s+m_cellHeight,m_epos[2]);
|
||||||
|
glVertex3f(m_epos[0],m_epos[1]+m_cellHeight,m_epos[2]-s);
|
||||||
|
glVertex3f(m_epos[0],m_epos[1]+m_cellHeight,m_epos[2]+s);
|
||||||
|
glEnd();
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||||
|
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||||
|
static const float pathCol[4] = {0,0,0,0.25f};
|
||||||
|
|
||||||
|
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||||
|
{
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_endRef, endCol);
|
||||||
|
|
||||||
|
if (m_npolys)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < m_npolys-1; ++i)
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
|
||||||
|
}
|
||||||
|
if (m_nstraightPath)
|
||||||
|
{
|
||||||
|
glColor4ub(64,16,0,220);
|
||||||
|
glLineWidth(3.0f);
|
||||||
|
glBegin(GL_LINE_STRIP);
|
||||||
|
for (int i = 0; i < m_nstraightPath; ++i)
|
||||||
|
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||||
|
glEnd();
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
glPointSize(4.0f);
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
for (int i = 0; i < m_nstraightPath; ++i)
|
||||||
|
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||||
|
glEnd();
|
||||||
|
glPointSize(1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||||
|
{
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||||
|
|
||||||
|
if (m_nstraightPath)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < m_npolys; ++i)
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
|
||||||
|
|
||||||
|
glColor4ub(64,16,0,220);
|
||||||
|
glLineWidth(3.0f);
|
||||||
|
glBegin(GL_LINE_STRIP);
|
||||||
|
for (int i = 0; i < m_nstraightPath; ++i)
|
||||||
|
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||||
|
glEnd();
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
glPointSize(4.0f);
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
for (int i = 0; i < m_nstraightPath; ++i)
|
||||||
|
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||||
|
glEnd();
|
||||||
|
glPointSize(1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||||
|
{
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||||
|
const float col[4] = {1,1,1,0.5f};
|
||||||
|
rcDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
|
||||||
|
m_spos[0]+m_distanceToWall, m_spos[1]+m_agentHeight, m_spos[2]+m_distanceToWall, col);
|
||||||
|
glLineWidth(3.0f);
|
||||||
|
glColor4fv(col);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.02f, m_hitPos[2]);
|
||||||
|
glVertex3f(m_hitPos[0], m_hitPos[1] + m_agentHeight, m_hitPos[2]);
|
||||||
|
glEnd();
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
}
|
||||||
|
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||||
|
{
|
||||||
|
const float cola[4] = {0,0,0,0.5f};
|
||||||
|
for (int i = 0; i < m_npolys; ++i)
|
||||||
|
{
|
||||||
|
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
|
||||||
|
if (m_parent[i])
|
||||||
|
{
|
||||||
|
float p0[3], p1[3];
|
||||||
|
getPolyCenter(m_navMesh, m_polys[i], p0);
|
||||||
|
getPolyCenter(m_navMesh, m_parent[i], p1);
|
||||||
|
glColor4ub(0,0,0,128);
|
||||||
|
rcDrawArc(&dd, p0, p1, cola, 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const float dx = m_epos[0] - m_spos[0];
|
||||||
|
const float dz = m_epos[2] - m_spos[2];
|
||||||
|
float dist = sqrtf(dx*dx + dz*dz);
|
||||||
|
const float col[4] = {1,1,1,0.5f};
|
||||||
|
rcDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
|
||||||
|
m_spos[0]+dist, m_spos[1]+m_agentHeight, m_spos[2]+dist, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleRenderOverlay(double* proj, double* model, int* view)
|
||||||
|
{
|
||||||
|
GLdouble x, y, z;
|
||||||
|
|
||||||
|
// Draw start and end point labels
|
||||||
|
if (m_tileBuildTime > 0.0f && gluProject((GLdouble)(m_tileBmin[0]+m_tileBmax[0])/2, (GLdouble)(m_tileBmin[1]+m_tileBmax[1])/2, (GLdouble)(m_tileBmin[2]+m_tileBmax[2])/2,
|
||||||
|
model, proj, view, &x, &y, &z))
|
||||||
|
{
|
||||||
|
char text[32];
|
||||||
|
snprintf(text,32,"%.3fms / %dTris / %.1fkB", m_tileBuildTime, m_tileTriCount, m_tileMemUsage);
|
||||||
|
imguiDrawText((int)x, (int)y-25, IMGUI_ALIGN_CENTER, text, imguiRGBA(0,0,0,220));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::handleMeshChanged(const float* verts, int nverts,
|
||||||
|
const int* tris, const float* trinorms, int ntris,
|
||||||
|
const float* bmin, const float* bmax)
|
||||||
|
{
|
||||||
|
m_verts = verts;
|
||||||
|
m_nverts = nverts;
|
||||||
|
m_tris = tris;
|
||||||
|
m_trinorms = trinorms;
|
||||||
|
m_ntris = ntris;
|
||||||
|
vcopy(m_bmin, bmin);
|
||||||
|
vcopy(m_bmax, bmax);
|
||||||
|
|
||||||
|
delete m_chunkyMesh;
|
||||||
|
m_chunkyMesh = 0;
|
||||||
|
delete m_navMesh;
|
||||||
|
m_navMesh = 0;
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::setToolStartPos(const float* p)
|
||||||
|
{
|
||||||
|
m_sposSet = true;
|
||||||
|
vcopy(m_spos, p);
|
||||||
|
|
||||||
|
if (m_toolMode == TOOLMODE_CREATE_TILES)
|
||||||
|
removeTile(m_spos);
|
||||||
|
else
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::setToolEndPos(const float* p)
|
||||||
|
{
|
||||||
|
if (!m_navMesh)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_eposSet = true;
|
||||||
|
vcopy(m_epos, p);
|
||||||
|
|
||||||
|
if (m_toolMode == TOOLMODE_CREATE_TILES)
|
||||||
|
buildTile(m_epos);
|
||||||
|
else
|
||||||
|
toolRecalc();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sample_DynMesh::handleBuild()
|
||||||
|
{
|
||||||
|
if (!m_verts || !m_tris)
|
||||||
|
{
|
||||||
|
printf("No verts or tris\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_navMesh;
|
||||||
|
m_navMesh = new dtNavMesh;
|
||||||
|
if (!m_navMesh)
|
||||||
|
{
|
||||||
|
printf("Could not allocate navmehs\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!m_navMesh->init(m_bmin, m_tileSize*m_cellSize, m_agentMaxClimb*m_cellHeight, 512, 512, 2048))
|
||||||
|
{
|
||||||
|
printf("Could not init navmesh\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build chunky mesh.
|
||||||
|
delete m_chunkyMesh;
|
||||||
|
m_chunkyMesh = new rcChunkyTriMesh;
|
||||||
|
if (!m_chunkyMesh)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'm_chunkyMesh'.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!rcCreateChunkyTriMesh(m_verts, m_tris, m_ntris, 256, m_chunkyMesh))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Could not build chunky mesh.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::buildTile(const float* pos)
|
||||||
|
{
|
||||||
|
if (!m_navMesh)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const float ts = m_tileSize*m_cellSize;
|
||||||
|
const int tx = (int)floorf((pos[0]-m_bmin[0]) / ts);
|
||||||
|
const int ty = (int)floorf((pos[2]-m_bmin[2]) / ts);
|
||||||
|
if (tx < 0 || ty < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_tileBmin[0] = m_bmin[0] + tx*ts;
|
||||||
|
m_tileBmin[1] = m_bmin[1];
|
||||||
|
m_tileBmin[2] = m_bmin[2] + ty*ts;
|
||||||
|
|
||||||
|
m_tileBmax[0] = m_bmin[0] + (tx+1)*ts;
|
||||||
|
m_tileBmax[1] = m_bmax[1];
|
||||||
|
m_tileBmax[2] = m_bmin[2] + (ty+1)*ts;
|
||||||
|
|
||||||
|
m_tileCol[0] = 0.3f; m_tileCol[1] = 0.8f; m_tileCol[2] = 0; m_tileCol[3] = 1;
|
||||||
|
|
||||||
|
int dataSize = 0;
|
||||||
|
unsigned char* data = buildTileMesh(m_tileBmin, m_tileBmax, dataSize);
|
||||||
|
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
// Remove any previous data (navmesh owns and deletes the data).
|
||||||
|
m_navMesh->removeTileAt(tx,ty,0,0);
|
||||||
|
|
||||||
|
// Let the navmesh own the data.
|
||||||
|
if (!m_navMesh->addTileAt(tx,ty,data,dataSize,true))
|
||||||
|
delete [] data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample_DynMesh::removeTile(const float* pos)
|
||||||
|
{
|
||||||
|
if (!m_navMesh)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const float ts = m_tileSize*m_cellSize;
|
||||||
|
const int tx = (int)floorf((pos[0]-m_bmin[0]) / ts);
|
||||||
|
const int ty = (int)floorf((pos[2]-m_bmin[2]) / ts);
|
||||||
|
|
||||||
|
m_tileBmin[0] = m_bmin[0] + tx*ts;
|
||||||
|
m_tileBmin[1] = m_bmin[1];
|
||||||
|
m_tileBmin[2] = m_bmin[2] + ty*ts;
|
||||||
|
|
||||||
|
m_tileBmax[0] = m_bmin[0] + (tx+1)*ts;
|
||||||
|
m_tileBmax[1] = m_bmax[1];
|
||||||
|
m_tileBmax[2] = m_bmin[2] + (ty+1)*ts;
|
||||||
|
|
||||||
|
m_tileCol[0] = 0.8f; m_tileCol[1] = 0.1f; m_tileCol[2] = 0; m_tileCol[3] = 1;
|
||||||
|
|
||||||
|
unsigned char* rdata = 0;
|
||||||
|
int rdataSize = 0;
|
||||||
|
if (m_navMesh->removeTileAt(tx,ty,&rdata,&rdataSize))
|
||||||
|
delete [] rdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* Sample_DynMesh::buildTileMesh(const float* bmin, const float* bmax, int& dataSize)
|
||||||
|
{
|
||||||
|
if (!m_verts || ! m_tris)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
// Init build configuration from GUI
|
||||||
|
memset(&m_cfg, 0, sizeof(m_cfg));
|
||||||
|
m_cfg.cs = m_cellSize;
|
||||||
|
m_cfg.ch = m_cellHeight;
|
||||||
|
m_cfg.walkableSlopeAngle = m_agentMaxSlope;
|
||||||
|
m_cfg.walkableHeight = (int)ceilf(m_agentHeight / m_cfg.ch);
|
||||||
|
m_cfg.walkableClimb = (int)ceilf(m_agentMaxClimb / m_cfg.ch);
|
||||||
|
m_cfg.walkableRadius = (int)ceilf(m_agentRadius / m_cfg.cs);
|
||||||
|
m_cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize);
|
||||||
|
m_cfg.maxSimplificationError = m_edgeMaxError;
|
||||||
|
m_cfg.minRegionSize = (int)rcSqr(m_regionMinSize);
|
||||||
|
m_cfg.mergeRegionSize = (int)rcSqr(m_regionMergeSize);
|
||||||
|
m_cfg.maxVertsPerPoly = (int)m_vertsPerPoly;
|
||||||
|
m_cfg.tileSize = (int)m_tileSize;
|
||||||
|
m_cfg.borderSize = m_cfg.walkableRadius + 3; // Reserve enough padding.
|
||||||
|
m_cfg.width = m_cfg.tileSize + m_cfg.borderSize*2;
|
||||||
|
m_cfg.height = m_cfg.tileSize + m_cfg.borderSize*2;
|
||||||
|
m_cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist;
|
||||||
|
m_cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError;
|
||||||
|
|
||||||
|
vcopy(m_cfg.bmin, bmin);
|
||||||
|
vcopy(m_cfg.bmax, bmax);
|
||||||
|
m_cfg.bmin[0] -= m_cfg.borderSize*m_cfg.cs;
|
||||||
|
m_cfg.bmin[2] -= m_cfg.borderSize*m_cfg.cs;
|
||||||
|
m_cfg.bmax[0] += m_cfg.borderSize*m_cfg.cs;
|
||||||
|
m_cfg.bmax[2] += m_cfg.borderSize*m_cfg.cs;
|
||||||
|
|
||||||
|
// Reset build times gathering.
|
||||||
|
memset(&m_buildTimes, 0, sizeof(m_buildTimes));
|
||||||
|
rcSetBuildTimes(&m_buildTimes);
|
||||||
|
|
||||||
|
// Start the build process.
|
||||||
|
rcTimeVal totStartTime = rcGetPerformanceTimer();
|
||||||
|
|
||||||
|
if (rcGetLog())
|
||||||
|
{
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Building navigation:");
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - %d x %d cells", m_cfg.width, m_cfg.height);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", m_nverts/1000.0f, m_ntris/1000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate voxel heighfield where we rasterize our input data to.
|
||||||
|
m_solid = new rcHeightfield;
|
||||||
|
if (!m_solid)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!rcCreateHeightfield(*m_solid, m_cfg.width, m_cfg.height, m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate array that can hold triangle flags.
|
||||||
|
// If you have multiple meshes you need to process, allocate
|
||||||
|
// and array which can hold the max number of triangles you need to process.
|
||||||
|
m_triflags = new unsigned char[m_chunkyMesh->maxTrisPerChunk];
|
||||||
|
if (!m_triflags)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'triangleFlags' (%d).", m_chunkyMesh->maxTrisPerChunk);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float tbmin[2], tbmax[2];
|
||||||
|
tbmin[0] = m_cfg.bmin[0];
|
||||||
|
tbmin[1] = m_cfg.bmin[2];
|
||||||
|
tbmax[0] = m_cfg.bmax[0];
|
||||||
|
tbmax[1] = m_cfg.bmax[2];
|
||||||
|
int cid[256];// TODO: Make grow when returning too many items.
|
||||||
|
const int ncid = rcGetChunksInRect(m_chunkyMesh, tbmin, tbmax, cid, 256);
|
||||||
|
if (!ncid)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
m_tileTriCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < ncid; ++i)
|
||||||
|
{
|
||||||
|
const rcChunkyTriMeshNode& node = m_chunkyMesh->nodes[cid[i]];
|
||||||
|
const int* tris = &m_chunkyMesh->tris[node.i*3];
|
||||||
|
const int ntris = node.n;
|
||||||
|
|
||||||
|
m_tileTriCount += ntris;
|
||||||
|
|
||||||
|
memset(m_triflags, 0, ntris*sizeof(unsigned char));
|
||||||
|
rcMarkWalkableTriangles(m_cfg.walkableSlopeAngle,
|
||||||
|
m_verts, m_nverts, tris, ntris, m_triflags);
|
||||||
|
|
||||||
|
rcRasterizeTriangles(m_verts, m_nverts, tris, m_triflags, ntris, *m_solid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_keepInterResults)
|
||||||
|
{
|
||||||
|
delete [] m_triflags;
|
||||||
|
m_triflags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once all geoemtry is rasterized, we do initial pass of filtering to
|
||||||
|
// remove unwanted overhangs caused by the conservative rasterization
|
||||||
|
// as well as filter spans where the character cannot possibly stand.
|
||||||
|
rcFilterLedgeSpans(m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
|
||||||
|
rcFilterWalkableLowHeightSpans(m_cfg.walkableHeight, *m_solid);
|
||||||
|
|
||||||
|
// Compact the heightfield so that it is faster to handle from now on.
|
||||||
|
// This will result more cache coherent data as well as the neighbours
|
||||||
|
// between walkable cells will be calculated.
|
||||||
|
m_chf = new rcCompactHeightfield;
|
||||||
|
if (!m_chf)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!rcBuildCompactHeightfield(m_cfg.walkableHeight, m_cfg.walkableClimb, RC_WALKABLE, *m_solid, *m_chf))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_keepInterResults)
|
||||||
|
{
|
||||||
|
delete m_solid;
|
||||||
|
m_solid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare for region partitioning, by calculating distance field along the walkable surface.
|
||||||
|
if (!rcBuildDistanceField(*m_chf))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Partition the walkable surface into simple regions without holes.
|
||||||
|
if (!rcBuildRegions(*m_chf, m_cfg.walkableRadius, m_cfg.borderSize, m_cfg.minRegionSize, m_cfg.mergeRegionSize))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not build regions.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create contours.
|
||||||
|
m_cset = new rcContourSet;
|
||||||
|
if (!m_cset)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!rcBuildContours(*m_chf, m_cfg.maxSimplificationError, m_cfg.maxEdgeLen, *m_cset))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not create contours.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_cset->nconts == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build polygon navmesh from the contours.
|
||||||
|
m_pmesh = new rcPolyMesh;
|
||||||
|
if (!m_pmesh)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!rcBuildPolyMesh(*m_cset, m_cfg.maxVertsPerPoly, *m_pmesh))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build detail mesh.
|
||||||
|
m_dmesh = new rcPolyMeshDetail;
|
||||||
|
if (!m_dmesh)
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'dmesh'.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rcBuildPolyMeshDetail(*m_pmesh, *m_chf,
|
||||||
|
m_cfg.detailSampleDist, m_cfg.detailSampleMaxError,
|
||||||
|
*m_dmesh))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could build polymesh detail.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_keepInterResults)
|
||||||
|
{
|
||||||
|
delete m_chf;
|
||||||
|
m_chf = 0;
|
||||||
|
delete m_cset;
|
||||||
|
m_cset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* navData = 0;
|
||||||
|
int navDataSize = 0;
|
||||||
|
if (m_cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON)
|
||||||
|
{
|
||||||
|
// Remove padding from the polymesh data. TODO: Remove this odditity.
|
||||||
|
for (int i = 0; i < m_pmesh->nverts; ++i)
|
||||||
|
{
|
||||||
|
unsigned short* v = &m_pmesh->verts[i*3];
|
||||||
|
v[0] -= (unsigned short)m_cfg.borderSize;
|
||||||
|
v[2] -= (unsigned short)m_cfg.borderSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pmesh->nverts >= 0xffff)
|
||||||
|
{
|
||||||
|
// The vertex indices are ushorts, and cannot point to more than 0xffff vertices.
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "Too many vertices per tile %d (max: %d).", m_pmesh->nverts, 0xffff);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* if (m_pmesh->npolys > DT_MAX_TILES)
|
||||||
|
{
|
||||||
|
// If you hit this error, you have too many polygons per tile.
|
||||||
|
// You can trade off tile count to poly count by adjusting DT_TILE_REF_TILE_BITS and DT_TILE_REF_POLY_BITS.
|
||||||
|
// The current setup is optimized for large number of tiles and small number of polys per tile.
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "Too many polygons per tile %d (max: %d).", m_pmesh->npolys, DT_MAX_TILES);
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (!dtCreateNavMeshData(m_pmesh->verts, m_pmesh->nverts,
|
||||||
|
m_pmesh->polys, m_pmesh->npolys, m_pmesh->nvp,
|
||||||
|
m_dmesh->meshes, m_dmesh->verts, m_dmesh->nverts, m_dmesh->tris, m_dmesh->ntris,
|
||||||
|
bmin, bmax, m_cfg.cs, m_cfg.ch, m_cfg.tileSize, m_cfg.walkableClimb, &navData, &navDataSize))
|
||||||
|
{
|
||||||
|
if (rcGetLog())
|
||||||
|
rcGetLog()->log(RC_LOG_ERROR, "Could not build Detour navmesh.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_tileMemUsage = navDataSize/1024.0f;
|
||||||
|
|
||||||
|
rcTimeVal totEndTime = rcGetPerformanceTimer();
|
||||||
|
|
||||||
|
// Show performance stats.
|
||||||
|
if (rcGetLog())
|
||||||
|
{
|
||||||
|
const float pc = 100.0f / rcGetDeltaTimeUsec(totStartTime, totEndTime);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Rasterize: %.1fms (%.1f%%)", m_buildTimes.rasterizeTriangles/1000.0f, m_buildTimes.rasterizeTriangles*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Compact: %.1fms (%.1f%%)", m_buildTimes.buildCompact/1000.0f, m_buildTimes.buildCompact*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Filter Border: %.1fms (%.1f%%)", m_buildTimes.filterBorder/1000.0f, m_buildTimes.filterBorder*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Filter Walkable: %.1fms (%.1f%%)", m_buildTimes.filterWalkable/1000.0f, m_buildTimes.filterWalkable*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Filter Reachable: %.1fms (%.1f%%)", m_buildTimes.filterMarkReachable/1000.0f, m_buildTimes.filterMarkReachable*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Distancefield: %.1fms (%.1f%%)", m_buildTimes.buildDistanceField/1000.0f, m_buildTimes.buildDistanceField*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - distance: %.1fms (%.1f%%)", m_buildTimes.buildDistanceFieldDist/1000.0f, m_buildTimes.buildDistanceFieldDist*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - blur: %.1fms (%.1f%%)", m_buildTimes.buildDistanceFieldBlur/1000.0f, m_buildTimes.buildDistanceFieldBlur*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Regions: %.1fms (%.1f%%)", m_buildTimes.buildRegions/1000.0f, m_buildTimes.buildRegions*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - watershed: %.1fms (%.1f%%)", m_buildTimes.buildRegionsReg/1000.0f, m_buildTimes.buildRegionsReg*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - expand: %.1fms (%.1f%%)", m_buildTimes.buildRegionsExp/1000.0f, m_buildTimes.buildRegionsExp*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - find catchment basins: %.1fms (%.1f%%)", m_buildTimes.buildRegionsFlood/1000.0f, m_buildTimes.buildRegionsFlood*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - filter: %.1fms (%.1f%%)", m_buildTimes.buildRegionsFilter/1000.0f, m_buildTimes.buildRegionsFilter*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Contours: %.1fms (%.1f%%)", m_buildTimes.buildContours/1000.0f, m_buildTimes.buildContours*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - trace: %.1fms (%.1f%%)", m_buildTimes.buildContoursTrace/1000.0f, m_buildTimes.buildContoursTrace*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, " - simplify: %.1fms (%.1f%%)", m_buildTimes.buildContoursSimplify/1000.0f, m_buildTimes.buildContoursSimplify*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Polymesh: %.1fms (%.1f%%)", m_buildTimes.buildPolymesh/1000.0f, m_buildTimes.buildPolymesh*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Polymesh Detail: %.1fms (%.1f%%)", m_buildTimes.buildDetailMesh/1000.0f, m_buildTimes.buildDetailMesh*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Merge Polymeshes: %.1fms (%.1f%%)", m_buildTimes.mergePolyMesh/1000.0f, m_buildTimes.mergePolyMesh*pc);
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Merge Polymesh Details: %.1fms (%.1f%%)", m_buildTimes.mergePolyMeshDetail/1000.0f, m_buildTimes.mergePolyMeshDetail*pc);
|
||||||
|
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Build Polymesh: %.1fms (%.1f%%)", m_buildTimes.buildPolymesh/1000.0f, m_buildTimes.buildPolymesh*pc);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "Polymesh: Verts:%d Polys:%d", m_pmesh->nverts, m_pmesh->npolys);
|
||||||
|
|
||||||
|
rcGetLog()->log(RC_LOG_PROGRESS, "TOTAL: %.1fms", rcGetDeltaTimeUsec(totStartTime, totEndTime)/1000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_tileBuildTime = rcGetDeltaTimeUsec(totStartTime, totEndTime)/1000.0f;
|
||||||
|
|
||||||
|
dataSize = navDataSize;
|
||||||
|
return navData;
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
#include "Sample_StatMeshSimple.h"
|
#include "Sample_StatMeshSimple.h"
|
||||||
#include "Sample_StatMeshTiled.h"
|
#include "Sample_StatMeshTiled.h"
|
||||||
#include "Sample_TileMesh.h"
|
#include "Sample_TileMesh.h"
|
||||||
|
#include "Sample_DynMesh.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# define snprintf _snprintf
|
# define snprintf _snprintf
|
||||||
@ -197,16 +198,17 @@ struct SampleItem
|
|||||||
Sample* createStatSimple() { return new Sample_StatMeshSimple(); }
|
Sample* createStatSimple() { return new Sample_StatMeshSimple(); }
|
||||||
Sample* createStatTiled() { return new Sample_StatMeshTiled(); }
|
Sample* createStatTiled() { return new Sample_StatMeshTiled(); }
|
||||||
Sample* createTile() { return new Sample_TileMesh(); }
|
Sample* createTile() { return new Sample_TileMesh(); }
|
||||||
|
Sample* createDyn() { return new Sample_DynMesh(); }
|
||||||
|
|
||||||
static SampleItem g_samples[] =
|
static SampleItem g_samples[] =
|
||||||
{
|
{
|
||||||
{ createStatSimple, "Static Mesh (Simple)" },
|
{ createStatSimple, "Static Mesh (Simple)" },
|
||||||
{ createStatTiled, "Static Mesh (Tiled)" },
|
{ createStatTiled, "Static Mesh (Tiled)" },
|
||||||
{ createTile, "Tile Mesh" },
|
{ createTile, "Tile Mesh" },
|
||||||
|
{ createDyn, "Dyn Mesh" },
|
||||||
};
|
};
|
||||||
static const int g_nsamples = sizeof(g_samples)/sizeof(SampleItem);
|
static const int g_nsamples = sizeof(g_samples)/sizeof(SampleItem);
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Init SDL
|
// Init SDL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user