Bounds

An axis-aligned bounding box in the space of whatever owns it.

Properties

Empty

(Bounds) = new( new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity), new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity)): A box with an inverted range, so the first Encapsulate(Vector3) call collapses it onto that point.

IsEmpty

(bool): Gets a value indicating whether the box covers no volume because no point was added.

Center

(Vector3): Gets the midpoint between Min and Max.

Size

(Vector3): Gets the extent of the box along each axis.

Public Methods

Encapsulate

public Bounds Encapsulate(Vector3 point)

Returns a box grown to contain point.

Parameters:

  • point (Vector3)

Returns: Bounds

Encapsulate

public Bounds Encapsulate(Bounds other)

Returns a box grown to contain other.

Parameters:

  • other (Bounds)

Returns: Bounds

TryIntersect

public bool TryIntersect(Ray ray, float distance)

Tests ray against this box using the standard slab method.

Parameters:

  • ray (Ray): The ray to test, in the same space as this box.
  • distance (float): The distance from the ray's origin to the nearest intersection, or 0 when the origin is already inside the box. Undefined when this method returns false.

Returns: bool

  • true when the ray hits the box at or ahead of its origin.