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:
authorCampbell Barton <ideasman42@gmail.com>2015-04-30 00:22:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-30 00:22:18 +0300
commite9dcb068c749bc9e73450a4feb491551ede58c07 (patch)
treeb9e61bd343e014ee438df4121b85635fb3e563e6 /source/blender
parent99811c283efaa8f5bc13b81bb5cc42761c42a8a0 (diff)
Fix T44484: Edge-split corrupts mesh
Splitting non-manifold edges could produce duplicate edges.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/bmesh/operators/bmo_split_edges.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_edgesplit.c43
-rw-r--r--source/blender/bmesh/tools/bmesh_edgesplit.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c2
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c2
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c2
6 files changed, 48 insertions, 8 deletions
diff --git a/source/blender/bmesh/operators/bmo_split_edges.c b/source/blender/bmesh/operators/bmo_split_edges.c
index eb7946caff0..ca2088339cf 100644
--- a/source/blender/bmesh/operators/bmo_split_edges.c
+++ b/source/blender/bmesh/operators/bmo_split_edges.c
@@ -48,7 +48,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
}
/* this is where everything happens */
- BM_mesh_edgesplit(bm, use_verts, true, false);
+ BM_mesh_edgesplit(bm, use_verts, true, true, false);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG);
}
diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.c b/source/blender/bmesh/tools/bmesh_edgesplit.c
index c01b4880d7a..30ba07c2d8f 100644
--- a/source/blender/bmesh/tools/bmesh_edgesplit.c
+++ b/source/blender/bmesh/tools/bmesh_edgesplit.c
@@ -42,7 +42,7 @@
* un-tag edges not connected to other tagged edges,
* unless they are on a boundary
*/
-static void bm_edgesplit_validate_seams(BMesh *bm)
+static void bm_edgesplit_validate_seams(BMesh *bm, const bool use_non_manifold)
{
BMIter iter;
BMEdge *e;
@@ -72,6 +72,11 @@ static void bm_edgesplit_validate_seams(BMesh *bm)
* the edge its self can't be split */
BM_elem_flag_disable(e, BM_ELEM_TAG);
}
+ else if ((use_non_manifold == false) &&
+ (BM_edge_is_manifold(e) == false))
+ {
+ BM_elem_flag_disable(e, BM_ELEM_TAG);
+ }
}
/* single marked edges unconnected to any other marked edges
@@ -98,7 +103,16 @@ static void bm_edgesplit_validate_seams(BMesh *bm)
MEM_freeN(vtouch);
}
-void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, const bool copy_select)
+/**
+ * \param use_verts Use flagged verts instead of edges.
+ * \param use_non_manifold Split non-manifold edges (a little slower, must check for doubles).
+ * \param tag_only Only split tagged edges.
+ * \param copy_select Copy selection history.
+ */
+void BM_mesh_edgesplit(
+ BMesh *bm,
+ const bool use_verts, const bool use_non_manifold,
+ const bool tag_only, const bool copy_select)
{
BMIter iter;
BMEdge *e;
@@ -142,7 +156,7 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, con
}
}
- bm_edgesplit_validate_seams(bm);
+ bm_edgesplit_validate_seams(bm, use_non_manifold);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
@@ -204,6 +218,29 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, con
}
}
+ if (use_non_manifold) {
+ /* if we split non-manifold, double edge may remain */
+ BMEdge *e_next;
+ BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BMEdge *e_other;
+ if ((e_other = BM_edge_find_double(e))) {
+ BM_edge_splice(bm, e, e_other);
+ }
+ }
+ }
+ }
+ else {
+#ifndef NDEBUG
+ /* ensure we don't have any double edges! */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BLI_assert(BM_edge_find_double(e) == NULL);
+ }
+ }
+#endif
+ }
+
if (use_ese) {
BLI_ghash_free(ese_gh, NULL, NULL);
}
diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.h b/source/blender/bmesh/tools/bmesh_edgesplit.h
index bd66f6a9e2f..531af964a99 100644
--- a/source/blender/bmesh/tools/bmesh_edgesplit.h
+++ b/source/blender/bmesh/tools/bmesh_edgesplit.h
@@ -27,6 +27,9 @@
* \ingroup bmesh
*/
-void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, const bool copy_select);
+void BM_mesh_edgesplit(
+ BMesh *bm,
+ const bool use_verts, const bool use_non_manifold,
+ const bool tag_only, const bool copy_select);
#endif /* __BMESH_EDGESPLIT_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index ceb6ded5a43..76a289feaaa 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -1283,7 +1283,7 @@ bool BM_mesh_intersect(
BM_elem_flag_enable(e, BM_ELEM_TAG);
}
- BM_mesh_edgesplit(bm, false, true, false);
+ BM_mesh_edgesplit(bm, false, false, true, false);
}
#else
(void)use_separate;
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index f5d22eac641..7bd072ac6cb 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -941,7 +941,7 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve
fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm);
}
- BM_mesh_edgesplit(em->bm, true, true, true);
+ BM_mesh_edgesplit(em->bm, true, true, true, true);
/* note: the output of the bmesh operator is ignored, since we built
* the contiguous loop pairs to split already, its possible that some
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index fa29921b325..2e6360c3ded 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -91,7 +91,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
}
}
- BM_mesh_edgesplit(bm, false, true, false);
+ BM_mesh_edgesplit(bm, false, false, true, false);
/* BM_mesh_validate(bm); */ /* for troubleshooting */