author Brecht Van Lommel Tue, 20 Mar 2012 19:32:31 +0000 (19:32 +0000) committer Brecht Van Lommel Tue, 20 Mar 2012 19:32:31 +0000 (19:32 +0000)
arbitrary limit of pi/24 for picking 3 vertices to use for computing a normal,
now it uses vertices with the maximum angle between them.

index 6a20d8582145d740420322464ff7b80b90de71c7..420481f165bf0a1ca475a7e78d6c577db3231da7 100644 (file)
@@ -872,30 +872,29 @@ int BLI_edgefill(short mat_nr)
/* just use the first three different vertices */

/* THIS PART STILL IS PRETTY WEAK! (ton) */
-
+
eve= fillvertbase.last;
len= 0.0;
v1= eve->co;
v2= 0;
eve= fillvertbase.first;
-       limit = a < 5 ? FLT_EPSILON*200 : M_PI/24.0;
+       limit = 1e-8f;
+
while(eve) {
if(v2) {
-                       if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) {
+                       if(!compare_v3v3(v2, eve->co, COMPLIMIT)) {
float inner = angle_v3v3v3(v1, v2, eve->co);
-
-                               if (fabsf(inner-M_PI) < limit || fabsf(inner) < limit) {
-                                       eve = eve->next;
-                                       continue;
-                               }
+                               inner = MIN2(fabsf(inner), fabsf(M_PI - inner));

-                               len= normal_tri_v3( norm,v1, v2, eve->co);
-                               if(len != 0.0f) break;
+                               if(inner > limit) {
+                                       limit = inner;
+                                       len= normal_tri_v3(norm, v1, v2, eve->co);
+                               }
}
}
-               else if(compare_v3v3(v1, eve->co, COMPLIMIT)==0) {
+               else if(!compare_v3v3(v1, eve->co, COMPLIMIT))
v2= eve->co;
-               }
+
eve= eve->next;
}