本文整理汇总了C#中Pathfinding.TriangleMeshNode类的典型用法代码示例。如果您正苦于以下问题:C# TriangleMeshNode类的具体用法?C# TriangleMeshNode怎么用?C# TriangleMeshNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TriangleMeshNode类属于Pathfinding命名空间,在下文中一共展示了TriangleMeshNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNodes
public override void CreateNodes (int number) {
TriangleMeshNode[] tmp = new TriangleMeshNode[number];
for (int i=0;i<number;i++) {
tmp[i] = new TriangleMeshNode (active);
tmp[i].Penalty = initialPenalty;
}
}
示例2: UpdateFunnelCorridor
/** Split funnel at node index \a splitIndex and throw the nodes up to that point away and replace with \a prefix.
* Used when the AI has happened to get sidetracked and entered a node outside the funnel.
*/
public void UpdateFunnelCorridor (int splitIndex, TriangleMeshNode prefix) {
if (splitIndex > 0) {
nodes.RemoveRange(0,splitIndex-1);
//This is a node which should be removed, we replace it with the prefix
nodes[0] = prefix;
} else {
nodes.Insert(0,prefix);
}
left.Clear();
right.Clear();
left.Add(exactStart);
right.Add(exactStart);
for (int i=0;i<nodes.Count-1;i++) {
//NOTE should use return value in future versions
nodes[i].GetPortal (nodes[i+1],left,right,false);
}
left.Add(exactEnd);
right.Add(exactEnd);
}
示例3: ContainsPoint
/** Returns if the point is inside the node in XZ space */
public bool ContainsPoint (TriangleMeshNode node, Vector3 pos) {
if ( Polygon.IsClockwise ((Vector3)GetVertex(node.v0),(Vector3)GetVertex(node.v1), pos)
&& Polygon.IsClockwise ((Vector3)GetVertex(node.v1),(Vector3)GetVertex(node.v2), pos)
&& Polygon.IsClockwise ((Vector3)GetVertex(node.v2),(Vector3)GetVertex(node.v0), pos)) {
return true;
}
return false;
}
示例4: ClosestPointOnNode
/** Returns the closest point of the node */
public Vector3 ClosestPointOnNode (TriangleMeshNode node, Vector3 pos) {
return Polygon.ClosestPointOnTriangle ((Vector3)GetVertex(node.v0),(Vector3)GetVertex(node.v1),(Vector3)GetVertex(node.v2),pos);
}
示例5: DeserializeExtraInfo
public override void DeserializeExtraInfo (GraphSerializationContext ctx) {
//NavMeshGraph.DeserializeMeshNodes (this,nodes,bytes);
System.IO.BinaryReader reader = ctx.reader;
tileXCount = reader.ReadInt32();
if (tileXCount < 0) return;
tileZCount = reader.ReadInt32();
tiles = new NavmeshTile[tileXCount * tileZCount];
//Make sure mesh nodes can reference this graph
TriangleMeshNode.SetNavmeshHolder (ctx.graphIndex, this);
for (int z=0;z<tileZCount;z++) {
for (int x=0;x<tileXCount;x++) {
int tileIndex = x + z*tileXCount;
int tx = reader.ReadInt32();
if (tx < 0) throw new System.Exception ("Invalid tile coordinates (x < 0)");
int tz = reader.ReadInt32();
if (tz < 0) throw new System.Exception ("Invalid tile coordinates (z < 0)");
// This is not the origin of a large tile. Refer back to that tile.
if (tx != x || tz != z) {
tiles[tileIndex] = tiles[tz*tileXCount + tx];
continue;
}
NavmeshTile tile = new NavmeshTile ();
tile.x = tx;
tile.z = tz;
tile.w = reader.ReadInt32();
tile.d = reader.ReadInt32();
tile.bbTree = new BBTree (tile);
tiles[tileIndex] = tile;
int trisCount = reader.ReadInt32 ();
if (trisCount % 3 != 0) throw new System.Exception ("Corrupt data. Triangle indices count must be divisable by 3. Got " + trisCount);
tile.tris = new int[trisCount];
for (int i=0;i<tile.tris.Length;i++) tile.tris[i] = reader.ReadInt32();
tile.verts = new Int3[reader.ReadInt32()];
for (int i=0;i<tile.verts.Length;i++) {
tile.verts[i] = new Int3 (reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
}
int nodeCount = reader.ReadInt32();
tile.nodes = new TriangleMeshNode[nodeCount];
//Prepare for storing in vertex indices
tileIndex <<= TileIndexOffset;
for (int i=0;i<tile.nodes.Length;i++) {
TriangleMeshNode node = new TriangleMeshNode (active);
tile.nodes[i] = node;
node.GraphIndex = (uint)ctx.graphIndex;
node.DeserializeNode (ctx);
node.v0 = tile.tris[i*3+0] | tileIndex;
node.v1 = tile.tris[i*3+1] | tileIndex;
node.v2 = tile.tris[i*3+2] | tileIndex;
node.UpdatePositionFromVertices();
tile.bbTree.Insert (node);
}
}
}
}
示例6: CreateNodeConnections
private void CreateNodeConnections(TriangleMeshNode[] nodes)
{
List<MeshNode> list = ListPool<MeshNode>.Claim();
List<uint> list2 = ListPool<uint>.Claim();
Dictionary<Int2, int> dictionary = this.cachedInt2_int_dict;
dictionary.Clear();
for (int i = 0; i < nodes.Length; i++)
{
TriangleMeshNode triangleMeshNode = nodes[i];
int vertexCount = triangleMeshNode.GetVertexCount();
for (int j = 0; j < vertexCount; j++)
{
Int2 key = new Int2(triangleMeshNode.GetVertexIndex(j), triangleMeshNode.GetVertexIndex((j + 1) % vertexCount));
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, i);
}
}
}
for (int k = 0; k < nodes.Length; k++)
{
TriangleMeshNode triangleMeshNode2 = nodes[k];
list.Clear();
list2.Clear();
int vertexCount2 = triangleMeshNode2.GetVertexCount();
for (int l = 0; l < vertexCount2; l++)
{
int vertexIndex = triangleMeshNode2.GetVertexIndex(l);
int vertexIndex2 = triangleMeshNode2.GetVertexIndex((l + 1) % vertexCount2);
int num;
if (dictionary.TryGetValue(new Int2(vertexIndex2, vertexIndex), out num))
{
TriangleMeshNode triangleMeshNode3 = nodes[num];
int vertexCount3 = triangleMeshNode3.GetVertexCount();
for (int m = 0; m < vertexCount3; m++)
{
if (triangleMeshNode3.GetVertexIndex(m) == vertexIndex2 && triangleMeshNode3.GetVertexIndex((m + 1) % vertexCount3) == vertexIndex)
{
uint costMagnitude = (uint)(triangleMeshNode2.position - triangleMeshNode3.position).costMagnitude;
list.Add(triangleMeshNode3);
list2.Add(costMagnitude);
break;
}
}
}
}
triangleMeshNode2.connections = list.ToArray();
triangleMeshNode2.connectionCosts = list2.ToArray();
}
ListPool<MeshNode>.Release(list);
ListPool<uint>.Release(list2);
}
示例7: ContainsPoint
/** Returns if the point is inside the node in XZ space */
public static bool ContainsPoint (TriangleMeshNode node, Vector3 pos, Int3[] vertices) {
if (!Polygon.IsClockwiseMargin ((Vector3)vertices[node.v0],(Vector3)vertices[node.v1], (Vector3)vertices[node.v2])) {
Debug.LogError ("Noes!");
}
if ( Polygon.IsClockwiseMargin ((Vector3)vertices[node.v0],(Vector3)vertices[node.v1], pos)
&& Polygon.IsClockwiseMargin ((Vector3)vertices[node.v1],(Vector3)vertices[node.v2], pos)
&& Polygon.IsClockwiseMargin ((Vector3)vertices[node.v2],(Vector3)vertices[node.v0], pos)) {
return true;
}
return false;
}
示例8: ClosestPointOnNode
/** Returns the closest point of the node */
public static Vector3 ClosestPointOnNode (TriangleMeshNode node, Int3[] vertices, Vector3 pos) {
return Polygon.ClosestPointOnTriangle ((Vector3)vertices[node.v0],(Vector3)vertices[node.v1],(Vector3)vertices[node.v2],pos);
}
示例9: GenerateNodes
/** Generates a navmesh. Based on the supplied vertices and triangles. Memory usage is about O(n) */
public void GenerateNodes (Vector3[] vectorVertices, int[] triangles, out Vector3[] originalVertices, out Int3[] vertices) {
Profiler.BeginSample ("Init");
if (vectorVertices.Length == 0 || triangles.Length == 0) {
originalVertices = vectorVertices;
vertices = new Int3[0];
//graph.CreateNodes (0);
nodes = new TriangleMeshNode[0];
return;
}
vertices = new Int3[vectorVertices.Length];
//Backup the original vertices
//for (int i=0;i<vectorVertices.Length;i++) {
// vectorVertices[i] = graph.matrix.MultiplyPoint (vectorVertices[i]);
//}
int c = 0;
for (int i=0;i<vertices.Length;i++) {
vertices[i] = (Int3)matrix.MultiplyPoint3x4 (vectorVertices[i]);
}
Dictionary<Int3,int> hashedVerts = new Dictionary<Int3,int> ();
int[] newVertices = new int[vertices.Length];
Profiler.EndSample ();
Profiler.BeginSample ("Hashing");
for (int i=0;i<vertices.Length;i++) {
if (!hashedVerts.ContainsKey (vertices[i])) {
newVertices[c] = i;
hashedVerts.Add (vertices[i], c);
c++;
}// else {
//Debug.Log ("Hash Duplicate "+hash+" "+vertices[i].ToString ());
//}
}
/*newVertices[c] = vertices.Length-1;
if (!hashedVerts.ContainsKey (vertices[newVertices[c]])) {
hashedVerts.Add (vertices[newVertices[c]], c);
c++;
}*/
for (int x=0;x<triangles.Length;x++) {
Int3 vertex = vertices[triangles[x]];
triangles[x] = hashedVerts[vertex];
}
/*for (int i=0;i<triangles.Length;i += 3) {
Vector3 offset = Vector3.forward*i*0.01F;
Debug.DrawLine (newVertices[triangles[i]]+offset,newVertices[triangles[i+1]]+offset,Color.blue);
Debug.DrawLine (newVertices[triangles[i+1]]+offset,newVertices[triangles[i+2]]+offset,Color.blue);
Debug.DrawLine (newVertices[triangles[i+2]]+offset,newVertices[triangles[i]]+offset,Color.blue);
}*/
Int3[] totalIntVertices = vertices;
vertices = new Int3[c];
originalVertices = new Vector3[c];
for (int i=0;i<c;i++) {
vertices[i] = totalIntVertices[newVertices[i]];//(Int3)graph.matrix.MultiplyPoint (vectorVertices[i]);
originalVertices[i] = (Vector3)vectorVertices[newVertices[i]];//vectorVertices[newVertices[i]];
}
Profiler.EndSample ();
Profiler.BeginSample ("Constructing Nodes");
//graph.CreateNodes (triangles.Length/3);//new Node[triangles.Length/3];
nodes = new TriangleMeshNode[triangles.Length/3];
for (int i=0;i<nodes.Length;i++) {
nodes[i] = new TriangleMeshNode(active);
TriangleMeshNode node = nodes[i];//new MeshNode ();
node.Penalty = initialPenalty;
node.Walkable = true;
node.v0 = triangles[i*3];
node.v1 = triangles[i*3+1];
node.v2 = triangles[i*3+2];
if (!Polygon.IsClockwise (vertices[node.v0],vertices[node.v1],vertices[node.v2])) {
//Debug.DrawLine (vertices[node.v0],vertices[node.v1],Color.red);
//Debug.DrawLine (vertices[node.v1],vertices[node.v2],Color.red);
//Debug.DrawLine (vertices[node.v2],vertices[node.v0],Color.red);
int tmp = node.v0;
node.v0 = node.v2;
//.........这里部分代码省略.........
示例10: DeserializeExtraInfo
public override void DeserializeExtraInfo (GraphSerializationContext ctx) {
uint graphIndex = (uint)ctx.graphIndex;
TriangleMeshNode.SetNavmeshHolder ((int)graphIndex,this);
int nodeCount = ctx.reader.ReadInt32();
int vertexCount = ctx.reader.ReadInt32();
if (nodeCount == -1) {
nodes = new TriangleMeshNode[0];
_vertices = new Int3[0];
originalVertices = new Vector3[0];
}
nodes = new TriangleMeshNode[nodeCount];
_vertices = new Int3[vertexCount];
originalVertices = new Vector3[vertexCount];
for (int i=0;i<vertexCount;i++) {
_vertices[i] = new Int3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
}
bbTree = new BBTree();
for (int i = 0; i < nodeCount;i++) {
nodes[i] = new TriangleMeshNode(active);
TriangleMeshNode node = nodes[i];
node.DeserializeNode(ctx);
node.UpdatePositionFromVertices();
}
bbTree.RebuildFrom (nodes);
}
示例11: GenerateNodes
/** Generates a navmesh. Based on the supplied vertices and triangles */
void GenerateNodes (Vector3[] vectorVertices, int[] triangles, out Vector3[] originalVertices, out Int3[] vertices) {
Profiler.BeginSample ("Init");
if (vectorVertices.Length == 0 || triangles.Length == 0) {
originalVertices = vectorVertices;
vertices = new Int3[0];
nodes = new TriangleMeshNode[0];
return;
}
vertices = new Int3[vectorVertices.Length];
int c = 0;
for (int i=0;i<vertices.Length;i++) {
vertices[i] = (Int3)matrix.MultiplyPoint3x4 (vectorVertices[i]);
}
var hashedVerts = new Dictionary<Int3,int> ();
var newVertices = new int[vertices.Length];
Profiler.EndSample ();
Profiler.BeginSample ("Hashing");
for (int i=0;i<vertices.Length;i++) {
if (!hashedVerts.ContainsKey (vertices[i])) {
newVertices[c] = i;
hashedVerts.Add (vertices[i], c);
c++;
}
}
for (int x=0;x<triangles.Length;x++) {
Int3 vertex = vertices[triangles[x]];
triangles[x] = hashedVerts[vertex];
}
Int3[] totalIntVertices = vertices;
vertices = new Int3[c];
originalVertices = new Vector3[c];
for (int i=0;i<c;i++) {
vertices[i] = totalIntVertices[newVertices[i]];
originalVertices[i] = vectorVertices[newVertices[i]];
}
Profiler.EndSample ();
Profiler.BeginSample ("Constructing Nodes");
nodes = new TriangleMeshNode[triangles.Length/3];
int graphIndex = active.astarData.GetGraphIndex(this);
// Does not have to set this, it is set in ScanInternal
//TriangleMeshNode.SetNavmeshHolder ((int)graphIndex,this);
for (int i=0;i<nodes.Length;i++) {
nodes[i] = new TriangleMeshNode(active);
TriangleMeshNode node = nodes[i];//new MeshNode ();
node.GraphIndex = (uint)graphIndex;
node.Penalty = initialPenalty;
node.Walkable = true;
node.v0 = triangles[i*3];
node.v1 = triangles[i*3+1];
node.v2 = triangles[i*3+2];
if (!Polygon.IsClockwise (vertices[node.v0],vertices[node.v1],vertices[node.v2])) {
//Debug.DrawLine (vertices[node.v0],vertices[node.v1],Color.red);
//Debug.DrawLine (vertices[node.v1],vertices[node.v2],Color.red);
//Debug.DrawLine (vertices[node.v2],vertices[node.v0],Color.red);
int tmp = node.v0;
node.v0 = node.v2;
node.v2 = tmp;
}
if (Polygon.IsColinear (vertices[node.v0],vertices[node.v1],vertices[node.v2])) {
Debug.DrawLine ((Vector3)vertices[node.v0],(Vector3)vertices[node.v1],Color.red);
Debug.DrawLine ((Vector3)vertices[node.v1],(Vector3)vertices[node.v2],Color.red);
Debug.DrawLine ((Vector3)vertices[node.v2],(Vector3)vertices[node.v0],Color.red);
}
// Make sure position is correctly set
node.UpdatePositionFromVertices();
}
Profiler.EndSample ();
var sides = new Dictionary<Int2, TriangleMeshNode>();
for (int i=0, j=0;i<triangles.Length; j+=1, i+=3) {
sides[new Int2(triangles[i+0],triangles[i+1])] = nodes[j];
//.........这里部分代码省略.........
示例12: ReplaceTile
//.........这里部分代码省略.........
{
throw new Exception("This should not happen");
}
if (l < z || l >= z + d || m < x || m >= x + w)
{
this.tiles[m + l * this.tileXCount] = RecastGraph.NewEmptyTile(m, l);
if (this.batchTileUpdate)
{
this.batchUpdatedTiles.Add(m + l * this.tileXCount);
}
}
else
{
this.tiles[m + l * this.tileXCount] = null;
}
}
}
}
}
}
RecastGraph.NavmeshTile navmeshTile3 = new RecastGraph.NavmeshTile();
navmeshTile3.x = x;
navmeshTile3.z = z;
navmeshTile3.w = w;
navmeshTile3.d = d;
navmeshTile3.tris = tris;
navmeshTile3.verts = verts;
navmeshTile3.bbTree = new BBTree();
if (navmeshTile3.tris.Length % 3 != 0)
{
throw new ArgumentException("Triangle array's length must be a multiple of 3 (tris)");
}
if (navmeshTile3.verts.Length > 65535)
{
throw new ArgumentException("Too many vertices per tile (more than 65535)");
}
if (!worldSpace)
{
if (!Mathf.Approximately((float)(x * this.tileSizeX) * this.cellSize * 1000f, (float)Math.Round((double)((float)(x * this.tileSizeX) * this.cellSize * 1000f))))
{
UnityEngine.Debug.LogWarning("Possible numerical imprecision. Consider adjusting tileSize and/or cellSize");
}
if (!Mathf.Approximately((float)(z * this.tileSizeZ) * this.cellSize * 1000f, (float)Math.Round((double)((float)(z * this.tileSizeZ) * this.cellSize * 1000f))))
{
UnityEngine.Debug.LogWarning("Possible numerical imprecision. Consider adjusting tileSize and/or cellSize");
}
Int3 rhs = (Int3)(new Vector3((float)(x * this.tileSizeX) * this.cellSize, 0f, (float)(z * this.tileSizeZ) * this.cellSize) + this.forcedBounds.min);
for (int n = 0; n < verts.Length; n++)
{
verts[n] += rhs;
}
}
TriangleMeshNode[] array = new TriangleMeshNode[navmeshTile3.tris.Length / 3];
navmeshTile3.nodes = array;
int graphIndex = AstarPath.active.astarData.graphs.Length;
TriangleMeshNode.SetNavmeshHolder(graphIndex, navmeshTile3);
int num = x + z * this.tileXCount;
num <<= 12;
for (int num2 = 0; num2 < array.Length; num2++)
{
TriangleMeshNode triangleMeshNode = new TriangleMeshNode(this.active);
array[num2] = triangleMeshNode;
triangleMeshNode.GraphIndex = (uint)graphIndex;
triangleMeshNode.v0 = (navmeshTile3.tris[num2 * 3] | num);
triangleMeshNode.v1 = (navmeshTile3.tris[num2 * 3 + 1] | num);
triangleMeshNode.v2 = (navmeshTile3.tris[num2 * 3 + 2] | num);
if (!Polygon.IsClockwise(triangleMeshNode.GetVertex(0), triangleMeshNode.GetVertex(1), triangleMeshNode.GetVertex(2)))
{
int v = triangleMeshNode.v0;
triangleMeshNode.v0 = triangleMeshNode.v2;
triangleMeshNode.v2 = v;
}
triangleMeshNode.Walkable = true;
triangleMeshNode.Penalty = this.initialPenalty;
triangleMeshNode.UpdatePositionFromVertices();
}
navmeshTile3.bbTree.RebuildFrom(array);
this.CreateNodeConnections(navmeshTile3.nodes);
for (int num3 = z; num3 < z + d; num3++)
{
for (int num4 = x; num4 < x + w; num4++)
{
this.tiles[num4 + num3 * this.tileXCount] = navmeshTile3;
}
}
if (this.batchTileUpdate)
{
this.batchUpdatedTiles.Add(x + z * this.tileXCount);
}
else
{
this.ConnectTileWithNeighbours(navmeshTile3);
}
TriangleMeshNode.SetNavmeshHolder(graphIndex, null);
graphIndex = AstarPath.active.astarData.GetGraphIndex(this);
for (int num5 = 0; num5 < array.Length; num5++)
{
array[num5].GraphIndex = (uint)graphIndex;
}
}
示例13: DeserializeExtraInfo
public override void DeserializeExtraInfo(GraphSerializationContext ctx)
{
BinaryReader reader = ctx.reader;
this.tileXCount = reader.ReadInt32();
if (this.tileXCount < 0)
{
return;
}
this.tileZCount = reader.ReadInt32();
this.tiles = new RecastGraph.NavmeshTile[this.tileXCount * this.tileZCount];
TriangleMeshNode.SetNavmeshHolder(ctx.graphIndex, this);
for (int i = 0; i < this.tileZCount; i++)
{
for (int j = 0; j < this.tileXCount; j++)
{
int num = j + i * this.tileXCount;
int num2 = reader.ReadInt32();
if (num2 < 0)
{
throw new Exception("Invalid tile coordinates (x < 0)");
}
int num3 = reader.ReadInt32();
if (num3 < 0)
{
throw new Exception("Invalid tile coordinates (z < 0)");
}
if (num2 != j || num3 != i)
{
this.tiles[num] = this.tiles[num3 * this.tileXCount + num2];
}
else
{
RecastGraph.NavmeshTile navmeshTile = new RecastGraph.NavmeshTile();
navmeshTile.x = num2;
navmeshTile.z = num3;
navmeshTile.w = reader.ReadInt32();
navmeshTile.d = reader.ReadInt32();
navmeshTile.bbTree = new BBTree();
this.tiles[num] = navmeshTile;
int num4 = reader.ReadInt32();
if (num4 % 3 != 0)
{
throw new Exception("Corrupt data. Triangle indices count must be divisable by 3. Got " + num4);
}
navmeshTile.tris = new int[num4];
for (int k = 0; k < navmeshTile.tris.Length; k++)
{
navmeshTile.tris[k] = reader.ReadInt32();
}
navmeshTile.verts = new Int3[reader.ReadInt32()];
for (int l = 0; l < navmeshTile.verts.Length; l++)
{
navmeshTile.verts[l] = new Int3(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
}
int num5 = reader.ReadInt32();
navmeshTile.nodes = new TriangleMeshNode[num5];
num <<= 12;
for (int m = 0; m < navmeshTile.nodes.Length; m++)
{
TriangleMeshNode triangleMeshNode = new TriangleMeshNode(this.active);
navmeshTile.nodes[m] = triangleMeshNode;
triangleMeshNode.DeserializeNode(ctx);
triangleMeshNode.v0 = (navmeshTile.tris[m * 3] | num);
triangleMeshNode.v1 = (navmeshTile.tris[m * 3 + 1] | num);
triangleMeshNode.v2 = (navmeshTile.tris[m * 3 + 2] | num);
triangleMeshNode.UpdatePositionFromVertices();
}
navmeshTile.bbTree.RebuildFrom(navmeshTile.nodes);
}
}
}
}
示例14: ContainsPoint
public bool ContainsPoint(TriangleMeshNode node, Vector3 pos)
{
return Polygon.IsClockwise((Vector3)this.GetVertex(node.v0), (Vector3)this.GetVertex(node.v1), pos) && Polygon.IsClockwise((Vector3)this.GetVertex(node.v1), (Vector3)this.GetVertex(node.v2), pos) && Polygon.IsClockwise((Vector3)this.GetVertex(node.v2), (Vector3)this.GetVertex(node.v0), pos);
}
示例15: CreateTile
private RecastGraph.NavmeshTile CreateTile(Voxelize vox, VoxelMesh mesh, int x, int z)
{
if (mesh.tris == null)
{
throw new ArgumentNullException("mesh.tris");
}
if (mesh.verts == null)
{
throw new ArgumentNullException("mesh.verts");
}
RecastGraph.NavmeshTile navmeshTile = new RecastGraph.NavmeshTile();
navmeshTile.x = x;
navmeshTile.z = z;
navmeshTile.w = 1;
navmeshTile.d = 1;
navmeshTile.tris = mesh.tris;
navmeshTile.verts = mesh.verts;
navmeshTile.bbTree = new BBTree();
if (navmeshTile.tris.Length % 3 != 0)
{
throw new ArgumentException("Indices array's length must be a multiple of 3 (mesh.tris)");
}
if (navmeshTile.verts.Length >= 4095)
{
throw new ArgumentException("Too many vertices per tile (more than " + 4095 + ").\nTry enabling ASTAR_RECAST_LARGER_TILES under the 'Optimizations' tab in the A* Inspector");
}
Dictionary<Int3, int> dictionary = this.cachedInt3_int_dict;
dictionary.Clear();
int[] array = new int[navmeshTile.verts.Length];
int num = 0;
for (int i = 0; i < navmeshTile.verts.Length; i++)
{
if (!dictionary.ContainsKey(navmeshTile.verts[i]))
{
dictionary.Add(navmeshTile.verts[i], num);
array[i] = num;
navmeshTile.verts[num] = navmeshTile.verts[i];
num++;
}
else
{
array[i] = dictionary[navmeshTile.verts[i]];
}
}
for (int j = 0; j < navmeshTile.tris.Length; j++)
{
navmeshTile.tris[j] = array[navmeshTile.tris[j]];
}
Int3[] array2 = new Int3[num];
for (int k = 0; k < num; k++)
{
array2[k] = navmeshTile.verts[k];
}
navmeshTile.verts = array2;
TriangleMeshNode[] array3 = new TriangleMeshNode[navmeshTile.tris.Length / 3];
navmeshTile.nodes = array3;
int graphIndex = AstarPath.active.astarData.graphs.Length;
TriangleMeshNode.SetNavmeshHolder(graphIndex, navmeshTile);
int num2 = x + z * this.tileXCount;
num2 <<= 12;
for (int l = 0; l < array3.Length; l++)
{
TriangleMeshNode triangleMeshNode = new TriangleMeshNode(this.active);
array3[l] = triangleMeshNode;
triangleMeshNode.GraphIndex = (uint)graphIndex;
triangleMeshNode.v0 = (navmeshTile.tris[l * 3] | num2);
triangleMeshNode.v1 = (navmeshTile.tris[l * 3 + 1] | num2);
triangleMeshNode.v2 = (navmeshTile.tris[l * 3 + 2] | num2);
if (!Polygon.IsClockwise(triangleMeshNode.GetVertex(0), triangleMeshNode.GetVertex(1), triangleMeshNode.GetVertex(2)))
{
int v = triangleMeshNode.v0;
triangleMeshNode.v0 = triangleMeshNode.v2;
triangleMeshNode.v2 = v;
}
triangleMeshNode.Walkable = true;
triangleMeshNode.Penalty = this.initialPenalty;
triangleMeshNode.UpdatePositionFromVertices();
}
navmeshTile.bbTree.RebuildFrom(array3);
this.CreateNodeConnections(navmeshTile.nodes);
TriangleMeshNode.SetNavmeshHolder(graphIndex, null);
return navmeshTile;
}