Implemented with const FRotator instead of const T

I have implemented Lerp with const FRotator because I wasn’t sure what const T is when consulting doc on Lerp.

CurrentRotation = FMath::Lerp(CurrentRotation, EndRotation, 0.1);

This works but isn’t compatible with the functions Sam later talked about , FInterpConstantTo(), and FInterpTo(), because there are no overloads for FRotator.
I guess it is best to use floats.?

It’s because Lerp is defined as a template e.g.

template<typename T, typename U>
T Lerp(const T& A, const T& B, const U& T);

Then if you were to call it like so

FMath::Lerp(CurrentRotation, EndRotation, 0.1);

Then the compiler will deduce the types of T to be float and U to be double and will generate the function

float Lerp(const float& A, const float& B, const double& T);

That’s because F is for floating point. There’s RInterpTo and RInterpConstantTo for rotations.

1 Like

Oic. Very interesting. Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms