UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LinearEase.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6
7
9{
10public:
12 : StartValue(0.0f)
13 , CurrentValue(0.0f)
14 , DeltaValue(0.0f)
15 , SampleRate(44100.0f)
16 , DurationTicks(0)
17 , DefaultDurationTicks(0)
18 , CurrentTick(0)
19 { }
20
22
23 bool IsDone() const
24 {
25 return CurrentTick >= DurationTicks;
26 }
27
28 void Init(float InSampleRate)
29 {
30 SampleRate = InSampleRate;
31 }
32
33 void SetValueRange(const float Start, const float End, const float InTimeSec)
34 {
35 StartValue = Start;
36 CurrentValue = Start;
38 }
39
40 float GetValue()
41 {
42 if (IsDone())
43 {
44 return CurrentValue;
45 }
46
47 CurrentValue = DeltaValue * (float)CurrentTick / DurationTicks + StartValue;
48
49 ++CurrentTick;
50 return CurrentValue;
51 }
52
53 // Updates the target value without changing the duration or tick data.
54 // Sets the state as if the new value was the target value all along
55 void SetValueInterrupt(const float InValue)
56 {
57 if (IsDone())
58 {
59 CurrentValue = InValue;
60 }
61 else
62 {
63 DurationTicks = DurationTicks - CurrentTick;
64 CurrentTick = 0;
65 DeltaValue = InValue - CurrentValue;
66 StartValue = CurrentValue;
67 }
68 }
69
70 void SetValue(const float InValue, float InTimeSec = 0.0f)
71 {
72 DurationTicks = (int32)(SampleRate * InTimeSec);
73 CurrentTick = 0;
74
75 if (DurationTicks == 0)
76 {
77 CurrentValue = InValue;
78 }
79 else
80 {
81 DeltaValue = InValue - CurrentValue;
82 StartValue = CurrentValue;
83 }
84 }
85
86private:
87
88 float StartValue;
89 float CurrentValue;
90 float DeltaValue;
91 float SampleRate;
92 int32 DurationTicks;
93 int32 DefaultDurationTicks;
94 int32 CurrentTick;
95};
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
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition LinearEase.h:9
void Init(float InSampleRate)
Definition LinearEase.h:28
void SetValueRange(const float Start, const float End, const float InTimeSec)
Definition LinearEase.h:33
float GetValue()
Definition LinearEase.h:40
~FLinearEase()
Definition LinearEase.h:21
bool IsDone() const
Definition LinearEase.h:23
FLinearEase()
Definition LinearEase.h:11
void SetValue(const float InValue, float InTimeSec=0.0f)
Definition LinearEase.h:70
void SetValueInterrupt(const float InValue)
Definition LinearEase.h:55