UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AttributeTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
10#include "CoreMinimal.h"
12
13#include "CoreTypes.h"
15
17
19
20namespace UE
21{
22 namespace Anim
23 {
26 {
27 template <typename T>
28 auto Requires(T& Val) -> decltype(
29 Val.Multiply(.5f),
30 Val.Accumulate(Val, 1.f, (EAdditiveAnimationType)0),
31 Val.MakeAdditive(Val),
32 Val.Interpolate(Val, 0.5f)
33 );
34 };
35
38 {
39 template <typename T>
40 auto Requires(T& Val) -> decltype(
41 Val.Normalize()
42 );
43 };
44
46 {
48
49 protected:
54
57
60
61 public:
62 UE_DEPRECATED(5.4, "This function is no longer used, the system will initialize built-in and user-defined types at the appropriate times")
64
66
68 template<typename AttributeType, typename OperatorType, typename... OperatorArgs>
70 {
71 static_assert(TAttributeTypeTraits<AttributeType>::WithCustomBlendOperator, "Attribute type does not require a custom blend operation");
72 UScriptStruct* ScriptStruct = AttributeType::StaticStruct();
73
74 AttributeTypes::RegisteredTypes.Add(ScriptStruct);
75 AttributeTypes::Operators.Add(MakeUnique<OperatorType>(Forward<OperatorArgs>(args)...));
76
78 {
79 AttributeTypes::InterpolatableTypes.Add(ScriptStruct);
80 }
81 }
82
84 template<typename AttributeType>
85 static void RegisterType()
86 {
87 static_assert(!TAttributeTypeTraits<AttributeType>::WithCustomBlendOperator, "Attribute type requires a custom blend operation");
88
89 UScriptStruct* ScriptStruct = AttributeType::StaticStruct();
90 AttributeTypes::RegisteredTypes.Add(ScriptStruct);
91
93 {
94 static_assert(TModels_V<CBlendableAttribute, AttributeType>, "Missing function implementations required for Attribute blending");
95
97 {
98 static_assert(TModels_V<CNormalizedAttribute, AttributeType>, "Missing function implementations required for Attribute normalization");
99 }
100
102 {
103 AttributeTypes::InterpolatableTypes.Add(ScriptStruct);
104 }
105 }
106
107 AttributeTypes::Operators.Add(MakeUnique<TAttributeBlendOperator<AttributeType>>());
108 }
109
111 template<typename AttributeType>
112 static void UnregisterType()
113 {
114 if (UObjectInitialized())
115 {
116 UScriptStruct* ScriptStruct = AttributeType::StaticStruct();
117 const int32 Index = AttributeTypes::RegisteredTypes.IndexOfByKey(ScriptStruct);
118 if (Index != INDEX_NONE)
119 {
120 AttributeTypes::RegisteredTypes.RemoveAtSwap(Index);
121 AttributeTypes::Operators.RemoveAtSwap(Index);
122 }
123 }
124 }
125
128 {
129 const int32 Index = AttributeTypes::RegisteredTypes.IndexOfByKey(WeakStruct);
130 ensure(WeakStruct.IsValid());
131 checkf(Index != INDEX_NONE, TEXT("Missing operator for attribute, type %s was not registered previously"), *WeakStruct->GetName());
132 return AttributeTypes::Operators[Index].Get();
133 }
134
137 {
138 return AttributeTypes::InterpolatableTypes.Contains(WeakStruct);
139 }
140
142 static bool IsTypeRegistered(const UScriptStruct* ScriptStruct)
143 {
144 return AttributeTypes::RegisteredTypes.Contains(ScriptStruct);
145 }
146
149 {
150 return AttributeTypes::RegisteredTypes;
151 }
152
153 friend class ::UAnimationSettings;
155 };
156 }
157}
EAdditiveAnimationType
Definition AnimTypes.h:575
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
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
bool UObjectInitialized()
Definition UObjectBase.cpp:59
UE_FORCEINLINE_HINT TUniquePtr< T > MakeUnique(TArgs &&... Args)
Definition UniquePtr.h:918
float Val(const FString &Value)
Definition UnrealMath.cpp:3163
Definition Array.h:670
Definition AnimationSettings.h:32
Definition IAttributeBlendOperator.h:16
Definition AttributeBlendOperator.h:21
Definition Class.h:1720
int
Definition TestServer.py:515
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition WeakObjectPtrTemplates.h:25
Definition AttributeTypes.h:46
static const IAttributeBlendOperator * GetTypeOperator(TWeakObjectPtr< const UScriptStruct > WeakStruct)
Definition AttributeTypes.h:127
static void LazyInitialize()
Definition AttributeTypes.h:63
static void RegisterType()
Definition AttributeTypes.h:85
static ENGINE_API TArray< TUniquePtr< IAttributeBlendOperator > > Operators
Definition AttributeTypes.h:51
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnAttributeTypesChanged, const UScriptStruct *, bool)
static void RegisterTypeWithOperator(OperatorArgs &&... args)
Definition AttributeTypes.h:69
static ENGINE_API TArray< TWeakObjectPtr< const UScriptStruct > > RegisteredTypes
Definition AttributeTypes.h:50
static ENGINE_API TArray< TWeakObjectPtr< const UScriptStruct > > InterpolatableTypes
Definition AttributeTypes.h:52
static TArray< TWeakObjectPtr< const UScriptStruct > > & GetRegisteredTypes()
Definition AttributeTypes.h:148
static bool CanInterpolateType(TWeakObjectPtr< const UScriptStruct > WeakStruct)
Definition AttributeTypes.h:136
static ENGINE_API FOnAttributeTypesChanged OnAttributeTypesChangedDelegate
Definition AttributeTypes.h:53
static void UnregisterType()
Definition AttributeTypes.h:112
static FOnAttributeTypesChanged & GetOnAttributeTypesChanged()
Definition AttributeTypes.h:65
static bool IsTypeRegistered(const UScriptStruct *ScriptStruct)
Definition AttributeTypes.h:142
static ENGINE_API bool RegisterNonBlendableType(const UScriptStruct *InScriptStruct)
Definition AttributeTypes.cpp:51
Definition AttributeTypes.h:26
auto Requires(T &Val) -> decltype(Val.Multiply(.5f), Val.Accumulate(Val, 1.f,(EAdditiveAnimationType) 0), Val.MakeAdditive(Val), Val.Interpolate(Val, 0.5f))
Definition AttributeTypes.h:38
auto Requires(T &Val) -> decltype(Val.Normalize())
Definition AttributeTypes.cpp:21
Definition AttributeTraits.h:30