Insert() public method

public Insert ( Pathfinding.MeshNode node ) : void
node Pathfinding.MeshNode
return void
Ejemplo n.º 1
0
        /** Rebuilds the BBTree on a NavGraph.
         * \astarpro
         * \see NavMeshGraph.bbTree */
        public static void RebuildBBTree(NavMeshGraph graph)
        {
            //Build Axis Aligned Bounding Box Tree

            BBTree bbTree = graph.bbTree;

            bbTree = bbTree ?? new BBTree(graph);
            bbTree.Clear();

            var nodes = graph.nodes;

            for (int i = nodes.Length - 1; i >= 0; i--)
            {
                bbTree.Insert(nodes[i]);
            }

            graph.bbTree = bbTree;
        }
Ejemplo n.º 2
0
        public override void DeserializeExtraInfo(GraphSerializationContext ctx)
        {
            uint graphIndex = (uint)ctx.graphIndex;

            TriangleMeshNode.SetNavmeshHolder((int)graphIndex, this);

            int c1 = ctx.reader.ReadInt32();
            int c2 = ctx.reader.ReadInt32();

            if (c1 == -1)
            {
                nodes            = new TriangleMeshNode[0];
                _vertices        = new Int3[0];
                originalVertices = new Vector3[0];
            }

            nodes            = new TriangleMeshNode[c1];
            _vertices        = new Int3[c2];
            originalVertices = new Vector3[c2];

            for (int i = 0; i < c2; i++)
            {
                _vertices[i]        = new Int3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
                originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
            }

            bbTree = new BBTree(this);

            for (int i = 0; i < c1; i++)
            {
                nodes[i] = new TriangleMeshNode(active);
                TriangleMeshNode node = nodes[i];
                node.DeserializeNode(ctx);
                node.UpdatePositionFromVertices();
                bbTree.Insert(node);
            }
        }
Ejemplo n.º 3
0
		/** Rebuilds the BBTree on a NavGraph.
		 * \astarpro
		 * \see NavMeshGraph.bbTree */
		public static void RebuildBBTree (NavMeshGraph graph) {
			//Build Axis Aligned Bounding Box Tree
			
			NavMeshGraph meshGraph = graph as NavMeshGraph;
			
			BBTree bbTree = new BBTree (graph as INavmeshHolder);
			
			TriangleMeshNode[] nodes = meshGraph.TriNodes;
			
			for (int i=nodes.Length-1;i>=0;i--) {
				bbTree.Insert (nodes[i]);
			}
			
			meshGraph.bbTree = bbTree;
		}
Ejemplo n.º 4
0
		/** Relocates the nodes to match the newMatrix.
		 * The "oldMatrix" variable can be left out in this function call (only for this graph generator) since it is not used */
		public override void RelocateNodes (Matrix4x4 oldMatrix, Matrix4x4 newMatrix) {
			//base.RelocateNodes (oldMatrix,newMatrix);
			
			if (vertices == null || vertices.Length == 0 || originalVertices == null || originalVertices.Length != vertices.Length) {
				return;
			}
			
			for (int i=0;i<_vertices.Length;i++) {
				//Vector3 tmp = inv.MultiplyPoint3x4 (vertices[i]);
				//vertices[i] = (Int3)newMatrix.MultiplyPoint3x4 (tmp);
				_vertices[i] = (Int3)newMatrix.MultiplyPoint3x4 ((Vector3)originalVertices[i]);
			}
			
			for (int i=0;i<nodes.Length;i++) {
				TriangleMeshNode node = (TriangleMeshNode)nodes[i];
				node.UpdatePositionFromVertices();
				
				if (node.connections != null) {
					for (int q=0;q<node.connections.Length;q++) {
						node.connectionCosts[q] = (uint)(node.position-node.connections[q].position).costMagnitude;
					}
				}
			}
			
			SetMatrix (newMatrix);
			
			// Make a new BBTree
			bbTree = new BBTree(this);
			for (int i=0;i<nodes.Length;i++) {
				bbTree.Insert (nodes[i]);
			}
		}
Ejemplo n.º 5
0
		public override void DeserializeExtraInfo (GraphSerializationContext ctx)
		{
			
			uint graphIndex = (uint)active.astarData.GetGraphIndex(this);
			TriangleMeshNode.SetNavmeshHolder ((int)graphIndex,this);
			
			int c1 = ctx.reader.ReadInt32();
			int c2 = ctx.reader.ReadInt32();
			
			if (c1 == -1) {
				nodes = new TriangleMeshNode[0];
				_vertices = new Int3[0];
				originalVertices = new Vector3[0];
			}
			
			nodes = new TriangleMeshNode[c1];
			_vertices = new Int3[c2];
			originalVertices = new Vector3[c2];
			
			for (int i=0;i<c2;i++) {
				_vertices[i] = new Int3(ctx.reader.ReadInt32(), ctx.reader.ReadInt32(), ctx.reader.ReadInt32());
				originalVertices[i] = new Vector3(ctx.reader.ReadSingle(), ctx.reader.ReadSingle(), ctx.reader.ReadSingle());
			}
			
			bbTree = new BBTree(this);
			
			for (int i=0;i<c1;i++) {
				nodes[i] = new TriangleMeshNode(active);
				TriangleMeshNode node = nodes[i];
				node.DeserializeNode(ctx);
				node.GraphIndex = graphIndex;
				node.UpdatePositionFromVertices();
				bbTree.Insert (node);
			}
		}
Ejemplo n.º 6
0
        /** Rebuilds the BBTree on a NavGraph.
         * \astarpro
         * \see NavMeshGraph.bbTree */
        public static void RebuildBBTree(NavGraph graph)
        {
            //Build Axis Aligned Bounding Box Tree

            INavmesh meshGraph = graph as INavmesh;

            BBTree bbTree = new BBTree (graph as INavmesh);

            for (int i=0;i<graph.nodes.Length;i++) {
                bbTree.Insert (graph.nodes[i] as MeshNode);
            }

            meshGraph.bbTree = bbTree;
        }