Revision: 41034
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41034
Author:   ender79
Date:     2011-10-15 14:46:26 +0000 (Sat, 15 Oct 2011)
Log Message:
-----------
More solidify cleanup: comment updates and make shell_angle_to_dist a 
continuous function in the edge case 

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenlib/intern/math_base_inline.c
    branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c

Modified: 
branches/bmesh/blender/source/blender/blenlib/intern/math_base_inline.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/math_base_inline.c     
2011-10-15 14:21:03 UTC (rev 41033)
+++ branches/bmesh/blender/source/blender/blenlib/intern/math_base_inline.c     
2011-10-15 14:46:26 UTC (rev 41034)
@@ -41,7 +41,7 @@
 #define BLI_MATH_BASE_INLINE_H
 
 /* A few small defines. Keep'em local! */
-#define SMALL_NUMBER   1.e-8
+#define SMALL_NUMBER   1.e-8f
 
 MINLINE float sqrt3f(float f)
 {
@@ -108,7 +108,7 @@
  * the distance gets very high, 180d would be inf, but this case isn't valid */
 MINLINE float shell_angle_to_dist(const float angle)
 {
-       return (angle < (float)SMALL_NUMBER) ? 1.0f : fabsf(1.0f / cosf(angle));
+       return (1.0f + SMALL_NUMBER) / (fabs(cosf(angle)) + SMALL_NUMBER);
 }
 
 /* used for zoom values*/

Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c  
2011-10-15 14:21:03 UTC (rev 41033)
+++ branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c  
2011-10-15 14:46:26 UTC (rev 41034)
@@ -334,9 +334,10 @@
 }
 
 /*
- *  Compute higher-quality vertex normals used by solidify.
- *  Note that this will not work for non-manifold regions.
- *
+ * Compute higher-quality vertex normals used by solidify.
+ * Only considers geometry in the marked solidify region.
+ * Note that this does not work so well for non-manifold
+ * regions.
  */
 static void calc_solidify_normals(BMesh *bm)
 {
@@ -347,8 +348,6 @@
        float edge_normal[3];
        int i;
 
-       BM_Compute_Normals(bm);
-
        /* Clear indices of verts & edges */
        BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
                BM_SetIndex(v, 0);
@@ -363,11 +362,12 @@
                }
 
                BM_ITER(e, &eiter, bm, BM_EDGES_OF_FACE, f) {
+                       /* Count number of marked faces using e */
                        i = BM_GetIndex(e);
-                       /* Count number of marked faces using each edge */
                        BM_SetIndex(e, i+1);
 
-                       /* And mark the edges and verts around marked faces */
+                       /* And mark all edges and vertices on the
+                          marked faces */
                        BMO_SetFlag(bm, e, EDGE_MARK);
                        BMO_SetFlag(bm, e->v1, VERT_MARK);
                        BMO_SetFlag(bm, e->v2, VERT_MARK);
@@ -404,10 +404,18 @@
        BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
                float angle;
                
-               if (!BMO_TestFlag(bm, e, EDGE_MARK) || BMO_TestFlag(bm, e, 
EDGE_NONMAN)) {
+               /* If the edge is not part of a the solidify region
+                  its normal should not be considered */
+               if (!BMO_TestFlag(bm, e, EDGE_MARK)) {
                        continue;
                }
 
+               /* If the edge joins more than two marked faces high
+                  quality normal computation won't work */
+               if (BMO_TestFlag(bm, e, EDGE_NONMAN)) {
+                       continue;
+               }
+
                f1 = f2 = NULL;
 
                BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
@@ -415,7 +423,8 @@
                                if (f1 == NULL) {
                                        f1 = f;
                                }
-                               else if (f2 == NULL) {
+                               else {
+                                       BLI_assert(f2 == NULL);
                                        f2 = f;
                                }
                        }
@@ -427,7 +436,7 @@
                        angle = angle_normalized_v3v3(f1->no, f2->no);
 
                        if (angle > 0.0f) {
-                               /* two faces using this edge, calculate the 
edges normal
+                               /* two faces using this edge, calculate the 
edge normal
                                 * using the angle between the faces as a 
weighting */
                                add_v3_v3v3(edge_normal, f1->no, f2->no);
                                normalize_v3(edge_normal);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to