This commit is contained in:
aozhiwei 2020-08-13 20:05:07 +08:00
parent 0223227a47
commit d7c6c79045

View File

@ -306,6 +306,10 @@ struct BuilderParams
LinearAllocator* talloc = nullptr;
FastLZCompressor* tcomp = nullptr;
MeshProcess* tmproc = nullptr;
int gw = 0;
int gh = 0;
int ts = 0;
int tw = 0;
int th = 0;
};
@ -314,11 +318,14 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance)
{
BuilderParams builder_params;
// Init cache
int gw = 0, gh = 0;
rcCalcGridSize(builder_params.bmin, builder_params.bmax, builder_params.kCellSize, &gw, &gh);
const int ts = (int)kTileSize;
const int tw = (gw + ts-1) / ts;
const int th = (gh + ts-1) / ts;
rcCalcGridSize(builder_params.bmin,
builder_params.bmax,
builder_params.kCellSize,
&builder_params.gw,
&builder_params.gh);
builder_params.ts = (int)kTileSize;
builder_params.tw = (builder_params.gw + builder_params.ts-1) / builder_params.ts;
builder_params.th = (builder_params.gh + builder_params.ts-1) / builder_params.ts;
InitRcConfig(builder_params);
InitTileCacheParams(builder_params);
@ -351,8 +358,8 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance)
int m_cacheCompressedSize = 0;
int m_cacheRawSize = 0;
for (int y = 0; y < th; ++y) {
for (int x = 0; x < tw; ++x) {
for (int y = 0; y < builder_params.th; ++y) {
for (int x = 0; x < builder_params.tw; ++x) {
TileCacheData tiles[MAX_LAYERS];
memset(tiles, 0, sizeof(tiles));
int ntiles = RasterizeTileLayers(x, y, builder_params.cfg, tiles, MAX_LAYERS);
@ -376,8 +383,8 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance)
}
// Build initial meshes
for (int y = 0; y < th; ++y) {
for (int x = 0; x < tw; ++x) {
for (int y = 0; y < builder_params.th; ++y) {
for (int x = 0; x < builder_params.tw; ++x) {
tile_cache->buildNavMeshTilesAt(x,y, navmesh);
}
}