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/Grid/Jobs/JobNodeGridLayout.cs | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobNodeGridLayout.cs
(limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobNodeGridLayout.cs')
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobNodeGridLayout.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobNodeGridLayout.cs
new file mode 100644
index 0000000..e9bdaf3
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobNodeGridLayout.cs
@@ -0,0 +1,36 @@
+using UnityEngine;
+using Unity.Burst;
+using Unity.Collections;
+using Unity.Jobs;
+using Unity.Mathematics;
+using Pathfinding.Jobs;
+
+namespace Pathfinding.Graphs.Grid.Jobs {
+ ///
+ /// Calculates the default node positions for a grid graph.
+ ///
+ /// The node positions will lie on the base plane of the grid graph.
+ ///
+ /// See:
+ ///
+ [BurstCompile(FloatMode = FloatMode.Fast)]
+ public struct JobNodeGridLayout : IJob, GridIterationUtilities.ICellAction {
+ public Matrix4x4 graphToWorld;
+ public IntBounds bounds;
+
+ [WriteOnly]
+ public NativeArray nodePositions;
+
+ public static Vector3 NodePosition (Matrix4x4 graphToWorld, int x, int z) {
+ return graphToWorld.MultiplyPoint3x4(new Vector3(x + 0.5f, 0, z + 0.5f));
+ }
+
+ public void Execute () {
+ GridIterationUtilities.ForEachCellIn3DArray(bounds.size, ref this);
+ }
+
+ public void Execute (uint innerIndex, int x, int y, int z) {
+ nodePositions[(int)innerIndex] = NodePosition(graphToWorld, x + bounds.min.x, z + bounds.min.z);
+ }
+ }
+}
--
cgit v1.1-26-g67d0