533 printf(
"%s Building movemap tiles...\n", tileString.c_str());
535 IntermediateValues iv;
537 float* tVerts = meshData.solidVerts.getCArray();
538 int tVertCount = meshData.solidVerts.size() / 3;
539 int* tTris = meshData.solidTris.getCArray();
540 int tTriCount = meshData.solidTris.size() / 3;
542 float* lVerts = meshData.liquidVerts.getCArray();
543 int lVertCount = meshData.liquidVerts.size() / 3;
544 int* lTris = meshData.liquidTris.getCArray();
545 int lTriCount = meshData.liquidTris.size() / 3;
546 uint8* lTriFlags = meshData.liquidType.getCArray();
551 const static float BASE_UNIT_DIM =
m_bigBaseUnit ? 0.5333333f : 0.2666666f;
554 const static int VERTEX_PER_MAP = int(
GRID_SIZE/BASE_UNIT_DIM + 0.5f);
556 const static int TILES_PER_MAP = VERTEX_PER_MAP/VERTEX_PER_TILE;
559 memset(&config, 0,
sizeof(
rcConfig));
565 config.
cs = BASE_UNIT_DIM;
566 config.
ch = BASE_UNIT_DIM;
586 Tile* tiles =
new Tile[TILES_PER_MAP * TILES_PER_MAP];
598 for (
int y = 0;
y < TILES_PER_MAP; ++
y)
600 for (
int x = 0;
x < TILES_PER_MAP; ++
x)
602 Tile& tile = tiles[
x +
y * TILES_PER_MAP];
614 printf(
"%s Failed building heightfield! \n", tileString.c_str());
619 unsigned char* triFlags =
new unsigned char[tTriCount];
620 memset(triFlags,
NAV_GROUND, tTriCount*
sizeof(
unsigned char));
635 printf(
"%s Failed compacting heightfield! \n", tileString.c_str());
642 printf(
"%s Failed eroding area! \n", tileString.c_str());
648 printf(
"%s Failed building distance field! \n", tileString.c_str());
654 printf(
"%s Failed building regions! \n", tileString.c_str());
661 printf(
"%s Failed building contours! \n", tileString.c_str());
669 printf(
"%s Failed building polymesh! \n", tileString.c_str());
676 printf(
"%s Failed building polymesh detail! \n", tileString.c_str());
690 pmmerge[nmerge] = tile.pmesh;
691 dmmerge[nmerge] = tile.dmesh;
699 printf(
"%s alloc iv.polyMesh FAILED!\n", tileString.c_str());
708 if (!iv.polyMeshDetail)
710 printf(
"%s alloc m_dmesh FAILED!\n", tileString.c_str());
725 for (
int i = 0; i < iv.polyMesh->npolys; ++i)
727 iv.polyMesh->flags[i] = iv.polyMesh->areas[i];
731 memset(¶ms, 0,
sizeof(params));
732 params.
verts = iv.polyMesh->verts;
734 params.
polys = iv.polyMesh->polys;
738 params.
nvp = iv.polyMesh->nvp;
747 params.
offMeshConRad = meshData.offMeshConnectionRads.getCArray();
748 params.
offMeshConDir = meshData.offMeshConnectionDirs.getCArray();
759 params.
cs = config.
cs;
760 params.
ch = config.
ch;
765 unsigned char* navData =
NULL;
774 printf(
"%s Invalid verts-per-polygon value! \n", tileString.c_str());
779 printf(
"%s Too many vertices! \n", tileString.c_str());
792 TILES_PER_MAP*TILES_PER_MAP == params.
polyCount)
797 printf(
"%s No polygons to build on tile! \n", tileString.c_str());
802 printf(
"%s No detail mesh to build tile! \n", tileString.c_str());
806 printf(
"%s Building navmesh tile...\n", tileString.c_str());
809 printf(
"%s Failed building navmesh tile! \n", tileString.c_str());
814 printf(
"%s Adding tile to navmesh...\n", tileString.c_str());
820 printf(
"%s Failed adding tile to navmesh! \n", tileString.c_str());
826 sprintf(fileName,
"mmaps/%04u%02i%02i.mmtile", mapID, tileY, tileX);
827 FILE* file = fopen(fileName,
"wb");
831 sprintf(message,
"[Map %04u] Failed to open %s for writing!\n", mapID, fileName);
837 printf(
"%s Writing to file...\n", tileString.c_str());
842 header.size =
uint32(navDataSize);
846 fwrite(navData,
sizeof(
unsigned char), navDataSize, file);
857 for (
int i = 0; i < iv.polyMesh->nverts; ++i)
859 unsigned short* v = &iv.polyMesh->verts[i*3];
864 iv.generateObjFile(mapID, tileX, tileY, meshData);
865 iv.writeIV(mapID, tileX, tileY);
bool rcBuildPolyMeshDetail(rcContext *ctx, const rcPolyMesh &mesh, const rcCompactHeightfield &chf, const float sampleDist, const float sampleMaxError, rcPolyMeshDetail &dmesh)
Definition: RecastMeshDetail.cpp:1117
int tileLayer
The tile's layer within the layered destination mesh. Limit: >= 0
Definition: DetourNavMeshBuilder.h:86
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:104
bool usesLiquids()
Definition: TerrainBuilder.h:88
rcCompactHeightfield * rcAllocCompactHeightfield()
Definition: Recast.cpp:95
float detailSampleMaxError
Definition: Recast.h:242
void rcFreeCompactHeightfield(rcCompactHeightfield *chf)
Definition: Recast.cpp:102
float cs
The xz-plane cell size of the polygon mesh. [Limit: > 0] [Unit: wu].
Definition: DetourNavMeshBuilder.h:97
uint64_d dtTileRef
Definition: DetourNavMesh.h:53
Definition: MapDefines.h:25
const unsigned char * offMeshConDir
Definition: DetourNavMeshBuilder.h:72
int walkableRadius
Definition: Recast.h:216
const unsigned char * polyAreas
The user defined area ids assigned to each polygon. [Size: polyCount].
Definition: DetourNavMeshBuilder.h:38
const float * offMeshConVerts
Off-mesh connection vertices. [(ax, ay, az, bx, by, bz) * offMeshConCount] [Unit: wu]...
Definition: DetourNavMeshBuilder.h:61
const unsigned short * polys
The polygon data. [Size: polyCount * 2 * nvp].
Definition: DetourNavMeshBuilder.h:36
float bmin[3]
The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu].
Definition: Recast.h:199
int nvp
Number maximum number of vertices per polygon. [Limit: >= 3].
Definition: DetourNavMeshBuilder.h:40
bool rcCreateHeightfield(rcContext *ctx, rcHeightfield &hf, int width, int height, const float *bmin, const float *bmax, float cs, float ch)
Definition: Recast.cpp:211
int tileSize
The width/height size of tile's on the xz-plane. [Limit: >= 0] [Units: vx].
Definition: Recast.h:187
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:314
float walkableHeight
The agent height. [Unit: wu].
Definition: DetourNavMeshBuilder.h:94
Definition: DetourNavMeshBuilder.h:26
const unsigned char * detailTris
The detail mesh triangles. [Size: 4 * detailTriCount].
Definition: DetourNavMeshBuilder.h:50
float ch
The y-axis cell height of the polygon mesh. [Limit: > 0] [Unit: wu].
Definition: DetourNavMeshBuilder.h:98
int walkableClimb
Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]...
Definition: Recast.h:212
const dtNavMeshParams * getParams() const
The navigation mesh initialization params.
Definition: DetourNavMesh.cpp:286
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
float bmax[3]
The maximum bounds of the tile. [(x, y, z)] [Unit: wu].
Definition: DetourNavMeshBuilder.h:88
arena_t NULL
Definition: jemalloc_internal.h:624
dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Definition: DetourNavMesh.cpp:834
int mergeRegionArea
Definition: Recast.h:230
bool rcMergePolyMeshes(rcContext *ctx, rcPolyMesh **meshes, const int nmeshes, rcPolyMesh &mesh)
Definition: RecastMesh.cpp:1302
void rcFreeHeightField(rcHeightfield *hf)
Definition: Recast.cpp:80
float walkableClimb
The agent maximum traversable ledge. (Up/Down) [Unit: wu].
Definition: DetourNavMeshBuilder.h:96
int borderSize
The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]...
Definition: Recast.h:190
void rcFilterLedgeSpans(rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &solid)
Definition: RecastFilter.cpp:84
float detailSampleDist
Definition: Recast.h:238
void rcCalcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h)
Definition: Recast.cpp:200
unsigned int dtStatus
Definition: DetourStatus.h:22
int maxEdgeLen
The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]...
Definition: Recast.h:219
void rcFilterLowHangingWalkableObstacles(rcContext *ctx, const int walkableClimb, rcHeightfield &solid)
Definition: RecastFilter.cpp:36
void rcFilterWalkableLowHeightSpans(rcContext *ctx, int walkableHeight, rcHeightfield &solid)
Definition: RecastFilter.cpp:180
int walkableHeight
Definition: Recast.h:209
const unsigned short * offMeshConFlags
User defined flags assigned to the off-mesh connections. [Size: offMeshConCount]. ...
Definition: DetourNavMeshBuilder.h:65
rcContourSet * rcAllocContourSet()
Definition: Recast.cpp:134
bool buildBvTree
Definition: DetourNavMeshBuilder.h:102
int detailTriCount
The number of triangles in the detail mesh.
Definition: DetourNavMeshBuilder.h:51
float maxSimplificationError
Definition: Recast.h:223
int offMeshConCount
The number of off-mesh connections. [Limit: >= 0].
Definition: DetourNavMeshBuilder.h:76
float ch
The y-axis cell size to use for fields. [Limit: > 0] [Units: wu].
Definition: Recast.h:196
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
rcPolyMeshDetail * rcAllocPolyMeshDetail()
Definition: Recast.cpp:171
rcHeightfield * rcAllocHeightfield()
Definition: Recast.cpp:73
bool dtCreateNavMeshData(dtNavMeshCreateParams *params, unsigned char **outData, int *outDataSize)
Definition: DetourNavMeshBuilder.cpp:254
const unsigned short * verts
The polygon mesh vertices. [(x, y, z) * vertCount] [Unit: vx].
Definition: DetourNavMeshBuilder.h:34
float bmin[3]
The minimum bounds of the tile. [(x, y, z)] [Unit: wu].
Definition: DetourNavMeshBuilder.h:87
static const unsigned char RC_WALKABLE_AREA
Definition: Recast.h:543
bool m_bigBaseUnit
Definition: MapBuilder.h:140
G3D::int16 y
Definition: Vector2int16.h:38
int maxVertsPerPoly
Definition: Recast.h:234
void rcClearUnwalkableTriangles(rcContext *ctx, const float walkableSlopeAngle, const float *verts, int nv, const int *tris, int nt, unsigned char *areas)
Definition: Recast.cpp:276
bool m_debugOutput
Definition: MapBuilder.h:132
void rcVcopy(float *dest, const float *v)
Definition: Recast.h:677
float bmax[3]
The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu].
Definition: Recast.h:202
float walkableRadius
The agent radius. [Unit: wu].
Definition: DetourNavMeshBuilder.h:95
float m_maxWalkableAngle
Definition: MapBuilder.h:139
float walkableSlopeAngle
The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees].
Definition: Recast.h:205
rcPolyMesh * rcAllocPolyMesh()
Definition: Recast.cpp:153
const float * detailVerts
The detail mesh vertices. [Size: 3 * detailVertsCount] [Unit: wu].
Definition: DetourNavMeshBuilder.h:48
bool rcErodeWalkableArea(rcContext *ctx, int radius, rcCompactHeightfield &chf)
Definition: RecastArea.cpp:37
T rcSqr(T a)
Definition: Recast.h:582
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
TerrainBuilder * m_terrainBuilder
Definition: MapBuilder.h:129
int tileY
The tile's y-grid location within the multi-tile desitation mesh. (Along the z-axis.)
Definition: DetourNavMeshBuilder.h:85
int polyCount
Number of polygons in the mesh. [Limit: >= 1].
Definition: DetourNavMeshBuilder.h:39
int height
The height of the field along the z-axis. [Limit: >= 0] [Units: vx].
Definition: Recast.h:184
float cs
The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu].
Definition: Recast.h:193
const unsigned int * detailMeshes
The height detail sub-mesh data. [Size: 4 * polyCount].
Definition: DetourNavMeshBuilder.h:47
bool rcBuildDistanceField(rcContext *ctx, rcCompactHeightfield &chf)
Definition: RecastRegion.cpp:1256
bool rcBuildRegions(rcContext *ctx, rcCompactHeightfield &chf, const int borderSize, const int minRegionArea, const int mergeRegionArea)
Definition: RecastRegion.cpp:1532
void rcRasterizeTriangles(rcContext *ctx, const float *verts, const int nv, const int *tris, const unsigned char *areas, const int nt, rcHeightfield &solid, const int flagMergeThr=1)
Definition: RecastRasterization.cpp:348
int tileX
The tile's x-grid location within the multi-tile destination mesh. (Along the x-axis.)
Definition: DetourNavMeshBuilder.h:84
rcContext * m_rcContext
Definition: MapBuilder.h:143
uint8_t uint8
Definition: Define.h:152
const unsigned short * polyFlags
The user defined flags assigned to each polygon. [Size: polyCount].
Definition: DetourNavMeshBuilder.h:37
int vertCount
The number vertices in the polygon mesh. [Limit: >= 3].
Definition: DetourNavMeshBuilder.h:35
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
const float * offMeshConRad
Off-mesh connection radii. [Size: offMeshConCount] [Unit: wu].
Definition: DetourNavMeshBuilder.h:63
bool rcBuildContours(rcContext *ctx, rcCompactHeightfield &chf, const float maxError, const int maxEdgeLen, rcContourSet &cset, const int buildFlags=RC_CONTOUR_TESS_WALL_EDGES)
Definition: RecastContour.cpp:824
int minRegionArea
The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]...
Definition: Recast.h:226
std::set< uint32 > params[2]
Definition: DisableMgr.cpp:45
dtStatus removeTile(dtTileRef ref, unsigned char **data, int *dataSize)
Definition: DetourNavMesh.cpp:1156
static const float GRID_SIZE
Definition: TerrainBuilder.h:50
int detailVertsCount
The number of vertices in the detail mesh.
Definition: DetourNavMeshBuilder.h:49
bool rcBuildPolyMesh(rcContext *ctx, rcContourSet &cset, const int nvp, rcPolyMesh &mesh)
Definition: RecastMesh.cpp:982
int width
The width of the field along the x-axis. [Limit: >= 0] [Units: vx].
Definition: Recast.h:181
bool rcMergePolyMeshDetails(rcContext *ctx, rcPolyMeshDetail **meshes, const int nmeshes, rcPolyMeshDetail &mesh)
Definition: RecastMeshDetail.cpp:1336
const unsigned char * offMeshConAreas
User defined area ids assigned to the off-mesh connections. [Size: offMeshConCount].
Definition: DetourNavMeshBuilder.h:67
static const int DT_VERTS_PER_POLYGON
Definition: DetourNavMesh.h:57
void rcFreeContourSet(rcContourSet *cset)
Definition: Recast.cpp:141
bool rcBuildCompactHeightfield(rcContext *ctx, const int walkableHeight, const int walkableClimb, rcHeightfield &hf, rcCompactHeightfield &chf)
Definition: Recast.cpp:327
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083