[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35648] branches/bmesh/blender/source/ blender/bmesh/intern/bmesh_polygon.c: fix bug in calculating polygon normal , was passing double arrays to copy_v3v3()

Campbell Barton ideasman42 at gmail.com
Sun Mar 20 15:01:10 CET 2011


Revision: 35648
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35648
Author:   campbellbarton
Date:     2011-03-20 14:01:10 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
fix bug in calculating polygon normal, was passing double arrays to copy_v3v3()

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c	2011-03-20 13:54:03 UTC (rev 35647)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c	2011-03-20 14:01:10 UTC (rev 35648)
@@ -90,8 +90,8 @@
 static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts)
 {
 
-	double u[3],  v[3], w[3];/*, *w, v1[3], v2[3];*/
-	double n[3] = {0.0, 0.0, 0.0}, l /*, v1[3], v2[3] */;
+	float u[3],  v[3], w[3];/*, *w, v1[3], v2[3];*/
+	float n[3] = {0.0, 0.0, 0.0}, l /*, v1[3], v2[3] */;
 	/* double l2; */
 	int i /*, s=0 */;
 
@@ -131,7 +131,12 @@
 		n[1] += (u[2] - v[2]) * (u[0] + v[0]);
 		n[2] += (u[0] - v[0]) * (u[1] + v[1]);
 	}
-	
+
+	if(normalize_v3_v3(normal, n) == 0.0f) {
+		normal[2] = 1.0f; /* other axis set to 0.0 */
+	}
+
+#if 0
 	l = n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
 	l = sqrt(l);
 	/*fast square root, newton/babylonian method:
@@ -157,6 +162,7 @@
 	normal[0] = (float) n[0];
 	normal[1] = (float) n[1];
 	normal[2] = (float) n[2];
+#endif
 }
 
 /*




More information about the Bf-blender-cvs mailing list