UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SphereElem.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 "SphereElem.generated.h"
9
11
13USTRUCT()
15{
17
18#if WITH_EDITORONLY_DATA
19 UPROPERTY()
21#endif
22
24 UPROPERTY(Category=Sphere, EditAnywhere)
26
28 UPROPERTY(Category=Sphere, EditAnywhere)
29 float Radius;
30
33#if WITH_EDITORONLY_DATA
35#endif
37 , Radius(1)
38 {
39
40 }
41
42 FKSphereElem( float r )
46#endif
47 , Center( FVector::ZeroVector )
48 , Radius(r)
49 {
50
51 }
52
54
55#if WITH_EDITORONLY_DATA
56 void FixupDeprecated( FArchive& Ar );
57#endif
58
59 friend bool operator==( const FKSphereElem& LHS, const FKSphereElem& RHS )
60 {
61 return ( LHS.Center == RHS.Center &&
62 LHS.Radius == RHS.Radius );
63 }
64
65 // Utility function that builds an FTransform from the current data
66 virtual FTransform GetTransform() const override final
67 {
68 return FTransform( Center );
69 };
70
72 {
73 ensure(InTransform.IsValid());
74 Center = InTransform.GetLocation();
75 }
76
77 UE_DEPRECATED(5.1, "Changed to GetScaledVolume to support non-uniform scales on other element types")
78 FVector::FReal GetVolume(const FVector& Scale) const { return GetScaledVolume(Scale); }
79
80 FVector::FReal GetScaledVolume(const FVector& Scale) const { return 1.3333f * UE_PI * FMath::Pow(Radius * Scale.GetAbsMin(), 3); }
81
82 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FColor Color) const override;
83 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FMaterialRenderProxy* MaterialRenderProxy) const override;
84
85 ENGINE_API void DrawElemWire(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FColor Color) const;
86 ENGINE_API void DrawElemSolid(class FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy) const;
87
88 ENGINE_API void GetElemSolid(const FTransform& ElemTM, const FVector& Scale3D, const FMaterialRenderProxy* MaterialRenderProxy, int32 ViewIndex, class FMeshElementCollector& Collector) const;
89 ENGINE_API FBox CalcAABB(const FTransform& BoneTM, float Scale) const;
90
91 ENGINE_API void ScaleElem(FVector DeltaSize, float MinSize);
92
94
95 ENGINE_API FKSphereElem GetFinalScaled(const FVector& Scale3D, const FTransform& RelativeTM) const;
96
103 ENGINE_API float GetShortestDistanceToPoint(const FVector& WorldPosition, const FTransform& BodyToWorldTM) const;
104
113 ENGINE_API float GetClosestPointAndNormal(const FVector& WorldPosition, const FTransform& BodyToWorldTM, FVector& ClosestWorldPosition, FVector& Normal) const;
114};
@ 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 SphereElem.h:15
FKSphereElem(float r)
Definition SphereElem.h:42
virtual ENGINE_API ~FKSphereElem()
FVector Center
Definition SphereElem.h:25
void SetTransform(const FTransform &InTransform)
Definition SphereElem.h:71
friend bool operator==(const FKSphereElem &LHS, const FKSphereElem &RHS)
Definition SphereElem.h:59
float Radius
Definition SphereElem.h:29
static ENGINE_API EAggCollisionShape::Type StaticShapeType
Definition SphereElem.h:93
FVector::FReal GetScaledVolume(const FVector &Scale) const
Definition SphereElem.h:80
virtual FTransform GetTransform() const override final
Definition SphereElem.h:66
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
double FReal
Definition Vector.h:55