Contains() публичный Метод

public Contains ( GraphNode node ) : bool
node GraphNode
Результат bool
Пример #1
0
        /** Updates the specified node using this GUO's settings */
        public virtual void Apply(GraphNode node)
        {
            if (shape == null || shape.Contains(node))
            {
                //Update penalty and walkability
                node.Penalty = (uint)(node.Penalty + addPenalty);
                if (modifyWalkability)
                {
                    node.Walkable = setWalkability;
                }

                //Update tags
                if (modifyTag)
                {
                    node.Tag = (uint)setTag;
                }
            }
        }
Пример #2
0
        /** Updates the specified node using this GUO's settings */
        public virtual void Apply(Node node)
        {
            if (shape == null || shape.Contains(node))
            {
                //Update penalty and walkability
                node.penalty = (uint)(node.penalty + addPenalty);
                if (modifyWalkability)
                {
                    node.walkable = setWalkability;
                }

                //Update tags
#if ConfigureTagsAsMultiple
                node.tags = (node.tags & ~tags.tagsChange) | (tags.tagsSet & tags.tagsChange);
#else
                if (modifyTag)
                {
                    node.tags = setTag;
                }
#endif
            }
        }
Пример #3
0
		/** All nodes inside the shape or if null, the bounding box.
		 * If a shape is supplied, it is assumed to be contained inside the bounding box.
		 * \see GraphUpdateShape.GetBounds
		 */
		private List<GraphNode> GetNodesInArea (Bounds b, GraphUpdateShape shape) {
			
			if (nodes == null || width*depth != nodes.Length) {
				return null;
			}
			
			List<GraphNode> inArea = Pathfinding.Util.ListPool<GraphNode>.Claim ();
			
			Vector3 min, max;
			GetBoundsMinMax (b,inverseMatrix,out min, out max);
			
			int minX = Mathf.RoundToInt (min.x-0.5F);
			int maxX = Mathf.RoundToInt (max.x-0.5F);
			
			int minZ = Mathf.RoundToInt (min.z-0.5F);
			int maxZ = Mathf.RoundToInt (max.z-0.5F);
			
			IntRect originalRect = new IntRect(minX,minZ,maxX,maxZ);
			IntRect gridRect = new IntRect(0,0,width-1,depth-1);
			
			IntRect rect = IntRect.Intersection (originalRect, gridRect);
			
			for (int x = rect.xmin; x <= rect.xmax;x++) {
				for (int z = rect.ymin;z <= rect.ymax;z++) {
					
					int index = z*width+x;
					
					GraphNode node = nodes[index];
					
					if (b.Contains ((Vector3)node.position) && (shape == null || shape.Contains ((Vector3)node.position))) {
						inArea.Add (node);
					}
				}
			}
			
			return inArea;
		}
Пример #4
0
        protected override List <GraphNode> GetNodesInRegion(Bounds b, GraphUpdateShape shape)
        {
            IntRect rectFromBounds = base.GetRectFromBounds(b);

            if (this.nodes == null || !rectFromBounds.IsValid() || this.nodes.Length != this.width * this.depth * this.layerCount)
            {
                return(ListPool <GraphNode> .Claim());
            }
            List <GraphNode> list = ListPool <GraphNode> .Claim(rectFromBounds.Width *rectFromBounds.Height *this.layerCount);

            for (int i = 0; i < this.layerCount; i++)
            {
                int num = i * this.width * this.depth;
                for (int j = rectFromBounds.xmin; j <= rectFromBounds.xmax; j++)
                {
                    for (int k = rectFromBounds.ymin; k <= rectFromBounds.ymax; k++)
                    {
                        int       num2      = num + k * this.width + j;
                        GraphNode graphNode = this.nodes[num2];
                        if (graphNode != null && b.Contains((Vector3)graphNode.position) && (shape == null || shape.Contains((Vector3)graphNode.position)))
                        {
                            list.Add(graphNode);
                        }
                    }
                }
            }
            return(list);
        }
Пример #5
0
		/** All nodes inside the shape or if null, the bounding box.
		 * If a shape is supplied, it is assumed to be contained inside the bounding box.
		 * \see GraphUpdateShape.GetBounds
		 */
		private List<GraphNode> GetNodesInArea (Bounds b, GraphUpdateShape shape) {
			if (nodes == null || width*depth != nodes.Length) {
				return null;
			}

			// Get a buffer we can use
			List<GraphNode> inArea = Pathfinding.Util.ListPool<GraphNode>.Claim();

			// Take the bounds and transform it using the matrix
			// Then convert that to a rectangle which contains
			// all nodes that might be inside the bounds
			Vector3 min, max;
			GetBoundsMinMax(b, inverseMatrix, out min, out max);

			int minX = Mathf.RoundToInt(min.x-0.5F);
			int maxX = Mathf.RoundToInt(max.x-0.5F);

			int minZ = Mathf.RoundToInt(min.z-0.5F);
			int maxZ = Mathf.RoundToInt(max.z-0.5F);

			var originalRect = new IntRect(minX, minZ, maxX, maxZ);

			// Rect which covers the whole grid
			var gridRect = new IntRect(0, 0, width-1, depth-1);

			// Clamp the rect to the grid
			var rect = IntRect.Intersection(originalRect, gridRect);

			// Loop through all nodes in the rectangle
			for (int x = rect.xmin; x <= rect.xmax; x++) {
				for (int z = rect.ymin; z <= rect.ymax; z++) {
					int index = z*width+x;

					GraphNode node = nodes[index];

					// If it is contained in the bounds (and optionally the shape)
					// then add it to the buffer
					if (b.Contains((Vector3)node.position) && (shape == null || shape.Contains((Vector3)node.position))) {
						inArea.Add(node);
					}
				}
			}

			return inArea;
		}