UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RealCurve.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"
7#include "Misc/FrameRate.h"
8#include "RealCurve.generated.h"
9
11UENUM(BlueprintType)
13{
15 RCIM_Linear UMETA(DisplayName = "Linear"),
17 RCIM_Constant UMETA(DisplayName = "Constant"),
19 RCIM_Cubic UMETA(DisplayName = "Cubic"),
22};
23
25UENUM(BlueprintType)
27{
29 RCCE_Cycle UMETA(DisplayName = "Cycle"),
31 RCCE_CycleWithOffset UMETA(DisplayName = "CycleWithOffset"),
33 RCCE_Oscillate UMETA(DisplayName = "Oscillate"),
35 RCCE_Linear UMETA(DisplayName = "Linear"),
37 RCCE_Constant UMETA(DisplayName = "Constant"),
39 RCCE_None UMETA(DisplayName = "None")
40};
41
42
47{
49 {
50 bHasPreExtrapolation = 0;
51 bHasPostExtrapolation = 0;
52 PreExtrapolation = ERichCurveExtrapolation::RCCE_None;
53 PostExtrapolation = ERichCurveExtrapolation::RCCE_None;
54 }
55
59 bool HasPreExtrapolation() const { return bHasPreExtrapolation; }
60 bool HasPostExtrapolation() const { return bHasPostExtrapolation; }
61
65 ERichCurveExtrapolation GetPreExtrapolation() const { check(bHasPreExtrapolation); return PreExtrapolation; }
66 ERichCurveExtrapolation GetPostExtrapolation() const { check(bHasPostExtrapolation); return PostExtrapolation; }
67
71 FCurveAttributes& SetPreExtrapolation(ERichCurveExtrapolation InPreExtrapolation) { bHasPreExtrapolation = 1; PreExtrapolation = InPreExtrapolation; return *this; }
72 FCurveAttributes& SetPostExtrapolation(ERichCurveExtrapolation InPostExtrapolation) { bHasPostExtrapolation = 1; PostExtrapolation = InPostExtrapolation; return *this; }
76 void UnsetPreExtrapolation() { bHasPreExtrapolation = 0; }
77 void UnsetPostExtrapolation() { bHasPostExtrapolation = 0; }
78
83 {
85
86 if (A.bHasPreExtrapolation && B.bHasPreExtrapolation && A.PreExtrapolation == B.PreExtrapolation)
87 {
88 NewAttributes.SetPreExtrapolation(A.PreExtrapolation);
89 }
90
91 if (A.bHasPostExtrapolation && B.bHasPostExtrapolation && A.PostExtrapolation == B.PostExtrapolation)
92 {
93 NewAttributes.SetPostExtrapolation(A.PostExtrapolation);
94 }
95
96 return NewAttributes;
97 }
98
100 {
101 return Left.bHasPreExtrapolation == Right.bHasPreExtrapolation
102 && Left.bHasPostExtrapolation == Right.bHasPostExtrapolation
103 && (!Left.bHasPreExtrapolation || Left.PreExtrapolation == Right.PreExtrapolation)
104 && (!Left.bHasPostExtrapolation || Left.PostExtrapolation == Right.PostExtrapolation);
105 }
106 friend bool operator!=(const FCurveAttributes& Left, const FCurveAttributes& Right) { return !(Left == Right); }
107
108private:
109
111 uint8 bHasPreExtrapolation : 1;
113 uint8 bHasPostExtrapolation : 1;
114
116 ERichCurveExtrapolation PreExtrapolation;
118 ERichCurveExtrapolation PostExtrapolation;
119};
120
122USTRUCT()
125{
127
129 : FIndexedCurve()
130 , DefaultValue(MAX_flt)
131 , PreInfinityExtrap(RCCE_Constant)
132 , PostInfinityExtrap(RCCE_Constant)
133 { }
134
135public:
136
140 bool HasAnyData() const
141 {
142 return DefaultValue != MAX_flt || GetNumKeys();
143 }
144
151 virtual FKeyHandle AddKey(float InTime, float InValue, const bool bUnwindRotation = false, FKeyHandle KeyHandle = FKeyHandle()) PURE_VIRTUAL(FRealCurve::AddKey, return FKeyHandle::Invalid(););
152
159 virtual void DeleteKey(FKeyHandle KeyHandle) PURE_VIRTUAL(FRealCurve::DeleteKey,);
160
162 virtual FKeyHandle UpdateOrAddKey(float InTime, float InValue, const bool bUnwindRotation = false, float KeyTimeTolerance = UE_KINDA_SMALL_NUMBER) PURE_VIRTUAL(FRealCurve::UpdateOrAddKey, return FKeyHandle::Invalid(););
163
166
168 ENGINE_API bool KeyExistsAtTime(float KeyTime, float KeyTimeTolerance = UE_KINDA_SMALL_NUMBER) const;
169
171 virtual void SetKeyValue(FKeyHandle KeyHandle, float NewValue, bool bAutoSetTangents = true) PURE_VIRTUAL(FRealCurve::SetKeyValue,);
172
174 virtual float GetKeyValue(FKeyHandle KeyHandle) const PURE_VIRTUAL(FRealCurve::GetKeyValue, return 0.f;);
175
177 virtual TPair<float, float> GetKeyTimeValuePair(FKeyHandle KeyHandle) const PURE_VIRTUAL(FRealCurve::GetKeyTimeValuePair, return (TPair<float,float>(0.f,0.f)););
178
179 virtual void SetKeyInterpMode(FKeyHandle KeyHandle, ERichCurveInterpMode NewInterpMode) PURE_VIRTUAL(FRealCurve::SetKeyInterpMode,);
180
182 void SetDefaultValue(float InDefaultValue) { DefaultValue = InDefaultValue; }
183
185 float GetDefaultValue() const { return DefaultValue; }
186
188 void ClearDefaultValue() { DefaultValue = MAX_flt; }
189
190 virtual ERichCurveInterpMode GetKeyInterpMode(FKeyHandle KeyHandle) const PURE_VIRTUAL(FRealCurve::GetTimeRange, return RCIM_None; );
191
193 virtual void GetTimeRange(float& MinTime, float& MaxTime) const PURE_VIRTUAL(FRealCurve::GetTimeRange, );
194
196 virtual void GetValueRange(float& MinValue, float& MaxValue) const PURE_VIRTUAL(FRealCurve::GetValueRange, );
197
199 virtual void Reset() PURE_VIRTUAL(FRealCurve::Reset, );
200
202 virtual void RemapTimeValue(float& InTime, float& CycleValueOffset) const PURE_VIRTUAL(FRealCurve::RemapTimeValue, );
203
205 virtual float Eval(float InTime, float InDefaultValue = 0.0f) const PURE_VIRTUAL(FRealCurve::Eval, return 0.f;);
206
208 virtual void ReadjustTimeRange(float NewMinTimeRange, float NewMaxTimeRange, bool bInsert/* whether insert or remove*/, float OldStartTime, float OldEndTime) PURE_VIRTUAL(FRealCurve::ReadjustTimeRange, );
209
211 virtual void BakeCurve(float SampleRate) PURE_VIRTUAL(FRealCurve::BakeCurve, );
212 virtual void BakeCurve(float SampleRate, float FirstKeyTime, float LastKeyTime) PURE_VIRTUAL(FRealCurve::BakeCurve, );
213
215 virtual void RemoveRedundantKeys(float Tolerance, FFrameRate SampleRate = FFrameRate(0,0)) PURE_VIRTUAL(FRealCurve::RemoveRedundantKeys, );
216 virtual void RemoveRedundantKeys(float Tolerance, float FirstKeyTime, float LastKeyTime, FFrameRate SampleRate = FFrameRate(0,0)) PURE_VIRTUAL(FRealCurve::RemoveRedundantKeys, );
217
219 static ENGINE_API void CycleTime(float MinTime, float MaxTime, float& InTime, int& CycleCount);
220 virtual int32 GetKeyIndex(float KeyTime, float KeyTimeTolerance) const PURE_VIRTUAL(FRealCurve::GetKeyIndex, return INDEX_NONE;);
221
222public:
223
225 UPROPERTY(EditAnywhere, Category = "Curve")
226 float DefaultValue;
227
229 UPROPERTY()
231
233 UPROPERTY()
235};
236
237template<>
239{
240 enum
241 {
242 WithPureVirtual = true,
243 };
244};
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
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
return true
Definition ExternalRpcRegistry.cpp:601
#define MAX_flt
Definition NumericLimits.h:29
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
ERichCurveExtrapolation
Definition RealCurve.h:27
@ UMETA
Definition RealCurve.h:15
ERichCurveInterpMode
Definition RealCurve.h:13
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition EnumAsByte.h:22
@ false
Definition radaudio_common.h:23
Definition RealCurve.h:47
ERichCurveExtrapolation GetPreExtrapolation() const
Definition RealCurve.h:65
FCurveAttributes & SetPreExtrapolation(ERichCurveExtrapolation InPreExtrapolation)
Definition RealCurve.h:71
friend bool operator==(const FCurveAttributes &Left, const FCurveAttributes &Right)
Definition RealCurve.h:99
void UnsetPostExtrapolation()
Definition RealCurve.h:77
FCurveAttributes & SetPostExtrapolation(ERichCurveExtrapolation InPostExtrapolation)
Definition RealCurve.h:72
friend bool operator!=(const FCurveAttributes &Left, const FCurveAttributes &Right)
Definition RealCurve.h:106
static FCurveAttributes MaskCommon(const FCurveAttributes &A, const FCurveAttributes &B)
Definition RealCurve.h:82
FCurveAttributes()
Definition RealCurve.h:48
bool HasPreExtrapolation() const
Definition RealCurve.h:59
void UnsetPreExtrapolation()
Definition RealCurve.h:76
bool HasPostExtrapolation() const
Definition RealCurve.h:60
ERichCurveExtrapolation GetPostExtrapolation() const
Definition RealCurve.h:66
Definition FrameRate.h:21
Definition IndexedCurve.h:18
Definition KeyHandle.h:15
Definition RealCurve.h:125
void ClearDefaultValue()
Definition RealCurve.h:188
float GetDefaultValue() const
Definition RealCurve.h:185
bool HasAnyData() const
Definition RealCurve.h:140
virtual ERichCurveInterpMode GetKeyInterpMode(FKeyHandle KeyHandle) const PURE_VIRTUAL(FRealCurve
Definition RealCurve.h:190
virtual FKeyHandle AddKey(float InTime, float InValue, const bool bUnwindRotation=false, FKeyHandle KeyHandle=FKeyHandle()) PURE_VIRTUAL(FRealCurve
Definition RealCurve.h:151
Definition StructOpsTypeTraits.h:11
Definition StructOpsTypeTraits.h:46
Definition Tuple.h:652