Struct BoundingBox
Represents an axis-aligned bounding box in three dimensional space.
Assembly: FlaxEngine.dll
File: Engine/Core/Math/BoundingBox.h
Syntax
public struct BoundingBox
Constructors
BoundingBox()
Empty constructor.
Declaration
public BoundingBox() = default
BoundingBox(const Vector3& minimum, const Vector3& maximum)
Initializes a new instance of the BoundingBox struct.
Declaration
public BoundingBox(const Vector3& minimum, const Vector3& maximum)
Parameters
Vector3
minimum
The minimum vertex of the bounding box. |
Vector3
maximum
The maximum vertex of the bounding box. |
BoundingBox(const Vector3& point)
Initializes a new instance of the BoundingBox struct.
Declaration
public BoundingBox(const Vector3& point)
Parameters
Vector3
point
The location of the empty bounding box. |
Fields
Empty
A BoundingBox which represents an empty space.
Declaration
public static BoundingBox Empty
Field Value
BoundingBox
|
Maximum
The maximum point of the box.
Declaration
public Vector3 Maximum
Field Value
Vector3
|
Minimum
The minimum point of the box.
Declaration
public Vector3 Minimum
Field Value
Vector3
|
Zero
A BoundingBox located at zero point with zero size.
Declaration
public static BoundingBox Zero
Field Value
BoundingBox
|
Methods
Contains(const BoundingBox& box)
Determines whether box contains a Bounding Box.
Declaration
public ContainmentType Contains(const BoundingBox& box) const
Parameters
BoundingBox
box
The box to test. |
Returns
ContainmentType
The type of containment the two objects have. |
Contains(const BoundingSphere& sphere)
Determines whether box contains a Bounding Sphere.
Declaration
public ContainmentType Contains(const BoundingSphere& sphere) const
Parameters
BoundingSphere
sphere
The sphere to test. |
Returns
ContainmentType
The type of containment the two objects have. |
Contains(const Vector3& point)
Determines whether box contains a point.
Declaration
public ContainmentType Contains(const Vector3& point) const
Parameters
Vector3
point
The point to test. |
Returns
ContainmentType
The type of containment the two objects have. |
Distance(const BoundingBox& box)
Determines the distance between two boxes.
Declaration
public Real Distance(const BoundingBox& box) const
Parameters
BoundingBox
box
The bounding box to test. |
Returns
Real
The distance between bounding boxes. |
Distance(const Vector3& point)
Determines the distance between box and a point.
Declaration
public Real Distance(const Vector3& point) const
Parameters
Vector3
point
The point to test. |
Returns
Real
The distance between bounding box and a point. |
FromPoints(const Double3* points, int32 pointsCount, BoundingBox& result)
Constructs a Bounding Box that fully contains the given points.
Declaration
public static void FromPoints(const Double3* points, int32 pointsCount, BoundingBox& result)
Parameters
Double3
points
The points that will be contained by the box. |
int32
pointsCount
The amount of points to use. |
BoundingBox
result
The constructed bounding box. |
FromPoints(const Float3* points, int32 pointsCount, BoundingBox& result)
Constructs a Bounding Box that fully contains the given points.
Declaration
public static void FromPoints(const Float3* points, int32 pointsCount, BoundingBox& result)
Parameters
Float3
points
The points that will be contained by the box. |
int32
pointsCount
The amount of points to use. |
BoundingBox
result
The constructed bounding box. |
FromPoints(const Vector3& pointA, const Vector3& pointB, BoundingBox& result)
Constructs a Bounding Box that fully contains the given pair of points.
Declaration
public static void FromPoints(const Vector3& pointA, const Vector3& pointB, BoundingBox& result)
Parameters
Vector3
pointA
The first point that will be contained by the box. |
Vector3
pointB
The second point that will be contained by the box. |
BoundingBox
result
The constructed bounding box. |
FromSphere(const BoundingSphere& sphere)
Constructs a Bounding Box from a given sphere.
Declaration
public static BoundingBox FromSphere(const BoundingSphere& sphere)
Parameters
BoundingSphere
sphere
The sphere that will designate the extents of the box. |
Returns
BoundingBox
The constructed bounding box. |
FromSphere(const BoundingSphere& sphere, BoundingBox& result)
Constructs a Bounding Box from a given sphere.
Declaration
public static void FromSphere(const BoundingSphere& sphere, BoundingBox& result)
Parameters
BoundingSphere
sphere
The sphere that will designate the extents of the box. |
BoundingBox
result
The constructed bounding box. |
GetCenter()
Gets the center point location.
Declaration
public Vector3 GetCenter() const
Returns
Vector3
The box center. |
GetCenter(Vector3& result)
Gets the center point location.
Declaration
public void GetCenter(Vector3& result) const
Parameters
Vector3
result
The result box center. |
GetCorners(Double3 corners[8])
Gets the eight corners of the bounding box.
Declaration
public void GetCorners(Double3 corners[8]) const
Parameters
Double3
corners
An array of points representing the eight corners of the bounding box. |
GetCorners(Float3 corners[8])
Gets the eight corners of the bounding box.
Declaration
public void GetCorners(Float3 corners[8]) const
Parameters
Float3
corners
An array of points representing the eight corners of the bounding box. |
GetSize()
Calculates the size of the box.
Declaration
public Vector3 GetSize() const
Returns
Vector3
The box size. |
GetSize(Vector3& result)
Calculates the size of the box.
Declaration
public void GetSize(Vector3& result) const
Parameters
Vector3
result
The result box size. |
GetVolume()
Calculates volume of the box.
Declaration
public Real GetVolume() const
Returns
Real
The box volume. |
Intersects(const BoundingBox& box)
Determines if there is an intersection between two boxes.
Declaration
public bool Intersects(const BoundingBox& box) const
Parameters
BoundingBox
box
The box to test. |
Returns
bool
Whether the two objects intersected. |
Intersects(const BoundingSphere& sphere)
Determines if there is an intersection between box and a sphere.
Declaration
public bool Intersects(const BoundingSphere& sphere) const
Parameters
BoundingSphere
sphere
The sphere to test. |
Returns
bool
Whether the two objects intersected. |
Intersects(const Plane& plane)
Determines if there is an intersection between box and a plane.
Declaration
public PlaneIntersectionType Intersects(const Plane& plane) const
Parameters
Plane
plane
The plane to test. |
Returns
PlaneIntersectionType
Whether the two objects intersected. |
Intersects(const Ray& ray)
Determines if there is an intersection between box and a ray.
Declaration
public bool Intersects(const Ray& ray) const
Parameters
Ray
ray
The ray to test. |
Returns
bool
Whether the two objects intersected. |
Intersects(const Ray& ray, Real& distance)
Determines if there is an intersection between box and a ray.
Declaration
public bool Intersects(const Ray& ray, Real& distance) const
Parameters
Ray
ray
The ray to test. |
Real
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. |
Returns
bool
Whether the two objects intersected. |
Intersects(const Ray& ray, Real& distance, Vector3& normal)
Determines if there is an intersection between box and a ray.
Declaration
public bool Intersects(const Ray& ray, Real& distance, Vector3& normal) const
Parameters
Ray
ray
The ray to test. |
Real
distance
When the method completes, contains the distance of the intersection, or 0 if there was no intersection. |
Vector3
normal
When the method completes, contains the intersection surface normal vector, or Vector3::Up if there was no intersection. |
Returns
bool
Whether the two objects intersected. |
Intersects(const Ray& ray, Vector3& point)
Determines if there is an intersection between box and a ray.
Declaration
public bool Intersects(const Ray& ray, Vector3& point) const
Parameters
Ray
ray
The ray to test. |
Vector3
point
When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection. |
Returns
bool
Whether the two objects intersected. |
MakeOffsetted(const BoundingBox& box, const Vector3& offset)
Creates the bounding box that is offseted by the given vector. Adds the offset value to minimum and maximum points.
Declaration
public static BoundingBox MakeOffsetted(const BoundingBox& box, const Vector3& offset)
Parameters
BoundingBox
box
The box. |
Vector3
offset
The bounds offset. |
Returns
BoundingBox
The offsetted bounds. |
MakeOffsetted(const Vector3& offset)
Creates the bounding box that is offseted by the given vector. Adds the offset value to minimum and maximum points.
Declaration
public BoundingBox MakeOffsetted(const Vector3& offset) const
Parameters
Vector3
offset
The offset. |
Returns
BoundingBox
The result. |
MakeScaled(const BoundingBox& box, Real scale)
Creates the bounding box that is scaled by the given factor. Applies scale to the size of the bounds.
Declaration
public static BoundingBox MakeScaled(const BoundingBox& box, Real scale)
Parameters
BoundingBox
box
The box. |
Real
scale
The bounds scale. |
Returns
BoundingBox
The scaled bounds. |
Merge(const BoundingBox& box)
Merges the box with the other box.
Declaration
public void Merge(const BoundingBox& box)
Parameters
BoundingBox
box
The other box to add to the box bounds. |
Merge(const BoundingBox& value1, const BoundingBox& value2, BoundingBox& result)
Constructs a Bounding Box that is as large as the total combined area of the two specified boxes.
Declaration
public static void Merge(const BoundingBox& value1, const BoundingBox& value2, BoundingBox& result)
Parameters
BoundingBox
value1
The first box to merge. |
BoundingBox
value2
The second box to merge. |
BoundingBox
result
The constructed bounding box. |
Merge(const Vector3& point)
Merges the box with a point.
Declaration
public void Merge(const Vector3& point)
Parameters
Vector3
point
The point to add to the box bounds. |
NearEqual(const BoundingBox& a, const BoundingBox& b)
Declaration
public static bool NearEqual(const BoundingBox& a, const BoundingBox& b)
Parameters
BoundingBox
a
|
BoundingBox
b
|
Returns
bool
|
NearEqual(const BoundingBox& a, const BoundingBox& b, Real epsilon)
Declaration
public static bool NearEqual(const BoundingBox& a, const BoundingBox& b, Real epsilon)
Parameters
BoundingBox
a
|
BoundingBox
b
|
Real
epsilon
|
Returns
bool
|
operator!=(const BoundingBox& other)
Declaration
public bool operator!=(const BoundingBox& other) const
Parameters
BoundingBox
other
|
Returns
bool
|
operator*(const Matrix& matrix)
Declaration
public BoundingBox operator*(const Matrix& matrix) const
Parameters
Matrix
matrix
|
Returns
BoundingBox
|
operator==(const BoundingBox& other)
Declaration
public bool operator==(const BoundingBox& other) const
Parameters
BoundingBox
other
|
Returns
bool
|
SetCenter(const Vector3& value)
Sets the center point location.
Declaration
public void SetCenter(const Vector3& value)
Parameters
Vector3
value
The box center to set. |
SetSize(const Vector3& value)
Sets the size of the box.
Declaration
public void SetSize(const Vector3& value)
Parameters
Vector3
value
The box size to set. |
ToString()
Transform(const BoundingBox& box, const ::Transform& transform, BoundingBox& result)
Transforms the bounding box using the specified transformation.
Declaration
public static void Transform(const BoundingBox& box, const ::Transform& transform, BoundingBox& result)
Parameters
BoundingBox
box
The box. |
::Transform
transform
The transformation. |
BoundingBox
result
The result transformed box. |
Transform(const BoundingBox& box, const Matrix& matrix)
Transforms the bounding box using the specified matrix.
Declaration
public static BoundingBox Transform(const BoundingBox& box, const Matrix& matrix)
Parameters
BoundingBox
box
The box. |
Matrix
matrix
The matrix. |
Returns
BoundingBox
The result transformed box. |
Transform(const BoundingBox& box, const Matrix& matrix, BoundingBox& result)
Transforms the bounding box using the specified matrix.
Declaration
public static void Transform(const BoundingBox& box, const Matrix& matrix, BoundingBox& result)
Parameters
BoundingBox
box
The box. |
Matrix
matrix
The matrix. |
BoundingBox
result
The result transformed box. |