// Set the border size of the tile in voxels vox.borderSize = TileBorderSizeInVoxels; // Set the width and depth of the tile including the border vox.width = tileSizeX + vox.borderSize2; vox.depth = tileSizeZ + vox.borderSize2;

// Set the relevant graph surface mode for the tile if (!useTiles && relevantGraphSurfaceMode == RelevantGraphSurfaceMode.OnlyForCompletelyInsideTile) { // If not using tiles and only want relevant surfaces completely inside the tile, set to require for all vox.relevantGraphSurfaceMode = RelevantGraphSurfaceMode.RequireForAll; } else { vox.relevantGraphSurfaceMode = relevantGraphSurfaceMode; }

// Set the minimum region size in voxels vox.minRegionSize = Mathf.RoundToInt(minRegionSize / (cellSize*cellSize));

// Initialize the voxelizer and voxelize the input vox.Init(); vox.VoxelizeInput(transform, CalculateTileBoundsWithBorder(x, z));

// Filter ledges and low height spans vox.FilterLedges(vox.voxelWalkableHeight, vox.voxelWalkableClimb, vox.cellSize, vox.cellHeight); vox.FilterLowHeightSpans(vox.voxelWalkableHeight, vox.cellSize, vox.cellHeight);

// Build the compact field, voxel connections, erode the walkable area, and build the distance field and regions vox.BuildCompactField(); vox.BuildVoxelConnections(); vox.ErodeWalkableArea(CharacterRadiusInVoxels); vox.BuildDistanceField(); vox.BuildRegions();

// Build the voxel contour set and mesh var cset = new VoxelContourSet(); vox.BuildContours(contourMaxError, 1, cset, Voxelize.RC_CONTOUR_TESS_WALL_EDGES | Voxelize.RC_CONTOUR_TESS_TILE_EDGES); VoxelMesh mesh; vox.BuildPolyMesh(cset, 3, out mesh);

// Position the vertices correctly in graph space (all tiles are laid out on the xz plane with the (0,0) tile at the origin) for (int i = 0; i < mesh.verts.Length; i++) { mesh.verts[i] *= Int3.Precision; } vox.transformVoxel2Graph.Transform(mesh.verts);

// Create the navmesh tile and return it NavmeshTile tile = CreateTile(vox, mesh, x, z, threadIndex); return tile;

voxborderSize = TileBorderSizeInVoxels;			voxwidth = tileSizeX + voxborderSize2;			voxdepth = tileSizeZ + voxborderSize2;			if !useTiles && relevantGraphSurfaceMode == RelevantGraphSurfaceModeOnlyForC

原文地址: http://www.cveoy.top/t/topic/MaN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录