UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
OrientedBox.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Math/Vector.h"
7#include "Math/Interval.h"
8
13{
16
19
22
25
28
31
34
35public:
36
43 : Center(0.0f)
44 , AxisX(1.0f, 0.0f, 0.0f)
45 , AxisY(0.0f, 1.0f, 0.0f)
46 , AxisZ(0.0f, 0.0f, 1.0f)
47 , ExtentX(1.0f)
48 , ExtentY(1.0f)
49 , ExtentZ(1.0f)
50 { }
51
52public:
53
59 inline void CalcVertices(FVector* Verts) const;
60
66 [[nodiscard]] inline FFloatInterval Project(const FVector& Axis) const;
67};
68
69
70/* FOrientedBox inline functions
71 *****************************************************************************/
72
73inline void FOrientedBox::CalcVertices( FVector* Verts ) const
74{
75 const float Signs[] = { -1.0f, 1.0f };
76
77 for (int32 i = 0; i < 2; i++)
78 {
79 for (int32 j = 0; j < 2; j++)
80 {
81 for (int32 k = 0; k < 2; k++)
82 {
83 *Verts++ = Center + (Signs[i] * ExtentX) * AxisX + (Signs[j] * ExtentY) * AxisY + (Signs[k] * ExtentZ) * AxisZ;
84 }
85 }
86 }
87}
88
90{
91 // Consider:
92 // max { dot(Center +- ExtentX * AxisX +- ExtentY * AxisY +- ExtentZ * AxisZ, Axis) }
93 // =max { dot(Center, Axis) +- ExtentX * dot(AxisX, Axis) +- ExtentY * dot(AxisY, Axis) +- ExtentZ * dot(AxisZ, Axis) }
94 //
95 // These individual terms can be maximized separately and are clearly maximal when their effective signs
96 // are all positive. Analogous for the min with all-negative signs.
97
98 // Calculate the projections of the box center and the extent-scaled axes.
103
105 return FFloatInterval {
108 };
109}
110
111template <> struct TIsPODType<FOrientedBox> { enum { Value = true }; };
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition OrientedBox.h:13
FFloatInterval Project(const FVector &Axis) const
Definition OrientedBox.h:89
FVector::FReal ExtentY
Definition OrientedBox.h:30
FOrientedBox()
Definition OrientedBox.h:42
FVector::FReal ExtentZ
Definition OrientedBox.h:33
FVector AxisY
Definition OrientedBox.h:21
FVector Center
Definition OrientedBox.h:15
FVector AxisX
Definition OrientedBox.h:18
void CalcVertices(FVector *Verts) const
Definition OrientedBox.h:73
FVector AxisZ
Definition OrientedBox.h:24
FVector::FReal ExtentX
Definition OrientedBox.h:27
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13
T FReal
Definition Vector.h:55