[Bf-blender-cvs] [e9beb6827ac] bli-math-basic-types: Rename to `is_math_float_type`

Hans Goudey noreply at git.blender.org
Wed Feb 16 16:34:08 CET 2022


Commit: e9beb6827ac9e43f6881a9be5e6672f367a34a64
Author: Hans Goudey
Date:   Tue Feb 15 12:20:10 2022 -0600
Branches: bli-math-basic-types
https://developer.blender.org/rBe9beb6827ac9e43f6881a9be5e6672f367a34a64

Rename to `is_math_float_type`

===================================================================

M	source/blender/blenlib/BLI_math_base.hh
M	source/blender/blenlib/BLI_math_vec_types.hh
M	source/blender/blenlib/BLI_math_vector.hh

===================================================================

diff --git a/source/blender/blenlib/BLI_math_base.hh b/source/blender/blenlib/BLI_math_base.hh
index 02a13d6472a..ab8b5d99393 100644
--- a/source/blender/blenlib/BLI_math_base.hh
+++ b/source/blender/blenlib/BLI_math_base.hh
@@ -51,12 +51,13 @@ template<typename T> inline T clamp(const T &a, const T &min, const T &max)
   return std::clamp(a, min, max);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T mod(const T &a, const T &b)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> inline T mod(const T &a, const T &b)
 {
   return std::fmod(a, b);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T safe_mod(const T &a, const T &b)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
+inline T safe_mod(const T &a, const T &b)
 {
   return (b != 0) ? std::fmod(a, b) : 0;
 }
@@ -67,37 +68,38 @@ template<typename T> inline void min_max(const T &value, T &min, T &max)
   max = math::max(value, max);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T safe_divide(const T &a, const T &b)
 {
   return (b != 0) ? a / b : T(0.0f);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T floor(const T &a)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> inline T floor(const T &a)
 {
   return std::floor(a);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T ceil(const T &a)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> inline T ceil(const T &a)
 {
   return std::ceil(a);
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T fract(const T &a)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))> inline T fract(const T &a)
 {
   return a - std::floor(a);
 }
 
 template<typename T,
          typename FactorT,
-         BLI_ENABLE_IF((math_is_float<T>)),
-         BLI_ENABLE_IF((math_is_float<T>))>
+         BLI_ENABLE_IF((is_math_float_type<T>)),
+         BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T interpolate(const T &a, const T &b, const FactorT &t)
 {
   return a * (1 - t) + b * t;
 }
 
-template<typename T, BLI_ENABLE_IF((math_is_float<T>))> inline T midpoint(const T &a, const T &b)
+template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
+inline T midpoint(const T &a, const T &b)
 {
   return (a + b) * T(0.5);
 }
diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh
index a11e3907fcb..eac43506874 100644
--- a/source/blender/blenlib/BLI_math_vec_types.hh
+++ b/source/blender/blenlib/BLI_math_vec_types.hh
@@ -584,12 +584,12 @@ using double3 = vec_base<double, 3>;
 using double4 = vec_base<double, 4>;
 
 template<typename T>
-inline constexpr bool math_is_float = (std::is_floating_point_v<T>
+inline constexpr bool is_math_float_type = (std::is_floating_point_v<T>
 #ifdef WITH_GMP
-                                       || std::is_same_v<T, mpq_class>
+                                            || std::is_same_v<T, mpq_class>
 #endif
 );
 
-template<typename T> inline constexpr bool math_is_integral = std::is_integral_v<T>;
+template<typename T> inline constexpr bool is_math_integral_type = std::is_integral_v<T>;
 
 }  // namespace blender
diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh
index a34888f8ad0..3bb89bb26b2 100644
--- a/source/blender/blenlib/BLI_math_vector.hh
+++ b/source/blender/blenlib/BLI_math_vector.hh
@@ -90,7 +90,7 @@ inline vec_base<T, Size> clamp(const vec_base<T, Size> &a, const T &min, const T
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> mod(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   vec_base<T, Size> result;
@@ -101,7 +101,7 @@ inline vec_base<T, Size> mod(const vec_base<T, Size> &a, const vec_base<T, Size>
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> mod(const vec_base<T, Size> &a, const T &b)
 {
   BLI_assert(b != 0);
@@ -112,7 +112,7 @@ inline vec_base<T, Size> mod(const vec_base<T, Size> &a, const T &b)
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T safe_mod(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   vec_base<T, Size> result;
@@ -122,7 +122,7 @@ inline T safe_mod(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T safe_mod(const vec_base<T, Size> &a, const T &b)
 {
   if (b == 0) {
@@ -144,7 +144,7 @@ inline void min_max(const vec_base<T, Size> &vector,
   max = math::max(vector, max);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> safe_divide(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   vec_base<T, Size> result;
@@ -154,13 +154,13 @@ inline vec_base<T, Size> safe_divide(const vec_base<T, Size> &a, const vec_base<
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> safe_divide(const vec_base<T, Size> &a, const T &b)
 {
   return (b != 0) ? a / b : vec_base<T, Size>(0.0f);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> floor(const vec_base<T, Size> &a)
 {
   vec_base<T, Size> result;
@@ -170,7 +170,7 @@ inline vec_base<T, Size> floor(const vec_base<T, Size> &a)
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> ceil(const vec_base<T, Size> &a)
 {
   vec_base<T, Size> result;
@@ -180,7 +180,7 @@ inline vec_base<T, Size> ceil(const vec_base<T, Size> &a)
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> fract(const vec_base<T, Size> &a)
 {
   vec_base<T, Size> result;
@@ -190,7 +190,7 @@ inline vec_base<T, Size> fract(const vec_base<T, Size> &a)
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T dot(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   T result = a[0] * b[0];
@@ -209,37 +209,37 @@ template<typename T, int Size> inline T length_manhattan(const vec_base<T, Size>
   return result;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T length_squared(const vec_base<T, Size> &a)
 {
   return dot(a, a);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T length(const vec_base<T, Size> &a)
 {
   return std::sqrt(length_squared(a));
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T distance_manhattan(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   return length_manhattan(a - b);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T distance_squared(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   return length_squared(a - b);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline T distance(const vec_base<T, Size> &a, const vec_base<T, Size> &b)
 {
   return length(a - b);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> reflect(const vec_base<T, Size> &incident,
                                  const vec_base<T, Size> &normal)
 {
@@ -247,7 +247,7 @@ inline vec_base<T, Size> reflect(const vec_base<T, Size> &incident,
   return incident - 2.0 * dot(normal, incident) * normal;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> refract(const vec_base<T, Size> &incident,
                                  const vec_base<T, Size> &normal,
                                  const T &eta)
@@ -260,7 +260,7 @@ inline vec_base<T, Size> refract(const vec_base<T, Size> &incident,
   return eta * incident - (eta * dot_ni + sqrt(k)) * normal;
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> project(const vec_base<T, Size> &p, const vec_base<T, Size> &v_proj)
 {
   if (UNLIKELY(is_zero(v_proj))) {
@@ -269,7 +269,7 @@ inline vec_base<T, Size> project(const vec_base<T, Size> &p, const vec_base<T, S
   return v_proj * (dot(p, v_proj) / dot(v_proj, v_proj));
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> normalize_and_get_length(const vec_base<T, Size> &v, T &out_length)
 {
   out_length = length_squared(v);
@@ -284,14 +284,14 @@ inline vec_base<T, Size> normalize_and_get_length(const vec_base<T, Size> &v, T
   return vec_base<T, Size>(0.0);
 }
 
-template<typename T, int Size, BLI_ENABLE_IF((math_is_float<T>))>
+template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))>
 inline vec_base<T, Size> normali

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list