[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48984] trunk/blender/source/blender/ blenkernel/intern/mask.c: Fixed disappearing in some circumstances feather

Sergey Sharybin sergey.vfx at gmail.com
Mon Jul 16 21:23:16 CEST 2012


Revision: 48984
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48984
Author:   nazgul
Date:     2012-07-16 19:23:15 +0000 (Mon, 16 Jul 2012)
Log Message:
-----------
Fixed disappearing in some circumstances feather

Real fix would be to find a point which is definitely now on loop
to be collapsed, but that's for a bit later. This commit should
remove possible stoppers.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mask.c

Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c	2012-07-16 19:15:26 UTC (rev 48983)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c	2012-07-16 19:23:15 UTC (rev 48984)
@@ -431,7 +431,8 @@
 	bucket->tot_segment++;
 }
 
-static void feather_bucket_check_intersect(float (*feather_points)[2], FeatherEdgesBucket *bucket, int cur_a, int cur_b)
+static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_feather_point, FeatherEdgesBucket *bucket,
+                                           int cur_a, int cur_b)
 {
 	int i;
 
@@ -449,21 +450,43 @@
 			continue;
 
 		if (isect_seg_seg_v2(v1, v2, v3, v4)) {
-			int k;
+			int k, len;
 			float p[2];
 
 			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 {
+				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);
+					}
 
+					for (k = cur_b; k < tot_feather_point; k++) {
+						copy_v2_v2(feather_points[k], p);
+					}
+				}
+			}
+
 			break;
 		}
 	}
 }
 
-static int feather_bucket_index_from_coord(float co[2], float min[2], float max[2], const int buckets_per_side, const float bucket_size)
+static int feather_bucket_index_from_coord(float co[2], float min[2], float max[2],
+                                           const int buckets_per_side, const float bucket_size)
 {
 #define BUCKET_SIDE_INDEX(co, min, max) ((int) ((co - min) / (max - min) / bucket_size))
 
@@ -526,10 +549,10 @@
 		FeatherEdgesBucket *start_bucket = &buckets[start_bucket_index];
 		FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index];
 
-		feather_bucket_check_intersect(feather_points, start_bucket, cur_a, cur_b);
+		feather_bucket_check_intersect(feather_points, tot_feather_point, start_bucket, cur_a, cur_b);
 
 		if (start_bucket != end_bucket)
-			feather_bucket_check_intersect(feather_points, end_bucket, cur_a, cur_b);
+			feather_bucket_check_intersect(feather_points, tot_feather_point, end_bucket, cur_a, cur_b);
 	}
 
 	/* free buckets */




More information about the Bf-blender-cvs mailing list