UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BoxElem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "BoxElem.generated.h"
9
12
14USTRUCT()
16{
18
19#if WITH_EDITORONLY_DATA
20 UPROPERTY()
22 UPROPERTY()
23 FQuat Orientation_DEPRECATED;
24#endif
25
27 UPROPERTY(Category=Box, EditAnywhere)
29
31 UPROPERTY(Category=Box, EditAnywhere, meta = (ClampMin = "-360", ClampMax = "360"))
33
35 UPROPERTY(Category= Box, EditAnywhere, meta =(DisplayName = "X Extent"))
36 float X;
37
39 UPROPERTY(Category= Box, EditAnywhere, meta = (DisplayName = "Y Extent"))
40 float Y;
41
43 UPROPERTY(Category= Box, EditAnywhere, meta = (DisplayName = "Z Extent"))
44 float Z;
45
46
49#if WITH_EDITORONLY_DATA
51 , Orientation_DEPRECATED( FQuat::Identity )
52#endif
55 , X(1), Y(1), Z(1)
56 {
57
58 }
59
60 FKBoxElem( float s )
64 , Orientation_DEPRECATED( FQuat::Identity )
65#endif
66 , Center( FVector::ZeroVector )
67 , Rotation(FRotator::ZeroRotator)
68 , X(s), Y(s), Z(s)
69 {
70
71 }
72
73 FKBoxElem( float InX, float InY, float InZ )
77 , Orientation_DEPRECATED( FQuat::Identity )
78#endif
79 , Center( FVector::ZeroVector )
80 , Rotation(FRotator::ZeroRotator)
81 , X(InX), Y(InY), Z(InZ)
82 {
83
84 }
85
87
88#if WITH_EDITORONLY_DATA
89 void FixupDeprecated( FArchive& Ar );
90#endif
91
92 friend bool operator==( const FKBoxElem& LHS, const FKBoxElem& RHS )
93 {
94 return ( LHS.Center == RHS.Center &&
95 LHS.Rotation == RHS.Rotation &&
96 LHS.X == RHS.X &&
97 LHS.Y == RHS.Y &&
98 LHS.Z == RHS.Z );
99 };
100
101 // Utility function that builds an FTransform from the current data
102 virtual FTransform GetTransform() const override final
103 {
104 return FTransform( Rotation, Center );
105 };
106
108 {
109 ensure(InTransform.IsValid());
110 Rotation = InTransform.Rotator();
111 Center = InTransform.GetLocation();
112 }
113
114 UE_DEPRECATED(5.1, "Changed to GetScaledVolume. Note that Volume calculation now includes non-uniform scale so values may have changed")
115 FVector::FReal GetVolume(const FVector& Scale3D) const { return GetScaledVolume(Scale3D); }
116
117 FVector::FReal GetScaledVolume(const FVector& Scale3D) const { return FMath::Abs(Scale3D.X * Scale3D.Y * Scale3D.Z * X * Y * Z); }
118
119 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FColor Color) const override;
120 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FMaterialRenderProxy* MaterialRenderProxy) const override;
121
122 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FColor Color) const;
123 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy) const;
124
125 ENGINE_API void GetElemSolid(const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy, int32 ViewIndex, FMeshElementCollector& Collector) const;
126
127 ENGINE_API FBox CalcAABB(const FTransform& BoneTM, float Scale) const;
128
129 ENGINE_API void ScaleElem(FVector DeltaSize, float MinSize);
130
131 ENGINE_API FKBoxElem GetFinalScaled(const FVector& Scale3D, const FTransform& RelativeTM) const;
132
134
141 ENGINE_API float GetShortestDistanceToPoint(const FVector& WorldPosition, const FTransform& BodyToWorldTM) const;
142
143
152 ENGINE_API float GetClosestPointAndNormal(const FVector& WorldPosition, const FTransform& BodyToWorldTM, FVector& ClosestWorldPosition, FVector& Normal) const;
153};
@ Normal
Definition AndroidInputInterface.h:116
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define WITH_EDITORONLY_DATA
Definition CoreMiscDefines.h:24
@ ForceInitToZero
Definition CoreMiscDefines.h:156
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define X(Name, Desc)
Definition FormatStringSan.h:47
UE::Math::TTransform< double > FTransform
Definition MathFwd.h:53
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
if(Failed) console_printf("Failed.\n")
Definition Archive.h:1208
Definition MaterialRenderProxy.h:102
Definition MeshElementCollector.h:26
Definition PrimitiveDrawInterface.h:19
Definition PhysicsAsset.h:13
Type
Definition ShapeElem.h:17
Definition Color.h:486
Definition BoxElem.h:16
FRotator Rotation
Definition BoxElem.h:32
void SetTransform(const FTransform &InTransform)
Definition BoxElem.h:107
FVector::FReal GetScaledVolume(const FVector &Scale3D) const
Definition BoxElem.h:117
virtual FTransform GetTransform() const override final
Definition BoxElem.h:102
static ENGINE_API EAggCollisionShape::Type StaticShapeType
Definition BoxElem.h:133
float X
Definition BoxElem.h:36
FKBoxElem(float InX, float InY, float InZ)
Definition BoxElem.h:73
float Y
Definition BoxElem.h:40
FKBoxElem(float s)
Definition BoxElem.h:60
float Z
Definition BoxElem.h:44
virtual ENGINE_API ~FKBoxElem()
FVector Center
Definition BoxElem.h:28
friend bool operator==(const FKBoxElem &LHS, const FKBoxElem &RHS)
Definition BoxElem.h:92
Definition ShapeElem.h:35
static CORE_API const TQuat< double > Identity
Definition Quat.h:63
static CORE_API const TRotator< double > ZeroRotator
Definition Rotator.h:57
UE_FORCEINLINE_HINT UE::Math::TRotator< T > Rotation() const
Definition Vector.h:834
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
double FReal
Definition Vector.h:55
T X
Definition Vector.h:62