void TransformBuffer(List <Vector3> buffer, bool reverse) { var offset = center; // Take rotation and scaling into account if (useRotationAndScale) { var local2world = tr.localToWorldMatrix; for (int i = 0; i < buffer.Count; i++) { buffer[i] = local2world.MultiplyPoint3x4(buffer[i] + offset); } reverse ^= VectorMath.ReversesFaceOrientationsXZ(local2world); } else { offset += tr.position; for (int i = 0; i < buffer.Count; i++) { buffer[i] += offset; } } if (reverse) { buffer.Reverse(); } }
// Token: 0x06002693 RID: 9875 RVA: 0x001A8714 File Offset: 0x001A6914 private void TransformBuffer(List <Vector3> buffer, bool reverse) { Vector3 vector = this.center; if (this.useRotationAndScale) { Matrix4x4 localToWorldMatrix = this.tr.localToWorldMatrix; for (int i = 0; i < buffer.Count; i++) { buffer[i] = localToWorldMatrix.MultiplyPoint3x4(buffer[i] + vector); } reverse ^= VectorMath.ReversesFaceOrientationsXZ(localToWorldMatrix); } else { vector += this.tr.position; for (int j = 0; j < buffer.Count; j++) { int index = j; buffer[index] += vector; } } if (reverse) { buffer.Reverse(); } }
/** * World space contour of the navmesh cut. * Fills the specified buffer with all contours. * The cut may contain several contours which is why the buffer is a list of lists. */ public void GetContour(List <List <Pathfinding.ClipperLib.IntPoint> > buffer) { if (circleResolution < 3) { circleResolution = 3; } Vector3 woffset = tr.position; Matrix4x4 local2world = Matrix4x4.identity; bool reverse = false; // Take rotation and scaling into account if (useRotation) { local2world = tr.localToWorldMatrix; reverse = VectorMath.ReversesFaceOrientationsXZ(local2world); } switch (type) { case MeshType.Rectangle: List <Pathfinding.ClipperLib.IntPoint> buffer0 = Pathfinding.Util.ListPool <Pathfinding.ClipperLib.IntPoint> .Claim(); reverse ^= (rectangleSize.x < 0) ^ (rectangleSize.y < 0); if (useRotation) { buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0, -rectangleSize.y) * 0.5f))); buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0, -rectangleSize.y) * 0.5f))); buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0, rectangleSize.y) * 0.5f))); buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0, rectangleSize.y) * 0.5f))); } else { woffset += center; buffer0.Add(V3ToIntPoint(woffset + new Vector3(-rectangleSize.x, 0, -rectangleSize.y) * 0.5f)); buffer0.Add(V3ToIntPoint(woffset + new Vector3(rectangleSize.x, 0, -rectangleSize.y) * 0.5f)); buffer0.Add(V3ToIntPoint(woffset + new Vector3(rectangleSize.x, 0, rectangleSize.y) * 0.5f)); buffer0.Add(V3ToIntPoint(woffset + new Vector3(-rectangleSize.x, 0, rectangleSize.y) * 0.5f)); } if (reverse) { buffer0.Reverse(); } buffer.Add(buffer0); break; case MeshType.Circle: buffer0 = Pathfinding.Util.ListPool <Pathfinding.ClipperLib.IntPoint> .Claim(circleResolution); reverse ^= circleRadius < 0; if (useRotation) { for (int i = 0; i < circleResolution; i++) { buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + new Vector3(Mathf.Cos((i * 2 * Mathf.PI) / circleResolution), 0, Mathf.Sin((i * 2 * Mathf.PI) / circleResolution)) * circleRadius))); } } else { woffset += center; for (int i = 0; i < circleResolution; i++) { buffer0.Add(V3ToIntPoint(woffset + new Vector3(Mathf.Cos((i * 2 * Mathf.PI) / circleResolution), 0, Mathf.Sin((i * 2 * Mathf.PI) / circleResolution)) * circleRadius)); } } if (reverse) { buffer0.Reverse(); } buffer.Add(buffer0); break; case MeshType.CustomMesh: if (mesh != lastMesh || contours == null) { CalculateMeshContour(); lastMesh = mesh; } if (contours != null) { woffset += center; reverse ^= meshScale < 0; for (int i = 0; i < contours.Length; i++) { Vector3[] contour = contours[i]; buffer0 = Pathfinding.Util.ListPool <Pathfinding.ClipperLib.IntPoint> .Claim(contour.Length); if (useRotation) { for (int x = 0; x < contour.Length; x++) { buffer0.Add(V3ToIntPoint(local2world.MultiplyPoint3x4(center + contour[x] * meshScale))); } } else { for (int x = 0; x < contour.Length; x++) { buffer0.Add(V3ToIntPoint(woffset + contour[x] * meshScale)); } } if (reverse) { buffer0.Reverse(); } buffer.Add(buffer0); } } break; } }
public void GetContour(List<List<IntPoint>> buffer) { if (this.circleResolution < 3) { this.circleResolution = 3; } Vector3 a = this.tr.position; Matrix4x4 matrix = Matrix4x4.identity; bool flag = false; if (this.useRotation) { matrix = this.tr.localToWorldMatrix; flag = VectorMath.ReversesFaceOrientationsXZ(matrix); } NavmeshCut.MeshType meshType = this.type; if (meshType != NavmeshCut.MeshType.Rectangle) { if (meshType != NavmeshCut.MeshType.Circle) { if (meshType == NavmeshCut.MeshType.CustomMesh) { if (this.mesh != this.lastMesh || this.contours == null) { this.CalculateMeshContour(); this.lastMesh = this.mesh; } if (this.contours != null) { a += this.center; flag ^= (this.meshScale < 0f); for (int i = 0; i < this.contours.Length; i++) { Vector3[] array = this.contours[i]; List<IntPoint> list = ListPool<IntPoint>.Claim(array.Length); if (this.useRotation) { for (int j = 0; j < array.Length; j++) { list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + array[j] * this.meshScale))); } } else { for (int k = 0; k < array.Length; k++) { list.Add(NavmeshCut.V3ToIntPoint(a + array[k] * this.meshScale)); } } if (flag) { list.Reverse(); } buffer.Add(list); } } } } else { List<IntPoint> list = ListPool<IntPoint>.Claim(this.circleResolution); flag ^= (this.circleRadius < 0f); if (this.useRotation) { for (int l = 0; l < this.circleResolution; l++) { list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + new Vector3(Mathf.Cos((float)(l * 2) * 3.14159274f / (float)this.circleResolution), 0f, Mathf.Sin((float)(l * 2) * 3.14159274f / (float)this.circleResolution)) * this.circleRadius))); } } else { a += this.center; for (int m = 0; m < this.circleResolution; m++) { list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(Mathf.Cos((float)(m * 2) * 3.14159274f / (float)this.circleResolution), 0f, Mathf.Sin((float)(m * 2) * 3.14159274f / (float)this.circleResolution)) * this.circleRadius)); } } if (flag) { list.Reverse(); } buffer.Add(list); } } else { List<IntPoint> list = ListPool<IntPoint>.Claim(); flag ^= (this.rectangleSize.x < 0f ^ this.rectangleSize.y < 0f); if (this.useRotation) { list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + new Vector3(-this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f))); list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + new Vector3(this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f))); list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + new Vector3(this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f))); list.Add(NavmeshCut.V3ToIntPoint(matrix.MultiplyPoint3x4(this.center + new Vector3(-this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f))); } else { a += this.center; list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)); list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)); list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f)); list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f)); } if (flag) { list.Reverse(); } buffer.Add(list); } }
public void GetContour(List <List <IntPoint> > buffer) { List <IntPoint> list; if (this.circleResolution < 3) { this.circleResolution = 3; } Vector3 position = this.tr.position; Matrix4x4 identity = Matrix4x4.identity; bool flag = false; if (this.useRotation) { identity = this.tr.localToWorldMatrix; flag = VectorMath.ReversesFaceOrientationsXZ(identity); } switch (this.type) { case MeshType.Rectangle: list = ListPool <IntPoint> .Claim(); flag ^= (this.rectangleSize.x < 0f) ^ (this.rectangleSize.y < 0f); if (!this.useRotation) { position += this.center; list.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(-this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)))); list.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)))); list.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f)))); list.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(-this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f)))); break; } list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(new Vector3(-this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f))))); list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(new Vector3(this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f))))); list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(new Vector3(this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f))))); list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(new Vector3(-this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f))))); break; case MeshType.Circle: list = ListPool <IntPoint> .Claim(this.circleResolution); flag ^= this.circleRadius < 0f; if (!this.useRotation) { position += this.center; for (int i = 0; i < this.circleResolution; i++) { list.Add(V3ToIntPoint(position + ((Vector3)(new Vector3(Mathf.Cos(((i * 2) * 3.141593f) / ((float)this.circleResolution)), 0f, Mathf.Sin(((i * 2) * 3.141593f) / ((float)this.circleResolution))) * this.circleRadius)))); } } else { for (int j = 0; j < this.circleResolution; j++) { list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(new Vector3(Mathf.Cos(((j * 2) * 3.141593f) / ((float)this.circleResolution)), 0f, Mathf.Sin(((j * 2) * 3.141593f) / ((float)this.circleResolution))) * this.circleRadius))))); } } if (flag) { list.Reverse(); } buffer.Add(list); return; case MeshType.CustomMesh: if ((this.mesh != this.lastMesh) || (this.contours == null)) { this.CalculateMeshContour(); this.lastMesh = this.mesh; } if (this.contours != null) { position += this.center; flag ^= this.meshScale < 0f; for (int k = 0; k < this.contours.Length; k++) { Vector3[] vectorArray = this.contours[k]; list = ListPool <IntPoint> .Claim(vectorArray.Length); if (this.useRotation) { for (int m = 0; m < vectorArray.Length; m++) { list.Add(V3ToIntPoint(identity.MultiplyPoint3x4(this.center + ((Vector3)(vectorArray[m] * this.meshScale))))); } } else { for (int n = 0; n < vectorArray.Length; n++) { list.Add(V3ToIntPoint(position + ((Vector3)(vectorArray[n] * this.meshScale)))); } } if (flag) { list.Reverse(); } buffer.Add(list); } } return; default: return; } if (flag) { list.Reverse(); } buffer.Add(list); }