Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-07-16 23:23:15 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-07-16 23:23:15 +0400
commit1f96470b5d80f05aef1dc1c262ba1a0a56a1d1fb (patch)
treeba5dbc0907f7bd70cbd4be33929cb5278056a45e /source
parent5915b533508d4414b1f8f2351d85f6a87b3c14f8 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/mask.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index a5ec9743ae6..7eb06a1b9ca 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -411,7 +411,7 @@ typedef struct FeatherEdgesBucket {
static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end)
{
- const int alloc_delta = 20;
+ const int alloc_delta = 32;
if (bucket->tot_segment >= bucket->alloc_segment) {
if (!bucket->segments) {
@@ -431,7 +431,8 @@ static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int e
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,35 @@ static void feather_bucket_check_intersect(float (*feather_points)[2], FeatherEd
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 {
+ for (k = 0; k <= check_a; k++) {
+ copy_v2_v2(feather_points[k], p);
+ }
- break;
+ if (cur_b != 0) {
+ for (k = cur_b; k < tot_feather_point; k++) {
+ copy_v2_v2(feather_points[k], p);
+ }
+ }
+ }
}
}
}
-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 +541,10 @@ static void spline_feather_collapse_inner_loops(float (*feather_points)[2], int
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 */