示例#1
0
        Vector3 ClosestPointOnNodeXZ(VInt3 vertex, VInt3 vertex2, VInt3 vertex3, 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(IntMath.NearestPointFloatXZ(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(IntMath.NearestPointFloatXZ(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(IntMath.NearestPointFloatXZ(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);
        }