示例#1
0
        public override Vector3 ClosestPointOnNodeXZ(Vector3 _p)
        {
            INavmeshHolder navmeshHolder = GetNavmeshHolder(base.DataGroupIndex, base.GraphIndex);
            VInt3          vertex        = navmeshHolder.GetVertex(this.v0);
            VInt3          lineEnd       = navmeshHolder.GetVertex(this.v1);
            VInt3          num3          = navmeshHolder.GetVertex(this.v2);
            VInt3          point         = (VInt3)_p;
            int            y             = point.y;

            vertex.y  = 0;
            lineEnd.y = 0;
            num3.y    = 0;
            point.y   = 0;
            if ((((lineEnd.x - vertex.x) * (point.z - vertex.z)) - ((point.x - vertex.x) * (lineEnd.z - vertex.z))) > 0L)
            {
                float num6 = Mathf.Clamp01(AstarMath.NearestPointFactorXZ(vertex, lineEnd, point));
                return((Vector3)(new Vector3(vertex.x + ((lineEnd.x - vertex.x) * num6), (float)y, vertex.z + ((lineEnd.z - vertex.z) * num6)) * 0.001f));
            }
            if ((((num3.x - lineEnd.x) * (point.z - lineEnd.z)) - ((point.x - lineEnd.x) * (num3.z - lineEnd.z))) > 0L)
            {
                float num7 = Mathf.Clamp01(AstarMath.NearestPointFactorXZ(lineEnd, num3, point));
                return((Vector3)(new Vector3(lineEnd.x + ((num3.x - lineEnd.x) * num7), (float)y, lineEnd.z + ((num3.z - lineEnd.z) * num7)) * 0.001f));
            }
            if ((((vertex.x - num3.x) * (point.z - num3.z)) - ((point.x - num3.x) * (vertex.z - num3.z))) > 0L)
            {
                float num8 = Mathf.Clamp01(AstarMath.NearestPointFactorXZ(num3, vertex, point));
                return((Vector3)(new Vector3(num3.x + ((vertex.x - num3.x) * num8), (float)y, num3.z + ((vertex.z - num3.z) * num8)) * 0.001f));
            }
            return(_p);
        }
示例#2
0
        public override Vector3 ClosestPointOnNodeXZ(Vector3 _p)
        {
            INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex);
            VInt3          vertex        = navmeshHolder.GetVertex(this.v0);
            VInt3          vertex2       = navmeshHolder.GetVertex(this.v1);
            VInt3          vertex3       = navmeshHolder.GetVertex(this.v2);
            VInt3          point         = (VInt3)_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.NearestPointFactorXZ(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.NearestPointFactorXZ(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.NearestPointFactorXZ(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);
        }