V3ToIntPoint() public method

public V3ToIntPoint ( Vector3 p ) : Pathfinding.ClipperLib.IntPoint
p UnityEngine.Vector3
return Pathfinding.ClipperLib.IntPoint
Ejemplo n.º 1
0
        public static void GetContour_Rectangle(List <IntPoint> buffer, Transform tr, Vector2 rectangleSize, Vector3 center, bool useRotation)
        {
            Vector3 a = tr.position;

            if (useRotation)
            {
                Matrix4x4 localToWorldMatrix = tr.localToWorldMatrix;
                buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0f, -rectangleSize.y) * 0.5f)));
                buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0f, -rectangleSize.y) * 0.5f)));
                buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(rectangleSize.x, 0f, rectangleSize.y) * 0.5f)));
                buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x, 0f, rectangleSize.y) * 0.5f)));
            }
            else
            {
                float num  = rectangleSize.x * tr.lossyScale.x;
                float num2 = rectangleSize.y * tr.lossyScale.y;
                a += center.Mul(tr.lossyScale);
                buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-num, 0f, -num2) * 0.5f));
                buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(num, 0f, -num2) * 0.5f));
                buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(num, 0f, num2) * 0.5f));
                buffer.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(-num, 0f, num2) * 0.5f));
            }
        }
Ejemplo n.º 2
0
        public static void GetContour_Circle(List <IntPoint> buffer, Transform tr, int circleResolution, float circleRadius, Vector3 center, bool useRotation)
        {
            Vector3 a = tr.position;

            if (useRotation)
            {
                Matrix4x4 localToWorldMatrix = tr.localToWorldMatrix;
                for (int i = 0; i < circleResolution; i++)
                {
                    buffer.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(center + new Vector3(Mathf.Cos((float)(i * 2) * 3.14159274f / (float)circleResolution), 0f, Mathf.Sin((float)(i * 2) * 3.14159274f / (float)circleResolution)) * circleRadius)));
                }
            }
            else
            {
                Vector3 zero = Vector3.zero;
                a += center.Mul(tr.lossyScale);
                for (int j = 0; j < circleResolution; j++)
                {
                    zero.x = Mathf.Cos((float)(j * 2) * 3.14159274f / (float)circleResolution) * circleRadius * tr.lossyScale.x;
                    zero.z = Mathf.Sin((float)(j * 2) * 3.14159274f / (float)circleResolution) * circleRadius * tr.lossyScale.z;
                    buffer.Add(NavmeshCut.V3ToIntPoint(a + zero));
                }
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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();

                if (this.useRotation)
                {
                    Matrix4x4 localToWorldMatrix = this.tr.localToWorldMatrix;
                    list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(-this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)));
                    list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(this.rectangleSize.x, 0f, -this.rectangleSize.y) * 0.5f)));
                    list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(this.rectangleSize.x, 0f, this.rectangleSize.y) * 0.5f)));
                    list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix.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));
                }
                buffer.Add(list);
                break;
            }

            case NavmeshCut.MeshType.Circle:
            {
                List <IntPoint> list = ListPool <IntPoint> .Claim(this.circleResolution);

                if (this.useRotation)
                {
                    Matrix4x4 localToWorldMatrix2 = this.tr.localToWorldMatrix;
                    for (int i = 0; i < this.circleResolution; i++)
                    {
                        list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix2.MultiplyPoint3x4(this.center + new Vector3(Mathf.Cos((float)(i * 2) * 3.14159274f / (float)this.circleResolution), 0f, Mathf.Sin((float)(i * 2) * 3.14159274f / (float)this.circleResolution)) * this.circleRadius)));
                    }
                }
                else
                {
                    a += this.center;
                    for (int j = 0; j < this.circleResolution; j++)
                    {
                        list.Add(NavmeshCut.V3ToIntPoint(a + new Vector3(Mathf.Cos((float)(j * 2) * 3.14159274f / (float)this.circleResolution), 0f, Mathf.Sin((float)(j * 2) * 3.14159274f / (float)this.circleResolution)) * this.circleRadius));
                    }
                }
                buffer.Add(list);
                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 k = 0; k < this.contours.Length; k++)
                    {
                        Vector3[]       array = this.contours[k];
                        List <IntPoint> list  = ListPool <IntPoint> .Claim(array.Length);

                        if (this.useRotation)
                        {
                            Matrix4x4 localToWorldMatrix3 = this.tr.localToWorldMatrix;
                            for (int l = 0; l < array.Length; l++)
                            {
                                list.Add(NavmeshCut.V3ToIntPoint(localToWorldMatrix3.MultiplyPoint3x4(this.center + array[l] * this.meshScale)));
                            }
                        }
                        else
                        {
                            for (int m = 0; m < array.Length; m++)
                            {
                                list.Add(NavmeshCut.V3ToIntPoint(a + array[m] * this.meshScale));
                            }
                        }
                        if (flag)
                        {
                            list.Reverse();
                        }
                        buffer.Add(list);
                    }
                }
                break;
            }
        }
Ejemplo n.º 5
0
		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);
			}
		}