Beispiel #1
0
    public void BuildTile(int x, int y)
    {
        RecastVertex bmin     = Geometry.MinBounds;
        RecastVertex bmax     = Geometry.MaxBounds;
        float        tcs      = Config.TileSize * Config.CellSize;
        RecastVertex tileBMin = new RecastVertex();
        RecastVertex tileBMax = new RecastVertex();

        tileBMin.X = bmin.X + x * tcs;
        tileBMin.Y = bmin.Y;
        tileBMin.Z = bmin.Z + y * tcs;

        tileBMax.X = bmin.X + (x + 1) * tcs;
        tileBMax.Y = bmax.Y;
        tileBMax.Z = bmin.Z + (y + 1) * tcs;

        var builder = BuildTileMesh(x, y, tileBMin, tileBMax);

        // remove/add new tile?
        if (builder != null)
        {
            Detour.NavMeshBuilder outBuilder;
            // nav mesh remove tile
            NavMesh.RemoveTile(NavMesh.GetTileRefAt(x, y, 0), out outBuilder);
            // nav mesh add tile
            long result = 0;
            NavMesh.AddTile(builder, NavMesh.TileFreeData, 0, ref result);
        }
    }
Beispiel #2
0
    public void RebuildTiles()
    {
        Progress   = 0;
        IsBuilding = true;
        RecastVertex bmin     = Geometry.MinBounds;
        RecastVertex bmax     = Geometry.MaxBounds;
        RecastVertex tileBMin = new RecastVertex();
        RecastVertex tileBMax = new RecastVertex();
        float        tcs      = Config.TileSize * Config.CellSize;

        Total = TileWidth * TileHeight;
        for (int y = 0; y < TileHeight; y++)
        {
            for (int x = 0; x < TileWidth; x++)
            {
                Progress   = y * TileWidth + x;
                tileBMin.X = bmin.X + x * tcs;
                tileBMin.Y = bmin.Y;
                tileBMin.Z = bmin.Z + y * tcs;

                tileBMax.X = bmin.X + (x + 1) * tcs;
                tileBMax.Y = bmax.Y;
                tileBMax.Z = bmin.Z + (y + 1) * tcs;

                EditorUtility.DisplayProgressBar("Generating...", "Generating Tile " + Progress + " of " + Total, Progress / (float)Total);
                var builder = BuildTileMesh(x, y, tileBMin, tileBMax);

                // remove/add new tile?
                if (builder != null)
                {
                    Detour.NavMeshBuilder outBuilder;
                    // nav mesh remove tile
                    NavMesh.RemoveTile(NavMesh.GetTileRefAt(x, y, 0), out outBuilder);
                    // nav mesh add tile
                    long result = 0;
                    NavMesh.AddTile(builder, NavMesh.TileFreeData, 0, ref result);
                }
            }
        }

        EditorUtility.ClearProgressBar();
        IsBuilding = false;
        BuildGeometry();
    }
Beispiel #3
0
    public void BuildTile(int x, int y, RecastVertex tileBMin, RecastVertex tileBMax)
    {
        var builder = BuildTileMesh(x, y, tileBMin, tileBMax);

        // remove/add new tile?
        if (builder != null)
        {
            lock (this)
            {
                Detour.NavMeshBuilder outBuilder;
                // nav mesh remove tile
                NavMesh.RemoveTile(NavMesh.GetTileRefAt(x, y, 0), out outBuilder);
                // nav mesh add tile
                long result = 0;
                NavMesh.AddTile(builder, NavMesh.TileFreeData, 0, ref result);
            }
        }
        Progress++;
    }
Beispiel #4
0
 public void RemoveTile(int x, int y)
 {
     Detour.NavMeshBuilder outBuilder;
     // nav mesh remove tile
     NavMesh.RemoveTile(NavMesh.GetTileRefAt(x, y, 0), out outBuilder);
 }