Represents two sets of coordinates, minimum and maximum for each direction; thus defining an
axis-aligned cuboid with floating-point boundaries. It supports operations changing the size and
position of the box, as well as querying whether a point or another BoundingBox is inside the box.
All the points within the coordinate limits (inclusive the edges) are considered "inside" the box.
However, for intersection purposes, if the intersection is "sharp" in any coord (min1 == max2, i. e.
zero volume), the boxes are considered non-intersecting.
Name | Parameters | Return value | Notes |
() (constructor) |
|
|
Creates a new bounding box with the coords specified as two vectors |
() (constructor) |
MinX | number | MaxX | number | MinY | number | MaxY | number | MinZ | number | MaxZ | number |
|
|
Creates a new bounding box with the specified edges |
() (constructor) |
|
|
Creates a new bounding box from the position given and radius (X/Z) and height. Radius is added from X/Z to calculate the maximum coords and subtracted from X/Z to get the minimum; minimum Y is set to Pos.y and maxumim Y to Pos.y plus Height. This corresponds with how entities are represented in Minecraft. |
() (constructor) |
|
|
Creates a new copy of the given bounding box. Same result can be achieved by using a simple assignment. |
() (constructor) |
|
|
Creates a new bounding box as a cube with the specified side length centered around the specified point. |
CalcLineIntersection |
|
|
Calculates the intersection of a ray (half-line), given by two of its points, with the bounding box. Returns false if the line doesn't intersect the bounding box, or true, together with coefficient of the intersection (how much of the difference between the two ray points is needed to reach the intersection), and the face of the box which is intersected. |
CalcLineIntersection |
|
|
(STATIC) Calculates the intersection of a ray (half-line), given by two of its points, with the bounding box specified as its minimum and maximum coords. Returns false if the line doesn't intersect the bounding box, or true, together with coefficient of the intersection (how much of the difference between the two ray points is needed to reach the intersection), and the face of the box which is intersected. |
DoesIntersect |
|
|
Returns true if the two bounding boxes have an intersection of nonzero volume. |
Expand |
ExpandX | number | ExpandY | number | ExpandZ | number |
|
|
Expands this bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each axis). |
GetMax |
|
|
Returns the boundary point with the maximum coords |
GetMaxX |
|
|
Returns the maximum X coord of the bounding box |
GetMaxY |
|
|
Returns the maximum Y coord of the bounding box |
GetMaxZ |
|
|
Returns the maximum Z coord of the bounding box |
GetMin |
|
|
Returns the boundary point with the minimum coords |
GetMinX |
|
|
Returns the minimum X coord of the bounding box |
GetMinY |
|
|
Returns the minimum Y coord of the bounding box |
GetMinZ |
|
|
Returns the minimum Z coord of the bounding box |
Intersect |
|
|
Checks if the intersection between this bounding box and another one is non-empty. Returns false if the intersection is empty, true and a new cBoundingBox representing the intersection of the two boxes. |
IsInside |
|
|
Returns true if the specified point is inside (including on the edge) of the box. |
IsInside |
|
|
Returns true if the other bounding box, specified by its 2 corners, is inside of this box. |
IsInside |
|
|
(STATIC) Returns true if the specified point is inside the bounding box specified by its min / max corners |
IsInside |
PointX | number | PointY | number | PointZ | number |
|
|
Returns true if the specified point is inside (including on the edge) of the box. |
IsInside |
|
|
Returns true if OtherBoundingBox is inside of this box. |
IsInside |
|
|
(STATIC) Returns true if the specified point is inside the bounding box specified by its min / max corners |
Move |
OffsetX | number | OffsetY | number | OffsetZ | number |
|
|
Moves the bounding box by the specified offset in each axis |
Move |
|
|
Moves the bounding box by the specified offset in each axis |
Union |
|
|
Returns the smallest bounding box that contains both OtherBoundingBox and this bounding box. Note that unlike the strict geometrical meaning of "union", this operation actually returns a cBoundingBox. |