Note: This is possibly related to [Link Removed].
For some inputs, function UE::Curves::WeightedEvalForTwoKeys() inside file "CurveEvaluation.cpp" can incorrectly return the value of the first key, when the expected result was something very close to the second key. This has been noticed, for example, when calling UCurveFloat::GetFloatValue(), which can result in popping artifacts as the input value is slowly interpolated from one key to the next.
A UDN user pointed out that adding "UE_DISABLE_OPTIMIZATION" at the top of file "CurveEvaluation.cpp" fixes the behavior. An alternative fix is to add "#pragma float_control(precise,on,push)" and "#pragma float_control(pop)" to either side of the WeightedEvalForTwoKeys() function.
A preliminary investigation revealed a problem in the following snippet from UE::Curves::WeightedEvalForTwoKeys() in "CurveEvaluation.cpp":
[:158] const int32 NumResults = SolveCubic(Coeff, Results);
[:165]
In the code above, when the sampled time is very close to the second key of an interval, function SolveCubic() is expected to return at least one result very close to 1 in the interval [0,1]. However, for some inputs and because of floating-point precision issues, that calculated output can be slightly above 1 instead. As a consequence, the test in line 169 fails and we end up executing line 180, which brings the final interpolation result to the first key instead of the second.
1. Download, unzip and open the attached repro project.
2. From the Content Browser:
2.1. Open asset "MyFloatCurve" and keep it open for future reference.
2.2. Run the Editor Utility Widget "EUW_CurveInspector"
3. On the editor utility widget tab:
3.1. Select asset "MyFloatCurve"
3.2. Spin around the input values to see the behavior output matching the curve.
3.3. Type in -0.00004 for the input. The output is close to zero, as expected.
3.4. Type in -0.00003 for the input. The output is 200, close to the first curve key, which is completely wrong.
3.5. Type in 0.00000 for the input. The output is zero, as expected.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-229247 in the post.
0 |
Component | UE - Anim - Runtime |
---|---|
Affects Versions | 5.4.4 |
Created | Oct 31, 2024 |
---|---|
Updated | Nov 6, 2024 |