From 3d1f2974899308b5a58d28493da6f9eab966564c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 30 Nov 2009 00:18:36 +0000 Subject: Added temporary compiling fix for MSVC after Campbell's rounding commit. Copied (in if-defs - for msvc win32/64) the python math functions used for dealing with the lack of a 'round()' function. --- source/blender/blenlib/intern/math_base.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source/blender/blenlib/intern/math_base.c') diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index e1a53a09d40..c5d0a1090b3 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -109,6 +109,35 @@ float power_of_2(float val) return (float)pow(2, ceil(log(val) / log(2))); } + +/* WARNING: MSVC compiling hack for double_round() */ +#if (WIN32 || WIN64) && !(FREE_WINDOWS) + +/* from python 3.1 pymath.c */ +double copysign(double x, double y) +{ + /* use atan2 to distinguish -0. from 0. */ + if (y > 0. || (y == 0. && atan2(y, -1.) > 0.)) { + return fabs(x); + } else { + return -fabs(x); + } +} + +/* from python 3.1 pymath.c */ +double round(double x) +{ + double absx, y; + absx = fabs(x); + y = floor(absx); + if (absx - y >= 0.5) + y += 1.0; + return copysign(y, x); +} + +#endif + + /* from python 3.1 floatobject.c * ndigits must be between 0 and 21 */ double double_round(double x, int ndigits) { -- cgit v1.2.3