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

#include <Box2D.h>

Public Types

using FReal = T
 

Public Member Functions

 TBox2 ()=default
 
 TBox2 (EForceInit)
 
 TBox2 (const TVector2< T > &InMin, const TVector2< T > &InMax)
 
 TBox2 (const TVector2< T > *Points, const int32 Count)
 
 TBox2 (const TArray< TVector2< T > > &Points)
 
bool operator== (const TBox2< T > &Other) const
 
bool operator!= (const TBox2< T > &Other) const
 
bool Equals (const TBox2< T > &Other, T Tolerance=UE_KINDA_SMALL_NUMBER) const
 
TBox2< T > & operator+= (const TVector2< T > &Other)
 
TBox2< T > operator+ (const TVector2< T > &Other) const
 
TBox2< T > & operator+= (const TBox2< T > &Other)
 
TBox2< T > operator+ (const TBox2< T > &Other) const
 
TVector2< T > & operator[] (int32 Index)
 
const TVector2< T > & operator[] (int32 Index) const
 
ComputeSquaredDistanceToPoint (const TVector2< T > &Point) const
 
TBox2< T > ExpandBy (const T W) const
 
TBox2< T > ExpandBy (const TVector2< T > &V) const
 
GetArea () const
 
TVector2< T > GetCenter () const
 
void GetCenterAndExtents (TVector2< T > &center, TVector2< T > &Extents) const
 
TVector2< T > GetClosestPointTo (const TVector2< T > &Point) const
 
TVector2< T > GetExtent () const
 
TVector2< T > GetSize () const
 
void Init ()
 
TBox2< T > Overlap (const TBox2< T > &Other) const
 
bool Intersect (const TBox2< T > &Other) const
 
bool IsInside (const TVector2< T > &TestPoint) const
 
bool IsInsideOrOn (const TVector2< T > &TestPoint) const
 
bool IsInside (const TBox2< T > &Other) const
 
TBox2< T > ShiftBy (const TVector2< T > &Offset) const
 
TBox2< T > MoveTo (const TVector2< T > &Destination) const
 
FString ToString () const
 
bool Serialize (FArchive &Ar)
 
bool SerializeFromMismatchedTag (FName StructTag, FArchive &Ar)
 
template<typename FArg UE_REQUIRES>
 TBox2 (const TBox2< FArg > &From)
 

Static Public Member Functions

static TBox2< T > BuildAABB (const TVector2< T > &Origin, const TVector2< T > &Extent)
 

Public Attributes

TVector2< T > Min
 
TVector2< T > Max
 
bool bIsValid
 

Friends

FArchiveoperator<< (FArchive &Ar, TBox2< T > &Box)
 

Member Typedef Documentation

◆ FReal

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

Constructor & Destructor Documentation

◆ TBox2() [1/6]

template<typename T >
UE::Math::TBox2< T >::TBox2 ( )
default

Default constructor (no initialization).

◆ TBox2() [2/6]

template<typename T >
UE::Math::TBox2< T >::TBox2 ( EForceInit  )
inlineexplicit

Creates and initializes a new box.

The box extents are initialized to zero and the box is marked as invalid.

Parameters
EForceInitForce Init Enum.

◆ TBox2() [3/6]

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

Creates and initializes a new box from the specified parameters.

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

◆ TBox2() [4/6]

template<typename T >
UE::Math::TBox2< T >::TBox2 ( const TVector2< T > *  Points,
const int32  Count 
)

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.

◆ TBox2() [5/6]

template<typename T >
UE::Math::TBox2< T >::TBox2 ( const TArray< TVector2< T > > &  Points)

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

Parameters
PointsArray of Points to create for the bounding volume.

◆ TBox2() [6/6]

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

Member Function Documentation

◆ BuildAABB()

template<typename T >
static TBox2< T > UE::Math::TBox2< T >::BuildAABB ( const TVector2< T > &  Origin,
const TVector2< 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.

◆ ComputeSquaredDistanceToPoint()

template<typename T >
T UE::Math::TBox2< T >::ComputeSquaredDistanceToPoint ( const TVector2< T > &  Point) const
inline

Calculates the distance of a point to this box.

Parameters
PointThe point.
Returns
The distance.

◆ Equals()

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

Checks for equality with error-tolerant comparison.

Parameters
OtherThe box to compare.
ToleranceError tolerance.
Returns
true if the boxes are equal within specified tolerance, otherwise false.

◆ ExpandBy() [1/2]

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

Increase the bounding box volume.

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

◆ ExpandBy() [2/2]

template<typename T >
TBox2< T > UE::Math::TBox2< T >::ExpandBy ( const TVector2< T > &  V) const
inline

Returns a box of increased size.

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

◆ GetArea()

template<typename T >
T UE::Math::TBox2< T >::GetArea ( ) const
inline

Gets the box area.

Returns
Box area.
See also
GetCenter, GetCenterAndExtents, GetExtent, GetSize

◆ GetCenter()

template<typename T >
TVector2< T > UE::Math::TBox2< T >::GetCenter ( ) const
inline

Gets the box's center point.

Returns
Th center point.
See also
GetArea, GetCenterAndExtents, GetExtent, GetSize

◆ GetCenterAndExtents()

template<typename T >
void UE::Math::TBox2< T >::GetCenterAndExtents ( TVector2< T > &  center,
TVector2< T > &  Extents 
) const
inline

Get the center and extents

Parameters
center[out]reference to center point
Extents[out]reference to the extent around the center
See also
GetArea, GetCenter, GetExtent, GetSize

◆ GetClosestPointTo()

template<typename T >
TVector2< T > UE::Math::TBox2< T >::GetClosestPointTo ( const TVector2< 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 >
TVector2< T > UE::Math::TBox2< T >::GetExtent ( ) const
inline

Gets the box extents around the center.

Returns
Box extents.
See also
GetArea, GetCenter, GetCenterAndExtents, GetSize

◆ GetSize()

template<typename T >
TVector2< T > UE::Math::TBox2< T >::GetSize ( ) const
inline

Gets the box size.

Returns
Box size.
See also
GetArea, GetCenter, GetCenterAndExtents, GetExtent

◆ Init()

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

Set the initial values of the bounding box to Zero.

◆ Intersect()

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

Checks whether the given box intersects this box.

Parameters
Otherbounding box to test intersection
Returns
true if boxes intersect, false otherwise.

◆ IsInside() [1/2]

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

Checks whether the 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, false otherwise.

◆ IsInside() [2/2]

template<typename T >
bool UE::Math::TBox2< T >::IsInside ( const TVector2< T > &  TestPoint) const
inline

Checks whether the given point is inside this box.

Parameters
PointThe point to test.
Returns
true if the point is inside this box, otherwise false.

◆ IsInsideOrOn()

template<typename T >
bool UE::Math::TBox2< T >::IsInsideOrOn ( const TVector2< T > &  TestPoint) const
inline

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

Parameters
PointThe point to test.
Returns
true if point is inside or on this box, otherwise false.
See also
IsInside

◆ MoveTo()

template<typename T >
TBox2< T > UE::Math::TBox2< T >::MoveTo ( const TVector2< 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 >
bool UE::Math::TBox2< T >::operator!= ( const TBox2< T > &  Other) const
inline

Compares two boxes for inequality.

Parameters
OtherThe other box to compare with.
Returns
true if the boxes are not equal, false otherwise.

◆ operator+() [1/2]

template<typename T >
TBox2< T > UE::Math::TBox2< T >::operator+ ( const TBox2< 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 >
TBox2< T > UE::Math::TBox2< T >::operator+ ( const TVector2< 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 >
TBox2< T > & UE::Math::TBox2< T >::operator+= ( const TBox2< 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 >
TBox2< T > & UE::Math::TBox2< T >::operator+= ( const TVector2< 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 >
bool UE::Math::TBox2< T >::operator== ( const TBox2< T > &  Other) const
inline

Compares two boxes for equality.

Parameters
OtherThe other box to compare with.
Returns
true if the boxes are equal, false otherwise.

◆ operator[]() [1/2]

template<typename T >
TVector2< T > & UE::Math::TBox2< 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 TVector2< T > & UE::Math::TBox2< T >::operator[] ( int32  Index) const
inline

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

Parameters
IndexThe index into points of the bounding volume.
Returns
A const reference to a point of the bounding volume.

◆ Overlap()

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

Returns the overlap box of two boxes

Parameters
OtherThe bounding box to test overlap
Returns
the overlap box. Result will be invalid if they don't overlap

◆ Serialize()

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

◆ SerializeFromMismatchedTag()

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

◆ ShiftBy()

template<typename T >
TBox2< T > UE::Math::TBox2< T >::ShiftBy ( const TVector2< T > &  Offset) const
inline

Shift bounding box position.

Parameters
Theoffset vector to shift by.
Returns
A new shifted bounding box.

◆ ToString()

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

Get a textual representation of this box.

Returns
A string describing the box.

Friends And Related Symbol Documentation

◆ operator<<

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

Serializes the bounding box.

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

Member Data Documentation

◆ bIsValid

template<typename T >
bool UE::Math::TBox2< T >::bIsValid

Holds a flag indicating whether this box is valid.

◆ Max

template<typename T >
TVector2<T> UE::Math::TBox2< T >::Max

Holds the box's maximum point.

◆ Min

template<typename T >
TVector2<T> UE::Math::TBox2< T >::Min

Holds the box's minimum point.


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