[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25013] trunk/blender/source/blender/ blenlib/intern/math_base.c: Added temporary compiling fix for MSVC after Campbell's rounding commit.
Joshua Leung
aligorith at gmail.com
Mon Nov 30 01:18:36 CET 2009
Revision: 25013
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25013
Author: aligorith
Date: 2009-11-30 01:18:36 +0100 (Mon, 30 Nov 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/math_base.c
Modified: trunk/blender/source/blender/blenlib/intern/math_base.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_base.c 2009-11-30 00:08:30 UTC (rev 25012)
+++ trunk/blender/source/blender/blenlib/intern/math_base.c 2009-11-30 00:18:36 UTC (rev 25013)
@@ -109,6 +109,35 @@
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) {
More information about the Bf-blender-cvs
mailing list