Unreal Engine nonsensical code duplication shenanigans

@IrSoil already covered a lot of good reasons for having a platform-independent API.

Just for fun, I did a bit of archeology in our SCM history and this code dates back to at least UE3 days and 2011 (very likely even older).

There’s at least one example where having a platform independent API was useful, in 2015 we provided a custom atan2 implementation due to compiler bugs:

FMath::Atan2() no longer calls atan2f() because of some compiler or library bugs causing it to randomly return NaN for valid input. It now uses a high-precision minimax approximation instead, measured to be 2x faster than the stock C version.

In some cases like this one it’s useful to be able to replace a standard library implementation with something faster, e.g. if the standard library has stricter requirements on accuracy that forces them to use a slower algorithm.

2 Likes