UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SphylElem.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 "SphylElem.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=Capsule, EditAnywhere)
29
31 UPROPERTY(Category = Capsule, EditAnywhere, meta = (ClampMin = "-360", ClampMax = "360"))
33
35 UPROPERTY(Category= Capsule, EditAnywhere)
36 float Radius;
37
39 UPROPERTY(Category= Capsule, EditAnywhere)
40 float Length;
41
44#if WITH_EDITORONLY_DATA
46 , Orientation_DEPRECATED( FQuat::Identity )
47#endif
50 , Radius(1), Length(1)
51 {
52
53 }
54
59 , Orientation_DEPRECATED( FQuat::Identity )
60#endif
61 , Center( FVector::ZeroVector )
62 , Rotation(FRotator::ZeroRotator)
63 , Radius(InRadius), Length(InLength)
64 {
65
66 }
67
69
70#if WITH_EDITORONLY_DATA
71 void FixupDeprecated( FArchive& Ar );
72#endif
73
74 friend bool operator==( const FKSphylElem& LHS, const FKSphylElem& RHS )
75 {
76 return ( LHS.Center == RHS.Center &&
77 LHS.Rotation == RHS.Rotation &&
78 LHS.Radius == RHS.Radius &&
79 LHS.Length == RHS.Length );
80 };
81
82 // Utility function that builds an FTransform from the current data
83 virtual FTransform GetTransform() const override final
84 {
85 return FTransform(Rotation, Center );
86 };
87
89 {
90 ensure(InTransform.IsValid());
91 Rotation = InTransform.Rotator();
92 Center = InTransform.GetLocation();
93 }
94
95 UE_DEPRECATED(5.1, "Changed to GetScaledVolume. Note that Volume calculation now includes non-uniform scale so values may have changed")
96 FVector::FReal GetVolume(const FVector& Scale) const { return GetScaledVolume(Scale); }
97
98 FVector::FReal GetScaledVolume(const FVector& Scale3D) const
99 {
100 FVector::FReal ScaledRadius = GetScaledRadius(Scale3D);
101 FVector::FReal ScaledLength = GetScaledCylinderLength(Scale3D);
102 return UE_PI * FMath::Square(ScaledRadius) * (1.3333f * ScaledRadius + ScaledLength);
103 }
104
105 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FColor Color) const override;
106 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FMaterialRenderProxy* MaterialRenderProxy) const override;
107
108 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FColor Color) const;
109 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy) const;
110
111 ENGINE_API void GetElemSolid(const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy, int32 ViewIndex, FMeshElementCollector& Collector) const;
112 ENGINE_API FBox CalcAABB(const FTransform& BoneTM, float Scale) const;
113
114 ENGINE_API void ScaleElem(FVector DeltaSize, float MinSize);
115
116 ENGINE_API FKSphylElem GetFinalScaled(const FVector& Scale3D, const FTransform& RelativeTM) const;
117
119 ENGINE_API float GetScaledRadius(const FVector& Scale3D) const;
121 ENGINE_API float GetScaledCylinderLength(const FVector& Scale3D) const;
123 ENGINE_API float GetScaledHalfLength(const FVector& Scale3D) const;
124
132 ENGINE_API float GetShortestDistanceToPoint(const FVector& WorldPosition, const FTransform& BodyToWorldTM) const;
133
142 ENGINE_API float GetClosestPointAndNormal(const FVector& WorldPosition, const FTransform& BodyToWorldTM, FVector& ClosestWorldPosition, FVector& Normal) const;
143
145};
@ 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
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
#define UE_PI
Definition UnrealMathUtility.h:129
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 ShapeElem.h:35
Definition SphylElem.h:16
FRotator Rotation
Definition SphylElem.h:32
virtual ENGINE_API ~FKSphylElem()
friend bool operator==(const FKSphylElem &LHS, const FKSphylElem &RHS)
Definition SphylElem.h:74
float Radius
Definition SphylElem.h:36
static ENGINE_API EAggCollisionShape::Type StaticShapeType
Definition SphylElem.h:144
virtual FTransform GetTransform() const override final
Definition SphylElem.h:83
float Length
Definition SphylElem.h:40
void SetTransform(const FTransform &InTransform)
Definition SphylElem.h:88
FKSphylElem(float InRadius, float InLength)
Definition SphylElem.h:55
FVector Center
Definition SphylElem.h:28
FVector::FReal GetScaledVolume(const FVector &Scale3D) const
Definition SphylElem.h:98
static constexpr UE_FORCEINLINE_HINT T Square(const T A)
Definition UnrealMathUtility.h:578
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
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
double FReal
Definition Vector.h:55