Merging r48981 through r48984 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 16 Jul 2012 19:24:25 +0000 (19:24 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 16 Jul 2012 19:24:25 +0000 (19:24 +0000)
1  2 
source/blender/blenkernel/intern/mask.c

index 86838c5565aad3c0fea3bdd08514bf76b203dc6f,7eb06a1b9caa9196dff5de993ee422e5aa9b2a5c..d86e2c72ebede9121a43e1a7b0f8882112285ff7
@@@ -469,11 -455,24 +470,32 @@@ static void feather_bucket_check_inters
  
                        isect_seg_seg_v2_point(v1, v2, v3, v4, p);
  
-                       for (k = check_b; k <= cur_a; k++) {
-                               copy_v2_v2(feather_points[k], p);
+                       /* TODO: for now simply choose the shortest loop, could be made smarter in some way */
+                       len = cur_a - check_b;
+                       if (len < tot_feather_point - len) {
+                               for (k = check_b; k <= cur_a; k++) {
+                                       copy_v2_v2(feather_points[k], p);
+                               }
+                       }
+                       else {
 -                              for (k = 0; k <= check_a; k++) {
 -                                      copy_v2_v2(feather_points[k], p);
++                              if (cur_b < check_a) {
++                                      /* special case when intersection happens with first segment */
++                                      for (k = cur_b; k <= check_a; k++) {
++                                              copy_v2_v2(feather_points[k], p);
++                                      }
+                               }
++                              else {
++                                      for (k = 0; k <= check_a; k++) {
++                                              copy_v2_v2(feather_points[k], p);
++                                      }
 -                              if (cur_b != 0) {
+                                       for (k = cur_b; k < tot_feather_point; k++) {
+                                               copy_v2_v2(feather_points[k], p);
+                                       }
+                               }
                        }
 +
 +                      break;
                }
        }
  }