Пример #1
0
		public void CreateNodeRec (QuadtreeNodeHolder holder, int depth, int x, int y) {
			
			int width = 1 << (System.Math.Min (editorHeightLog2,editorWidthLog2)-depth);
			int walkable;
			if (depth < minDepth) {
				walkable = -1;
			} else {
				walkable = CheckNode (x,y, width);
			}
			
			if (walkable == 1 || walkable == 0 || width == 1) {
				QuadtreeNode node = new QuadtreeNode(active);
				node.SetPosition ((Int3)LocalToWorldPosition(x,y,width));
				node.Walkable = walkable == 1;
				holder.node = node;
				
				
			} else { //walkable = -1 //Undefined
				holder.c0 = new QuadtreeNodeHolder ();
				holder.c1 = new QuadtreeNodeHolder ();
				holder.c2 = new QuadtreeNodeHolder ();
				holder.c3 = new QuadtreeNodeHolder ();
				
				CreateNodeRec (holder.c0,depth+1,x          , y          );
				CreateNodeRec (holder.c1,depth+1,x + width/2, y          );
				CreateNodeRec (holder.c2,depth+1,x + width/2, y + width/2);
				CreateNodeRec (holder.c3,depth+1,x          , y + width/2);
			}
		}