From d7c6c79045bb4f64780c1733caf035751f642e08 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 13 Aug 2020 20:05:07 +0800 Subject: [PATCH] 1 --- server/gameserver/navmeshbuilder.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/server/gameserver/navmeshbuilder.cc b/server/gameserver/navmeshbuilder.cc index 59193bf..9964022 100644 --- a/server/gameserver/navmeshbuilder.cc +++ b/server/gameserver/navmeshbuilder.cc @@ -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); } }