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
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2020-01-02 03:06:59 +0300
committermano-wii <germano.costa@ig.com.br>2020-01-02 03:06:59 +0300
commitd27fb4671512a3834b61c5c350f428ddccc4669e (patch)
tree698c1355f9393c99dca24783bbbc6d6666ebc3e0 /source/blender/editors
parent86a2ffc3ab321f00317aa05fb423c4df6f68aced (diff)
EditMesh: Improve AutoMerge with Split Edges & Faces
Previously, compared to `Auto Merge` without `Split Edges & Faces`, `Auto Merge` with this option ignored duplicates between selected vertices. It only considered duplicates between selected vertices and unselected vertices. This is a regress and not a progress. This commit implements this behavior, so this option matches the other `Auto Merge`.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_mesh.h6
-rw-r--r--source/blender/editors/mesh/editmesh_automerge.c52
2 files changed, 47 insertions, 11 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 90ad90058e7..b28f645e982 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -144,9 +144,9 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree,
/* editmesh_automerge.c */
void EDBM_automerge(struct Object *ob, bool update, const char hflag, const float dist);
void EDBM_automerge_and_split(struct Object *ob,
- bool split_edges,
- bool split_faces,
- bool update,
+ const bool split_edges,
+ const bool split_faces,
+ const bool update,
const char hflag,
const float dist);
diff --git a/source/blender/editors/mesh/editmesh_automerge.c b/source/blender/editors/mesh/editmesh_automerge.c
index fb8ee85f9db..55b52e01fc3 100644
--- a/source/blender/editors/mesh/editmesh_automerge.c
+++ b/source/blender/editors/mesh/editmesh_automerge.c
@@ -92,9 +92,9 @@ void EDBM_automerge(Object *obedit, bool update, const char hflag, const float d
* \{ */
void EDBM_automerge_and_split(Object *obedit,
- bool UNUSED(split_edges),
- bool split_faces,
- bool update,
+ const bool UNUSED(split_edges),
+ const bool split_faces,
+ const bool update,
const char hflag,
const float dist)
{
@@ -126,18 +126,54 @@ void EDBM_automerge_and_split(Object *obedit,
ok = BM_mesh_intersect_edges(bm, hflag, dist, ghash_targetmap);
if (ok) {
+ GHashIterator gh_iter;
+ BMVert **v_survivors, **v_iter;
+ uint v_survivors_len = 0;
+ if (split_faces) {
+ BMVert *v_src, *v_dst;
+ GHASH_ITER (gh_iter, ghash_targetmap) {
+ v_src = BLI_ghashIterator_getKey(&gh_iter);
+ v_dst = BLI_ghashIterator_getValue(&gh_iter);
+ BM_elem_flag_disable(v_src, BM_ELEM_TAG);
+ BM_elem_flag_disable(v_dst, BM_ELEM_TAG);
+ }
+
+ int v_survivors_len_max = BLI_ghash_len(ghash_targetmap);
+ GHASH_ITER (gh_iter, ghash_targetmap) {
+ v_src = BLI_ghashIterator_getKey(&gh_iter);
+ v_dst = BLI_ghashIterator_getValue(&gh_iter);
+ if (!BM_elem_flag_test(v_src, BM_ELEM_TAG)) {
+ BM_elem_flag_enable(v_src, BM_ELEM_TAG);
+ }
+ if (BM_elem_flag_test(v_dst, BM_ELEM_TAG)) {
+ v_survivors_len_max--;
+ }
+ }
+
+ v_survivors = MEM_mallocN(sizeof(*v_survivors) * v_survivors_len_max, __func__);
+ v_iter = &v_survivors[0];
+ GHASH_ITER (gh_iter, ghash_targetmap) {
+ v_dst = BLI_ghashIterator_getValue(&gh_iter);
+ if (!BM_elem_flag_test(v_dst, BM_ELEM_TAG)) {
+ *v_iter = v_dst;
+ v_iter++;
+ v_survivors_len++;
+ }
+ }
+ }
+
BMO_op_exec(bm, &weldop);
BMEdge **edgenet = NULL;
int edgenet_alloc_len = 0;
if (split_faces) {
- GHashIterator gh_iter;
- GHASH_ITER (gh_iter, ghash_targetmap) {
- BMVert *v = BLI_ghashIterator_getValue(&gh_iter);
- // BLI_assert(BM_elem_flag_test(v, hflag) || hflag == BM_ELEM_TAG);
+ v_iter = &v_survivors[0];
+ for (int i = v_survivors_len; i--; v_iter++) {
BM_vert_weld_linked_wire_edges_into_linked_faces(
- bm, v, dist, &edgenet, &edgenet_alloc_len);
+ bm, *v_iter, dist, &edgenet, &edgenet_alloc_len);
}
+
+ MEM_freeN(v_survivors);
}
if (edgenet) {