UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Math::TBox< T > Struct Template Reference

#include <Box.h>

Public Types

using FReal = T
 

Public Member Functions

constexpr TBox ()
 
constexpr TBox (ENoInit)
 
constexpr TBox (EForceInit)
 
constexpr TBox (EForceInit, TBoxConstInit)
 
UE_FORCEINLINE_HINT void DiagnosticCheck () const
 
bool ContainsNaN () const
 
template<typename FArg >
 TBox (const TVector< FArg > &InMin, const TVector< FArg > &InMax)
 
 TBox (const TVector4< T > &InMin, const TVector4< T > &InMax)
 
 TBox (const TVector< T > *Points, const int32 Count)
 
 TBox (const TArray< TVector< T > > &Points)
 
template<typename FArg UE_REQUIRES>
 TBox (const TBox< FArg > &From)
 
 TBox (const TSphere< T > &Sphere)
 
UE_FORCEINLINE_HINT bool operator== (const TBox< T > &Other) const
 
UE_FORCEINLINE_HINT bool operator!= (const TBox< T > &Other) const
 
bool Equals (const TBox< T > &Other, T Tolerance=UE_KINDA_SMALL_NUMBER) const
 
TBox< T > & operator+= (const TVector< T > &Other)
 
UE_FORCEINLINE_HINT TBox< T > operator+ (const TVector< T > &Other) const
 
TBox< T > & operator+= (const TBox< T > &Other)
 
UE_FORCEINLINE_HINT TBox< T > operator+ (const TBox< T > &Other) const
 
TVector< T > & operator[] (int32 Index)
 
const TVector< T > & operator[] (int32 Index) const
 
UE_FORCEINLINE_HINTComputeSquaredDistanceToPoint (const TVector< T > &Point) const
 
ComputeSquaredDistanceToBox (const TBox< T > &Box) const
 
UE_FORCEINLINE_HINT TBox< T > ExpandBy (T W) const
 
UE_FORCEINLINE_HINT TBox< T > ExpandBy (const TVector< T > &V) const
 
TBox< T > ExpandBy (const TVector< T > &Neg, const TVector< T > &Pos) const
 
UE_FORCEINLINE_HINT TBox< T > ShiftBy (const TVector< T > &Offset) const
 
TBox< T > MoveTo (const TVector< T > &Destination) const
 
TVector< T > GetCenter () const
 
void GetCenterAndExtents (TVector< T > &Center, TVector< T > &Extents) const
 
TVector< T > GetClosestPointTo (const TVector< T > &Point) const
 
TVector< T > GetExtent () const
 
TVector< T > GetSize () const
 
GetVolume () const
 
void Init ()
 
bool Intersect (const TBox< T > &Other) const
 
bool IntersectXY (const TBox< T > &Other) const
 
TBox< T > Overlap (const TBox< T > &Other) const
 
TBox< T > InverseTransformBy (const TTransform< T > &M) const
 
bool IsInside (const TVector< T > &In) const
 
bool IsInsideOrOn (const TVector< T > &In) const
 
UE_FORCEINLINE_HINT bool IsInside (const TBox< T > &Other) const
 
UE_FORCEINLINE_HINT bool IsInsideOrOn (const TBox< T > &Other) const
 
bool IsInsideXY (const TVector< T > &In) const
 
bool IsInsideOrOnXY (const TVector< T > &In) const
 
UE_FORCEINLINE_HINT bool IsInsideXY (const TBox< T > &Other) const
 
TBox< T > TransformBy (const TMatrix< T > &M) const
 
TBox< T > TransformBy (const TTransform< T > &M) const
 
TBox< T > TransformProjectBy (const TMatrix< T > &ProjM) const
 
FString ToString () const
 
FString ToCompactString () const
 
void GetVertices (TVector< T >(&Vertices)[8]) const
 
bool Serialize (FArchive &Ar)
 
bool Serialize (FStructuredArchive::FSlot Slot)
 
bool SerializeFromMismatchedTag (FName StructTag, FArchive &Ar)
 

Static Public Member Functions

static TBox< T > BuildAABB (const TVector< T > &Origin, const TVector< T > &Extent)
 

Public Attributes

TVector< T > Min
 
TVector< T > Max
 
uint8 IsValid
 

Friends

FArchiveoperator<< (FArchive &Ar, TBox< T > &Box)
 
void operator<< (FStructuredArchive::FSlot Slot, TBox< T > &Box)
 

Member Typedef Documentation

◆ FReal

template<typename T >
using UE::Math::TBox< T >::FReal = T

Constructor & Destructor Documentation

◆ TBox() [1/10]

template<typename T >
constexpr UE::Math::TBox< T >::TBox ( )
inlineconstexpr

Default constructor. Creates a new box with uninitialized extents and marks it as invalid.

NOTE: This default constructor is unlike TVector, TMatrix etc. in that it actually initializes the instance. Ideally it should be = default; in the same way, but this would break backwards compatibility. It might be possible if the questionable IsValid field ever gets removed.

◆ TBox() [2/10]

template<typename T >
constexpr UE::Math::TBox< T >::TBox ( ENoInit  )
inlineexplicitconstexpr

Creates a new box without initialization.

◆ TBox() [3/10]

template<typename T >
constexpr UE::Math::TBox< T >::TBox ( EForceInit  )
inlineexplicitconstexpr

Creates and initializes a new box with zero extent and marks it as invalid.

◆ TBox() [4/10]

template<typename T >
constexpr UE::Math::TBox< T >::TBox ( EForceInit  ,
TBoxConstInit   
)
inlineconstexpr

◆ TBox() [5/10]

template<typename T >
template<typename FArg >
UE::Math::TBox< T >::TBox ( const TVector< FArg > &  InMin,
const TVector< FArg > &  InMax 
)
inline

Creates and initializes a new box from the specified extents.

Parameters
InMinThe box's minimum point.
InMaxThe box's maximum point.

◆ TBox() [6/10]

template<typename T >
UE::Math::TBox< T >::TBox ( const TVector4< T > &  InMin,
const TVector4< T > &  InMax 
)
inline

◆ TBox() [7/10]

template<typename T >
UE::Math::TBox< T >::TBox ( const TVector< T > *  Points,
const int32  Count 
)
inline

Creates and initializes a new box from the given set of points.

Parameters
PointsArray of Points to create for the bounding volume.
CountThe number of points.

◆ TBox() [8/10]

template<typename T >
UE::Math::TBox< T >::TBox ( const TArray< TVector< T > > &  Points)
inlineexplicit

Creates and initializes a new box from an array of points.

Parameters
PointsArray of Points to create for the bounding volume.

◆ TBox() [9/10]

template<typename T >
template<typename FArg UE_REQUIRES>
UE::Math::TBox< T >::TBox ( const TBox< FArg > &  From)
inlineexplicit

◆ TBox() [10/10]

template<typename T >
UE::Math::TBox< T >::TBox ( const TSphere< T > &  Sphere)
inlineexplicit

Creates and initializes a box that tightly encloses the given sphere.

Parameters
SphereThe sphere being enclosed.

Member Function Documentation

◆ BuildAABB()

template<typename T >
static TBox< T > UE::Math::TBox< T >::BuildAABB ( const TVector< T > &  Origin,
const TVector< T > &  Extent 
)
inlinestatic

Utility function to build an AABB from Origin and Extent

Parameters
OriginThe location of the bounding box.
ExtentHalf size of the bounding box.
Returns
A new axis-aligned bounding box.

◆ ComputeSquaredDistanceToBox()

template<typename T >
T UE::Math::TBox< T >::ComputeSquaredDistanceToBox ( const TBox< T > &  Box) const
inline

Calculates squared distance between two boxes.

◆ ComputeSquaredDistanceToPoint()

template<typename T >
UE_FORCEINLINE_HINT T UE::Math::TBox< T >::ComputeSquaredDistanceToPoint ( const TVector< T > &  Point) const
inline

Calculates the distance of a point to this box.

Parameters
PointThe point.
Returns
The distance.

◆ ContainsNaN()

template<typename T >
bool UE::Math::TBox< T >::ContainsNaN ( ) const
inline

◆ DiagnosticCheck()

template<typename T >
UE_FORCEINLINE_HINT void UE::Math::TBox< T >::DiagnosticCheck ( ) const
inline

◆ Equals()

template<typename T >
bool UE::Math::TBox< T >::Equals ( const TBox< T > &  Other,
Tolerance = UE_KINDA_SMALL_NUMBER 
) const
inline

Check against another box for equality, within specified error limits.

Returns true if both bounding boxes are invalid. Returns false if one of the bounding boxes is invalid.

Parameters
OtherThe box to check against.
ToleranceError tolerance.
Returns
true if the boxes are equal within tolerance limits, false otherwise.

◆ ExpandBy() [1/3]

template<typename T >
TBox< T > UE::Math::TBox< T >::ExpandBy ( const TVector< T > &  Neg,
const TVector< T > &  Pos 
) const
inline

Returns a box of increased size.

Parameters
NegThe size to increase the volume by in the negative direction (positive values move the bounds outwards)
PosThe size to increase the volume by in the positive direction (positive values move the bounds outwards)
Returns
A new bounding box.

◆ ExpandBy() [2/3]

template<typename T >
UE_FORCEINLINE_HINT TBox< T > UE::Math::TBox< T >::ExpandBy ( const TVector< T > &  V) const
inline

Returns a box of increased size.

Parameters
VThe size to increase the volume by.
Returns
A new bounding box.

◆ ExpandBy() [3/3]

template<typename T >
UE_FORCEINLINE_HINT TBox< T > UE::Math::TBox< T >::ExpandBy ( W) const
inline

Returns a box of increased size.

Parameters
WThe size to increase the volume by.
Returns
A new bounding box.

◆ GetCenter()

template<typename T >
TVector< T > UE::Math::TBox< T >::GetCenter ( ) const
inline

Gets the center point of this box.

Returns
The center point.
See also
GetCenterAndExtents, GetExtent, GetSize, GetVolume

◆ GetCenterAndExtents()

template<typename T >
void UE::Math::TBox< T >::GetCenterAndExtents ( TVector< T > &  Center,
TVector< T > &  Extents 
) const
inline

Gets the center and extents of this box.

Parameters
Center[out] Will contain the box center point.
Extents[out] Will contain the extent around the center.
See also
GetCenter, GetExtent, GetSize, GetVolume

◆ GetClosestPointTo()

template<typename T >
TVector< T > UE::Math::TBox< T >::GetClosestPointTo ( const TVector< T > &  Point) const
inline

Calculates the closest point on or inside the box to a given point in space.

Parameters
PointThe point in space.
Returns
The closest point on or inside the box.

◆ GetExtent()

template<typename T >
TVector< T > UE::Math::TBox< T >::GetExtent ( ) const
inline

Gets the (half) extents of this box.

Returns
The box (half) extents.
See also
GetCenter, GetCenterAndExtents, GetSize, GetVolume

◆ GetSize()

template<typename T >
TVector< T > UE::Math::TBox< T >::GetSize ( ) const
inline

Gets the size of this box.

Returns
The box size.
See also
GetCenter, GetCenterAndExtents, GetExtent, GetVolume

◆ GetVertices()

template<typename T >
void UE::Math::TBox< T >::GetVertices ( TVector< T >(&)  Vertices[8]) const

Get the vertices that make up this box.

◆ GetVolume()

template<typename T >
T UE::Math::TBox< T >::GetVolume ( ) const
inline

Gets the volume of this box.

Returns
The box volume.
See also
GetCenter, GetCenterAndExtents, GetExtent, GetSize

◆ Init()

template<typename T >
void UE::Math::TBox< T >::Init ( )
inline

Set the initial values of the bounding box to Zero.

◆ Intersect()

template<typename T >
bool UE::Math::TBox< T >::Intersect ( const TBox< T > &  Other) const
inline

Checks whether the given bounding box intersects this bounding box.

Parameters
OtherThe bounding box to intersect with.
Returns
true if the boxes intersect, false otherwise.
Note
This function assumes boxes have closed bounds, i.e. boxes with coincident borders on any edge will overlap.

◆ IntersectXY()

template<typename T >
bool UE::Math::TBox< T >::IntersectXY ( const TBox< T > &  Other) const
inline

Checks whether the given bounding box intersects this bounding box in the XY plane.

Parameters
OtherThe bounding box to test intersection.
Returns
true if the boxes intersect in the XY Plane, false otherwise.
Note
This function assumes boxes have closed bounds, i.e. boxes with coincident borders on any edge will overlap.

◆ InverseTransformBy()

template<typename T >
TBox< T > UE::Math::TBox< T >::InverseTransformBy ( const TTransform< T > &  M) const

Gets a bounding volume transformed by an inverted TTransform<T> object.

Parameters
MThe transformation object to perform the inversely transform this box with.
Returns
The transformed box.

◆ IsInside() [1/2]

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TBox< T >::IsInside ( const TBox< T > &  Other) const
inline

Checks whether a given box is fully encapsulated by this box.

Parameters
OtherThe box to test for encapsulation within the bounding volume.
Returns
true if box is inside this volume.
See also
IsInsideXY
Note
This function assumes boxes have open bounds, i.e. boxes with coincident borders on any edge are not encapsulated.

◆ IsInside() [2/2]

template<typename T >
bool UE::Math::TBox< T >::IsInside ( const TVector< T > &  In) const
inline

Checks whether the given location is inside this box.

Parameters
InThe location to test for inside the bounding volume.
Returns
true if location is inside this volume.
See also
IsInsideXY
Note
This function assumes boxes have open bounds, i.e. points lying on the border of the box are not inside. Use IsInsideOrOn to include borders in the test.

◆ IsInsideOrOn() [1/2]

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TBox< T >::IsInsideOrOn ( const TBox< T > &  Other) const
inline

Checks whether a given box is fully encapsulated by this box.

Parameters
OtherThe box to test for encapsulation within the bounding volume.
Returns
true if box is inside this volume.
See also
IsInsideXY
Note
This function assumes boxes have closed bounds, i.e. boxes with coincident borders on any edge are encapsulated.

◆ IsInsideOrOn() [2/2]

template<typename T >
bool UE::Math::TBox< T >::IsInsideOrOn ( const TVector< T > &  In) const
inline

Checks whether the given location is inside or on this box.

Parameters
InThe location to test for inside or on the bounding volume.
Returns
true if location is inside or on this volume.
See also
IsInsideOrOnXY
Note
This function assumes boxes have closed bounds, i.e. points lying on the border of the box are inside. Use IsInside to exclude borders from the test.

◆ IsInsideOrOnXY()

template<typename T >
bool UE::Math::TBox< T >::IsInsideOrOnXY ( const TVector< T > &  In) const
inline

Checks whether the given location is inside or on this box in the XY plane.

Parameters
InThe location to test for inside or on the bounding volume.
Returns
true if location is inside or on this box in the XY plane.
See also
IsInsideOrOn
Note
This function assumes boxes have closed bounds, i.e. points lying on the border of the box are not inside. Use IsInsideXY to exclude borders from the test.

◆ IsInsideXY() [1/2]

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TBox< T >::IsInsideXY ( const TBox< T > &  Other) const
inline

Checks whether the given box is fully encapsulated by this box in the XY plane.

Parameters
OtherThe box to test for encapsulation within the bounding box.
Returns
true if box is inside this box in the XY plane.
See also
IsInside
Note
This function assumes boxes have open bounds, i.e. boxes with coincident borders on any edge are not encapsulated.

◆ IsInsideXY() [2/2]

template<typename T >
bool UE::Math::TBox< T >::IsInsideXY ( const TVector< T > &  In) const
inline

Checks whether the given location is inside this box in the XY plane.

Parameters
InThe location to test for inside the bounding box.
Returns
true if location is inside this box in the XY plane.
See also
IsInside
Note
This function assumes boxes have open bounds, i.e. points lying on the border of the box are not inside. Use IsInsideOrOnXY to include borders in the test.

◆ MoveTo()

template<typename T >
TBox< T > UE::Math::TBox< T >::MoveTo ( const TVector< T > &  Destination) const
inline

Returns a box with its center moved to the new destination.

Parameters
DestinationThe destination point to move center of box to.
Returns
A new bounding box.

◆ operator!=()

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TBox< T >::operator!= ( const TBox< T > &  Other) const
inline

Compares two boxes for inequality.

Returns
false if the boxes are equal, true otherwise.

◆ operator+() [1/2]

template<typename T >
UE_FORCEINLINE_HINT TBox< T > UE::Math::TBox< T >::operator+ ( const TBox< T > &  Other) const
inline

Gets the result of addition to this bounding volume.

Parameters
OtherThe other volume to add to this.
Returns
A new bounding volume.

◆ operator+() [2/2]

template<typename T >
UE_FORCEINLINE_HINT TBox< T > UE::Math::TBox< T >::operator+ ( const TVector< T > &  Other) const
inline

Gets the result of addition to this bounding volume.

Parameters
OtherThe other point to add to this.
Returns
A new bounding volume.

◆ operator+=() [1/2]

template<typename T >
TBox< T > & UE::Math::TBox< T >::operator+= ( const TBox< T > &  Other)
inline

Adds to this bounding box to include a new bounding volume.

Parameters
Otherthe bounding volume to increase the bounding volume to.
Returns
Reference to this bounding volume after resizing to include the other bounding volume.

◆ operator+=() [2/2]

template<typename T >
TBox< T > & UE::Math::TBox< T >::operator+= ( const TVector< T > &  Other)
inline

Adds to this bounding box to include a given point.

Parameters
Otherthe point to increase the bounding volume to.
Returns
Reference to this bounding box after resizing to include the other point.

◆ operator==()

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TBox< T >::operator== ( const TBox< T > &  Other) const
inline

Compares two boxes for equality.

Returns true if both bounding boxes are invalid. Returns false if one of the bounding boxes is invalid.

Returns
true if the boxes are equal, false otherwise.

◆ operator[]() [1/2]

template<typename T >
TVector< T > & UE::Math::TBox< T >::operator[] ( int32  Index)
inline

Gets reference to the min or max of this bounding volume.

Parameters
Indexthe index into points of the bounding volume.
Returns
a reference to a point of the bounding volume.

◆ operator[]() [2/2]

template<typename T >
const TVector< T > & UE::Math::TBox< T >::operator[] ( int32  Index) const
inline

◆ Overlap()

template<typename T >
TBox< T > UE::Math::TBox< T >::Overlap ( const TBox< T > &  Other) const

Returns the overlap TBox<T> of two box

Parameters
OtherThe bounding box to test overlap
Returns
the overlap box. It can be 0 if they don't overlap

◆ Serialize() [1/2]

template<typename T >
bool UE::Math::TBox< T >::Serialize ( FArchive Ar)
inline

◆ Serialize() [2/2]

template<typename T >
bool UE::Math::TBox< T >::Serialize ( FStructuredArchive::FSlot  Slot)
inline

◆ SerializeFromMismatchedTag()

template<typename T >
bool UE::Math::TBox< T >::SerializeFromMismatchedTag ( FName  StructTag,
FArchive Ar 
)
inline

◆ ShiftBy()

template<typename T >
UE_FORCEINLINE_HINT TBox< T > UE::Math::TBox< T >::ShiftBy ( const TVector< T > &  Offset) const
inline

Returns a box with its position shifted.

Parameters
OffsetThe vector to shift the box by.
Returns
A new bounding box.

◆ ToCompactString()

template<typename T >
UE_FORCEINLINE_HINT FString UE::Math::TBox< T >::ToCompactString ( ) const

Get a textual representation of this box, without min/max values if invalid.

Returns
A string describing the box.

◆ ToString()

template<typename T >
UE_FORCEINLINE_HINT FString UE::Math::TBox< T >::ToString ( ) const

Get a textual representation of this box.

Returns
A string describing the box.

◆ TransformBy() [1/2]

template<typename T >
TBox< T > UE::Math::TBox< T >::TransformBy ( const TMatrix< T > &  M) const

Gets a bounding volume transformed by a matrix.

Parameters
MThe matrix to transform by.
Returns
The transformed box.
See also
TransformProjectBy

◆ TransformBy() [2/2]

template<typename T >
TBox< T > UE::Math::TBox< T >::TransformBy ( const TTransform< T > &  M) const

Gets a bounding volume transformed by a TTransform<T> object.

Parameters
MThe transformation object.
Returns
The transformed box.
See also
TransformProjectBy

◆ TransformProjectBy()

template<typename T >
TBox< T > UE::Math::TBox< T >::TransformProjectBy ( const TMatrix< T > &  ProjM) const

Returns the current world bounding box transformed and projected to screen space

Parameters
ProjMThe projection matrix.
Returns
The transformed box.
See also
TransformBy

Friends And Related Symbol Documentation

◆ operator<< [1/2]

template<typename T >
FArchive & operator<< ( FArchive Ar,
TBox< T > &  Box 
)
friend

Serializes the bounding box.

Parameters
ArThe archive to serialize into.
BoxThe box to serialize.
Returns
Reference to the Archive after serialization.

◆ operator<< [2/2]

template<typename T >
void operator<< ( FStructuredArchive::FSlot  Slot,
TBox< T > &  Box 
)
friend

Serializes the bounding box.

Parameters
SlotThe structured archive slot to serialize into.
BoxThe box to serialize.

Member Data Documentation

◆ IsValid

template<typename T >
uint8 UE::Math::TBox< T >::IsValid

Holds a flag indicating whether this box is valid.

◆ Max

template<typename T >
TVector<T> UE::Math::TBox< T >::Max

Holds the box's maximum point.

◆ Min

template<typename T >
TVector<T> UE::Math::TBox< T >::Min

Holds the box's minimum point.


The documentation for this struct was generated from the following file: