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:
Diffstat (limited to 'source/blender/bmesh/operators/bmo_edgesplit.c')
-rw-r--r--source/blender/bmesh/operators/bmo_edgesplit.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c
index 0da44dcf9d4..6601fb1cd48 100644
--- a/source/blender/bmesh/operators/bmo_edgesplit.c
+++ b/source/blender/bmesh/operators/bmo_edgesplit.c
@@ -32,6 +32,10 @@ enum {
EDGE_SEAM = 1
};
+enum {
+ VERT_SEAM = 2
+};
+
/**
* Remove the EDGE_SEAM flag for edges we cant split
*
@@ -58,7 +62,10 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op)
* only place we loop over all edges, disable tag */
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
- if (BM_edge_is_boundary(e)) {
+ if (e->l == NULL) {
+ BMO_elem_flag_disable(bm, e, EDGE_SEAM);
+ }
+ else if (BM_edge_is_boundary(e)) {
vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++;
vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++;
@@ -88,13 +95,35 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op)
MEM_freeN(vtouch);
}
+/* keep this operator fast, its used in a modifier */
void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
BMEdge *e;
+ const int use_verts = BMO_slot_bool_get(op, "use_verts");
BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_SEAM);
+ if (use_verts) {
+ /* this slows down the operation but its ok because the modifier doesn't use */
+ BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_SEAM);
+
+ /* prevent one edge having both verts unflagged
+ * we could alternately disable these edges, either way its a corner case.
+ *
+ * This is needed so we don't split off the edge but then none of its verts which
+ * would leave a duplicate edge.
+ */
+ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+ if (UNLIKELY((BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE &&
+ (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE))))
+ {
+ BMO_elem_flag_enable(bm, e->v1, VERT_SEAM);
+ BMO_elem_flag_enable(bm, e->v2, VERT_SEAM);
+ }
+ }
+ }
+
bm_edgesplit_validate_seams(bm, op);
BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
@@ -108,6 +137,17 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
}
}
+ if (use_verts) {
+ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+ if (BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE) {
+ BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
+ }
+ if (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE) {
+ BM_elem_flag_disable(e->v2, BM_ELEM_TAG);
+ }
+ }
+ }
+
BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) {
if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) {
@@ -121,5 +161,5 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_hflag(bm, op, "edgeout", BM_EDGE, BM_ELEM_INTERNAL_TAG);
+ BMO_slot_buffer_from_enabled_hflag(bm, op, "edgeout", BM_EDGE, BM_ELEM_INTERNAL_TAG);
}