diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2016-09-27 12:21:44 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2016-09-27 21:54:54 +0300 |
commit | 13a4147c17f82681c29fcc25cce86aff1702f2d1 (patch) | |
tree | 40a357b5da5a5b987c08187d7eabc353b37f83d5 /source/blender/blenkernel/intern/dynamicpaint.c | |
parent | 9a66d0ad1b18f02a486a9e691f71896275ea1cdc (diff) |
Dynamic Paint: Don't store duplicate adjacency links.
Duplicates can happen at UV seams in case of resolution mismatch
or other complications. It's better not to store them in case it
confuses some math later on.
Reviewers: mont29
Differential Revision: https://developer.blender.org/D2261
Diffstat (limited to 'source/blender/blenkernel/intern/dynamicpaint.c')
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 2a01a7a962b..c7399047ed5 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2673,6 +2673,7 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, flo const int index = tx + w * ty; if (tempPoints[index].tri_index != -1) { + int start_pos = n_pos; ed->n_index[final_index[index]] = n_pos; ed->n_num[final_index[index]] = 0; @@ -2681,10 +2682,20 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, flo const int n_target = dynamic_paint_find_neighbour_pixel( &data, vert_to_looptri_map, w, h, tx, ty, i); - if (n_target >= 0) { - ed->n_target[n_pos] = final_index[n_target]; - ed->n_num[final_index[index]]++; - n_pos++; + if (n_target >= 0 && n_target != index) { + bool duplicate = false; + for (int j = start_pos; j < n_pos; j++) { + if (ed->n_target[j] == final_index[n_target]) { + duplicate = true; + break; + } + } + + if (!duplicate) { + ed->n_target[n_pos] = final_index[n_target]; + ed->n_num[final_index[index]]++; + n_pos++; + } } else if (n_target == ON_MESH_EDGE || n_target == OUT_OF_TEXTURE) { ed->flags[final_index[index]] |= ADJ_ON_MESH_EDGE; |