コード例 #1
0
 public void SetDefaultSettings()
 {
     BuildSettings = NavMeshBuildSettings.Default();
     AgentSettings = NavAgentSettings.Default();
 }
コード例 #2
0
ファイル: NavMeshBuilder.cs プロジェクト: taotao111/ainav
        private unsafe int BuildTile(int2 tileCoordinate, NavMeshBuildSettings buildSettings, NavAgentSettings agentSettings,
                                     NavMeshBuildInput buildInput, long buildTimeStamp, out NavMeshTile meshTile)
        {
            meshTile = null;

            if (buildInput.AreasLength != buildInput.IndicesLength / 3)
            {
                return(-1001);
            }

            if (buildInput.VerticesLength <= 0 || buildInput.IndicesLength <= 0)
            {
                return(-1000);
            }

            DtBoundingBox tileBoundingBox = NavMeshBuildUtils.CalculateTileBoundingBox(buildSettings, tileCoordinate);

            NavMeshBuildUtils.SnapBoundingBoxToCellHeight(buildSettings, ref tileBoundingBox);

            tileBoundingBox.min.y = HeightBounds.min.y;
            tileBoundingBox.max.y = HeightBounds.max.y;

            IntPtr builder = Navigation.NavMesh.CreateBuilder();

            DtBuildSettings internalBuildSettings = new DtBuildSettings
            {
                // Tile settings
                BoundingBox  = tileBoundingBox,
                TilePosition = tileCoordinate,
                TileSize     = buildSettings.TileSize,

                // General build settings
                CellHeight           = buildSettings.CellHeight,
                CellSize             = buildSettings.CellSize,
                RegionMinArea        = buildSettings.MinRegionArea,
                RegionMergeArea      = buildSettings.RegionMergeArea,
                EdgeMaxLen           = buildSettings.MaxEdgeLen,
                EdgeMaxError         = buildSettings.MaxEdgeError,
                DetailSampleDist     = buildSettings.DetailSamplingDistance,
                DetailSampleMaxError = buildSettings.MaxDetailSamplingError,

                // Agent settings
                AgentHeight   = agentSettings.Height,
                AgentRadius   = agentSettings.Radius,
                AgentMaxClimb = agentSettings.MaxClimb,
                AgentMaxSlope = agentSettings.MaxSlope
            };

            Navigation.NavMesh.SetSettings(builder, new IntPtr(&internalBuildSettings));

            IntPtr buildResultPtr = Navigation.NavMesh.Build2(builder, buildInput.Vertices, buildInput.VerticesLength, buildInput.Indices, buildInput.IndicesLength, buildInput.Areas);

            DtGeneratedData *generatedDataPtr = (DtGeneratedData *)buildResultPtr;

            if (generatedDataPtr->Success && generatedDataPtr->NavmeshDataLength > 0)
            {
                meshTile = new NavMeshTile();

                // Copy the generated navigationMesh data
                meshTile.Data = new byte[generatedDataPtr->NavmeshDataLength + sizeof(long)];
                Marshal.Copy(generatedDataPtr->NavmeshData, meshTile.Data, 0, generatedDataPtr->NavmeshDataLength);

                // Append time stamp
                byte[] timeStamp = BitConverter.GetBytes(buildTimeStamp);
                for (int i = 0; i < timeStamp.Length; i++)
                {
                    meshTile.Data[meshTile.Data.Length - sizeof(long) + i] = timeStamp[i];
                }
            }

            int error = generatedDataPtr->Error;

            Navigation.NavMesh.DestroyBuilder(builder);

            return(error);
        }
コード例 #3
0
ファイル: NavMeshBuilder.cs プロジェクト: taotao111/ainav
 public NavMeshBuilder(NavMeshBuildSettings buildSettings, NavAgentSettings agentSettings)
 {
     BuildSettings = buildSettings;
     AgentSettings = agentSettings;
 }
コード例 #4
0
 public NavMeshBuilderSettings(int id, NavMeshBuildSettings buildSettings, NavAgentSettings agentSettings)
 {
     Id            = id;
     BuildSettings = buildSettings;
     AgentSettings = agentSettings;
 }