Core: Convert Math
class to namespace
#94441
Open
+668
−675
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adopts the formatting seen in
godot-cpp
which opts forMath
as a namespace rather than a class. Given the class already shouldn't be instanced, nor did it really utilize any class-specific functionality, functioning as a namespace feels more apt. Beyond the conversion, the only adjustments were:core/math/random_pcg.h
include migrated tomath_funcs.cpp
; explicitly included in the handful of files utilizingRandomPCG
directly.default_rand
, the one private field in the entire class, migrated tomath_funcs.cpp
as a static variable.RANDOM_32BIT_MAX
replaced by existing, equivalent define:UINT32_MAX
.static
declaration removed from all functions.absd
,absf
,is_equal_approx
, andis_zero_approx
moved up—a consequence of needing to be declared before use in a namespace context.math_funcs.{h|cpp}
functions that weren't usingp_*
argument syntax now do.Math::
prefix removed in header where redundant.double
sorted beforefloat
equivalent where applicable.