Ejemplo n.º 1
0
        private bool getNearest(Int3 position, List <object> objs, ref long minDist, ref TriangleMeshNode nearestNode)
        {
            if (objs == null || objs.Count == 0)
            {
                return(false);
            }
            bool result = false;

            for (int i = 0; i < objs.Count; i++)
            {
                TriangleMeshNode triangleMeshNode = objs[i] as TriangleMeshNode;
                if (triangleMeshNode == null)
                {
                    return(false);
                }
                long num = position.XZSqrMagnitude(triangleMeshNode.position);
                if (num < minDist)
                {
                    minDist     = num;
                    nearestNode = triangleMeshNode;
                    result      = true;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        private TriangleMeshNode checkObjIntersects(ref int edge, Int3 start, Int3 end, int gridX, int gridY)
        {
            List <object> objs = this.rasterizer.GetObjs(gridX, gridY);

            if (objs == null || objs.Count == 0)
            {
                return(null);
            }
            Int3[]           array            = new Int3[3];
            TriangleMeshNode triangleMeshNode = null;
            int  num  = -1;
            long num2 = 9223372036854775807L;

            for (int i = 0; i < objs.Count; i++)
            {
                TriangleMeshNode triangleMeshNode2 = objs[i] as TriangleMeshNode;
                triangleMeshNode2.GetPoints(out array[0], out array[1], out array[2]);
                for (int j = 0; j < 3; j++)
                {
                    int num3 = j;
                    int num4 = (j + 1) % 3;
                    if (Polygon.Intersects(array[num3], array[num4], start, end))
                    {
                        bool flag;
                        Int3 vInt = Polygon.IntersectionPoint(ref array[num3], ref array[num4], ref start, ref end, out flag);

                        long num5 = start.XZSqrMagnitude(ref vInt);
                        if (num5 < num2)
                        {
                            num2             = num5;
                            triangleMeshNode = triangleMeshNode2;
                            num = j;
                        }
                    }
                }
            }
            if (num != -1 && triangleMeshNode != null)
            {
                edge = num;
                return(triangleMeshNode);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public bool CheckSegmentIntersects(Int3 start, Int3 end, int gridX, int gridY, out Int3 outPoint, out TriangleMeshNode nearestNode)
        {
            List <object> objs = this.rasterizer.GetObjs(gridX, gridY);

            outPoint    = end;
            nearestNode = null;
            if (objs == null || objs.Count == 0)
            {
                return(false);
            }
            Int3[] array  = new Int3[3];
            bool   result = false;
            long   num    = 9223372036854775807L;

            for (int i = 0; i < objs.Count; i++)
            {
                TriangleMeshNode triangleMeshNode = objs[i] as TriangleMeshNode;
                triangleMeshNode.GetPoints(out array[0], out array[1], out array[2]);
                for (int j = 0; j < 3; j++)
                {
                    int  num2 = j;
                    int  num3 = (j + 1) % 3;
                    bool flag = false;
                    Int3 vInt = Polygon.SegmentIntersectionPoint(array[num2], array[num3], start, end, out flag);
                    if (flag)
                    {
                        long num4 = start.XZSqrMagnitude(ref vInt);
                        if (num4 < num)
                        {
                            nearestNode = triangleMeshNode;
                            num         = num4;
                            outPoint    = vInt;
                            result      = true;
                        }
                    }
                }
            }
            return(result);
        }