Revision: 14318
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14318
Author:   campbellbarton
Date:     2008-04-02 18:19:12 +0200 (Wed, 02 Apr 2008)

Log Message:
-----------
Sculpts calc_area_normal() could result in a zero length vector if all faces 
were pointing away from the view.
deal with this by making 2 average vectors, one for front pointing faces, and 
another for back pointing faces,
also removed an unneeded acos().

Modified Paths:
--------------
    trunk/blender/source/blender/src/sculptmode.c

Modified: trunk/blender/source/blender/src/sculptmode.c
===================================================================
--- trunk/blender/source/blender/src/sculptmode.c       2008-04-02 15:03:03 UTC 
(rev 14317)
+++ trunk/blender/source/blender/src/sculptmode.c       2008-04-02 16:19:12 UTC 
(rev 14318)
@@ -418,14 +418,17 @@
        }               
 }
 
-void add_norm_if(const BrushAction *a, float out[3], const short no[3])
+static void add_norm_if(const BrushAction *a, float out[3], float out_flip[3], 
const short no[3])
 {
        float fno[3] = {no[0], no[1], no[2]};
 
        Normalize(fno);
 
-       if(acos(Inpf(((BrushAction*)a)->symm.out, fno)) < M_PI_2)
+       if((Inpf(((BrushAction*)a)->symm.out, fno)) < 0) {
                VecAddf(out, out, fno);
+       } else if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) {
+               VecAddf(out_flip, out_flip, fno); /* out_flip is used when out 
is {0,0,0} */
+       }
 }
 
 /* Currently only for the draw brush; finds average normal for all active
@@ -435,18 +438,23 @@
        Mesh *me = get_mesh(OBACT);
        ActiveData *node = active_verts->first;
        const int view = sculpt_data()->brush_type==DRAW_BRUSH ? 
sculptmode_brush()->view : 0;
+       float out_flip[3];
+       
+       out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0;
 
-       out[0] = out[1] = out[2] = 0;
-
        if(sculptmode_brush()->flag & SCULPT_BRUSH_ANCHORED) {
                for(; node; node = node->next)
-                       add_norm_if(a, out, a->orig_norms[node->Index]);
+                       add_norm_if(a, out, out_flip, 
a->orig_norms[node->Index]);
        }
        else {
                for(; node; node = node->next)
-                       add_norm_if(a, out, me->mvert[node->Index].no);
+                       add_norm_if(a, out, out_flip, 
me->mvert[node->Index].no);
        }
 
+       if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) {
+               VECCOPY(out, out_flip);
+       }
+       
        Normalize(out);
 
        if(outdir) {
@@ -690,9 +698,11 @@
                VecSubf(val, intr, co);
                VecMulf(val, node->Fade);
                VecAddf(val, val, co);
-                                    
+               
                sculpt_clip(a, co, val);
-               
+               if (isnan(co[0]) || isnan(co[1]) || isnan(co[2])) {
+                       printf("NAN\n");
+               } 
                node= node->next;
        }
 }


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

Reply via email to