diff --git a/server/gameserver/navmeshbuilder.cc b/server/gameserver/navmeshbuilder.cc index 7f0721f..403353c 100644 --- a/server/gameserver/navmeshbuilder.cc +++ b/server/gameserver/navmeshbuilder.cc @@ -43,6 +43,9 @@ static const int EXPECTED_LAYERS_PER_TILE = 4; static const int MAX_LAYERS = 32; +static const int kMaxTiles = 0; +static const int kMaxPolysPerTile = 0; + /// Mask of the ceil part of the area id (3 lower bits) /// the 0 value (RC_NULL_AREA) is left unused static const unsigned char SAMPLE_POLYAREA_TYPE_MASK = 0x07; @@ -92,6 +95,23 @@ private: #endif }; +static const int MAX_CONVEXVOL_PTS = 12; +struct ConvexVolume +{ + ConvexVolume(): areaMod(RC_AREA_FLAGS_MASK) {} + float verts[MAX_CONVEXVOL_PTS*3]; + float hmin, hmax; + int nverts; + rcAreaModification areaMod; +}; + +static int calcLayerBufferSize(const int gridWidth, const int gridHeight) +{ + const int headerSize = dtAlign4(sizeof(dtTileCacheLayerHeader)); + const int gridSize = gridWidth * gridHeight; + return headerSize + gridSize*4; +} + inline bool checkOverlapRect(const float amin[2], const float amax[2], const float bmin[2], const float bmax[2]) { @@ -313,10 +333,8 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance) rcVcopy(params.orig, builder_params.bmin); params.tileWidth = kTileSize * builder_params.kCellSize; params.tileHeight = kTileSize * builder_params.kCellSize; - #if 0 params.maxTiles = kMaxTiles; params.maxPolys = kMaxPolysPerTile; - #endif } dtNavMesh* navmesh = dtAllocNavMesh(); @@ -351,9 +369,8 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance) m_cacheLayerCount++; m_cacheCompressedSize += tile->dataSize; - #if 0 - m_cacheRawSize += calcLayerBufferSize(tcparams.width, tcparams.height); - #endif + m_cacheRawSize += calcLayerBufferSize(builder_params.tcparams.width, + builder_params.tcparams.height); } } } @@ -365,10 +382,10 @@ dtNavMesh* NavMeshBuilder::Build(MapInstance* map_instance) } } - #if 0 - m_cacheBuildTimeMs = m_ctx->getAccumulatedTime(RC_TIMER_TOTAL)/1000.0f; - m_cacheBuildMemUsage = m_talloc->high; - #endif +#if 0 + m_cacheBuildTimeMs = ctx->getAccumulatedTime(RC_TIMER_TOTAL)/1000.0f; + m_cacheBuildMemUsage = builder_params.talloc->high; +#endif const dtNavMesh* nav = navmesh; int navmeshMemUsage = 0; @@ -648,15 +665,18 @@ int NavMeshBuilder::RasterizeTileLayers(const int tx, const int ty, return 0; } - #if 0 // (Optional) Mark areas. + #if 1 + const ConvexVolume* vols = nullptr; + int vol_count = 0; + #else const ConvexVolume* vols = m_geom->getConvexVolumes(); - for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i) { - rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, + #endif + for (int i = 0; i < vol_count; ++i) { + rcMarkConvexPolyArea(ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, vols[i].areaMod, *rc.chf); } - #endif rc.lset = rcAllocHeightfieldLayerSet(); if (!rc.lset) {