godot icon indicating copy to clipboard operation
godot copied to clipboard

Core: Support floats in `ABS`, remove `Math::abs`

Open Repiteo opened this issue 1 year ago • 3 comments

Adjusted the generic ABS template function to support signed zeros, which consequently allows it to handle floating-point numbers. This puts it on even footing with SIGN, where a single constexpr function can be used exclusively thoughout the repo. As such, it removes the need for the various Math::abs implementations; everything can simply call ABS instead. All instances of Math::abs have been replaced with ABS, and the Math functions themselves were safely removed as they were never directly bound.

Repiteo avatar Apr 28 '24 17:04 Repiteo

So basically opposite of #69406 🙃

KoBeWi avatar Apr 28 '24 17:04 KoBeWi

IMO this is a step backwards, and goes against how we've handled these, IMO using the Math class is better generally and make things less chaotic by mixing things, also helps with stray macros from other packages

See also: https://github.com/godotengine/godot/pull/66890#discussion_r1029428575

AThousandShips avatar Apr 28 '24 17:04 AThousandShips

I made this under the assumption that the typedef functions were there for a reason; abs was the odd-one-out to that end, having multiple implementations instead.

What I liked about the typedef versions was that they're constexpr templates; the Math equivalents are largely steps back in that respect imo. If the Math class were to get these functions, I'd prefer they be in the form of constexpr templates as well; though, that might be more suited for a cleanup of the entire class at that stage.

Repiteo avatar Apr 28 '24 17:04 Repiteo

Superseded by #91324

Repiteo avatar Jun 22 '24 12:06 Repiteo