[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25408] trunk/blender/source/blender/ editors/mesh/editmesh_lib.c: Solidify was faiing in cases with flat aras because normal calculation assumed some angle between faces .

Campbell Barton ideasman42 at gmail.com
Wed Dec 16 00:35:26 CET 2009


Revision: 25408
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25408
Author:   campbellbarton
Date:     2009-12-16 00:35:26 +0100 (Wed, 16 Dec 2009)

Log Message:
-----------
Solidify was faiing in cases with flat aras because normal calculation assumed some angle between faces.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_lib.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_lib.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_lib.c	2009-12-15 18:53:16 UTC (rev 25407)
+++ trunk/blender/source/blender/editors/mesh/editmesh_lib.c	2009-12-15 23:35:26 UTC (rev 25408)
@@ -528,7 +528,7 @@
 /* flush selection to edges & faces */
 
 /*  this only based on coherent selected vertices, for example when adding new
-    objects. call clear_flag_all() before you select vertices to be sure it ends OK!
+	objects. call clear_flag_all() before you select vertices to be sure it ends OK!
 	
 */
 
@@ -2360,11 +2360,22 @@
 		edge_ref = BLI_edgehashIterator_getValue(edge_iter);
 
 		if (edge_ref->f2 != -1) {
-			/* We have 2 faces using this edge, calculate the edges normal
-			 * using the angle between the 2 faces as a weighting */
-			add_v3_v3v3(edge_normal, EM_get_face_for_index(edge_ref->f1)->n, EM_get_face_for_index(edge_ref->f2)->n);
-			normalize_v3(edge_normal);
-			mul_v3_fl(edge_normal, angle_normalized_v3v3(EM_get_face_for_index(edge_ref->f1)->n, EM_get_face_for_index(edge_ref->f2)->n));
+			EditFace *ef1= EM_get_face_for_index(edge_ref->f1), *ef2= EM_get_face_for_index(edge_ref->f2);
+			float angle= angle_normalized_v3v3(ef1->n, ef2->n);
+			if(angle > 0.0f) {
+				/* We have 2 faces using this edge, calculate the edges normal
+				 * using the angle between the 2 faces as a weighting */
+				add_v3_v3v3(edge_normal, ef1->n, ef2->n);
+				normalize_v3(edge_normal);
+				mul_v3_fl(edge_normal, angle);
+			}
+			else {
+				/* cant do anything useful here!
+				   Set the face index for a vert incase it gets a zero normal */
+				EM_get_vert_for_index(ed_v1)->tmp.l=
+				EM_get_vert_for_index(ed_v2)->tmp.l= -(edge_ref->f1 + 1);
+				continue;
+			}
 		} else {
 			/* only one face attached to that edge */
 			/* an edge without another attached- the weight on this is
@@ -2382,8 +2393,13 @@
 	MEM_freeN(edge_ref_array);
 
 	/* normalize vertex normals and assign */
-	for(eve= em->verts.first; eve; eve= eve->next)
-		normalize_v3(eve->no);
+	for(eve= em->verts.first; eve; eve= eve->next) {
+		if(normalize_v3(eve->no) == 0.0f && eve->tmp.l < 0) {
+			/* exceptional case, totally flat */
+			efa= EM_get_face_for_index(-(eve->tmp.l) - 1);
+			VECCOPY(eve->no, efa->n);
+		}	
+	}
 
 	EM_free_index_arrays();
 }





More information about the Bf-blender-cvs mailing list