/// <summary> /// Generates a human readable report of the mesh data. /// </summary> /// <returns>A human readable report of the mesh data.</returns> public string GetMeshReport() { if (!HasNavmesh) { return("No mesh."); } Navmesh nm = GetNavmesh(); NavmeshParams nmconfig = nm.GetConfig(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("Navigation mesh report for " + name); if (mBuildInfo != null) { sb.AppendLine("Built from scene: " + mBuildInfo.inputScene); } sb.AppendLine(string.Format("Tiles: {0}, Tile Size: {1:F3}x{2:F3}, Max Polys Per Tile: {3}" , nmconfig.maxTiles, nmconfig.tileWidth, nmconfig.tileDepth, nmconfig.maxPolysPerTile)); int polyCount = 0; int vertCount = 0; int connCount = 0; for (int i = 0; i < nmconfig.maxTiles; i++) { NavmeshTileHeader header = nm.GetTile(i).GetHeader(); if (header.polyCount == 0) { continue; } sb.AppendLine(string.Format( "Tile ({0},{1}): Polygons: {2}, Vertices: {3}, Off-mesh Connections: {4}" , header.tileX, header.tileZ , header.polyCount, header.vertCount , header.connCount)); polyCount += header.polyCount; vertCount += header.vertCount; connCount += header.connCount; } sb.AppendLine(string.Format( "Totals: Polygons: {0}, Vertices: {1}, Off-mesh Connections: {2}" , polyCount, vertCount, connCount)); return(sb.ToString()); }
private void SetConfigFromTargetIntern(Navmesh navmesh) { NavmeshBuildInfo targetConfig = BuildTarget.BuildInfo; NMGenParams currConfig = mConfig.GetConfig(); // Note: Must ensure exact match with original configuration. // So this process is using the fields and trusting the // original configuration to have valid values. currConfig.tileSize = targetConfig.tileSize; currConfig.walkableHeight = targetConfig.walkableHeight; currConfig.walkableRadius = targetConfig.walkableRadius; currConfig.walkableStep = targetConfig.walkableStep; currConfig.xzCellSize = targetConfig.xzCellSize; currConfig.yCellSize = targetConfig.yCellSize; currConfig.borderSize = targetConfig.borderSize; mBoundsMin = navmesh.GetConfig().origin; int maxTiles = navmesh.GetMaxTiles(); // Make sure the maximum bounds fits the target mesh. // Note: Will not shrink the existing max bounds. for (int i = 0; i < maxTiles; i++) { NavmeshTile tile = navmesh.GetTile(i); if (tile == null) { continue; } NavmeshTileHeader tileHeader = tile.GetHeader(); if (tileHeader.polyCount == 0) { continue; } mBoundsMax = Vector3.Max(mBoundsMax, tileHeader.boundsMax); } mConfig.SetConfig(currConfig); mIsDirty = true; }
internal bool CanLoadFromTarget(BuildContext context, bool fullCheck) { INavmeshData target = BuildTarget; if (target == null || !target.HasNavmesh) { if (context != null) { context.LogError("Build target does not have an existing navigation mesh.", this); } return(false); } NavmeshBuildInfo targetConfig = target.BuildInfo; // Note: The tile size is checked since the original builder // may have supported a tile size not supported by the the standard build. if (targetConfig == null || targetConfig.tileSize >= 0 && targetConfig.tileSize < MinAllowedTileSize) { if (context != null) { context.LogError("Unavailable or unsupported build target configuration.", this); } return(false); } if (!fullCheck) { return(true); } Navmesh nm = target.GetNavmesh(); if (nm == null) { if (context != null) { context.LogError( "Build target does not have an existing navigation mesh. (It lied.)", this); } return(false); } NavmeshParams nmConfig = nm.GetConfig(); if (nmConfig.maxTiles < 2) { if (context != null) { context.LogError("Target navigation mesh is not tiled.", this); } return(false); } int tileCount = 0; for (int i = 0; i < nmConfig.maxTiles; i++) { NavmeshTile tile = nm.GetTile(i); if (tile == null) { continue; } NavmeshTileHeader header = tile.GetHeader(); if (header.polyCount == 0) { continue; } tileCount++; if (header.layer > 0) { if (context != null) { context.LogError( "Target navigation mesh contains layered tiles. (Not supported.)", this); } return(false); } } if (tileCount < 2) { if (context != null) { context.LogError( "Target navigation mesh is either not tiled or has no tiles loaded.", this); } return(false); } return(true); }