Sculpt:
[blender.git] / source / blender / blenkernel / intern / CCGSubSurf.c
index 86595de..7c2c6d4 100644 (file)
@@ -3,12 +3,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include <float.h>
 
 #include "CCGSubSurf.h"
 
 #include "BLO_sys_types.h" // for intptr_t support
 
+/* used for normalize_v3 in BLI_math_vector
+ * float.h's FLT_EPSILON causes trouble with subsurf normals - campbell */
+#define EPSILON (1.0e-35f)
+
 /***/
 
 typedef unsigned char  byte;
@@ -593,7 +596,7 @@ void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int lev
 
        length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
 
-       if (length>FLT_EPSILON) {
+       if (length>EPSILON) {
                float invLength = 1.f/length;
 
                no[0] *= invLength;
@@ -1232,7 +1235,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
 
                length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
 
-               if (length>FLT_EPSILON) {
+               if (length>EPSILON) {
                        float invLength = 1.0f/length;
                        no[0] *= invLength;
                        no[1] *= invLength;
@@ -1291,7 +1294,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
                                        float *no = FACE_getIFNo(f, lvl, S, x, y);
                                        float length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
 
-                                       if (length>FLT_EPSILON) {
+                                       if (length>EPSILON) {
                                                float invLength = 1.0f/length;
                                                no[0] *= invLength;
                                                no[1] *= invLength;