UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterpCurvePoint.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#include "HAL/UnrealMemory.h"
8#include "Math/Color.h"
9#include "Math/Vector2D.h"
11#include "Math/Vector.h"
12#include "Math/Quat.h"
13#include "Math/TwoVectors.h"
14
40
41
50template< class T > class FInterpCurvePoint
51{
52public:
53
55 float InVal;
56
59
62
65
68
69public:
70
75
83 [[nodiscard]] FInterpCurvePoint( const float In, const T &Out );
84
94 [[nodiscard]] FInterpCurvePoint( const float In, const T &Out, const T &InArriveTangent, const T &InLeaveTangent, const EInterpCurveMode InInterpMode );
95
102
103public:
104
107
108public:
109
119 {
120 Ar << Point.InVal << Point.OutVal;
121 Ar << Point.ArriveTangent << Point.LeaveTangent;
122 Ar << Point.InterpMode;
123 return Ar;
124 }
125
129 [[nodiscard]] friend bool operator==( const FInterpCurvePoint& Point1, const FInterpCurvePoint& Point2 )
130 {
131 return (Point1.InVal == Point2.InVal &&
132 Point1.OutVal == Point2.OutVal &&
133 Point1.ArriveTangent == Point2.ArriveTangent &&
134 Point1.LeaveTangent == Point2.LeaveTangent &&
135 Point1.InterpMode == Point2.InterpMode);
136 }
137
141 [[nodiscard]] friend bool operator!=(const FInterpCurvePoint& Point1, const FInterpCurvePoint& Point2)
142 {
143 return !(Point1 == Point2);
144 }
145};
146
147
148/* FInterpCurvePoint inline functions
149 *****************************************************************************/
150
151template< class T >
152inline FInterpCurvePoint<T>::FInterpCurvePoint( const float In, const T &Out )
153 : InVal(In)
154 , OutVal(Out)
155{
156 FMemory::Memset( &ArriveTangent, 0, sizeof(T) );
157 FMemory::Memset( &LeaveTangent, 0, sizeof(T) );
158
160}
161
162
163template< class T >
164inline FInterpCurvePoint<T>::FInterpCurvePoint( const float In, const T &Out, const T &InArriveTangent, const T &InLeaveTangent, const EInterpCurveMode InInterpMode)
165 : InVal(In)
166 , OutVal(Out)
167 , ArriveTangent(InArriveTangent)
168 , LeaveTangent(InLeaveTangent)
169 , InterpMode(InInterpMode)
170{ }
171
172template< class T >
174{
175 InVal = 0.0f;
176 FMemory::Memset(&OutVal, 0, sizeof(T));
177 FMemory::Memset(&ArriveTangent, 0, sizeof(T));
178 FMemory::Memset(&LeaveTangent, 0, sizeof(T));
179 InterpMode = CIM_Linear;
180}
181
182template< class T >
184{
185 return ((InterpMode == CIM_CurveAuto) || (InterpMode == CIM_CurveAutoClamped) || (InterpMode == CIM_CurveUser) || (InterpMode == CIM_CurveBreak));
186}
187
191CORE_API float ClampFloatTangent( float PrevPointVal, float PrevTime, float CurPointVal, float CurTime, float NextPointVal, float NextTime );
192
193
195template< class T, class U >
196inline void AutoCalcTangent( const T& PrevP, const T& P, const T& NextP, const U& Tension, T& OutTan )
197{
198 OutTan = (1.f - Tension) * ( (P - PrevP) + (NextP - P) );
199}
200
201
205template< class U >
206inline void AutoCalcTangent( const FQuat& PrevP, const FQuat& P, const FQuat& NextP, const U& Tension, FQuat& OutTan )
207{
208 FQuat::CalcTangents(PrevP, P, NextP, Tension, OutTan);
209}
210
211
213template< class T >
214inline void ComputeCurveTangent( float PrevTime, const T& PrevPoint,
215 float CurTime, const T& CurPoint,
216 float NextTime, const T& NextPoint,
217 float Tension,
218 bool bWantClamping,
219 T& OutTangent )
220{
221 // NOTE: Clamping not supported for non-float vector types (bWantClamping is ignored)
222
224
225 const float PrevToNextTimeDiff = FMath::Max< float >( UE_KINDA_SMALL_NUMBER, NextTime - PrevTime );
226
228}
229
230
235template< class T >
237 float CurTime, const T& CurPoint,
238 float NextTime, const T& NextPoint,
239 float Tension,
240 bool bWantClamping,
241 T& OutTangent )
242{
243 // Clamp the tangents if we need to do that
244 if( bWantClamping )
245 {
246 // NOTE: We always treat the type as an array of floats
247 float* PrevPointVal = ( float* )&PrevPoint;
248 float* CurPointVal = ( float* )&CurPoint;
249 float* NextPointVal = ( float* )&NextPoint;
250 float* OutTangentVal = ( float* )&OutTangent;
251 for( int32 CurValPos = 0; CurValPos < sizeof( T ); CurValPos += sizeof( float ) )
252 {
253 // Clamp it!
254 const float ClampedTangent =
259
260 // Apply tension value
261 *OutTangentVal = ( 1.0f - Tension ) * ClampedTangent;
262
263
264 // Advance pointers
266 ++PrevPointVal;
267 ++CurPointVal;
268 ++NextPointVal;
269 }
270 }
271 else
272 {
273 // No clamping needed
275
276 const float PrevToNextTimeDiff = FMath::Max< float >( UE_KINDA_SMALL_NUMBER, NextTime - PrevTime );
277
279 }
280}
281
282
284inline void ComputeCurveTangent( float PrevTime, const float& PrevPoint,
285 float CurTime, const float& CurPoint,
286 float NextTime, const float& NextPoint,
287 float Tension,
288 bool bWantClamping,
289 float& OutTangent )
290{
295 Tension, bWantClamping, OutTangent );
296}
297
298
301 float CurTime, const FVector& CurPoint,
302 float NextTime, const FVector& NextPoint,
303 float Tension,
304 bool bWantClamping,
306{
311 Tension, bWantClamping, OutTangent );
312}
313
314
317 float CurTime, const FVector2D& CurPoint,
318 float NextTime, const FVector2D& NextPoint,
319 float Tension,
320 bool bWantClamping,
322{
327 Tension, bWantClamping, OutTangent );
328}
329
330
333 float CurTime, const FTwoVectors& CurPoint,
334 float NextTime, const FTwoVectors& NextPoint,
335 float Tension,
336 bool bWantClamping,
338{
343 Tension, bWantClamping, OutTangent );
344}
345
354void CORE_API CurveFloatFindIntervalBounds( const FInterpCurvePoint<float>& Start, const FInterpCurvePoint<float>& End, float& CurrentMin, float& CurrentMax );
355
356
366
367
377
378
388
389
399
400
401template< class T, class U >
402inline void CurveFindIntervalBounds( const FInterpCurvePoint<T>& Start, const FInterpCurvePoint<T>& End, T& CurrentMin, T& CurrentMax, const U& Dummy )
403{ }
404
405
406template< class U >
407inline void CurveFindIntervalBounds( const FInterpCurvePoint<float>& Start, const FInterpCurvePoint<float>& End, float& CurrentMin, float& CurrentMax, const U& Dummy )
408{
409 CurveFloatFindIntervalBounds(Start, End, CurrentMin, CurrentMax);
410}
411
412
413template< class U >
415{
416 CurveVector2DFindIntervalBounds(Start, End, CurrentMin, CurrentMax);
417}
418
419
420template< class U >
421inline void CurveFindIntervalBounds( const FInterpCurvePoint<FVector>& Start, const FInterpCurvePoint<FVector>& End, FVector& CurrentMin, FVector& CurrentMax, const U& Dummy )
422{
423 CurveVectorFindIntervalBounds(Start, End, CurrentMin, CurrentMax);
424}
425
426
427template< class U >
428inline void CurveFindIntervalBounds( const FInterpCurvePoint<FTwoVectors>& Start, const FInterpCurvePoint<FTwoVectors>& End, FTwoVectors& CurrentMin, FTwoVectors& CurrentMax, const U& Dummy )
429{
430 CurveTwoVectorsFindIntervalBounds(Start, End, CurrentMin, CurrentMax);
431}
432
433
434template< class U >
436{
437 CurveLinearColorFindIntervalBounds(Start, End, CurrentMin, CurrentMax);
438}
439
440// Native implementation of NOEXPORT FInterpCurvePoint structures
EForceInit
Definition CoreMiscDefines.h:154
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void ComputeClampableFloatVectorCurveTangent(float PrevTime, const T &PrevPoint, float CurTime, const T &CurPoint, float NextTime, const T &NextPoint, float Tension, bool bWantClamping, T &OutTangent)
Definition InterpCurvePoint.h:236
void CORE_API CurveLinearColorFindIntervalBounds(const FInterpCurvePoint< FLinearColor > &Start, const FInterpCurvePoint< FLinearColor > &End, FLinearColor &CurrentMin, FLinearColor &CurrentMax)
Definition UnrealMath.cpp:1656
void ComputeCurveTangent(float PrevTime, const T &PrevPoint, float CurTime, const T &CurPoint, float NextTime, const T &NextPoint, float Tension, bool bWantClamping, T &OutTangent)
Definition InterpCurvePoint.h:214
void CORE_API CurveFloatFindIntervalBounds(const FInterpCurvePoint< float > &Start, const FInterpCurvePoint< float > &End, float &CurrentMin, float &CurrentMax)
Definition UnrealMath.cpp:1577
FInterpCurvePoint< float > FInterpCurvePointFloat
Definition InterpCurvePoint.h:441
EInterpCurveMode
Definition InterpCurvePoint.h:16
@ CIM_CurveAutoClamped
Definition InterpCurvePoint.h:35
@ CIM_Linear
Definition InterpCurvePoint.h:18
@ CIM_CurveUser
Definition InterpCurvePoint.h:28
@ CIM_Constant
Definition InterpCurvePoint.h:25
@ CIM_CurveAuto
Definition InterpCurvePoint.h:22
@ CIM_CurveBreak
Definition InterpCurvePoint.h:31
@ CIM_Unknown
Definition InterpCurvePoint.h:38
void AutoCalcTangent(const T &PrevP, const T &P, const T &NextP, const U &Tension, T &OutTan)
Definition InterpCurvePoint.h:196
FInterpCurvePoint< FVector2D > FInterpCurvePointVector2D
Definition InterpCurvePoint.h:442
FInterpCurvePoint< FTwoVectors > FInterpCurvePointTwoVectors
Definition InterpCurvePoint.h:445
FInterpCurvePoint< FQuat > FInterpCurvePointQuat
Definition InterpCurvePoint.h:444
CORE_API float ClampFloatTangent(float PrevPointVal, float PrevTime, float CurPointVal, float CurTime, float NextPointVal, float NextTime)
Definition UnrealMath.cpp:2774
void CORE_API CurveVectorFindIntervalBounds(const FInterpCurvePoint< FVector > &Start, const FInterpCurvePoint< FVector > &End, FVector &CurrentMin, FVector &CurrentMax)
Definition UnrealMath.cpp:1604
void CurveFindIntervalBounds(const FInterpCurvePoint< T > &Start, const FInterpCurvePoint< T > &End, T &CurrentMin, T &CurrentMax, const U &Dummy)
Definition InterpCurvePoint.h:402
FInterpCurvePoint< FLinearColor > FInterpCurvePointLinearColor
Definition InterpCurvePoint.h:446
FInterpCurvePoint< FVector > FInterpCurvePointVector
Definition InterpCurvePoint.h:443
void CORE_API CurveVector2DFindIntervalBounds(const FInterpCurvePoint< FVector2D > &Start, const FInterpCurvePoint< FVector2D > &End, FVector2D &CurrentMin, FVector2D &CurrentMax)
Definition UnrealMath.cpp:1589
void CORE_API CurveTwoVectorsFindIntervalBounds(const FInterpCurvePoint< FTwoVectors > &Start, const FInterpCurvePoint< FTwoVectors > &End, FTwoVectors &CurrentMin, FTwoVectors &CurrentMax)
Definition UnrealMath.cpp:1623
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
Definition Archive.h:1208
Definition InterpCurvePoint.h:51
FInterpCurvePoint()=default
T OutVal
Definition InterpCurvePoint.h:58
friend bool operator==(const FInterpCurvePoint &Point1, const FInterpCurvePoint &Point2)
Definition InterpCurvePoint.h:129
float InVal
Definition InterpCurvePoint.h:55
friend FArchive & operator<<(FArchive &Ar, FInterpCurvePoint &Point)
Definition InterpCurvePoint.h:118
TEnumAsByte< EInterpCurveMode > InterpMode
Definition InterpCurvePoint.h:67
T LeaveTangent
Definition InterpCurvePoint.h:64
UE_FORCEINLINE_HINT bool IsCurveKey() const
Definition InterpCurvePoint.h:183
T ArriveTangent
Definition InterpCurvePoint.h:61
friend bool operator!=(const FInterpCurvePoint &Point1, const FInterpCurvePoint &Point2)
Definition InterpCurvePoint.h:141
Definition EnumAsByte.h:22
Definition Color.h:48
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition TwoVectors.h:15
static CORE_API void CalcTangents(const TQuat< double > &PrevP, const TQuat< double > &P, const TQuat< double > &NextP, double Tension, TQuat< double > &OutTan)
Definition UnrealMath.cpp:1302