public override Vector3 ClosestPointOnNodeXZ(Vector3 _p) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); Int3 vertex = navmeshHolder.GetVertex(this.v0); Int3 vertex2 = navmeshHolder.GetVertex(this.v1); Int3 vertex3 = navmeshHolder.GetVertex(this.v2); Int3 point = (Int3)_p; int y = point.y; vertex.y = 0; vertex2.y = 0; vertex3.y = 0; point.y = 0; if ((long)(vertex2.x - vertex.x) * (long)(point.z - vertex.z) - (long)(point.x - vertex.x) * (long)(vertex2.z - vertex.z) > 0L) { float num = Mathf.Clamp01(AstarMath.NearestPointFactor(vertex, vertex2, point)); return(new Vector3((float)vertex.x + (float)(vertex2.x - vertex.x) * num, (float)y, (float)vertex.z + (float)(vertex2.z - vertex.z) * num) * 0.001f); } if ((long)(vertex3.x - vertex2.x) * (long)(point.z - vertex2.z) - (long)(point.x - vertex2.x) * (long)(vertex3.z - vertex2.z) > 0L) { float num2 = Mathf.Clamp01(AstarMath.NearestPointFactor(vertex2, vertex3, point)); return(new Vector3((float)vertex2.x + (float)(vertex3.x - vertex2.x) * num2, (float)y, (float)vertex2.z + (float)(vertex3.z - vertex2.z) * num2) * 0.001f); } if ((long)(vertex.x - vertex3.x) * (long)(point.z - vertex3.z) - (long)(point.x - vertex3.x) * (long)(vertex.z - vertex3.z) > 0L) { float num3 = Mathf.Clamp01(AstarMath.NearestPointFactor(vertex3, vertex, point)); return(new Vector3((float)vertex3.x + (float)(vertex.x - vertex3.x) * num3, (float)y, (float)vertex3.z + (float)(vertex.z - vertex3.z) * num3) * 0.001f); } return(_p); }
public Int3 ClosestPointOnNodeXZ(Int3 p) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); Int3 vertex = navmeshHolder.GetVertex(this.v0); Int3 vertex2 = navmeshHolder.GetVertex(this.v1); Int3 vertex3 = navmeshHolder.GetVertex(this.v2); vertex.y = 0; vertex2.y = 0; vertex3.y = 0; Int3 result; if ((long)(vertex2.x - vertex.x) * (long)(p.z - vertex.z) - (long)(p.x - vertex.x) * (long)(vertex2.z - vertex.z) > 0L) { this.CalcNearestPoint(out result, ref vertex, ref vertex2, ref p); } else if ((long)(vertex3.x - vertex2.x) * (long)(p.z - vertex2.z) - (long)(p.x - vertex2.x) * (long)(vertex3.z - vertex2.z) > 0L) { this.CalcNearestPoint(out result, ref vertex2, ref vertex3, ref p); } else if ((long)(vertex.x - vertex3.x) * (long)(p.z - vertex3.z) - (long)(p.x - vertex3.x) * (long)(vertex.z - vertex3.z) > 0L) { this.CalcNearestPoint(out result, ref vertex3, ref vertex, ref p); } else { result = p; } return(result); }
// Token: 0x060025F1 RID: 9713 RVA: 0x001A6710 File Offset: 0x001A4910 public void GetVerticesInGraphSpace(out Int3 v0, out Int3 v1, out Int3 v2) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); v0 = navmeshHolder.GetVertexInGraphSpace(this.v0); v1 = navmeshHolder.GetVertexInGraphSpace(this.v1); v2 = navmeshHolder.GetVertexInGraphSpace(this.v2); }
public void GetPoints(out Int3 a, out Int3 b, out Int3 c) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(GraphIndex); a = navmeshHolder.GetVertex(this.v0); b = navmeshHolder.GetVertex(this.v1); c = navmeshHolder.GetVertex(this.v2); }
public void GetPoints(out Vector3 a, out Vector3 b, out Vector3 c) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); a = (Vector3)navmeshHolder.GetVertex(this.v0); b = (Vector3)navmeshHolder.GetVertex(this.v1); c = (Vector3)navmeshHolder.GetVertex(this.v2); }
public override bool ContainsPoint(Int3 p) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); Int3 vertex = navmeshHolder.GetVertex(this.v0); Int3 vertex2 = navmeshHolder.GetVertex(this.v1); Int3 vertex3 = navmeshHolder.GetVertex(this.v2); return((long)(vertex2.x - vertex.x) * (long)(p.z - vertex.z) - (long)(p.x - vertex.x) * (long)(vertex2.z - vertex.z) <= 0L && (long)(vertex3.x - vertex2.x) * (long)(p.z - vertex2.z) - (long)(p.x - vertex2.x) * (long)(vertex3.z - vertex2.z) <= 0L && (long)(vertex.x - vertex3.x) * (long)(p.z - vertex3.z) - (long)(p.x - vertex3.x) * (long)(vertex.z - vertex3.z) <= 0L); }
public override Vector3 ClosestPointOnNodeXZ(Vector3 p) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); Int3 vertex = navmeshHolder.GetVertex(this.v0); Int3 vertex2 = navmeshHolder.GetVertex(this.v1); Int3 vertex3 = navmeshHolder.GetVertex(this.v2); Vector2 vector = Polygon.ClosestPointOnTriangle(new Vector2((float)vertex.x * 0.001f, (float)vertex.z * 0.001f), new Vector2((float)vertex2.x * 0.001f, (float)vertex2.z * 0.001f), new Vector2((float)vertex3.x * 0.001f, (float)vertex3.z * 0.001f), new Vector2(p.x, p.z)); return(new Vector3(vector.x, p.y, vector.y)); }
public override Vector3 RandomPointOnSurface() { float value; float value2; do { value = UnityEngine.Random.value; value2 = UnityEngine.Random.value; }while (value + value2 > 1f); INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); return((Vector3)(navmeshHolder.GetVertex(this.v1) - navmeshHolder.GetVertex(this.v0)) * value + (Vector3)(navmeshHolder.GetVertex(this.v2) - navmeshHolder.GetVertex(this.v0)) * value2 + (Vector3)navmeshHolder.GetVertex(this.v0)); }
public override VInt3 GetVertex(int i) { VInt3 result = VInt3.zero; try { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex); result = navmeshHolder.GetVertex(this.GetVertexIndex(i)); } catch (Exception) { } return(result); }
// Token: 0x060025F6 RID: 9718 RVA: 0x001A67C8 File Offset: 0x001A49C8 internal Int3 ClosestPointOnNodeXZInGraphSpace(Vector3 p) { Int3 @int; Int3 int2; Int3 int3; this.GetVerticesInGraphSpace(out @int, out int2, out int3); p = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex).transform.InverseTransform(p); Int3 int4 = (Int3)Polygon.ClosestPointOnTriangleXZ((Vector3)@int, (Vector3)int2, (Vector3)int3, p); if (this.ContainsPointInGraphSpace(int4)) { return(int4); } for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i != 0 || j != 0) { Int3 int5 = new Int3(int4.x + i, int4.y, int4.z + j); if (this.ContainsPointInGraphSpace(int5)) { return(int5); } } } } long sqrMagnitudeLong = (@int - int4).sqrMagnitudeLong; long sqrMagnitudeLong2 = (int2 - int4).sqrMagnitudeLong; long sqrMagnitudeLong3 = (int3 - int4).sqrMagnitudeLong; if (sqrMagnitudeLong >= sqrMagnitudeLong2) { if (sqrMagnitudeLong2 >= sqrMagnitudeLong3) { return(int3); } return(int2); } else { if (sqrMagnitudeLong >= sqrMagnitudeLong3) { return(int3); } return(@int); } }
public bool IsVertex(Int3 p, out int index) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); index = -1; if (navmeshHolder.GetVertex(this.v0).IsEqualXZ(ref p)) { index = 0; } else if (navmeshHolder.GetVertex(this.v1).IsEqualXZ(ref p)) { index = 1; } else if (navmeshHolder.GetVertex(this.v2).IsEqualXZ(ref p)) { index = 2; } return(index != -1); }
public bool GetPortal(GraphNode _other, List <VInt3> left, List <VInt3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (_other.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode triangleMeshNode = _other as TriangleMeshNode; int num = this.GetVertexIndex(0) >> 12 & 524287; int num2 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287; if (num != num2 && TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex) is RecastGraph) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex); int num3; int num4; navmeshHolder.GetTileCoordinates(num, out num3, out num4); int num5; int num6; navmeshHolder.GetTileCoordinates(num2, out num5, out num6); int num7; if (Math.Abs(num3 - num5) == 1) { num7 = 0; } else { if (Math.Abs(num4 - num6) != 1) { throw new Exception(string.Concat(new object[] { "Tiles not adjacent (", num3, ", ", num4, ") (", num5, ", ", num6, ")" })); } num7 = 2; } int vertexCount = this.GetVertexCount(); int vertexCount2 = triangleMeshNode.GetVertexCount(); int num8 = -1; int num9 = -1; for (int i = 0; i < vertexCount; i++) { int num10 = this.GetVertex(i)[num7]; for (int j = 0; j < vertexCount2; j++) { if (num10 == triangleMeshNode.GetVertex((j + 1) % vertexCount2)[num7] && this.GetVertex((i + 1) % vertexCount)[num7] == triangleMeshNode.GetVertex(j)[num7]) { num8 = i; num9 = j; i = vertexCount; break; } } } aIndex = num8; bIndex = num9; if (num8 != -1) { VInt3 vertex = this.GetVertex(num8); VInt3 vertex2 = this.GetVertex((num8 + 1) % vertexCount); int i2 = (num7 == 2) ? 0 : 2; int num11 = Math.Min(vertex[i2], vertex2[i2]); int num12 = Math.Max(vertex[i2], vertex2[i2]); num11 = Math.Max(num11, Math.Min(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); num12 = Math.Min(num12, Math.Max(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); if (vertex[i2] < vertex2[i2]) { vertex[i2] = num11; vertex2[i2] = num12; } else { vertex[i2] = num12; vertex2[i2] = num11; } if (left != null) { left.Add(vertex); right.Add(vertex2); } return(true); } } else if (!backwards) { int num13 = -1; int num14 = -1; int vertexCount3 = this.GetVertexCount(); int vertexCount4 = triangleMeshNode.GetVertexCount(); for (int k = 0; k < vertexCount3; k++) { int vertexIndex = this.GetVertexIndex(k); for (int l = 0; l < vertexCount4; l++) { if (vertexIndex == triangleMeshNode.GetVertexIndex((l + 1) % vertexCount4) && this.GetVertexIndex((k + 1) % vertexCount3) == triangleMeshNode.GetVertexIndex(l)) { num13 = k; num14 = l; k = vertexCount3; break; } } } aIndex = num13; bIndex = num14; if (num13 == -1) { return(false); } if (left != null) { left.Add(this.GetVertex(num13)); right.Add(this.GetVertex((num13 + 1) % vertexCount3)); } } return(true); }
public int GetVertexArrayIndex(int i) { return(TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex).GetVertexArrayIndex((i == 0) ? this.v0 : ((i == 1) ? this.v1 : this.v2))); }
// Token: 0x060025FE RID: 9726 RVA: 0x001A6C10 File Offset: 0x001A4E10 public bool GetPortal(GraphNode toNode, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (backwards || toNode.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode triangleMeshNode = toNode as TriangleMeshNode; int num = this.SharedEdge(triangleMeshNode); if (num == 255) { return(false); } if (num == -1) { for (int i = 0; i < this.connections.Length; i++) { if (this.connections[i].node.GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node = this.connections[i].node as NodeLink3Node; if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode) { nodeLink3Node.GetPortal(triangleMeshNode, left, right, false); return(true); } } } return(false); } aIndex = num; bIndex = (num + 1) % this.GetVertexCount(); Int3 vertex = this.GetVertex(num); Int3 vertex2 = this.GetVertex((num + 1) % this.GetVertexCount()); int num2 = this.GetVertexIndex(0) >> 12 & 524287; int num3 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287; if (num2 != num3) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); int num4; int num5; navmeshHolder.GetTileCoordinates(num2, out num4, out num5); int num6; int num7; navmeshHolder.GetTileCoordinates(num3, out num6, out num7); int i2; if (Math.Abs(num4 - num6) == 1) { i2 = 2; } else { if (Math.Abs(num5 - num7) != 1) { return(false); } i2 = 0; } int num8 = triangleMeshNode.SharedEdge(this); if (num8 == 255) { throw new Exception("Connection used edge in one direction, but not in the other direction. Has the wrong overload of AddConnection been used?"); } if (num8 != -1) { int num9 = Math.Min(vertex[i2], vertex2[i2]); int num10 = Math.Max(vertex[i2], vertex2[i2]); Int3 vertex3 = triangleMeshNode.GetVertex(num8); Int3 vertex4 = triangleMeshNode.GetVertex((num8 + 1) % triangleMeshNode.GetVertexCount()); num9 = Math.Max(num9, Math.Min(vertex3[i2], vertex4[i2])); num10 = Math.Min(num10, Math.Max(vertex3[i2], vertex4[i2])); if (vertex[i2] < vertex2[i2]) { vertex[i2] = num9; vertex2[i2] = num10; } else { vertex[i2] = num10; vertex2[i2] = num9; } } } if (left != null) { left.Add((Vector3)vertex); right.Add((Vector3)vertex2); } return(true); }
// Token: 0x060025F8 RID: 9720 RVA: 0x001A68F9 File Offset: 0x001A4AF9 public override bool ContainsPoint(Vector3 p) { return(this.ContainsPointInGraphSpace((Int3)TriangleMeshNode.GetNavmeshHolder(base.GraphIndex).transform.InverseTransform(p))); }
public override Vector3 ClosestPointOnNode(Vector3 p) { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); return(Polygon.ClosestPointOnTriangle((Vector3)navmeshHolder.GetVertex(this.v0), (Vector3)navmeshHolder.GetVertex(this.v1), (Vector3)navmeshHolder.GetVertex(this.v2), p)); }
// Token: 0x060025F3 RID: 9715 RVA: 0x001A6778 File Offset: 0x001A4978 public Int3 GetVertexInGraphSpace(int i) { return(TriangleMeshNode.GetNavmeshHolder(base.GraphIndex).GetVertexInGraphSpace(this.GetVertexIndex(i))); }
public override Int3 GetVertex(int i) { return(TriangleMeshNode.GetNavmeshHolder(base.GraphIndex).GetVertex(this.GetVertexIndex(i))); }
public int GetVertexArrayIndex(int i) { return(TriangleMeshNode.GetNavmeshHolder(base.GraphIndex).GetVertexArrayIndex((i != 0) ? ((i != 1) ? this.v2 : this.v1) : this.v0)); }
public void UpdatePositionFromVertices() { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); this.position = (navmeshHolder.GetVertex(this.v0) + navmeshHolder.GetVertex(this.v1) + navmeshHolder.GetVertex(this.v2)) * 0.333333f; }
public bool GetPortal(GraphNode _other, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex) { aIndex = -1; bIndex = -1; if (_other.GraphIndex != base.GraphIndex) { return(false); } TriangleMeshNode triangleMeshNode = _other as TriangleMeshNode; int num = this.GetVertexIndex(0) >> 12 & 524287; int num2 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287; if (num != num2 && TriangleMeshNode.GetNavmeshHolder(base.GraphIndex) is RecastGraph) { for (int i = 0; i < this.connections.Length; i++) { if (this.connections[i].GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node = this.connections[i] as NodeLink3Node; if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode && left != null) { nodeLink3Node.GetPortal(triangleMeshNode, left, right, false); return(true); } } } INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); int num3; int num4; navmeshHolder.GetTileCoordinates(num, out num3, out num4); int num5; int num6; navmeshHolder.GetTileCoordinates(num2, out num5, out num6); int num7; if (Math.Abs(num3 - num5) == 1) { num7 = 0; } else { if (Math.Abs(num4 - num6) != 1) { throw new Exception(string.Concat(new object[] { "Tiles not adjacent (", num3, ", ", num4, ") (", num5, ", ", num6, ")" })); } num7 = 2; } int vertexCount = this.GetVertexCount(); int vertexCount2 = triangleMeshNode.GetVertexCount(); int num8 = -1; int num9 = -1; for (int j = 0; j < vertexCount; j++) { int num10 = this.GetVertex(j)[num7]; for (int k = 0; k < vertexCount2; k++) { if (num10 == triangleMeshNode.GetVertex((k + 1) % vertexCount2)[num7] && this.GetVertex((j + 1) % vertexCount)[num7] == triangleMeshNode.GetVertex(k)[num7]) { num8 = j; num9 = k; j = vertexCount; break; } } } aIndex = num8; bIndex = num9; if (num8 != -1) { Int3 vertex = this.GetVertex(num8); Int3 vertex2 = this.GetVertex((num8 + 1) % vertexCount); int i2 = (num7 != 2) ? 2 : 0; int num11 = Math.Min(vertex[i2], vertex2[i2]); int num12 = Math.Max(vertex[i2], vertex2[i2]); num11 = Math.Max(num11, Math.Min(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); num12 = Math.Min(num12, Math.Max(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2])); if (vertex[i2] < vertex2[i2]) { vertex[i2] = num11; vertex2[i2] = num12; } else { vertex[i2] = num12; vertex2[i2] = num11; } if (left != null) { left.Add((Vector3)vertex); right.Add((Vector3)vertex2); } return(true); } } else if (!backwards) { int num13 = -1; int num14 = -1; int vertexCount3 = this.GetVertexCount(); int vertexCount4 = triangleMeshNode.GetVertexCount(); for (int l = 0; l < vertexCount3; l++) { int vertexIndex = this.GetVertexIndex(l); for (int m = 0; m < vertexCount4; m++) { if (vertexIndex == triangleMeshNode.GetVertexIndex((m + 1) % vertexCount4) && this.GetVertexIndex((l + 1) % vertexCount3) == triangleMeshNode.GetVertexIndex(m)) { num13 = l; num14 = m; l = vertexCount3; break; } } } aIndex = num13; bIndex = num14; if (num13 == -1) { for (int n = 0; n < this.connections.Length; n++) { if (this.connections[n].GraphIndex != base.GraphIndex) { NodeLink3Node nodeLink3Node2 = this.connections[n] as NodeLink3Node; if (nodeLink3Node2 != null && nodeLink3Node2.GetOther(this) == triangleMeshNode && left != null) { nodeLink3Node2.GetPortal(triangleMeshNode, left, right, false); return(true); } } } return(false); } if (left != null) { left.Add((Vector3)this.GetVertex(num13)); right.Add((Vector3)this.GetVertex((num13 + 1) % vertexCount3)); } } return(true); }
public override float SurfaceArea() { INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex); return((float)Math.Abs(VectorMath.SignedTriangleAreaTimes2XZ(navmeshHolder.GetVertex(this.v0), navmeshHolder.GetVertex(this.v1), navmeshHolder.GetVertex(this.v2))) * 0.5f); }