Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-11-30 03:18:36 +0300
committerJoshua Leung <aligorith@gmail.com>2009-11-30 03:18:36 +0300
commit3d1f2974899308b5a58d28493da6f9eab966564c (patch)
tree6325dd869025e58f09d8bfd05b10ce33a72ed7b8 /source/blender/blenlib/intern/math_base.c
parenta96f6f2e15af08a9eb2f0ea4567abaddecdf5ac0 (diff)
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.
Diffstat (limited to 'source/blender/blenlib/intern/math_base.c')
-rw-r--r--source/blender/blenlib/intern/math_base.c29
1 files changed, 29 insertions, 0 deletions
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) {