From 9e365069afe156f33fadfad9705e1325f894cd54 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 9 Dec 2021 20:01:44 +1100 Subject: Cleanup: move public doc-strings into headers for 'blenlib' - Added space below non doc-string comments to make it clear these aren't comments for the symbols directly below them. - Use doxy sections for some headers. - Minor improvements to doc-strings. Ref T92709 --- source/blender/blenlib/intern/math_base_inline.c | 36 ------------------------ 1 file changed, 36 deletions(-) (limited to 'source/blender/blenlib/intern/math_base_inline.c') diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index f609d5f8e8b..53cf2d61963 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -45,7 +45,6 @@ extern "C" { # define UNLIKELY(x) (x) #endif -/* powf is really slow for raising to integer powers. */ MINLINE float pow2f(float x) { return x * x; @@ -192,21 +191,18 @@ MINLINE double ratiod(double min, double max, double pos) return range == 0 ? 0 : ((pos - min) / range); } -/* Map a normalized value, i.e. from interval [0, 1] to interval [a, b]. */ MINLINE float scalenorm(float a, float b, float x) { BLI_assert(x <= 1 && x >= 0); return (x * (b - a)) + a; } -/* Map a normalized value, i.e. from interval [0, 1] to interval [a, b]. */ MINLINE double scalenormd(double a, double b, double x) { BLI_assert(x <= 1 && x >= 0); return (x * (b - a)) + a; } -/* Used for zoom values. */ MINLINE float power_of_2(float val) { return (float)pow(2.0, ceil(log((double)val) / M_LN2)); @@ -363,16 +359,11 @@ MINLINE signed char round_db_to_char_clamp(double a){ #undef _round_clamp_fl_impl #undef _round_clamp_db_impl -/** - * Round to closest even number, halfway cases are rounded away from zero. - */ MINLINE float round_to_even(float f) { return roundf(f * 0.5f) * 2.0f; } -/* integer division that rounds 0.5 up, particularly useful for color blending - * with integers, to avoid gradual darkening when rounding down */ MINLINE int divide_round_i(int a, int b) { return (2 * a + b) / (2 * b); @@ -397,9 +388,6 @@ MINLINE uint divide_ceil_u(uint a, uint b) return (a + b - 1) / b; } -/** - * modulo that handles negative numbers, works the same as Python's. - */ MINLINE int mod_i(int i, int n) { return (i % n + n) % n; @@ -629,27 +617,11 @@ MINLINE size_t clamp_z(size_t value, size_t min, size_t max) return min_zz(max_zz(value, min), max); } -/** - * Almost-equal for IEEE floats, using absolute difference method. - * - * \param max_diff: the maximum absolute difference. - */ MINLINE int compare_ff(float a, float b, const float max_diff) { return fabsf(a - b) <= max_diff; } -/** - * Almost-equal for IEEE floats, using their integer representation - * (mixing ULP and absolute difference methods). - * - * \param max_diff: is the maximum absolute difference (allows to take care of the near-zero area, - * where relative difference methods cannot really work). - * \param max_ulps: is the 'maximum number of floats + 1' - * allowed between \a a and \a b to consider them equal. - * - * \see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ - */ MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps) { union { @@ -728,19 +700,11 @@ MINLINE int signum_i(float a) } } -/** - * Returns number of (base ten) *significant* digits of integer part of given float - * (negative in case of decimal-only floats, 0.01 returns -1 e.g.). - */ MINLINE int integer_digits_f(const float f) { return (f == 0.0f) ? 0 : (int)floor(log10(fabs(f))) + 1; } -/** - * Returns number of (base ten) *significant* digits of integer part of given double - * (negative in case of decimal-only floats, 0.01 returns -1 e.g.). - */ MINLINE int integer_digits_d(const double d) { return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1; -- cgit v1.2.3