5#include "HAL/Platform.h"
6#include "Internationalization/Text.h"
7#include "Math/NumericLimits.h"
9#include "Math/RangeBound.h"
10#include "Math/UnrealMathUtility.h"
11#include "Misc/ExpressionParserTypes.h"
12#include "Misc/FrameNumber.h"
13#include "Misc/FrameTime.h"
14#include "Templates/ValueOrError.h"
19
20
24
25
35
36
40
41
45
46
53
54
55
56
60
61
62
63
67
68
69
70
71
75
76
77
78
79
83
84
85
86
87
91
92
96
97
101
102
103
104
105
106
107
111
112
113
114
115
116
117
121
122
123
127
128
129
130
131
132
133
134
135
136 bool ComputeGridSpacing(
const float PixelsPerSecond,
double& OutMajorInterval, int32& OutMinorDivisions,
float MinTickPx = 30.f,
float DesiredMajorTickPx = 120.f)
const;
139
140
144
145
181 return TRange<
double>(
183 ? TRangeBound<
double>::Open()
184 : LowerBound.IsInclusive()
185 ? TRangeBound<
double>::Inclusive(Rate.AsSeconds(LowerBound.GetValue()))
186 : TRangeBound<
double>::Inclusive(Rate.AsSeconds(LowerBound.GetValue()+1)),
189 ? TRangeBound<
double>::Open()
190 : UpperBound.IsInclusive()
191 ? TRangeBound<
double>::Exclusive(Rate.AsSeconds(UpperBound.GetValue()+1))
192 : TRangeBound<
double>::Exclusive(Rate.AsSeconds(UpperBound.GetValue()))
231 return (
double(IntegerPart) + FloatPart) /
Numerator;
238 FFrameNumber FrameNumber =
static_cast<int32>(FMath::Clamp(FMath::FloorToDouble(TimeAsFrame),
static_cast<
double>(TNumericLimits<int32>::Min()),
static_cast<
double>(TNumericLimits<int32>::Max())));
240 float SubFrame =
static_cast<
float>(TimeAsFrame - FMath::FloorToDouble(TimeAsFrame));
241 const int32 TruncatedSubFrame = FMath::TruncToInt(SubFrame);
242 SubFrame -=
static_cast<
float>(TruncatedSubFrame);
243 FrameNumber
.Value += TruncatedSubFrame;
246 SubFrame = FMath::Min(SubFrame, FFrameTime::MaxSubframe);
256 return static_cast<int32>(FMath::Clamp(FMath::FloorToDouble(TimeAsFrame +
static_cast<
double>(FMath::TruncToInt(
static_cast<
float>(TimeAsFrame - FMath::FloorToDouble(TimeAsFrame))))),
static_cast<
double>(TNumericLimits<int32>::Min()),
static_cast<
double>(TNumericLimits<int32>::Max())));
261 if (SourceRate
== DestinationRate)
273 double NewNumerator_d =
double(NewNumerator);
274 double NewDenominator_d =
double(NewDenominator);
277 int64 IntegerPart = ( (int64)(SourceTime
.GetFrame().Value) * NewNumerator ) / NewDenominator;
278 const double IntegerFloatPart = ((
double(SourceTime
.GetFrame().Value) *
double(NewNumerator)) /
double(NewDenominator)) -
double(IntegerPart);
279 const double FloatPart = ((SourceTime
.GetSubFrame() * NewNumerator_d) / NewDenominator_d) + IntegerFloatPart;
280 const double FloatPartFloored = FMath::FloorToDouble(FloatPart);
281 const int64 FloatAsInt = int64(FloatPartFloored);
282 IntegerPart += FloatAsInt;
283 float SubFrame =
static_cast<
float>(FloatPart - FloatPartFloored);
286 SubFrame = FMath::Min(SubFrame, FFrameTime::MaxSubframe);
290 return FFrameTime(
static_cast<int32>(IntegerPart), SubFrame);
308 return CommonValueA <= CommonValueB && CommonValueB % CommonValueA == 0;
317
318
322
323
FFrameTime ConvertFrameTime(FFrameTime SourceTime, FFrameRate SourceRate, FFrameRate DestinationRate)
TValueOrError< FFrameRate, FExpressionError > ParseFrameRate(const TCHAR *FrameRateString)
bool TryParseString(FFrameRate &OutFrameRate, const TCHAR *InString)
friend FFrameTime operator*(float TimeInSeconds, FFrameRate Rate)
FFrameNumber AsFrameNumber(double InTimeSeconds) const
static FFrameTime Snap(FFrameTime SourceTime, FFrameRate SourceRate, FFrameRate SnapToRate)
friend double operator/(FFrameNumber Frame, FFrameRate Rate)
bool ComputeGridSpacing(const float PixelsPerSecond, double &OutMajorInterval, int32 &OutMinorDivisions, float MinTickPx=30.f, float DesiredMajorTickPx=120.f) const
static FFrameTime TransformTime(FFrameTime SourceTime, FFrameRate SourceRate, FFrameRate DestinationRate)
double AsSeconds(FFrameTime FrameNumber) const
friend FFrameRate operator/(FFrameRate A, FFrameRate B)
friend bool operator!=(const FFrameRate &A, const FFrameRate &B)
FText ToPrettyText() const
double MaxSeconds() const
friend bool operator==(const FFrameRate &A, const FFrameRate &B)
friend double operator/(FFrameTime FrameTime, FFrameRate Rate)
friend FFrameTime operator*(double TimeInSeconds, FFrameRate Rate)
double AsInterval() const
friend FFrameRate operator*(FFrameRate A, FFrameRate B)
friend TRange< double > operator/(const TRange< FFrameNumber > &FrameRange, FFrameRate Rate)
FFrameRate(uint32 InNumerator, uint32 InDenominator)
bool Serialize(FArchive &Ar)
bool IsMultipleOf(FFrameRate Other) const
FFrameTime AsFrameTime(double InTimeSeconds) const
bool IsFactorOf(FFrameRate Other) const
FFrameRate Reciprocal() const
FFrameTime(FFrameNumber InFrameNumber, float InSubFrame)
FFrameNumber RoundToFrame() const
FORCEINLINE FFrameNumber GetFrame() const
FORCEINLINE float GetSubFrame() const
FFrameTime(FFrameNumber InFrameNumber)
static constexpr NumericType Min()
static constexpr NumericType Max()