From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Thu, 23 May 2024 10:08:29 +0800
Subject: + astar project
---
.../Graphs/Navmesh/RecastBuilder.cs | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/RecastBuilder.cs
(limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/RecastBuilder.cs')
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/RecastBuilder.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/RecastBuilder.cs
new file mode 100644
index 0000000..2cd925b
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Navmesh/RecastBuilder.cs
@@ -0,0 +1,49 @@
+using Pathfinding.Graphs.Navmesh.Jobs;
+
+namespace Pathfinding.Graphs.Navmesh {
+ /// Helper methods for scanning a recast graph
+ public struct RecastBuilder {
+ ///
+ /// Builds meshes for the given tiles in a graph.
+ /// Call Schedule on the returned object to actually start the job.
+ ///
+ /// You may want to adjust the settings on the returned object before calling Schedule.
+ ///
+ ///
+ /// // Scans the first 6x6 chunk of tiles of the recast graph (the IntRect uses inclusive coordinates)
+ /// var graph = AstarPath.active.data.recastGraph;
+ /// var buildSettings = RecastBuilder.BuildTileMeshes(graph, new TileLayout(graph), new IntRect(0, 0, 5, 5));
+ /// var disposeArena = new Pathfinding.Jobs.DisposeArena();
+ /// var promise = buildSettings.Schedule(disposeArena);
+ ///
+ /// AstarPath.active.AddWorkItem(() => {
+ /// // Block until the asynchronous job completes
+ /// var result = promise.Complete();
+ /// TileMeshes tiles = result.tileMeshes.ToManaged();
+ /// // Take the scanned tiles and place them in the graph,
+ /// // but not at their original location, but 2 tiles away, rotated 90 degrees.
+ /// tiles.tileRect = tiles.tileRect.Offset(new Int2(2, 0));
+ /// tiles.Rotate(1);
+ /// graph.ReplaceTiles(tiles);
+ ///
+ /// // Dispose unmanaged data
+ /// disposeArena.DisposeAll();
+ /// result.Dispose();
+ /// });
+ ///
+ ///
+ public static TileBuilder BuildTileMeshes (RecastGraph graph, TileLayout tileLayout, IntRect tileRect) {
+ return new TileBuilder(graph, tileLayout, tileRect);
+ }
+
+ ///
+ /// Builds nodes given some tile meshes.
+ /// Call Schedule on the returned object to actually start the job.
+ ///
+ /// See:
+ ///
+ public static JobBuildNodes BuildNodeTiles (RecastGraph graph, TileLayout tileLayout) {
+ return new JobBuildNodes(graph, tileLayout);
+ }
+ }
+}
--
cgit v1.1-26-g67d0