Exemple #1
0
        public TriangleMeshNode GetLocatedByRasterizer(VInt3 position)
        {
            TriangleMeshNode result = null;

            if (this.rasterizer != null)
            {
                List <object> located = this.rasterizer.GetLocated(position);
                if (located != null)
                {
                    for (int i = 0; i < located.get_Count(); i++)
                    {
                        TriangleMeshNode triangleMeshNode = located.get_Item(i) as TriangleMeshNode;
                        if (triangleMeshNode == null)
                        {
                            break;
                        }
                        VInt3 a;
                        VInt3 b;
                        VInt3 c;
                        triangleMeshNode.GetPoints(out a, out b, out c);
                        if (Polygon.ContainsPoint(a, b, c, position))
                        {
                            result = triangleMeshNode;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
        public TriangleMeshNode GetLocatedByRasterizer(Int3 position)
        {
            TriangleMeshNode result = null;

            if (this.rasterizer != null)
            {
                List <object> located = this.rasterizer.GetLocated(position);
                if (located != null)
                {
                    for (int i = 0; i < located.Count; i++)
                    {
                        TriangleMeshNode triangleMeshNode = located[i] as TriangleMeshNode;
                        if (triangleMeshNode == null)
                        {
                            break;
                        }
                        Int3 a;
                        Int3 b;
                        Int3 c;
                        triangleMeshNode.GetPoints(out a, out b, out c);

                        AStarDebug.DrawTriangle(0, a, b, c);
                        if (Polygon.ContainsPoint(a, b, c, position))
                        {
                            result = triangleMeshNode;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
        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);
        }
Exemple #4
0
        private TriangleMeshNode checkObjIntersects(ref int edge, VInt3 start, VInt3 end, int gridX, int gridY)
        {
            List <object> objs = this.rasterizer.GetObjs(gridX, gridY);

            if ((objs != null) && (objs.Count != 0))
            {
                VInt3[]          numArray = new VInt3[3];
                TriangleMeshNode node     = null;
                int  num  = -1;
                long num2 = 0x7fffffffffffffffL;
                for (int i = 0; i < objs.Count; i++)
                {
                    TriangleMeshNode node2 = objs[i] as TriangleMeshNode;
                    node2.GetPoints(out numArray[0], out numArray[1], out numArray[2]);
                    for (int j = 0; j < 3; j++)
                    {
                        int index = j;
                        int num6  = (j + 1) % 3;
                        if (Polygon.Intersects(numArray[index], numArray[num6], start, end))
                        {
                            bool  flag;
                            VInt3 rhs = Polygon.IntersectionPoint(ref numArray[index], ref numArray[num6], ref start, ref end, out flag);
                            DebugHelper.Assert(flag);
                            long num8 = start.XZSqrMagnitude(ref rhs);
                            if (num8 < num2)
                            {
                                num2 = num8;
                                node = node2;
                                num  = j;
                            }
                        }
                    }
                }
                if ((num != -1) && (node != null))
                {
                    edge = num;
                    return(node);
                }
            }
            return(null);
        }
        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);
        }