Blender V4.3
math_base_inline.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#ifndef __MATH_BASE_INLINE_C__
10#define __MATH_BASE_INLINE_C__
11
12#include <float.h>
13#include <limits.h>
14#include <stdio.h>
15#include <stdlib.h>
16
17#include "BLI_math_base.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* copied from BLI_utildefines.h */
24#ifdef __GNUC__
25# define UNLIKELY(x) __builtin_expect(!!(x), 0)
26#else
27# define UNLIKELY(x) (x)
28#endif
29
30MINLINE float pow2f(float x)
31{
32 return x * x;
33}
34MINLINE float pow3f(float x)
35{
36 return pow2f(x) * x;
37}
38MINLINE float pow4f(float x)
39{
40 return pow2f(pow2f(x));
41}
42MINLINE float pow5f(float x)
43{
44 return pow4f(x) * x;
45}
46MINLINE float pow7f(float x)
47{
48 return pow2f(pow3f(x)) * x;
49}
50
51MINLINE float sqrt3f(float f)
52{
53 if (UNLIKELY(f == 0.0f)) {
54 return 0.0f;
55 }
56 else if (UNLIKELY(f < 0.0f)) {
57 return -(float)(exp(log(-f) / 3.0));
58 }
59 else {
60 return (float)(exp(log(f) / 3.0));
61 }
62}
63
64MINLINE double sqrt3d(double d)
65{
66 if (UNLIKELY(d == 0.0)) {
67 return 0.0;
68 }
69 else if (UNLIKELY(d < 0.0)) {
70 return -exp(log(-d) / 3.0);
71 }
72 else {
73 return exp(log(d) / 3.0);
74 }
75}
76
77MINLINE float sqrtf_signed(float f)
78{
79 return (f >= 0.0f) ? sqrtf(f) : -sqrtf(-f);
80}
81
82MINLINE float interpf(float target, float origin, float fac)
83{
84 return (fac * target) + (1.0f - fac) * origin;
85}
86
87MINLINE double interpd(double target, double origin, double fac)
88{
89 return (fac * target) + (1.0f - fac) * origin;
90}
91
92MINLINE float ratiof(float min, float max, float pos)
93{
94 float range = max - min;
95 return range == 0 ? 0 : ((pos - min) / range);
96}
97
98MINLINE double ratiod(double min, double max, double pos)
99{
100 double range = max - min;
101 return range == 0 ? 0 : ((pos - min) / range);
102}
103
104MINLINE float scalenorm(float a, float b, float x)
105{
107 return (x * (b - a)) + a;
108}
109
110MINLINE double scalenormd(double a, double b, double x)
111{
113 return (x * (b - a)) + a;
114}
115
116MINLINE float power_of_2(float val)
117{
118 return (float)pow(2.0, ceil(log((double)val) / M_LN2));
119}
120
122{
123 return (n & (n - 1)) == 0;
124}
125
127{
128 if (is_power_of_2_i(n)) {
129 return n;
130 }
131
132 do {
133 n = n & (n - 1);
134 } while (!is_power_of_2_i(n));
135
136 return n * 2;
137}
138
140{
141 while (!is_power_of_2_i(n)) {
142 n = n & (n - 1);
143 }
144
145 return n;
146}
147
148MINLINE unsigned int power_of_2_max_u(unsigned int x)
149{
150 x -= 1;
151 x |= (x >> 1);
152 x |= (x >> 2);
153 x |= (x >> 4);
154 x |= (x >> 8);
155 x |= (x >> 16);
156 return x + 1;
157}
158
159MINLINE unsigned int power_of_2_min_u(unsigned int x)
160{
161 x |= (x >> 1);
162 x |= (x >> 2);
163 x |= (x >> 4);
164 x |= (x >> 8);
165 x |= (x >> 16);
166 return x - (x >> 1);
167}
168
169MINLINE unsigned int log2_floor_u(unsigned int x)
170{
171 return x <= 1 ? 0 : 1 + log2_floor_u(x >> 1);
172}
173
174MINLINE unsigned int log2_ceil_u(unsigned int x)
175{
176 if (is_power_of_2_i((int)x)) {
177 return log2_floor_u(x);
178 }
179 else {
180 return log2_floor_u(x) + 1;
181 }
182}
183
184/* rounding and clamping */
185
186#define _round_clamp_fl_impl(arg, ty, min, max) \
187 { \
188 float r = floorf(arg + 0.5f); \
189 if (UNLIKELY(r <= (float)min)) { \
190 return (ty)min; \
191 } \
192 else if (UNLIKELY(r >= (float)max)) { \
193 return (ty)max; \
194 } \
195 else { \
196 return (ty)r; \
197 } \
198 }
199
200#define _round_clamp_db_impl(arg, ty, min, max) \
201 { \
202 double r = floor(arg + 0.5); \
203 if (UNLIKELY(r <= (double)min)) { \
204 return (ty)min; \
205 } \
206 else if (UNLIKELY(r >= (double)max)) { \
207 return (ty)max; \
208 } \
209 else { \
210 return (ty)r; \
211 } \
212 }
213
214#define _round_fl_impl(arg, ty) \
215 { \
216 return (ty)floorf(arg + 0.5f); \
217 }
218#define _round_db_impl(arg, ty) \
219 { \
220 return (ty)floor(arg + 0.5); \
221 }
222
223MINLINE signed char round_fl_to_char(float a){_round_fl_impl(a, signed char)} MINLINE
224 unsigned char round_fl_to_uchar(float a){_round_fl_impl(a, unsigned char)} MINLINE
225 short round_fl_to_short(float a){_round_fl_impl(a, short)} MINLINE
226 unsigned short round_fl_to_ushort(float a){_round_fl_impl(a, unsigned short)} MINLINE
228 unsigned int round_fl_to_uint(float a){_round_fl_impl(a, unsigned int)}
229
230MINLINE signed char round_db_to_char(double a){_round_db_impl(a, signed char)} MINLINE
231 unsigned char round_db_to_uchar(double a){_round_db_impl(a, unsigned char)} MINLINE
232 short round_db_to_short(double a){_round_db_impl(a, short)} MINLINE
233 unsigned short round_db_to_ushort(double a){_round_db_impl(a, unsigned short)} MINLINE
235 unsigned int round_db_to_uint(double a){_round_db_impl(a, unsigned int)}
236
237#undef _round_fl_impl
238#undef _round_db_impl
239
240MINLINE signed char round_fl_to_char_clamp(float a){
241 _round_clamp_fl_impl(a, signed char, SCHAR_MIN, SCHAR_MAX)} MINLINE
242 unsigned char round_fl_to_uchar_clamp(float a){
243 _round_clamp_fl_impl(a, unsigned char, 0, UCHAR_MAX)} MINLINE
245 _round_clamp_fl_impl(a, short, SHRT_MIN, SHRT_MAX)} MINLINE
246 unsigned short round_fl_to_ushort_clamp(float a){
247 _round_clamp_fl_impl(a, unsigned short, 0, USHRT_MAX)} MINLINE
248 int round_fl_to_int_clamp(float a){_round_clamp_fl_impl(a, int, INT_MIN, INT_MAX)} MINLINE
249 unsigned int round_fl_to_uint_clamp(float a){
250 _round_clamp_fl_impl(a, unsigned int, 0, UINT_MAX)}
251
252MINLINE signed char round_db_to_char_clamp(double a){
253 _round_clamp_db_impl(a, signed char, SCHAR_MIN, SCHAR_MAX)} MINLINE
254 unsigned char round_db_to_uchar_clamp(double a){
255 _round_clamp_db_impl(a, unsigned char, 0, UCHAR_MAX)} MINLINE
256 short round_db_to_short_clamp(double a){
257 _round_clamp_db_impl(a, short, SHRT_MIN, SHRT_MAX)} MINLINE
258 unsigned short round_db_to_ushort_clamp(double a){
259 _round_clamp_db_impl(a, unsigned short, 0, USHRT_MAX)} MINLINE
260 int round_db_to_int_clamp(double a){_round_clamp_db_impl(a, int, INT_MIN, INT_MAX)} MINLINE
261 unsigned int round_db_to_uint_clamp(double a){
262 _round_clamp_db_impl(a, unsigned int, 0, UINT_MAX)}
263
264#undef _round_clamp_fl_impl
265#undef _round_clamp_db_impl
266
267MINLINE float round_to_even(float f)
268{
269 return roundf(f * 0.5f) * 2.0f;
270}
271
272MINLINE int divide_round_i(int a, int b)
273{
274 return (2 * a + b) / (2 * b);
275}
276
281MINLINE int divide_floor_i(int a, int b)
282{
283 int d = a / b;
284 int r = a % b; /* Optimizes into a single division. */
285 return r ? d - ((a < 0) ^ (b < 0)) : d;
286}
287
289{
290 return (a + b - 1) / b;
291}
292
294{
295 return (a + b - 1) / b;
296}
297
299{
300 return divide_ceil_u(a, b) * b;
301}
302
307
308MINLINE int mod_i(int i, int n)
309{
310 return (i % n + n) % n;
311}
312
313MINLINE float floored_fmod(const float f, const float n)
314{
315 return f - n * floorf(f / n);
316}
317
318MINLINE float fractf(float a)
319{
320 return a - floorf(a);
321}
322
323/* Adapted from `godot-engine` math_funcs.h. */
324MINLINE float wrapf(float value, float max, float min)
325{
326 float range = max - min;
327 return (range != 0.0f) ? value - (range * floorf((value - min) / range)) : min;
328}
329
330MINLINE float pingpongf(float value, float scale)
331{
332 if (scale == 0.0f) {
333 return 0.0f;
334 }
335 return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale);
336}
337
338/* Square. */
339
340MINLINE int square_s(short a)
341{
342 return a * a;
343}
344
346{
347 return a * a;
348}
349
350MINLINE unsigned int square_uint(unsigned int a)
351{
352 return a * a;
353}
354
355MINLINE int square_uchar(unsigned char a)
356{
357 return a * a;
358}
359
360MINLINE float square_f(float a)
361{
362 return a * a;
363}
364
365MINLINE double square_d(double a)
366{
367 return a * a;
368}
369
370/* Cube. */
371
372MINLINE int cube_s(short a)
373{
374 return a * a * a;
375}
376
377MINLINE int cube_i(int a)
378{
379 return a * a * a;
380}
381
382MINLINE unsigned int cube_uint(unsigned int a)
383{
384 return a * a * a;
385}
386
387MINLINE int cube_uchar(unsigned char a)
388{
389 return a * a * a;
390}
391
392MINLINE float cube_f(float a)
393{
394 return a * a * a;
395}
396
397MINLINE double cube_d(double a)
398{
399 return a * a * a;
400}
401
402/* Min/max */
403
404MINLINE float min_ff(float a, float b)
405{
406 return (a < b) ? a : b;
407}
408MINLINE float max_ff(float a, float b)
409{
410 return (a > b) ? a : b;
411}
412/* See: https://www.iquilezles.org/www/articles/smin/smin.htm. */
413MINLINE float smoothminf(float a, float b, float c)
414{
415 if (c != 0.0f) {
416 float h = max_ff(c - fabsf(a - b), 0.0f) / c;
417 return min_ff(a, b) - h * h * h * c * (1.0f / 6.0f);
418 }
419 else {
420 return min_ff(a, b);
421 }
422}
423
424MINLINE float smoothstep(float edge0, float edge1, float x)
425{
426 float result;
427 if (x < edge0) {
428 result = 0.0f;
429 }
430 else if (x >= edge1) {
431 result = 1.0f;
432 }
433 else {
434 float t = (x - edge0) / (edge1 - edge0);
435 result = (3.0f - 2.0f * t) * (t * t);
436 }
437 return result;
438}
439
440MINLINE double min_dd(double a, double b)
441{
442 return (a < b) ? a : b;
443}
444MINLINE double max_dd(double a, double b)
445{
446 return (a > b) ? a : b;
447}
448
449MINLINE int min_ii(int a, int b)
450{
451 return (a < b) ? a : b;
452}
453MINLINE int max_ii(int a, int b)
454{
455 return (b < a) ? a : b;
456}
457
459{
460 return (a < b) ? a : b;
461}
463{
464 return (b < a) ? a : b;
465}
466
467MINLINE unsigned long long min_ulul(unsigned long long a, unsigned long long b)
468{
469 return (a < b) ? a : b;
470}
471MINLINE unsigned long long max_ulul(unsigned long long a, unsigned long long b)
472{
473 return (b < a) ? a : b;
474}
475
476MINLINE double min_ddd(double a, double b, double c)
477{
478 return min_dd(min_dd(a, b), c);
479}
480MINLINE double max_ddd(double a, double b, double c)
481{
482 return max_dd(max_dd(a, b), c);
483}
484
485MINLINE float min_fff(float a, float b, float c)
486{
487 return min_ff(min_ff(a, b), c);
488}
489MINLINE float max_fff(float a, float b, float c)
490{
491 return max_ff(max_ff(a, b), c);
492}
493
494MINLINE int min_iii(int a, int b, int c)
495{
496 return min_ii(min_ii(a, b), c);
497}
498MINLINE int max_iii(int a, int b, int c)
499{
500 return max_ii(max_ii(a, b), c);
501}
502
503MINLINE float min_ffff(float a, float b, float c, float d)
504{
505 return min_ff(min_fff(a, b, c), d);
506}
507MINLINE float max_ffff(float a, float b, float c, float d)
508{
509 return max_ff(max_fff(a, b, c), d);
510}
511
512MINLINE int min_iiii(int a, int b, int c, int d)
513{
514 return min_ii(min_iii(a, b, c), d);
515}
516MINLINE int max_iiii(int a, int b, int c, int d)
517{
518 return max_ii(max_iii(a, b, c), d);
519}
520
521MINLINE size_t min_zz(size_t a, size_t b)
522{
523 return (a < b) ? a : b;
524}
525MINLINE size_t max_zz(size_t a, size_t b)
526{
527 return (b < a) ? a : b;
528}
529
530MINLINE char min_cc(char a, char b)
531{
532 return (a < b) ? a : b;
533}
534MINLINE char max_cc(char a, char b)
535{
536 return (b < a) ? a : b;
537}
538
539MINLINE int clamp_i(int value, int min, int max)
540{
541 return min_ii(max_ii(value, min), max);
542}
543
544MINLINE float clamp_f(float value, float min, float max)
545{
546 if (value > max) {
547 return max;
548 }
549 else if (value < min) {
550 return min;
551 }
552 return value;
553}
554
555MINLINE size_t clamp_z(size_t value, size_t min, size_t max)
556{
557 return min_zz(max_zz(value, min), max);
558}
559
560MINLINE int compare_ff(float a, float b, const float max_diff)
561{
562 return fabsf(a - b) <= max_diff;
563}
564
565MINLINE uint ulp_diff_ff(float a, float b)
566{
567 BLI_assert(sizeof(float) == sizeof(uint));
568
569 const uint sign_bit = 0x80000000;
570 const uint infinity = 0x7f800000;
571
572 union {
573 float f;
574 uint i;
575 } ua, ub;
576 ua.f = a;
577 ub.f = b;
578
579 const uint a_sign = ua.i & sign_bit;
580 const uint b_sign = ub.i & sign_bit;
581 const uint a_abs = ua.i & ~sign_bit;
582 const uint b_abs = ub.i & ~sign_bit;
583
584 if (a_abs > infinity || b_abs > infinity) {
585 /* NaNs always return maximum ulps apart. */
586 return 0xffffffff;
587 }
588 else if (a_sign == b_sign) {
589 const uint min_abs = a_abs < b_abs ? a_abs : b_abs;
590 const uint max_abs = a_abs > b_abs ? a_abs : b_abs;
591 return max_abs - min_abs;
592 }
593 else {
594 return a_abs + b_abs;
595 }
596}
597
598MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps)
599{
600 BLI_assert(max_ulps >= 0 && max_ulps < (1 << 22));
601
602 if (fabsf(a - b) <= max_diff) {
603 return 1;
604 }
605
606 return (ulp_diff_ff(a, b) <= (uint)max_ulps) ? 1 : 0;
607}
608
609MINLINE bool compare_threshold_relative(const float value1, const float value2, const float thresh)
610{
611 const float abs_diff = fabsf(value1 - value2);
612 /* Avoid letting the threshold get too small just because the values happen to be close to zero.
613 */
614 if (fabsf(value2) < 1) {
615 return abs_diff > thresh;
616 }
617 /* Using relative threshold in general. */
618 return abs_diff > thresh * fabsf(value2);
619}
620
621MINLINE float signf(float f)
622{
623 return (f < 0.0f) ? -1.0f : 1.0f;
624}
625
627{
628 if (f > 0.0f) {
629 return 1.0f;
630 }
631 if (f < 0.0f) {
632 return -1.0f;
633 }
634 else {
635 return 0.0f;
636 }
637}
638
639MINLINE int signum_i_ex(float a, float eps)
640{
641 if (a > eps) {
642 return 1;
643 }
644 if (a < -eps) {
645 return -1;
646 }
647 else {
648 return 0;
649 }
650}
651
652MINLINE int signum_i(float a)
653{
654 if (a > 0.0f) {
655 return 1;
656 }
657 if (a < 0.0f) {
658 return -1;
659 }
660 else {
661 return 0;
662 }
663}
664
665MINLINE int integer_digits_f(const float f)
666{
667 return (f == 0.0f) ? 0 : (int)floor(log10(fabs(f))) + 1;
668}
669
670MINLINE int integer_digits_d(const double d)
671{
672 return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1;
673}
674
675MINLINE int integer_digits_i(const int i)
676{
677 return (int)log10((double)i) + 1;
678}
679
680/* Low level conversion functions */
681MINLINE unsigned char unit_float_to_uchar_clamp(float val)
682{
683 return (unsigned char)((
684 (val <= 0.0f) ? 0 : ((val > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * val) + 0.5f))));
685}
686#define unit_float_to_uchar_clamp(val) \
687 ((CHECK_TYPE_INLINE_NONCONST((val), float)), unit_float_to_uchar_clamp(val))
688
689MINLINE unsigned short unit_float_to_ushort_clamp(float val)
690{
691 return (unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 :
692 (val <= 0.0f) ? 0 :
693 (val * 65535.0f + 0.5f));
694}
695#define unit_float_to_ushort_clamp(val) \
696 ((CHECK_TYPE_INLINE_NONCONST(val, float)), unit_float_to_ushort_clamp(val))
697
698MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
699{
700 return (unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8);
701}
702#define unit_ushort_to_uchar(val) \
703 ((CHECK_TYPE_INLINE_NONCONST(val, unsigned short)), unit_ushort_to_uchar(val))
704
705#define unit_float_to_uchar_clamp_v3(v1, v2) \
706 { \
707 (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
708 (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
709 (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
710 } \
711 ((void)0)
712#define unit_float_to_uchar_clamp_v4(v1, v2) \
713 { \
714 (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
715 (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
716 (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
717 (v1)[3] = unit_float_to_uchar_clamp((v2[3])); \
718 } \
719 ((void)0)
720
721#ifdef __cplusplus
722}
723#endif
724
725#endif /* __MATH_BASE_INLINE_C__ */
#define BLI_assert(a)
Definition BLI_assert.h:50
#define M_LN2
#define MINLINE
unsigned int uint
local_group_size(16, 16) .push_constant(Type b
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
#define floorf(x)
#define fabsf(x)
#define sqrtf(x)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define UINT_MAX
Definition hash_md5.cc:44
MINLINE int round_fl_to_int_clamp(float a)
MINLINE unsigned char round_fl_to_uchar(float a)
MINLINE float max_fff(float a, float b, float c)
MINLINE uint ceil_to_multiple_u(uint a, uint b)
MINLINE double max_ddd(double a, double b, double c)
#define _round_clamp_fl_impl(arg, ty, min, max)
MINLINE unsigned short round_fl_to_ushort_clamp(float a)
MINLINE uint min_uu(uint a, uint b)
MINLINE float max_ffff(float a, float b, float c, float d)
MINLINE unsigned int round_db_to_uint_clamp(double a)
MINLINE unsigned int log2_ceil_u(unsigned int x)
MINLINE signed char round_fl_to_char(float a)
MINLINE int power_of_2_min_i(int n)
MINLINE double min_ddd(double a, double b, double c)
MINLINE int round_fl_to_int(float a)
MINLINE short round_db_to_short_clamp(double a)
MINLINE signed char round_db_to_char_clamp(double a)
MINLINE float max_ff(float a, float b)
MINLINE unsigned int cube_uint(unsigned int a)
MINLINE size_t min_zz(size_t a, size_t b)
MINLINE int min_ii(int a, int b)
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE short round_db_to_short(double a)
MINLINE int power_of_2_max_i(int n)
MINLINE float fractf(float a)
MINLINE int compare_ff(float a, float b, const float max_diff)
MINLINE float power_of_2(float val)
MINLINE float min_ffff(float a, float b, float c, float d)
MINLINE unsigned int power_of_2_max_u(unsigned int x)
MINLINE uint max_uu(uint a, uint b)
MINLINE bool compare_threshold_relative(const float value1, const float value2, const float thresh)
#define _round_fl_impl(arg, ty)
MINLINE int cube_i(int a)
#define _round_db_impl(arg, ty)
MINLINE unsigned short round_fl_to_ushort(float a)
MINLINE float pow2f(float x)
MINLINE unsigned int round_fl_to_uint_clamp(float a)
MINLINE double square_d(double a)
#define unit_float_to_ushort_clamp(val)
MINLINE double ratiod(double min, double max, double pos)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int divide_floor_i(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE double scalenormd(double a, double b, double x)
MINLINE size_t max_zz(size_t a, size_t b)
MINLINE unsigned long long min_ulul(unsigned long long a, unsigned long long b)
MINLINE unsigned long long max_ulul(unsigned long long a, unsigned long long b)
MINLINE int cube_s(short a)
MINLINE int integer_digits_d(const double d)
MINLINE int square_i(int a)
MINLINE float floored_fmod(const float f, const float n)
MINLINE short round_fl_to_short_clamp(float a)
MINLINE float pow5f(float x)
MINLINE int max_ii(int a, int b)
MINLINE short round_fl_to_short(float a)
MINLINE uint64_t divide_ceil_ul(uint64_t a, uint64_t b)
MINLINE unsigned int round_db_to_uint(double a)
#define unit_float_to_uchar_clamp(val)
MINLINE unsigned int power_of_2_min_u(unsigned int x)
MINLINE double min_dd(double a, double b)
MINLINE signed char round_fl_to_char_clamp(float a)
MINLINE float smoothminf(float a, float b, float c)
MINLINE float cube_f(float a)
MINLINE unsigned short round_db_to_ushort_clamp(double a)
MINLINE float scalenorm(float a, float b, float x)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
MINLINE double cube_d(double a)
MINLINE int min_iii(int a, int b, int c)
MINLINE int divide_round_i(int a, int b)
MINLINE int integer_digits_f(const float f)
MINLINE int integer_digits_i(const int i)
MINLINE int mod_i(int i, int n)
#define unit_ushort_to_uchar(val)
MINLINE double interpd(double target, double origin, double fac)
MINLINE float square_f(float a)
MINLINE unsigned int round_fl_to_uint(float a)
MINLINE float pingpongf(float value, float scale)
#define UNLIKELY(x)
MINLINE float interpf(float target, float origin, float fac)
MINLINE float sqrtf_signed(float f)
MINLINE double max_dd(double a, double b)
MINLINE uint ulp_diff_ff(float a, float b)
MINLINE int round_db_to_int_clamp(double a)
MINLINE char min_cc(char a, char b)
MINLINE signed char round_db_to_char(double a)
MINLINE int is_power_of_2_i(int n)
MINLINE float pow3f(float x)
MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps)
MINLINE double sqrt3d(double d)
MINLINE int round_db_to_int(double a)
MINLINE int max_iiii(int a, int b, int c, int d)
MINLINE float min_fff(float a, float b, float c)
MINLINE int signum_i_ex(float a, float eps)
MINLINE int min_iiii(int a, int b, int c, int d)
MINLINE unsigned int log2_floor_u(unsigned int x)
MINLINE float signf(float f)
MINLINE int max_iii(int a, int b, int c)
MINLINE size_t clamp_z(size_t value, size_t min, size_t max)
MINLINE unsigned short round_db_to_ushort(double a)
MINLINE int clamp_i(int value, int min, int max)
MINLINE int signum_i(float a)
MINLINE float ratiof(float min, float max, float pos)
MINLINE float smoothstep(float edge0, float edge1, float x)
MINLINE float round_to_even(float f)
#define _round_clamp_db_impl(arg, ty, min, max)
MINLINE int cube_uchar(unsigned char a)
MINLINE unsigned int square_uint(unsigned int a)
MINLINE int square_s(short a)
MINLINE uint64_t ceil_to_multiple_ul(uint64_t a, uint64_t b)
MINLINE float compatible_signf(float f)
MINLINE unsigned char round_db_to_uchar_clamp(double a)
MINLINE int square_uchar(unsigned char a)
MINLINE float pow4f(float x)
MINLINE float sqrt3f(float f)
MINLINE char max_cc(char a, char b)
MINLINE float pow7f(float x)
MINLINE float wrapf(float value, float max, float min)
MINLINE unsigned char round_db_to_uchar(double a)
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float3 ceil(const float3 a)
ccl_device_inline float3 log(float3 v)
const btScalar eps
Definition poly34.cpp:11
#define min(a, b)
Definition sort.c:32
unsigned __int64 uint64_t
Definition stdint.h:90
float max