diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenlib/BLI_math_base.h | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenlib/BLI_math_base.h')
-rw-r--r-- | source/blender/blenlib/BLI_math_base.h | 142 |
1 files changed, 77 insertions, 65 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 01ce35a2279..aff01622f35 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -36,43 +36,43 @@ #include "BLI_math_inline.h" #ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ +# define M_PI 3.14159265358979323846 /* pi */ #endif #ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 /* pi/2 */ +# define M_PI_2 1.57079632679489661923 /* pi/2 */ #endif #ifndef M_PI_4 -#define M_PI_4 0.78539816339744830962 /* pi/4 */ +# define M_PI_4 0.78539816339744830962 /* pi/4 */ #endif #ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #endif #ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif #ifndef M_SQRT3 -#define M_SQRT3 1.73205080756887729352 /* sqrt(3) */ +# define M_SQRT3 1.73205080756887729352 /* sqrt(3) */ #endif #ifndef M_SQRT1_3 -#define M_SQRT1_3 0.57735026918962576450 /* 1/sqrt(3) */ +# define M_SQRT1_3 0.57735026918962576450 /* 1/sqrt(3) */ #endif #ifndef M_1_PI -#define M_1_PI 0.318309886183790671538 /* 1/pi */ +# define M_1_PI 0.318309886183790671538 /* 1/pi */ #endif #ifndef M_E -#define M_E 2.7182818284590452354 /* e */ +# define M_E 2.7182818284590452354 /* e */ #endif #ifndef M_LOG2E -#define M_LOG2E 1.4426950408889634074 /* log_2 e */ +# define M_LOG2E 1.4426950408889634074 /* log_2 e */ #endif #ifndef M_LOG10E -#define M_LOG10E 0.43429448190325182765 /* log_10 e */ +# define M_LOG10E 0.43429448190325182765 /* log_10 e */ #endif #ifndef M_LN2 -#define M_LN2 0.69314718055994530942 /* log_e 2 */ +# define M_LN2 0.69314718055994530942 /* log_e 2 */ #endif #ifndef M_LN10 -#define M_LN10 2.30258509299404568402 /* log_e 10 */ +# define M_LN10 2.30258509299404568402 /* log_e 10 */ #endif #if defined(__GNUC__) @@ -80,11 +80,11 @@ #else /* evil quiet NaN definition */ static const int NAN_INT = 0x7FC00000; -# define NAN_FLT (*((float *)(&NAN_INT))) +# define NAN_FLT (*((float *)(&NAN_INT))) #endif #if BLI_MATH_DO_INLINE -#include "intern/math_base_inline.c" +# include "intern/math_base_inline.c" #endif #ifdef BLI_MATH_GCC_WARN_PRAGMA @@ -158,33 +158,33 @@ MINLINE unsigned int power_of_2_min_u(unsigned int x); MINLINE int divide_round_i(int a, int b); MINLINE int mod_i(int i, int n); -MINLINE signed char round_fl_to_char(float a); -MINLINE unsigned char round_fl_to_uchar(float a); -MINLINE short round_fl_to_short(float a); +MINLINE signed char round_fl_to_char(float a); +MINLINE unsigned char round_fl_to_uchar(float a); +MINLINE short round_fl_to_short(float a); MINLINE unsigned short round_fl_to_ushort(float a); -MINLINE int round_fl_to_int(float a); -MINLINE unsigned int round_fl_to_uint(float a); +MINLINE int round_fl_to_int(float a); +MINLINE unsigned int round_fl_to_uint(float a); -MINLINE signed char round_db_to_char(double a); -MINLINE unsigned char round_db_to_uchar(double a); -MINLINE short round_db_to_short(double a); +MINLINE signed char round_db_to_char(double a); +MINLINE unsigned char round_db_to_uchar(double a); +MINLINE short round_db_to_short(double a); MINLINE unsigned short round_db_to_ushort(double a); -MINLINE int round_db_to_int(double a); -MINLINE unsigned int round_db_to_uint(double a); +MINLINE int round_db_to_int(double a); +MINLINE unsigned int round_db_to_uint(double a); -MINLINE signed char round_fl_to_char_clamp(float a); -MINLINE unsigned char round_fl_to_uchar_clamp(float a); -MINLINE short round_fl_to_short_clamp(float a); +MINLINE signed char round_fl_to_char_clamp(float a); +MINLINE unsigned char round_fl_to_uchar_clamp(float a); +MINLINE short round_fl_to_short_clamp(float a); MINLINE unsigned short round_fl_to_ushort_clamp(float a); -MINLINE int round_fl_to_int_clamp(float a); -MINLINE unsigned int round_fl_to_uint_clamp(float a); +MINLINE int round_fl_to_int_clamp(float a); +MINLINE unsigned int round_fl_to_uint_clamp(float a); -MINLINE signed char round_db_to_char_clamp(double a); -MINLINE unsigned char round_db_to_uchar_clamp(double a); -MINLINE short round_db_to_short_clamp(double a); +MINLINE signed char round_db_to_char_clamp(double a); +MINLINE unsigned char round_db_to_uchar_clamp(double a); +MINLINE short round_db_to_short_clamp(double a); MINLINE unsigned short round_db_to_ushort_clamp(double a); -MINLINE int round_db_to_int_clamp(double a); -MINLINE unsigned int round_db_to_uint_clamp(double a); +MINLINE int round_db_to_int_clamp(double a); +MINLINE unsigned int round_db_to_uint_clamp(double a); int pow_i(int base, int exp); double double_round(double x, int ndigits); @@ -203,36 +203,48 @@ double double_round(double x, int ndigits); * \note Checks are flipped so NAN doesn't assert. This is done because we're making sure the value was normalized * and in the case we don't want NAN to be raising asserts since there is nothing to be done in that case. */ -# define BLI_ASSERT_UNIT_V3(v) { \ - const float _test_unit = len_squared_v3(v); \ - BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \ - !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \ -} (void)0 - -# define BLI_ASSERT_UNIT_V2(v) { \ - const float _test_unit = len_squared_v2(v); \ - BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \ - !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \ -} (void)0 - -# define BLI_ASSERT_UNIT_QUAT(q) { \ - const float _test_unit = dot_qtqt(q, q); \ - BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON * 10) || \ - !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON * 10)); \ -} (void)0 - -# define BLI_ASSERT_ZERO_M3(m) { \ - BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \ -} (void)0 - -# define BLI_ASSERT_ZERO_M4(m) { \ - BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 16) != 0.0); \ -} (void)0 -# define BLI_ASSERT_UNIT_M3(m) { \ - BLI_ASSERT_UNIT_V3((m)[0]); \ - BLI_ASSERT_UNIT_V3((m)[1]); \ - BLI_ASSERT_UNIT_V3((m)[2]); \ -} (void)0 +# define BLI_ASSERT_UNIT_V3(v) \ + { \ + const float _test_unit = len_squared_v3(v); \ + BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \ + !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \ + } \ + (void)0 + +# define BLI_ASSERT_UNIT_V2(v) \ + { \ + const float _test_unit = len_squared_v2(v); \ + BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \ + !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \ + } \ + (void)0 + +# define BLI_ASSERT_UNIT_QUAT(q) \ + { \ + const float _test_unit = dot_qtqt(q, q); \ + BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON * 10) || \ + !(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON * 10)); \ + } \ + (void)0 + +# define BLI_ASSERT_ZERO_M3(m) \ + { \ + BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \ + } \ + (void)0 + +# define BLI_ASSERT_ZERO_M4(m) \ + { \ + BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 16) != 0.0); \ + } \ + (void)0 +# define BLI_ASSERT_UNIT_M3(m) \ + { \ + BLI_ASSERT_UNIT_V3((m)[0]); \ + BLI_ASSERT_UNIT_V3((m)[1]); \ + BLI_ASSERT_UNIT_V3((m)[2]); \ + } \ + (void)0 #else # define BLI_ASSERT_UNIT_V2(v) (void)(v) # define BLI_ASSERT_UNIT_V3(v) (void)(v) |