public void OnDrawGismos(Transform tr) { Bounds bounds; List <IntPoint> buffer = ListPool <IntPoint> .Claim(); if (this.type == NavmeshCut.MeshType.Circle) { NavmeshCut.GetContour_Circle(buffer, tr, this.circleResolution, this.circleRadius, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Circle(tr, this.center, this.circleRadius, this.height, this.useRotation); } else { NavmeshCut.GetContour_Rectangle(buffer, tr, this.rectangleSize, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Rectangle(tr, this.center, this.rectangleSize, this.height, this.useRotation); } float y = bounds.min.y; Vector3 vector = (Vector3)(Vector3.up * (bounds.max.y - y)); for (int i = 0; i < buffer.Count; i++) { Vector3 from = NavmeshCut.IntPointToV3(buffer[i]); from.y = y; Vector3 to = NavmeshCut.IntPointToV3(buffer[(i + 1) % buffer.Count]); to.y = y; Gizmos.DrawLine(from, to); Gizmos.DrawLine(from + vector, to + vector); Gizmos.DrawLine(from, from + vector); Gizmos.DrawLine(to, to + vector); } ListPool <IntPoint> .Release(buffer); }
public void OnDrawGismos(Transform tr) { List <IntPoint> list = ListPool <IntPoint> .Claim(); Bounds bounds; if (this.type == NavmeshCut.MeshType.Circle) { NavmeshCut.GetContour_Circle(list, tr, this.circleResolution, this.circleRadius, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Circle(tr, this.center, this.circleRadius, this.height, this.useRotation); } else { NavmeshCut.GetContour_Rectangle(list, tr, this.rectangleSize, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Rectangle(tr, this.center, this.rectangleSize, this.height, this.useRotation); } float y = bounds.min.y; Vector3 b = Vector3.up * (bounds.max.y - y); for (int i = 0; i < list.get_Count(); i++) { Vector3 vector = NavmeshCut.IntPointToV3(list.get_Item(i)); vector.y = y; Vector3 vector2 = NavmeshCut.IntPointToV3(list.get_Item((i + 1) % list.get_Count())); vector2.y = y; Gizmos.DrawLine(vector, vector2); Gizmos.DrawLine(vector + b, vector2 + b); Gizmos.DrawLine(vector, vector + b); Gizmos.DrawLine(vector2, vector2 + b); } ListPool <IntPoint> .Release(list); }
public void GetContour(List <List <IntPoint> > buffer) { if (this.circleResolution < 3) { this.circleResolution = 3; } Vector3 a = this.tr.position; switch (this.type) { case NavmeshCut.MeshType.Rectangle: { List <IntPoint> list = ListPool <IntPoint> .Claim(); NavmeshCut.GetContour_Rectangle(list, this.tr, this.rectangleSize, this.center, this.useRotation); buffer.Add(list); break; } case NavmeshCut.MeshType.Circle: { List <IntPoint> list2 = ListPool <IntPoint> .Claim(this.circleResolution); NavmeshCut.GetContour_Circle(list2, this.tr, this.circleResolution, this.circleRadius, this.center, this.useRotation); buffer.Add(list2); break; } case NavmeshCut.MeshType.CustomMesh: if (this.mesh != this.lastMesh || this.contours == null) { this.CalculateMeshContour(); this.lastMesh = this.mesh; } if (this.contours != null) { a += this.center; bool flag = Vector3.Dot(this.tr.up, Vector3.up) < 0f; for (int i = 0; i < this.contours.Length; i++) { Vector3[] array = this.contours[i]; List <IntPoint> list3 = ListPool <IntPoint> .Claim(array.Length); if (this.useRotation) { Matrix4x4 localToWorldMatrix = this.tr.localToWorldMatrix; for (int j = 0; j < array.Length; j++) { list3.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(this.center + array[j] * this.meshScale))); } } else { for (int k = 0; k < array.Length; k++) { list3.Add(NavmeshCut.V3ToIntPoint(a + array[k] * this.meshScale)); } } if (flag) { list3.Reverse(); } buffer.Add(list3); } } break; } }