Api BBox
struct

BBox

public sealed struct BBox

An Axis Aligned Bounding Box.

Constructors

BBox(Vector3 mins, Vector3 maxs)

Initialize an AABB with given mins and maxs corners. See Sort(Vector3@,Vector3@).

BBox(Vector3 center, Single size)

Initializes a zero sized BBox with given center. This is useful if you intend to use AddPoint to expand the box later.

Properties

Name Type Description
Corners IEnumerable<Vector3> An enumerable that contains all corners of this AABB.
Center Vector3 Calculated center of the AABB.
Size Vector3 Calculated size of the AABB on each axis.
Extents Vector3 The extents of the bbox. This is half the size.
RandomPointInside Vector3 Returns a random point within this AABB.
RandomPointOnEdge Vector3 Returns a random point within this AABB.
Volume Single Returns the physical volume of this AABB.

Methods

BBox Translate(Vector3 point)

Move this box by this amount and return

BBox Rotate(Rotation rotation)

Rotate this box by this amount and return

BBox Transform(Transform transform)

Transform this box by this amount and return

Boolean Contains(BBox b)

Returns true if this AABB completely contains given AABB

Boolean Contains(Vector3 b, Single epsilon = 0.0001)

Returns true if this AABB contains given point

Boolean Overlaps(BBox b)

Returns true if this AABB somewhat overlaps given AABB

BBox AddPoint(Vector3 point)

Returns this bbox but stretched to include given point

BBox AddBBox(BBox point)

Returns this bbox but stretched to include given bbox

BBox Grow(Single skin)

Return a slightly bigger box

Vector3 ClosestPoint(Vector3 point)

Returns the closest point on this AABB to another point

static BBox FromHeightAndRadius(Single height, Single radius)

Creates an AABB of length and depth, and given

static BBox FromPositionAndSize(Vector3 center, Single size = 0)

Creates an AABB at given position and given which acts as a diameter of a sphere contained within the AABB.

static BBox FromPositionAndSize(Vector3 center, Vector3 size)

Creates an AABB at given position and given a.k.a. "extents".

static BBox FromBoxes(IEnumerable<BBox> boxes)
static BBox FromPoints(IEnumerable<Vector3> points, Single size = 0)
Boolean Trace(Ray ray, Single distance, Single hitDistance)

Trace a ray against this box. If hit then return the distance.

Single GetVolume()

Get the volume of this AABB

BBox Snap(Single distance)

Snap this AABB to a grid

Single GetEdgeDistance(Vector3 localPos)

Calculates the shortest distance from the specified local position to the nearest edge of the shape.

Fields

Name Type Description
Mins Vector3 The minimum corner extents of the AABB. Values on each axis should be mathematically smaller than values on the same axis of Maxs. See Sort(Vector3@,Vector3@)
Maxs Vector3 The maximum corner extents of the AABB. Values on each axis should be mathematically larger than values on the same axis of Mins. See Sort(Vector3@,Vector3@)
Assembly: Sandbox.System Full Name: BBox