Blender V5.3
math_base_inline.cc File Reference
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "BLI_assert.hh"
#include "BLI_math_inline.hh"
#include "BLI_sys_types.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define UNLIKELY(x)
#define _round_clamp_fl_impl(arg, ty, min, max)
#define _round_clamp_db_impl(arg, ty, min, max)
#define _round_fl_impl(arg, ty)
#define _round_db_impl(arg, ty)
#define unit_float_to_uchar_clamp_v3(v1, v2)
#define unit_float_to_uchar_clamp_v4(v1, v2)

Functions

MINLINE float blender::pow2f (float x)
MINLINE float blender::pow3f (float x)
MINLINE float blender::pow4f (float x)
MINLINE float blender::pow5f (float x)
MINLINE float blender::pow7f (float x)
MINLINE float blender::sqrt3f (float f)
MINLINE double blender::sqrt3d (double d)
MINLINE float blender::sqrtf_signed (float f)
MINLINE float blender::interpf (float target, float origin, float t)
MINLINE double blender::interpd (double target, double origin, double t)
MINLINE float blender::ratiof (float min, float max, float pos)
MINLINE double blender::ratiod (double min, double max, double pos)
MINLINE float blender::power_of_2 (float f)
MINLINE int blender::is_power_of_2_i (int n)
MINLINE int blender::power_of_2_max_i (int n)
MINLINE int blender::power_of_2_min_i (int n)
MINLINE unsigned int blender::power_of_2_max_u (unsigned int x)
MINLINE unsigned int blender::log2_floor_u (unsigned int x)
MINLINE unsigned int blender::log2_ceil_u (unsigned int x)
MINLINE unsigned char blender::round_fl_to_uchar (float a)
MINLINE short blender::round_fl_to_short (float a)
MINLINE int blender::round_fl_to_int (float a)
MINLINE unsigned int blender::round_fl_to_uint (float a)
MINLINE int blender::round_db_to_int (double a)
MINLINE unsigned char blender::round_fl_to_uchar_clamp (float a)
MINLINE int blender::round_fl_to_int_clamp (float a)
MINLINE unsigned char blender::round_db_to_uchar_clamp (double a)
MINLINE short blender::round_db_to_short_clamp (double a)
MINLINE int blender::round_db_to_int_clamp (double a)
MINLINE float blender::round_to_even (float f)
MINLINE int blender::divide_round_i (int a, int b)
MINLINE int blender::divide_floor_i (int a, int b)
MINLINE uint blender::divide_ceil_u (uint a, uint b)
MINLINE uint64_t blender::divide_ceil_ul (uint64_t a, uint64_t b)
MINLINE uint blender::ceil_to_multiple_u (uint a, uint b)
MINLINE uint64_t blender::ceil_to_multiple_ul (uint64_t a, uint64_t b)
MINLINE int blender::mod_i (int i, int n)
MINLINE float blender::floored_fmod (float f, float n)
MINLINE float blender::fractf (float a)
MINLINE float blender::wrapf (float value, float max, float min)
MINLINE float blender::pingpongf (float value, float scale)
MINLINE int blender::square_s (short a)
MINLINE int blender::square_i (int a)
MINLINE unsigned int blender::square_uint (unsigned int a)
MINLINE float blender::square_f (float a)
MINLINE int blender::cube_i (int a)
MINLINE float blender::cube_f (float a)
MINLINE float blender::min_ff (float a, float b)
MINLINE float blender::max_ff (float a, float b)
MINLINE float blender::smoothminf (float a, float b, float c)
MINLINE float blender::smoothstep (float edge0, float edge1, float x)
MINLINE double blender::min_dd (double a, double b)
MINLINE double blender::max_dd (double a, double b)
MINLINE int blender::min_ii (int a, int b)
MINLINE int blender::max_ii (int a, int b)
MINLINE uint blender::min_uu (uint a, uint b)
MINLINE uint blender::max_uu (uint a, uint b)
MINLINE unsigned long long blender::min_ulul (unsigned long long a, unsigned long long b)
MINLINE unsigned long long blender::max_ulul (unsigned long long a, unsigned long long b)
MINLINE size_t blender::min_zz (size_t a, size_t b)
MINLINE size_t blender::max_zz (size_t a, size_t b)
MINLINE int blender::clamp_i (int value, int min, int max)
MINLINE float blender::clamp_f (float value, float min, float max)
MINLINE int blender::compare_ff (float a, float b, float max_diff)
MINLINE uint blender::ulp_diff_ff (float a, float b)
MINLINE int blender::compare_ff_relative (float a, float b, float max_diff, int max_ulps)
MINLINE bool blender::compare_threshold_relative (float value1, float value2, float thresh)
MINLINE float blender::increment_ulp (float value)
MINLINE float blender::decrement_ulp (float value)
MINLINE float blender::signf (float f)
MINLINE float blender::compatible_signf (float f)
MINLINE int blender::signum_i_ex (float a, float eps)
MINLINE int blender::signum_i (float a)
MINLINE int blender::integer_digits_f (float f)
MINLINE int blender::integer_digits_d (double d)
MINLINE int blender::integer_digits_i (int i)
MINLINE unsigned char blender::unit_float_to_uchar_clamp (float val)
MINLINE unsigned short blender::unit_float_to_ushort_clamp (float val)
MINLINE unsigned char blender::unit_ushort_to_uchar (unsigned short val)

Macro Definition Documentation

◆ _round_clamp_db_impl

#define _round_clamp_db_impl ( arg,
ty,
min,
max )
Value:
{ \
double r = floor(arg + 0.5); \
if (r <= double(min)) [[unlikely]] { \
return (ty)min; \
} \
if (r >= double(max)) [[unlikely]] { \
return (ty)max; \
} \
return (ty)r; \
}
btScalar max
#define floor
#define min(a, b)
Definition sort.cc:38

Definition at line 170 of file math_base_inline.cc.

Referenced by blender::round_db_to_int_clamp(), blender::round_db_to_short_clamp(), and blender::round_db_to_uchar_clamp().

◆ _round_clamp_fl_impl

#define _round_clamp_fl_impl ( arg,
ty,
min,
max )
Value:
{ \
float r = floorf(arg + 0.5f); \
if (r <= float(min)) [[unlikely]] { \
return (ty)min; \
} \
if (r >= float(max)) [[unlikely]] { \
return (ty)max; \
} \
return (ty)r; \
}
#define floorf

Definition at line 158 of file math_base_inline.cc.

Referenced by blender::round_fl_to_int_clamp(), and blender::round_fl_to_uchar_clamp().

◆ _round_db_impl

#define _round_db_impl ( arg,
ty )
Value:
{ \
return (ty)floor(arg + 0.5); \
}

Definition at line 186 of file math_base_inline.cc.

Referenced by blender::round_db_to_int().

◆ _round_fl_impl

#define _round_fl_impl ( arg,
ty )
Value:
{ \
return (ty)floorf(arg + 0.5f); \
}

Definition at line 182 of file math_base_inline.cc.

Referenced by blender::round_fl_to_int(), blender::round_fl_to_short(), blender::round_fl_to_uchar(), and blender::round_fl_to_uint().

◆ unit_float_to_uchar_clamp_v3

#define unit_float_to_uchar_clamp_v3 ( v1,
v2 )
Value:
{ \
(v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
(v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
(v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
} \
((void)0)

Definition at line 597 of file math_base_inline.cc.

Referenced by blender::do_projectpaint_draw(), blender::do_projectpaint_thread(), blender::ui::theme::get_color_blend_shade_3ubv(), blender::linearrgb_to_srgb_uchar3(), and blender::rgb_float_to_uchar().

◆ unit_float_to_uchar_clamp_v4

#define unit_float_to_uchar_clamp_v4 ( v1,
v2 )
Value:
{ \
(v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
(v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
(v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
(v1)[3] = unit_float_to_uchar_clamp((v2[3])); \
} \
((void)0)

Definition at line 604 of file math_base_inline.cc.

Referenced by blender::ed::object::convert_float_color_to_byte_color(), blender::IMB_rectfill(), blender::linearrgb_to_srgb_uchar4(), and blender::rgba_float_to_uchar().

◆ UNLIKELY

#define UNLIKELY ( x)
Value:

Definition at line 27 of file math_base_inline.cc.