UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SimpleCurve.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"
6#include "Curves/RealCurve.h"
7#include "SimpleCurve.generated.h"
8
10USTRUCT()
12{
14
15
16 UPROPERTY(EditAnywhere, Category="Key")
18
20 UPROPERTY(EditAnywhere, Category="Key")
21 float Value;
22
24 : Time(0.f)
25 , Value(0.f)
26 { }
27
29 : Time(InTime)
30 , Value(InValue)
31 { }
32
35 ENGINE_API bool operator==(const FSimpleCurveKey& Other) const;
36 ENGINE_API bool operator!=(const FSimpleCurveKey& Other) const;
37
39 {
40 P.Serialize(Ar);
41 return Ar;
42 }
43};
44
45
46template<>
48{
49 enum { Value = true };
50};
51
52
53template<>
65
66
68USTRUCT()
71{
73
75 : FRealCurve()
76 , InterpMode(RCIM_Linear)
77 { }
78
79public:
80
82 ENGINE_API TArray<FSimpleCurveKey> GetCopyOfKeys() const;
83
85 ENGINE_API const TArray<FSimpleCurveKey>& GetConstRefOfKeys() const;
86
89
91 ENGINE_API FSimpleCurveKey& GetKey(FKeyHandle KeyHandle);
92 ENGINE_API FSimpleCurveKey GetKey(FKeyHandle KeyHandle) const;
93
95 ENGINE_API FSimpleCurveKey GetFirstKey() const;
96 ENGINE_API FSimpleCurveKey GetLastKey() const;
97
99 ENGINE_API FSimpleCurveKey* GetFirstMatchingKey(const TArray<FKeyHandle>& KeyHandles);
100
107 ENGINE_API FKeyHandle AddKey(float InTime, float InValue, const bool bUnwindRotation = false, FKeyHandle KeyHandle = FKeyHandle()) final override;
108
116 ENGINE_API void SetKeys(const TArray<FSimpleCurveKey>& InKeys);
117
124 ENGINE_API virtual void DeleteKey(FKeyHandle KeyHandle) final override;
125
127 ENGINE_API virtual FKeyHandle UpdateOrAddKey(float InTime, float InValue, const bool bUnwindRotation = false, float KeyTimeTolerance = UE_KINDA_SMALL_NUMBER) final override;
128
130 ENGINE_API virtual void SetKeyTime(FKeyHandle KeyHandle, float NewTime) final override;
131
133 ENGINE_API virtual float GetKeyTime(FKeyHandle KeyHandle) const final override;
134
136 ENGINE_API virtual void SetKeyValue(FKeyHandle KeyHandle, float NewValue, bool bAutoSetTangents = true) final override;
137
139 ENGINE_API virtual float GetKeyValue(FKeyHandle KeyHandle) const final override;
140
142 ENGINE_API virtual TPair<float, float> GetKeyTimeValuePair(FKeyHandle KeyHandle) const final override;
143
146
148 {
149 if (ensureMsgf(NewInterpMode != RCIM_Cubic, TEXT("SimpleCurves cannot use cubic interpolation")))
150 {
151 InterpMode = NewInterpMode;
152 }
153 }
154
156 virtual ERichCurveInterpMode GetKeyInterpMode(FKeyHandle KeyHandle) const final override { return GetKeyInterpMode(); }
157
159 ERichCurveInterpMode GetKeyInterpMode() const { return InterpMode; }
160
162 ENGINE_API virtual void GetTimeRange(float& MinTime, float& MaxTime) const final override;
163
165 ENGINE_API virtual void GetValueRange(float& MinValue, float& MaxValue) const final override;
166
168 ENGINE_API virtual void Reset() final override;
169
171 ENGINE_API virtual void RemapTimeValue(float& InTime, float& CycleValueOffset) const final override;
172
174 ENGINE_API virtual float Eval(float InTime, float InDefaultValue = 0.0f) const final override;
175
177 ENGINE_API virtual void ReadjustTimeRange(float NewMinTimeRange, float NewMaxTimeRange, bool bInsert/* whether insert or remove*/, float OldStartTime, float OldEndTime) final override;
178
180 ENGINE_API bool operator == (const FSimpleCurve& Curve) const;
181
183 ENGINE_API virtual void BakeCurve(float SampleRate) final override;
184 ENGINE_API virtual void BakeCurve(float SampleRate, float FirstKeyTime, float LastKeyTime) final override;
185
187 ENGINE_API virtual void RemoveRedundantKeys(float Tolerance, FFrameRate SampleRate = FFrameRate(0,0)) final override;
188 ENGINE_API virtual void RemoveRedundantKeys(float Tolerance, float FirstKeyTime, float LastKeyTime, FFrameRate SampleRate = FFrameRate(0,0)) final override;
189
191 virtual FIndexedCurve* Duplicate() const final { return new FSimpleCurve(*this); }
192
193protected:
194 ENGINE_API virtual int32 GetKeyIndex(float KeyTime, float KeyTimeTolerance) const override final;
195
196private:
197 ENGINE_API void RemoveRedundantKeysInternal(float Tolerance, int32 InStartKeepKey, int32 InEndKeepKey);
198
199 ENGINE_API float EvalForTwoKeys(const FSimpleCurveKey& Key1, const FSimpleCurveKey& Key2, const float InTime) const;
200
201public:
202
203 // FIndexedCurve interface
204
205 virtual int32 GetNumKeys() const final override { return Keys.Num(); }
206
207public:
208
210 UPROPERTY()
212
214 UPROPERTY(EditAnywhere, EditFixedSize, Category="Curve", meta=(EditFixedOrder))
216};
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#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
return true
Definition ExternalRpcRegistry.cpp:601
UE_FORCEINLINE_HINT bool operator!=(const FIndexedPointer &Other) const
Definition LockFreeList.h:76
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPropertyObjectReferenceType
Definition ObjectMacros.h:533
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
ERichCurveInterpMode
Definition RealCurve.h:13
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
Definition Archive.h:1208
Definition Array.h:670
Definition EnumAsByte.h:22
Definition Array.h:64
@ false
Definition radaudio_common.h:23
Definition FrameRate.h:21
Definition IndexedCurve.h:18
Definition KeyHandle.h:15
Definition RealCurve.h:125
Definition SimpleCurve.h:12
FSimpleCurveKey(float InTime, float InValue)
Definition SimpleCurve.h:28
friend FArchive & operator<<(FArchive &Ar, FSimpleCurveKey &P)
Definition SimpleCurve.h:38
Definition SimpleCurve.h:71
virtual ERichCurveInterpMode GetKeyInterpMode(FKeyHandle KeyHandle) const final override
Definition SimpleCurve.h:156
virtual int32 GetNumKeys() const final override
Definition SimpleCurve.h:205
void SetKeyInterpMode(ERichCurveInterpMode NewInterpMode)
Definition SimpleCurve.h:147
ERichCurveInterpMode GetKeyInterpMode() const
Definition SimpleCurve.h:159
virtual void SetKeyInterpMode(FKeyHandle, ERichCurveInterpMode NewInterpMode) final override
Definition SimpleCurve.h:145
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13
Definition StructOpsTypeTraits.h:11
@ WithIdenticalViaEquality
Definition StructOpsTypeTraits.h:18
@ WithCopy
Definition StructOpsTypeTraits.h:17
@ WithSerializer
Definition StructOpsTypeTraits.h:23
static constexpr EPropertyObjectReferenceType WithSerializerObjectReferences
Definition StructOpsTypeTraits.h:41
Definition StructOpsTypeTraits.h:46
Definition Tuple.h:652