Page MenuHome

bisect_split.patch

File Metadata

Author
Martin Felke (scorpion81)
Created
Nov 13 2013, 5:16 PM

bisect_split.patch

Index: source/blender/editors/mesh/editmesh_bisect.c
===================================================================
--- source/blender/editors/mesh/editmesh_bisect.c (Revision 60953)
+++ source/blender/editors/mesh/editmesh_bisect.c (Arbeitskopie)
@@ -194,6 +194,7 @@
const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
const bool clear_inner = RNA_boolean_get(op->ptr, "clear_inner");
const bool clear_outer = RNA_boolean_get(op->ptr, "clear_outer");
+ const bool use_split = RNA_boolean_get(op->ptr, "use_split");
PropertyRNA *prop_plane_co;
PropertyRNA *prop_plane_no;
@@ -251,14 +252,56 @@
BMO_op_exec(bm, &bmop);
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom_cut.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
+
+ if (use_split) {
+ float normal_fill[3];
+ BMOperator bmop_split;
+ BMOperator bmop_fill;
+
+ normalize_v3_v3(normal_fill, plane_no);
+
+ if (clear_outer == true && clear_inner == false) {
+ negate_v3(normal_fill);
+ }
+
+ /* select loop to region */
+ WM_operator_name_call(C, "MESH_OT_loop_to_region", WM_OP_INVOKE_DEFAULT, NULL);
+ /* Split */
+ BMO_op_initf(
+ bm, &bmop_split, op->flag,
+ "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, false);
+ BMO_op_exec(bm, &bmop_split);
+
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+ BMO_slot_buffer_hflag_enable(bm, bmop_split.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+
+ /*select region to loop */
+ WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, NULL);
+
+ /* Fill the open side of the other island */
+ if (use_fill)
+ {
+ BMO_op_initf(
+ bm, &bmop_fill, op->flag,
+ "triangle_fill edges=%he normal=%v use_dissolve=%b", BM_ELEM_SELECT, normal_fill, true);
+ BMO_op_exec(bm, &bmop_fill);
+
+ BMO_op_finish(bm, &bmop_fill);
+ }
+
+ BMO_op_finish(bm, &bmop_split);
+ }
+
if (use_fill) {
float normal_fill[3];
BMOperator bmop_fill;
BMOperator bmop_attr;
normalize_v3_v3(normal_fill, plane_no);
- if (clear_outer == true && clear_inner == false) {
+ if ((clear_outer == true && clear_inner == false) || use_split) {
negate_v3(normal_fill);
}
@@ -275,18 +318,27 @@
&bmop_fill, "geom.out", false, true);
BMO_op_exec(bm, &bmop_attr);
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
BMO_slot_buffer_hflag_enable(bm, bmop_fill.slots_out, "geom.out", BM_FACE, BM_ELEM_SELECT, true);
+ BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom_cut.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
BMO_op_finish(bm, &bmop_attr);
BMO_op_finish(bm, &bmop_fill);
}
+ else
+ {
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+ BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom_cut.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
+ }
- BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom_cut.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
-
if (!EDBM_op_finish(em, &bmop, op, true)) {
return OPERATOR_CANCELLED;
}
else {
+ if (use_split)
+ /* Geometry has changed, need to recalc normals and looptris */
+ EDBM_mesh_normals_update(em);
+
EDBM_update_generic(em, true, true);
EDBM_selectmode_flush(em);
return OPERATOR_FINISHED;
@@ -324,6 +376,7 @@
RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill in the cut");
RNA_def_boolean(ot->srna, "clear_inner", false, "Clear Inner", "Remove geometry behind the plane");
RNA_def_boolean(ot->srna, "clear_outer", false, "Clear Outer", "Remove geometry in front of the plane");
+ RNA_def_boolean(ot->srna, "use_split", false, "Split", "Split the two halves to separate islands");
RNA_def_float(ot->srna, "threshold", 0.0001, 0.0, 10.0, "Axis Threshold", "", 0.00001, 0.1);

Event Timeline