[Bf-blender-cvs] [da8619f] master: Math Lib: add iroundf function for: (int)floorf(a + 0.5f)
Campbell Barton
noreply at git.blender.org
Wed Jan 15 03:42:29 CET 2014
Commit: da8619fe23d22a5009868302bac05d965adb76ac
Author: Campbell Barton
Date: Wed Jan 15 12:31:30 2014 +1100
https://developer.blender.org/rBda8619fe23d22a5009868302bac05d965adb76ac
Math Lib: add iroundf function for: (int)floorf(a + 0.5f)
===================================================================
M source/blender/blenlib/BLI_math_base.h
M source/blender/blenlib/intern/math_base_inline.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index c634c9d..883f01d 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -231,6 +231,7 @@ MINLINE int is_power_of_2_i(int n);
MINLINE int power_of_2_max_i(int n);
MINLINE int power_of_2_min_i(int n);
+MINLINE int iroundf(float a);
MINLINE int divide_round_i(int a, int b);
MINLINE int mod_i(int i, int n);
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index a215d99..facc715 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -151,6 +151,11 @@ MINLINE int power_of_2_min_i(int n)
return n;
}
+MINLINE int iroundf(float a)
+{
+ return (int)floorf(a + 0.5f);
+}
+
/* 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)
More information about the Bf-blender-cvs
mailing list