Pathfinding.NavmeshCut.GetBounds C# (CSharp) Method

GetBounds() public method

public GetBounds ( ) : Bounds
return UnityEngine.Bounds
		public Bounds GetBounds () {
			switch (type) {
			case MeshType.Rectangle:
				if (useRotation) {
					Matrix4x4 m = tr.localToWorldMatrix;//Matrix4x4.TRS (tr.position, tr.rotation, Vector3.one);
					bounds = new Bounds(m.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x,-height,-rectangleSize.y)*0.5f), Vector3.zero);
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(rectangleSize.x,-height,-rectangleSize.y)*0.5f));
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(rectangleSize.x,-height,rectangleSize.y)*0.5f));
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x,-height,rectangleSize.y)*0.5f));
					
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x,height,-rectangleSize.y)*0.5f));
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(rectangleSize.x,height,-rectangleSize.y)*0.5f));
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(rectangleSize.x,height,rectangleSize.y)*0.5f));
					bounds.Encapsulate (m.MultiplyPoint3x4(center + new Vector3(-rectangleSize.x,height,rectangleSize.y)*0.5f));
					
				} else {
					bounds = new Bounds(tr.position+center, new Vector3(rectangleSize.x,height,rectangleSize.y));
				}
				break;
			case MeshType.Circle:
				if (useRotation) {
					Matrix4x4 m = tr.localToWorldMatrix;//Matrix4x4.TRS (tr.position, tr.rotation, Vector3.one);
					bounds = new Bounds(m.MultiplyPoint3x4 (center), new Vector3(circleRadius*2,height,circleRadius*2));
				} else {
					bounds = new Bounds(transform.position+center, new Vector3(circleRadius*2,height,circleRadius*2));
				}
				break;
			case MeshType.CustomMesh:
				if (mesh == null) break;
				
				Bounds b = mesh.bounds;
				if (useRotation) {
					Matrix4x4 m = tr.localToWorldMatrix;//Matrix4x4.TRS (tr.position, tr.rotation, Vector3.one);
					b.center *= meshScale;
					b.size *= meshScale;
					
					bounds = new Bounds ( m.MultiplyPoint3x4 ( center + b.center ), Vector3.zero );
					
					Vector3 mx = b.max;
					Vector3 mn = b.min;
					
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mx.x,mx.y,mx.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mn.x,mx.y,mx.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mn.x,mx.y,mn.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mx.x,mx.y,mn.z )) );
					
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mx.x,mn.y,mx.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mn.x,mn.y,mx.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mn.x,mn.y,mn.z )) );
					bounds.Encapsulate (m.MultiplyPoint3x4 ( center + new Vector3 (mx.x,mn.y,mn.z )) );
					
					Vector3 size = bounds.size;
					size.y = Mathf.Max(size.y, height * tr.lossyScale.y);
					bounds.size = size;
				} else {
					Vector3 size = b.size*meshScale;
					size.y = Mathf.Max(size.y, height);
					bounds = new Bounds(transform.position+center+b.center*meshScale,size);
				}
				break;
			}
			return bounds;
		}