예제 #1
0
        public bool GetPortal(GraphNode _other, System.Collections.Generic.List <Vector3> left, System.Collections.Generic.List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;

            //If the nodes are in different graphs, this function has no idea on how to find a shared edge.
            if (_other.GraphIndex != GraphIndex)
            {
                return(false);
            }

            TriangleMeshNode other = _other as TriangleMeshNode;

            //Get tile indices
            int tileIndex  = (GetVertexIndex(0) >> RecastGraph.TileIndexOffset) & RecastGraph.TileIndexMask;
            int tileIndex2 = (other.GetVertexIndex(0) >> RecastGraph.TileIndexOffset) & RecastGraph.TileIndexMask;

            //When the nodes are in different tiles, the edges might not be completely identical
            //so another technique is needed
            //Only do this on recast graphs
            if (tileIndex != tileIndex2 && (GetNavmeshHolder(GraphIndex) is RecastGraph))
            {
                for (int i = 0; i < connections.Length; i++)
                {
                    if (connections[i].GraphIndex != GraphIndex)
                    {
#if !ASTAR_NO_POINT_GRAPH
                        NodeLink3Node mid = connections[i] as NodeLink3Node;
                        if (mid != null && mid.GetOther(this) == other)
                        {
                            // We have found a node which is connected through a NodeLink3Node

                            if (left != null)
                            {
                                mid.GetPortal(other, left, right, false);
                                return(true);
                            }
                        }
#endif
                    }
                }

                //Get the tile coordinates, from them we can figure out which edge is going to be shared
                int            x1, x2, z1, z2;
                int            coord;
                INavmeshHolder nm = GetNavmeshHolder(GraphIndex);
                nm.GetTileCoordinates(tileIndex, out x1, out z1);
                nm.GetTileCoordinates(tileIndex2, out x2, out z2);

                if (System.Math.Abs(x1 - x2) == 1)
                {
                    coord = 0;
                }
                else if (System.Math.Abs(z1 - z2) == 1)
                {
                    coord = 2;
                }
                else
                {
                    throw new System.Exception("Tiles not adjacent (" + x1 + ", " + z1 + ") (" + x2 + ", " + z2 + ")");
                }

                int av = GetVertexCount();
                int bv = other.GetVertexCount();

                //Try the X and Z coordinate. For one of them the coordinates should be equal for one of the two nodes' edges
                //The midpoint between the tiles is the only place where they will be equal

                int first = -1, second = -1;

                //Find the shared edge
                for (int a = 0; a < av; a++)
                {
                    int va = GetVertex(a)[coord];
                    for (int b = 0; b < bv; b++)
                    {
                        if (va == other.GetVertex((b + 1) % bv)[coord] && GetVertex((a + 1) % av)[coord] == other.GetVertex(b)[coord])
                        {
                            first  = a;
                            second = b;
                            a      = av;
                            break;
                        }
                    }
                }

                aIndex = first;
                bIndex = second;

                if (first != -1)
                {
                    Int3 a = GetVertex(first);
                    Int3 b = GetVertex((first + 1) % av);

                    //The coordinate which is not the same for the vertices
                    int ocoord = coord == 2 ? 0 : 2;

                    //When the nodes are in different tiles, they might not share exactly the same edge
                    //so we clamp the portal to the segment of the edges which they both have.
                    int mincoord = System.Math.Min(a[ocoord], b[ocoord]);
                    int maxcoord = System.Math.Max(a[ocoord], b[ocoord]);

                    mincoord = System.Math.Max(mincoord, System.Math.Min(other.GetVertex(second)[ocoord], other.GetVertex((second + 1) % bv)[ocoord]));
                    maxcoord = System.Math.Min(maxcoord, System.Math.Max(other.GetVertex(second)[ocoord], other.GetVertex((second + 1) % bv)[ocoord]));

                    if (a[ocoord] < b[ocoord])
                    {
                        a[ocoord] = mincoord;
                        b[ocoord] = maxcoord;
                    }
                    else
                    {
                        a[ocoord] = maxcoord;
                        b[ocoord] = mincoord;
                    }

                    if (left != null)
                    {
                        //All triangles should be clockwise so second is the rightmost vertex (seen from this node)
                        left.Add((Vector3)a);
                        right.Add((Vector3)b);
                    }
                    return(true);
                }
            }
            else
            if (!backwards)
            {
                int first  = -1;
                int second = -1;

                int av = GetVertexCount();
                int bv = other.GetVertexCount();

                /** \todo Maybe optimize with pa=av-1 instead of modulus... */
                for (int a = 0; a < av; a++)
                {
                    int va = GetVertexIndex(a);
                    for (int b = 0; b < bv; b++)
                    {
                        if (va == other.GetVertexIndex((b + 1) % bv) && GetVertexIndex((a + 1) % av) == other.GetVertexIndex(b))
                        {
                            first  = a;
                            second = b;
                            a      = av;
                            break;
                        }
                    }
                }

                aIndex = first;
                bIndex = second;

                if (first != -1)
                {
                    if (left != null)
                    {
                        //All triangles should be clockwise so second is the rightmost vertex (seen from this node)
                        left.Add((Vector3)GetVertex(first));
                        right.Add((Vector3)GetVertex((first + 1) % av));
                    }
                }
                else
                {
                    for (int i = 0; i < connections.Length; i++)
                    {
                        if (connections[i].GraphIndex != GraphIndex)
                        {
#if !ASTAR_NO_POINT_GRAPH
                            NodeLink3Node mid = connections[i] as NodeLink3Node;
                            if (mid != null && mid.GetOther(this) == other)
                            {
                                // We have found a node which is connected through a NodeLink3Node

                                if (left != null)
                                {
                                    mid.GetPortal(other, left, right, false);
                                    return(true);
                                }
                            }
#endif
                        }
                    }
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public bool GetPortal(GraphNode toNode, System.Collections.Generic.List <Vector3> left, System.Collections.Generic.List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;

            //If the nodes are in different graphs, this function has no idea on how to find a shared edge.
            if (backwards || toNode.GraphIndex != GraphIndex)
            {
                return(false);
            }

            // Since the nodes are in the same graph, they are both TriangleMeshNodes
            // So we don't need to care about other types of nodes
            var toTriNode = toNode as TriangleMeshNode;
            var edge      = SharedEdge(toTriNode);

            // A connection was found, but it specifically didn't use an edge
            if (edge == 0xFF)
            {
                return(false);
            }

            // No connection was found between the nodes
            // Check if there is a node link that connects them
            if (edge == -1)
            {
#if !ASTAR_NO_POINT_GRAPH
                if (connections != null)
                {
                    for (int i = 0; i < connections.Length; i++)
                    {
                        if (connections[i].node.GraphIndex != GraphIndex)
                        {
                            var mid = connections[i].node as NodeLink3Node;
                            if (mid != null && mid.GetOther(this) == toTriNode)
                            {
                                // We have found a node which is connected through a NodeLink3Node
                                mid.GetPortal(toTriNode, left, right, false);
                                return(true);
                            }
                        }
                    }
                }
#endif

                return(false);
            }

            aIndex = edge;
            bIndex = (edge + 1) % GetVertexCount();

            // Get the vertices of the shared edge for the first node
            Int3 v1a = GetVertex(edge);
            Int3 v1b = GetVertex((edge + 1) % GetVertexCount());

            // Get tile indices
            int tileIndex1 = (GetVertexIndex(0) >> NavmeshBase.TileIndexOffset) & NavmeshBase.TileIndexMask;
            int tileIndex2 = (toTriNode.GetVertexIndex(0) >> NavmeshBase.TileIndexOffset) & NavmeshBase.TileIndexMask;

            if (tileIndex1 != tileIndex2)
            {
                // When the nodes are in different tiles, the edges might not be completely identical
                // so another technique is needed.

                // Get the tile coordinates, from them we can figure out which edge is going to be shared
                int            x1, x2, z1, z2, coord;
                INavmeshHolder nm = GetNavmeshHolder(GraphIndex);
                nm.GetTileCoordinates(tileIndex1, out x1, out z1);
                nm.GetTileCoordinates(tileIndex2, out x2, out z2);

                if (System.Math.Abs(x1 - x2) == 1)
                {
                    coord = 2;
                }
                else if (System.Math.Abs(z1 - z2) == 1)
                {
                    coord = 0;
                }
                else
                {
                    return(false);                 // Tiles are not adjacent. This is likely a custom connection between two nodes.
                }
                var otherEdge = toTriNode.SharedEdge(this);

                // A connection was found, but it specifically didn't use an edge. This is odd since the connection in the other direction did use an edge
                if (otherEdge == 0xFF)
                {
                    throw new System.Exception("Connection used edge in one direction, but not in the other direction. Has the wrong overload of AddConnection been used?");
                }

                // If it is -1 then it must be a one-way connection. Fall back to using the whole edge
                if (otherEdge != -1)
                {
                    // When the nodes are in different tiles, they might not share exactly the same edge
                    // so we clamp the portal to the segment of the edges which they both have.
                    int mincoord = System.Math.Min(v1a[coord], v1b[coord]);
                    int maxcoord = System.Math.Max(v1a[coord], v1b[coord]);

                    // Get the vertices of the shared edge for the second node
                    Int3 v2a = toTriNode.GetVertex(otherEdge);
                    Int3 v2b = toTriNode.GetVertex((otherEdge + 1) % toTriNode.GetVertexCount());

                    mincoord = System.Math.Max(mincoord, System.Math.Min(v2a[coord], v2b[coord]));
                    maxcoord = System.Math.Min(maxcoord, System.Math.Max(v2a[coord], v2b[coord]));

                    if (v1a[coord] < v1b[coord])
                    {
                        v1a[coord] = mincoord;
                        v1b[coord] = maxcoord;
                    }
                    else
                    {
                        v1a[coord] = maxcoord;
                        v1b[coord] = mincoord;
                    }
                }
            }

            if (left != null)
            {
                // All triangles should be laid out in clockwise order so v1b is the rightmost vertex (seen from this node)
                left.Add((Vector3)v1a);
                right.Add((Vector3)v1b);
            }
            return(true);
        }
예제 #3
0
        public bool GetPortal(GraphNode _other, List <VInt3> left, List <VInt3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;
            if (_other.GraphIndex != base.GraphIndex)
            {
                return(false);
            }
            TriangleMeshNode node = _other as TriangleMeshNode;
            int tileIndex         = (this.GetVertexIndex(0) >> 12) & 0x7ffff;
            int num2 = (node.GetVertexIndex(0) >> 12) & 0x7ffff;

            if ((tileIndex != num2) && (GetNavmeshHolder(base.DataGroupIndex, base.GraphIndex) is RecastGraph))
            {
                int            num3;
                int            num4;
                int            num5;
                int            num6;
                int            num7;
                INavmeshHolder navmeshHolder = GetNavmeshHolder(base.DataGroupIndex, base.GraphIndex);
                navmeshHolder.GetTileCoordinates(tileIndex, out num3, out num5);
                navmeshHolder.GetTileCoordinates(num2, out num4, out num6);
                if (Math.Abs((int)(num3 - num4)) == 1)
                {
                    num7 = 0;
                }
                else if (Math.Abs((int)(num5 - num6)) == 1)
                {
                    num7 = 2;
                }
                else
                {
                    object[] objArray1 = new object[] { "Tiles not adjacent (", num3, ", ", num5, ") (", num4, ", ", num6, ")" };
                    throw new Exception(string.Concat(objArray1));
                }
                int vertexCount = this.GetVertexCount();
                int num9        = node.GetVertexCount();
                int i           = -1;
                int num11       = -1;
                for (int j = 0; j < vertexCount; j++)
                {
                    int num13 = this.GetVertex(j)[num7];
                    for (int k = 0; k < num9; k++)
                    {
                        if ((num13 == node.GetVertex((k + 1) % num9)[num7]) && (this.GetVertex((j + 1) % vertexCount)[num7] == node.GetVertex(k)[num7]))
                        {
                            i     = j;
                            num11 = k;
                            j     = vertexCount;
                            break;
                        }
                    }
                }
                aIndex = i;
                bIndex = num11;
                if (i != -1)
                {
                    VInt3 vertex = this.GetVertex(i);
                    VInt3 item   = this.GetVertex((i + 1) % vertexCount);
                    int   num17  = (num7 != 2) ? 2 : 0;
                    int   num18  = Math.Min(vertex[num17], item[num17]);
                    int   num19  = Math.Max(vertex[num17], item[num17]);
                    num18 = Math.Max(num18, Math.Min(node.GetVertex(num11)[num17], node.GetVertex((num11 + 1) % num9)[num17]));
                    num19 = Math.Min(num19, Math.Max(node.GetVertex(num11)[num17], node.GetVertex((num11 + 1) % num9)[num17]));
                    if (vertex[num17] < item[num17])
                    {
                        vertex[num17] = num18;
                        item[num17]   = num19;
                    }
                    else
                    {
                        vertex[num17] = num19;
                        item[num17]   = num18;
                    }
                    if (left != null)
                    {
                        left.Add(vertex);
                        right.Add(item);
                    }
                    return(true);
                }
            }
            else if (!backwards)
            {
                int num20 = -1;
                int num21 = -1;
                int num22 = this.GetVertexCount();
                int num23 = node.GetVertexCount();
                for (int m = 0; m < num22; m++)
                {
                    int vertexIndex = this.GetVertexIndex(m);
                    for (int n = 0; n < num23; n++)
                    {
                        if ((vertexIndex == node.GetVertexIndex((n + 1) % num23)) && (this.GetVertexIndex((m + 1) % num22) == node.GetVertexIndex(n)))
                        {
                            num20 = m;
                            num21 = n;
                            m     = num22;
                            break;
                        }
                    }
                }
                aIndex = num20;
                bIndex = num21;
                if (num20 == -1)
                {
                    return(false);
                }
                if (left != null)
                {
                    left.Add(this.GetVertex(num20));
                    right.Add(this.GetVertex((num20 + 1) % num22));
                }
            }
            return(true);
        }
예제 #4
0
        public bool GetPortal(GraphNode _other, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;
            if (_other.GraphIndex != base.GraphIndex)
            {
                return(false);
            }
            TriangleMeshNode triangleMeshNode = _other as TriangleMeshNode;
            int num  = this.GetVertexIndex(0) >> 12 & 524287;
            int num2 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287;

            if (num != num2 && TriangleMeshNode.GetNavmeshHolder(base.GraphIndex) is RecastGraph)
            {
                for (int i = 0; i < this.connections.Length; i++)
                {
                    if (this.connections[i].GraphIndex != base.GraphIndex)
                    {
                        NodeLink3Node nodeLink3Node = this.connections[i] as NodeLink3Node;
                        if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode && left != null)
                        {
                            nodeLink3Node.GetPortal(triangleMeshNode, left, right, false);
                            return(true);
                        }
                    }
                }
                INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex);
                int            num3;
                int            num4;
                navmeshHolder.GetTileCoordinates(num, out num3, out num4);
                int num5;
                int num6;
                navmeshHolder.GetTileCoordinates(num2, out num5, out num6);
                int num7;
                if (Math.Abs(num3 - num5) == 1)
                {
                    num7 = 0;
                }
                else
                {
                    if (Math.Abs(num4 - num6) != 1)
                    {
                        throw new Exception(string.Concat(new object[]
                        {
                            "Tiles not adjacent (",
                            num3,
                            ", ",
                            num4,
                            ") (",
                            num5,
                            ", ",
                            num6,
                            ")"
                        }));
                    }
                    num7 = 2;
                }
                int vertexCount  = this.GetVertexCount();
                int vertexCount2 = triangleMeshNode.GetVertexCount();
                int num8         = -1;
                int num9         = -1;
                for (int j = 0; j < vertexCount; j++)
                {
                    int num10 = this.GetVertex(j)[num7];
                    for (int k = 0; k < vertexCount2; k++)
                    {
                        if (num10 == triangleMeshNode.GetVertex((k + 1) % vertexCount2)[num7] && this.GetVertex((j + 1) % vertexCount)[num7] == triangleMeshNode.GetVertex(k)[num7])
                        {
                            num8 = j;
                            num9 = k;
                            j    = vertexCount;
                            break;
                        }
                    }
                }
                aIndex = num8;
                bIndex = num9;
                if (num8 != -1)
                {
                    Int3 vertex  = this.GetVertex(num8);
                    Int3 vertex2 = this.GetVertex((num8 + 1) % vertexCount);
                    int  i2      = (num7 != 2) ? 2 : 0;
                    int  num11   = Math.Min(vertex[i2], vertex2[i2]);
                    int  num12   = Math.Max(vertex[i2], vertex2[i2]);
                    num11 = Math.Max(num11, Math.Min(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2]));
                    num12 = Math.Min(num12, Math.Max(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2]));
                    if (vertex[i2] < vertex2[i2])
                    {
                        vertex[i2]  = num11;
                        vertex2[i2] = num12;
                    }
                    else
                    {
                        vertex[i2]  = num12;
                        vertex2[i2] = num11;
                    }
                    if (left != null)
                    {
                        left.Add((Vector3)vertex);
                        right.Add((Vector3)vertex2);
                    }
                    return(true);
                }
            }
            else if (!backwards)
            {
                int num13        = -1;
                int num14        = -1;
                int vertexCount3 = this.GetVertexCount();
                int vertexCount4 = triangleMeshNode.GetVertexCount();
                for (int l = 0; l < vertexCount3; l++)
                {
                    int vertexIndex = this.GetVertexIndex(l);
                    for (int m = 0; m < vertexCount4; m++)
                    {
                        if (vertexIndex == triangleMeshNode.GetVertexIndex((m + 1) % vertexCount4) && this.GetVertexIndex((l + 1) % vertexCount3) == triangleMeshNode.GetVertexIndex(m))
                        {
                            num13 = l;
                            num14 = m;
                            l     = vertexCount3;
                            break;
                        }
                    }
                }
                aIndex = num13;
                bIndex = num14;
                if (num13 == -1)
                {
                    for (int n = 0; n < this.connections.Length; n++)
                    {
                        if (this.connections[n].GraphIndex != base.GraphIndex)
                        {
                            NodeLink3Node nodeLink3Node2 = this.connections[n] as NodeLink3Node;
                            if (nodeLink3Node2 != null && nodeLink3Node2.GetOther(this) == triangleMeshNode && left != null)
                            {
                                nodeLink3Node2.GetPortal(triangleMeshNode, left, right, false);
                                return(true);
                            }
                        }
                    }
                    return(false);
                }
                if (left != null)
                {
                    left.Add((Vector3)this.GetVertex(num13));
                    right.Add((Vector3)this.GetVertex((num13 + 1) % vertexCount3));
                }
            }
            return(true);
        }
예제 #5
0
        // Token: 0x060025FE RID: 9726 RVA: 0x001A6C10 File Offset: 0x001A4E10
        public bool GetPortal(GraphNode toNode, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;
            if (backwards || toNode.GraphIndex != base.GraphIndex)
            {
                return(false);
            }
            TriangleMeshNode triangleMeshNode = toNode as TriangleMeshNode;
            int num = this.SharedEdge(triangleMeshNode);

            if (num == 255)
            {
                return(false);
            }
            if (num == -1)
            {
                for (int i = 0; i < this.connections.Length; i++)
                {
                    if (this.connections[i].node.GraphIndex != base.GraphIndex)
                    {
                        NodeLink3Node nodeLink3Node = this.connections[i].node as NodeLink3Node;
                        if (nodeLink3Node != null && nodeLink3Node.GetOther(this) == triangleMeshNode)
                        {
                            nodeLink3Node.GetPortal(triangleMeshNode, left, right, false);
                            return(true);
                        }
                    }
                }
                return(false);
            }
            aIndex = num;
            bIndex = (num + 1) % this.GetVertexCount();
            Int3 vertex  = this.GetVertex(num);
            Int3 vertex2 = this.GetVertex((num + 1) % this.GetVertexCount());
            int  num2    = this.GetVertexIndex(0) >> 12 & 524287;
            int  num3    = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287;

            if (num2 != num3)
            {
                INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(base.GraphIndex);
                int            num4;
                int            num5;
                navmeshHolder.GetTileCoordinates(num2, out num4, out num5);
                int num6;
                int num7;
                navmeshHolder.GetTileCoordinates(num3, out num6, out num7);
                int i2;
                if (Math.Abs(num4 - num6) == 1)
                {
                    i2 = 2;
                }
                else
                {
                    if (Math.Abs(num5 - num7) != 1)
                    {
                        return(false);
                    }
                    i2 = 0;
                }
                int num8 = triangleMeshNode.SharedEdge(this);
                if (num8 == 255)
                {
                    throw new Exception("Connection used edge in one direction, but not in the other direction. Has the wrong overload of AddConnection been used?");
                }
                if (num8 != -1)
                {
                    int  num9    = Math.Min(vertex[i2], vertex2[i2]);
                    int  num10   = Math.Max(vertex[i2], vertex2[i2]);
                    Int3 vertex3 = triangleMeshNode.GetVertex(num8);
                    Int3 vertex4 = triangleMeshNode.GetVertex((num8 + 1) % triangleMeshNode.GetVertexCount());
                    num9  = Math.Max(num9, Math.Min(vertex3[i2], vertex4[i2]));
                    num10 = Math.Min(num10, Math.Max(vertex3[i2], vertex4[i2]));
                    if (vertex[i2] < vertex2[i2])
                    {
                        vertex[i2]  = num9;
                        vertex2[i2] = num10;
                    }
                    else
                    {
                        vertex[i2]  = num10;
                        vertex2[i2] = num9;
                    }
                }
            }
            if (left != null)
            {
                left.Add((Vector3)vertex);
                right.Add((Vector3)vertex2);
            }
            return(true);
        }
예제 #6
0
        public bool GetPortal(GraphNode _other, List <Vector3> left, List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;
            if (_other.GraphIndex != base.GraphIndex)
            {
                return(false);
            }
            TriangleMeshNode other = _other as TriangleMeshNode;
            int tileIndex          = (this.GetVertexIndex(0) >> 12) & 0x7ffff;
            int num2 = (other.GetVertexIndex(0) >> 12) & 0x7ffff;

            if ((tileIndex != num2) && (GetNavmeshHolder(base.GraphIndex) is RecastGraph))
            {
                int num4;
                int num5;
                int num6;
                int num7;
                int num8;
                for (int i = 0; i < base.connections.Length; i++)
                {
                    if (base.connections[i].GraphIndex != base.GraphIndex)
                    {
                        NodeLink3Node node2 = base.connections[i] as NodeLink3Node;
                        if (((node2 != null) && (node2.GetOther(this) == other)) && (left != null))
                        {
                            node2.GetPortal(other, left, right, false);
                            return(true);
                        }
                    }
                }
                INavmeshHolder navmeshHolder = GetNavmeshHolder(base.GraphIndex);
                navmeshHolder.GetTileCoordinates(tileIndex, out num4, out num6);
                navmeshHolder.GetTileCoordinates(num2, out num5, out num7);
                if (Math.Abs((int)(num4 - num5)) == 1)
                {
                    num8 = 0;
                }
                else if (Math.Abs((int)(num6 - num7)) == 1)
                {
                    num8 = 2;
                }
                else
                {
                    object[] objArray1 = new object[] { "Tiles not adjacent (", num4, ", ", num6, ") (", num5, ", ", num7, ")" };
                    throw new Exception(string.Concat(objArray1));
                }
                int vertexCount = this.GetVertexCount();
                int num10       = other.GetVertexCount();
                int num11       = -1;
                int num12       = -1;
                for (int j = 0; j < vertexCount; j++)
                {
                    int num14 = this.GetVertex(j)[num8];
                    for (int k = 0; k < num10; k++)
                    {
                        if ((num14 == other.GetVertex((k + 1) % num10)[num8]) && (this.GetVertex((j + 1) % vertexCount)[num8] == other.GetVertex(k)[num8]))
                        {
                            num11 = j;
                            num12 = k;
                            j     = vertexCount;
                            break;
                        }
                    }
                }
                aIndex = num11;
                bIndex = num12;
                if (num11 != -1)
                {
                    Int3 vertex = this.GetVertex(num11);
                    Int3 num17  = this.GetVertex((num11 + 1) % vertexCount);
                    int  num18  = (num8 != 2) ? 2 : 0;
                    int  num19  = Math.Min(vertex[num18], num17[num18]);
                    int  num20  = Math.Max(vertex[num18], num17[num18]);
                    num19 = Math.Max(num19, Math.Min(other.GetVertex(num12)[num18], other.GetVertex((num12 + 1) % num10)[num18]));
                    num20 = Math.Min(num20, Math.Max(other.GetVertex(num12)[num18], other.GetVertex((num12 + 1) % num10)[num18]));
                    if (vertex[num18] < num17[num18])
                    {
                        vertex[num18] = num19;
                        num17[num18]  = num20;
                    }
                    else
                    {
                        vertex[num18] = num20;
                        num17[num18]  = num19;
                    }
                    if (left != null)
                    {
                        left.Add((Vector3)vertex);
                        right.Add((Vector3)num17);
                    }
                    return(true);
                }
            }
            else if (!backwards)
            {
                int num21 = -1;
                int num22 = -1;
                int num23 = this.GetVertexCount();
                int num24 = other.GetVertexCount();
                for (int m = 0; m < num23; m++)
                {
                    int vertexIndex = this.GetVertexIndex(m);
                    for (int n = 0; n < num24; n++)
                    {
                        if ((vertexIndex == other.GetVertexIndex((n + 1) % num24)) && (this.GetVertexIndex((m + 1) % num23) == other.GetVertexIndex(n)))
                        {
                            num21 = m;
                            num22 = n;
                            m     = num23;
                            break;
                        }
                    }
                }
                aIndex = num21;
                bIndex = num22;
                if (num21 == -1)
                {
                    for (int num28 = 0; num28 < base.connections.Length; num28++)
                    {
                        if (base.connections[num28].GraphIndex != base.GraphIndex)
                        {
                            NodeLink3Node node3 = base.connections[num28] as NodeLink3Node;
                            if (((node3 != null) && (node3.GetOther(this) == other)) && (left != null))
                            {
                                node3.GetPortal(other, left, right, false);
                                return(true);
                            }
                        }
                    }
                    return(false);
                }
                if (left != null)
                {
                    left.Add((Vector3)this.GetVertex(num21));
                    right.Add((Vector3)this.GetVertex((num21 + 1) % num23));
                }
            }
            return(true);
        }
예제 #7
0
        public bool GetPortal(GraphNode _other, List <VInt3> left, List <VInt3> right, bool backwards, out int aIndex, out int bIndex)
        {
            aIndex = -1;
            bIndex = -1;
            if (_other.GraphIndex != base.GraphIndex)
            {
                return(false);
            }
            TriangleMeshNode triangleMeshNode = _other as TriangleMeshNode;
            int num  = this.GetVertexIndex(0) >> 12 & 524287;
            int num2 = triangleMeshNode.GetVertexIndex(0) >> 12 & 524287;

            if (num != num2 && TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex) is RecastGraph)
            {
                INavmeshHolder navmeshHolder = TriangleMeshNode.GetNavmeshHolder(this.DataGroupIndex, base.GraphIndex);
                int            num3;
                int            num4;
                navmeshHolder.GetTileCoordinates(num, out num3, out num4);
                int num5;
                int num6;
                navmeshHolder.GetTileCoordinates(num2, out num5, out num6);
                int num7;
                if (Math.Abs(num3 - num5) == 1)
                {
                    num7 = 0;
                }
                else
                {
                    if (Math.Abs(num4 - num6) != 1)
                    {
                        throw new Exception(string.Concat(new object[]
                        {
                            "Tiles not adjacent (",
                            num3,
                            ", ",
                            num4,
                            ") (",
                            num5,
                            ", ",
                            num6,
                            ")"
                        }));
                    }
                    num7 = 2;
                }
                int vertexCount  = this.GetVertexCount();
                int vertexCount2 = triangleMeshNode.GetVertexCount();
                int num8         = -1;
                int num9         = -1;
                for (int i = 0; i < vertexCount; i++)
                {
                    int num10 = this.GetVertex(i)[num7];
                    for (int j = 0; j < vertexCount2; j++)
                    {
                        if (num10 == triangleMeshNode.GetVertex((j + 1) % vertexCount2)[num7] && this.GetVertex((i + 1) % vertexCount)[num7] == triangleMeshNode.GetVertex(j)[num7])
                        {
                            num8 = i;
                            num9 = j;
                            i    = vertexCount;
                            break;
                        }
                    }
                }
                aIndex = num8;
                bIndex = num9;
                if (num8 != -1)
                {
                    VInt3 vertex  = this.GetVertex(num8);
                    VInt3 vertex2 = this.GetVertex((num8 + 1) % vertexCount);
                    int   i2      = (num7 == 2) ? 0 : 2;
                    int   num11   = Math.Min(vertex[i2], vertex2[i2]);
                    int   num12   = Math.Max(vertex[i2], vertex2[i2]);
                    num11 = Math.Max(num11, Math.Min(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2]));
                    num12 = Math.Min(num12, Math.Max(triangleMeshNode.GetVertex(num9)[i2], triangleMeshNode.GetVertex((num9 + 1) % vertexCount2)[i2]));
                    if (vertex[i2] < vertex2[i2])
                    {
                        vertex[i2]  = num11;
                        vertex2[i2] = num12;
                    }
                    else
                    {
                        vertex[i2]  = num12;
                        vertex2[i2] = num11;
                    }
                    if (left != null)
                    {
                        left.Add(vertex);
                        right.Add(vertex2);
                    }
                    return(true);
                }
            }
            else if (!backwards)
            {
                int num13        = -1;
                int num14        = -1;
                int vertexCount3 = this.GetVertexCount();
                int vertexCount4 = triangleMeshNode.GetVertexCount();
                for (int k = 0; k < vertexCount3; k++)
                {
                    int vertexIndex = this.GetVertexIndex(k);
                    for (int l = 0; l < vertexCount4; l++)
                    {
                        if (vertexIndex == triangleMeshNode.GetVertexIndex((l + 1) % vertexCount4) && this.GetVertexIndex((k + 1) % vertexCount3) == triangleMeshNode.GetVertexIndex(l))
                        {
                            num13 = k;
                            num14 = l;
                            k     = vertexCount3;
                            break;
                        }
                    }
                }
                aIndex = num13;
                bIndex = num14;
                if (num13 == -1)
                {
                    return(false);
                }
                if (left != null)
                {
                    left.Add(this.GetVertex(num13));
                    right.Add(this.GetVertex((num13 + 1) % vertexCount3));
                }
            }
            return(true);
        }