GetBounds() public method

public GetBounds ( ) : Bounds
return UnityEngine.Bounds
 // Token: 0x060022A1 RID: 8865 RVA: 0x00193904 File Offset: 0x00191B04
 public Bounds GetBounds()
 {
     if (this.points == null || this.points.Length == 0)
     {
         Collider   component  = base.GetComponent <Collider>();
         Collider2D component2 = base.GetComponent <Collider2D>();
         Renderer   component3 = base.GetComponent <Renderer>();
         Bounds     bounds;
         if (component != null)
         {
             bounds = component.bounds;
         }
         else if (component2 != null)
         {
             bounds      = component2.bounds;
             bounds.size = new Vector3(bounds.size.x, bounds.size.y, Mathf.Max(bounds.size.z, 1f));
         }
         else
         {
             if (!(component3 != null))
             {
                 return(new Bounds(Vector3.zero, Vector3.zero));
             }
             bounds = component3.bounds;
         }
         if (this.legacyMode && bounds.size.y < this.minBoundsHeight)
         {
             bounds.size = new Vector3(bounds.size.x, this.minBoundsHeight, bounds.size.z);
         }
         return(bounds);
     }
     return(GraphUpdateShape.GetBounds(this.convex ? this.convexPoints : this.points, (this.legacyMode && this.legacyUseWorldSpace) ? Matrix4x4.identity : base.transform.localToWorldMatrix, this.minBoundsHeight));
 }
Ejemplo n.º 2
0
    /** Updates graphs with a created GUO.
     * Creates a Pathfinding::GraphUpdateObject with a Pathfinding::GraphUpdateShape
     * representing the polygon of this object and update all graphs using AstarPath::UpdateGraphs.
     * This will not update graphs directly. See AstarPath::UpdateGraph for more info.
     */
    public void Apply()
    {
        if (AstarPath.active == null)
        {
            Debug.LogError("There is no AstarPath object in the scene");
            return;
        }

        firstApplied = true;

        Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape();
        shape.convex = convex;
        shape.points = points;

        GraphUpdateObject guo = new GraphUpdateObject(shape.GetBounds());

        guo.shape             = shape;
        guo.modifyWalkability = modifyWalkability;
        guo.setWalkability    = setWalkability;
        guo.addPenalty        = penalty;
#if ConfigureTagsAsMultiple
        guo.tags = tags;
#else
        guo.modifyTag = modifyTag;
        guo.setTag    = setTag;
#endif

        AstarPath.active.UpdateGraphs(guo);
    }
Ejemplo n.º 3
0
    /** Updates graphs with a created GUO.
     * Creates a Pathfinding::GraphUpdateObject with a Pathfinding::GraphUpdateShape
     * representing the polygon of this object and update all graphs using AstarPath::UpdateGraphs.
     * This will not update graphs directly. See AstarPath::UpdateGraph for more info.
     */
    public void Apply()
    {
        if (AstarPath.active == null) {
            Debug.LogError ("There is no AstarPath object in the scene");
            return;
        }

        firstApplied = true;

        Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape ();
        shape.convex = convex;
        shape.points = points;

        GraphUpdateObject guo = new GraphUpdateObject (shape.GetBounds ());
        guo.shape = shape;
        guo.modifyWalkability = modifyWalkability;
        guo.setWalkability = setWalkability;
        guo.addPenalty = penalty;
        #if ConfigureTagsAsMultiple
        guo.tags = tags;
        #else
        guo.modifyTag = modifyTag;
        guo.setTag = setTag;
        #endif

        AstarPath.active.UpdateGraphs (guo);
    }
Ejemplo n.º 4
0
        public static Bounds GetBounds(Vector3[] points, Matrix4x4 matrix, float minimumHeight)
        {
            Vector3 b       = matrix.MultiplyPoint3x4(Vector3.zero);
            Vector3 vector  = matrix.MultiplyPoint3x4(Vector3.right) - b;
            Vector3 vector2 = matrix.MultiplyPoint3x4(Vector3.up) - b;
            Vector3 vector3 = matrix.MultiplyPoint3x4(Vector3.forward) - b;

            return(GraphUpdateShape.GetBounds(points, vector, vector2, vector3, b, minimumHeight));
        }
Ejemplo n.º 5
0
    /** Updates graphs with a created GUO.
     * Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
     * representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
     * This will not update graphs directly. See AstarPath.UpdateGraph for more info.
     */
    public void Apply()
    {
        if (AstarPath.active == null)
        {
            Debug.LogError("There is no AstarPath object in the scene");
            return;
        }

        firstApplied = true;

        Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape();
        shape.convex = convex;
        Vector3[] worldPoints = points;
        if (!useWorldSpace)
        {
            worldPoints = new Vector3[points.Length];
            Matrix4x4 matrix = transform.localToWorldMatrix;
            for (int i = 0; i < worldPoints.Length; i++)
            {
                worldPoints[i] = matrix.MultiplyPoint3x4(points[i]);
            }
        }

        shape.points = worldPoints;

        Bounds b = shape.GetBounds();

        if (b.size.y < minBoundsHeight)
        {
            b.size = new Vector3(b.size.x, minBoundsHeight, b.size.z);
        }

        GraphUpdateObject guo = new GraphUpdateObject(b);

        guo.shape                 = shape;
        guo.modifyWalkability     = modifyWalkability;
        guo.setWalkability        = setWalkability;
        guo.addPenalty            = penaltyDelta;
        guo.updatePhysics         = updatePhysics;
        guo.updateErosion         = updateErosion;
        guo.resetPenaltyOnPhysics = resetPenaltyOnPhysics;

#if ConfigureTagsAsMultiple
        guo.tags = tags;
#else
        guo.modifyTag = modifyTag;
        guo.setTag    = setTag;
#endif

        AstarPath.active.UpdateGraphs(guo);
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Calculates the bounds for this component.
        /// This is a relatively expensive operation, it needs to go through all points and
        /// run matrix multiplications.
        /// </summary>
        public Bounds GetBounds()
        {
            if (points == null || points.Length == 0)
            {
                Bounds bounds;
                var    coll   = GetComponent <Collider>();
                var    coll2D = GetComponent <Collider2D>();
                var    rend   = GetComponent <Renderer>();

                if (coll != null)
                {
                    bounds = coll.bounds;
                }
                else if (coll2D != null)
                {
                    bounds      = coll2D.bounds;
                    bounds.size = new Vector3(bounds.size.x, bounds.size.y, Mathf.Max(bounds.size.z, 1f));
                }
                else if (rend != null)
                {
                    bounds = rend.bounds;
                }
                else
                {
                    return(new Bounds(Vector3.zero, Vector3.zero));
                }

                if (legacyMode && bounds.size.y < minBoundsHeight)
                {
                    bounds.size = new Vector3(bounds.size.x, minBoundsHeight, bounds.size.z);
                }
                return(bounds);
            }
            else
            {
                return(GraphUpdateShape.GetBounds(convex ? convexPoints : points,
                                                  legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix,
                                                  minBoundsHeight));
            }
        }
Ejemplo n.º 7
0
        /** Updates graphs with a created GUO.
         * Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
         * representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
         * This will not update graphs directly. See AstarPath.UpdateGraph for more info.
         */
        public void Apply()
        {
            if (AstarPath.active == null)
            {
                Debug.LogError("There is no AstarPath object in the scene");
                return;
            }

            GraphUpdateObject guo;

            if (points == null || points.Length == 0)
            {
                var coll = GetComponent <Collider>();
                var rend = GetComponent <Renderer>();

                Bounds b;
                if (coll != null)
                {
                    b = coll.bounds;
                }
                else if (rend != null)
                {
                    b = rend.bounds;
                }
                else
                {
                    Debug.LogWarning("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached");
                    return;
                }

                if (b.size.y < minBoundsHeight)
                {
                    b.size = new Vector3(b.size.x, minBoundsHeight, b.size.z);
                }

                guo = new GraphUpdateObject(b);
            }
            else
            {
                var shape = new GraphUpdateShape();
                shape.convex = convex;
                Vector3[] worldPoints = points;
                if (!useWorldSpace)
                {
                    worldPoints = new Vector3[points.Length];
                    Matrix4x4 matrix = transform.localToWorldMatrix;
                    for (int i = 0; i < worldPoints.Length; i++)
                    {
                        worldPoints[i] = matrix.MultiplyPoint3x4(points[i]);
                    }
                }

                shape.points = worldPoints;

                Bounds b = shape.GetBounds();
                if (b.size.y < minBoundsHeight)
                {
                    b.size = new Vector3(b.size.x, minBoundsHeight, b.size.z);
                }
                guo       = new GraphUpdateObject(b);
                guo.shape = shape;
            }

            firstApplied = true;

            guo.modifyWalkability     = modifyWalkability;
            guo.setWalkability        = setWalkability;
            guo.addPenalty            = penaltyDelta;
            guo.updatePhysics         = updatePhysics;
            guo.updateErosion         = updateErosion;
            guo.resetPenaltyOnPhysics = resetPenaltyOnPhysics;

            guo.modifyTag = modifyTag;
            guo.setTag    = setTag;

            AstarPath.active.UpdateGraphs(guo);
        }
Ejemplo n.º 8
0
		/** All nodes inside the shape.
		  * \note Be nice to the garbage collector and release the list when you have used it (optional)
		  * \see Pathfinding.Util.ListPool
		  * 
		  * \see GetNodesInArea(Bounds)
		  */
		public List<GraphNode> GetNodesInArea (GraphUpdateShape shape) {
			return GetNodesInArea (shape.GetBounds (), shape);
		}
		/** Updates graphs with a created GUO.
		 * Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
		 * representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
		 * This will not update graphs directly. See AstarPath.UpdateGraph for more info.
		 */
		public void Apply () {
			
			if (AstarPath.active == null) {
				Debug.LogError ("There is no AstarPath object in the scene");
				return;
			}
			
			GraphUpdateObject guo;
			
			if (points == null || points.Length == 0) {
				
				Bounds b;
				if (GetComponent<Collider>() != null) b = GetComponent<Collider>().bounds;
				else if (GetComponent<Renderer>() != null) b = GetComponent<Renderer>().bounds;
				else {
					Debug.LogWarning ("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached");
					return;
				}
				
				if (b.size.y < minBoundsHeight) b.size = new Vector3(b.size.x,minBoundsHeight,b.size.z);
				
				guo = new GraphUpdateObject (b);
				
			} else {
				Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape ();
				shape.convex = convex;
				Vector3[] worldPoints = points;
				if (!useWorldSpace) {
					worldPoints = new Vector3[points.Length];
					Matrix4x4 matrix = transform.localToWorldMatrix;
					for (int i=0;i<worldPoints.Length;i++) worldPoints[i] = matrix.MultiplyPoint3x4 (points[i]);
				}
				
				shape.points = worldPoints;
			
				Bounds b = shape.GetBounds ();
				if (b.size.y < minBoundsHeight) b.size = new Vector3(b.size.x,minBoundsHeight,b.size.z);
				guo = new GraphUpdateObject (b);
				guo.shape = shape;
			}
			
			firstApplied = true;
			
			guo.modifyWalkability = modifyWalkability;
			guo.setWalkability = setWalkability;
			guo.addPenalty = penaltyDelta;
			guo.updatePhysics = updatePhysics;
			guo.updateErosion = updateErosion;
			guo.resetPenaltyOnPhysics = resetPenaltyOnPhysics;
			
	#if ConfigureTagsAsMultiple
			guo.tags = tags;
	#else
			guo.modifyTag = modifyTag;
			guo.setTag = setTag;
	#endif
			
			AstarPath.active.UpdateGraphs (guo);
		}
Ejemplo n.º 10
0
    /** Updates graphs with a created GUO.
     * Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
     * representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
     * This will not update graphs directly. See AstarPath.UpdateGraph for more info.
     */
    public void Apply()
    {
        if (AstarPath.active == null) {
            Debug.LogError ("There is no AstarPath object in the scene");
            return;
        }

        firstApplied = true;

        Pathfinding.GraphUpdateShape shape = new Pathfinding.GraphUpdateShape ();
        shape.convex = convex;
        Vector3[] worldPoints = points;
        if (!useWorldSpace) {
            worldPoints = new Vector3[points.Length];
            Matrix4x4 matrix = transform.localToWorldMatrix;
            for (int i=0;i<worldPoints.Length;i++) worldPoints[i] = matrix.MultiplyPoint3x4 (points[i]);
        }

        shape.points = worldPoints;

        Bounds b = shape.GetBounds ();
        if (b.size.y < minBoundsHeight) b.size = new Vector3(b.size.x,minBoundsHeight,b.size.z);

        GraphUpdateObject guo = new GraphUpdateObject (b);
        guo.shape = shape;
        guo.modifyWalkability = modifyWalkability;
        guo.setWalkability = setWalkability;
        guo.addPenalty = penaltyDelta;
        guo.updatePhysics = updatePhysics;
        guo.updateErosion = updateErosion;

        guo.modifyTag = modifyTag;
        guo.setTag = setTag;

        AstarPath.active.UpdateGraphs (guo);
    }
Ejemplo n.º 11
0
 public void Apply()
 {
     if (AstarPath.active == null)
     {
         Debug.LogError("There is no AstarPath object in the scene");
     }
     else
     {
         GraphUpdateObject obj2;
         if ((this.points == null) || (this.points.Length == 0))
         {
             Bounds   bounds;
             Collider component = base.GetComponent <Collider>();
             Renderer renderer  = base.GetComponent <Renderer>();
             if (component != null)
             {
                 bounds = component.bounds;
             }
             else if (renderer != null)
             {
                 bounds = renderer.bounds;
             }
             else
             {
                 Debug.LogWarning("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached");
                 return;
             }
             if (bounds.size.y < this.minBoundsHeight)
             {
                 bounds.size = new Vector3(bounds.size.x, this.minBoundsHeight, bounds.size.z);
             }
             obj2 = new GraphUpdateObject(bounds);
         }
         else
         {
             GraphUpdateShape shape = new GraphUpdateShape {
                 convex = this.convex
             };
             Vector3[] points = this.points;
             if (!this.useWorldSpace)
             {
                 points = new Vector3[this.points.Length];
                 Matrix4x4 localToWorldMatrix = base.transform.localToWorldMatrix;
                 for (int i = 0; i < points.Length; i++)
                 {
                     points[i] = localToWorldMatrix.MultiplyPoint3x4(this.points[i]);
                 }
             }
             shape.points = points;
             Bounds b = shape.GetBounds();
             if (b.size.y < this.minBoundsHeight)
             {
                 b.size = new Vector3(b.size.x, this.minBoundsHeight, b.size.z);
             }
             obj2 = new GraphUpdateObject(b)
             {
                 shape = shape
             };
         }
         this.firstApplied          = true;
         obj2.modifyWalkability     = this.modifyWalkability;
         obj2.setWalkability        = this.setWalkability;
         obj2.addPenalty            = this.penaltyDelta;
         obj2.updatePhysics         = this.updatePhysics;
         obj2.updateErosion         = this.updateErosion;
         obj2.resetPenaltyOnPhysics = this.resetPenaltyOnPhysics;
         obj2.modifyTag             = this.modifyTag;
         obj2.setTag = this.setTag;
         AstarPath.active.UpdateGraphs(obj2);
     }
 }
Ejemplo n.º 12
0
        public void Apply()
        {
            if (AstarPath.active == null)
            {
                Debug.LogError("There is no AstarPath object in the scene");
                return;
            }
            GraphUpdateObject graphUpdateObject;

            if (this.points == null || this.points.Length == 0)
            {
                Collider component  = base.GetComponent <Collider>();
                Renderer component2 = base.GetComponent <Renderer>();
                Bounds   bounds;
                if (component != null)
                {
                    bounds = component.bounds;
                }
                else
                {
                    if (!(component2 != null))
                    {
                        Debug.LogWarning("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached");
                        return;
                    }
                    bounds = component2.bounds;
                }
                if (bounds.size.y < this.minBoundsHeight)
                {
                    bounds.size = new Vector3(bounds.size.x, this.minBoundsHeight, bounds.size.z);
                }
                graphUpdateObject = new GraphUpdateObject(bounds);
            }
            else
            {
                GraphUpdateShape graphUpdateShape = new GraphUpdateShape();
                graphUpdateShape.convex = this.convex;
                Vector3[] array = this.points;
                if (!this.useWorldSpace)
                {
                    array = new Vector3[this.points.Length];
                    Matrix4x4 localToWorldMatrix = base.transform.localToWorldMatrix;
                    for (int i = 0; i < array.Length; i++)
                    {
                        array[i] = localToWorldMatrix.MultiplyPoint3x4(this.points[i]);
                    }
                }
                graphUpdateShape.points = array;
                Bounds bounds2 = graphUpdateShape.GetBounds();
                if (bounds2.size.y < this.minBoundsHeight)
                {
                    bounds2.size = new Vector3(bounds2.size.x, this.minBoundsHeight, bounds2.size.z);
                }
                graphUpdateObject       = new GraphUpdateObject(bounds2);
                graphUpdateObject.shape = graphUpdateShape;
            }
            this.firstApplied = true;
            graphUpdateObject.modifyWalkability     = this.modifyWalkability;
            graphUpdateObject.setWalkability        = this.setWalkability;
            graphUpdateObject.addPenalty            = this.penaltyDelta;
            graphUpdateObject.updatePhysics         = this.updatePhysics;
            graphUpdateObject.updateErosion         = this.updateErosion;
            graphUpdateObject.resetPenaltyOnPhysics = this.resetPenaltyOnPhysics;
            graphUpdateObject.modifyTag             = this.modifyTag;
            graphUpdateObject.setTag = this.setTag;
            AstarPath.active.UpdateGraphs(graphUpdateObject);
        }
Ejemplo n.º 13
0
 public Bounds GetBounds()
 {
     return(GraphUpdateShape.GetBounds((!this.convex) ? this.points : this._convexPoints, this.right, this.up, this.forward, this.origin, this.minimumHeight));
 }