diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_extrude_spin.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude_spin.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 5f1670bf57d..a9e78f74012 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -61,16 +61,18 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) BMOperator spinop; float cent[3], axis[3]; float d[3] = {0.0f, 0.0f, 0.0f}; - int steps, dupli; - float angle; RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); - steps = RNA_int_get(op->ptr, "steps"); - angle = RNA_float_get(op->ptr, "angle"); - //if (ts->editbutflag & B_CLOCKWISE) - angle = -angle; - dupli = RNA_boolean_get(op->ptr, "dupli"); + const int steps = RNA_int_get(op->ptr, "steps"); + const float angle = RNA_float_get(op->ptr, "angle"); + const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip") ^ (angle < 0.0f); + const bool dupli = RNA_boolean_get(op->ptr, "dupli"); + const bool use_auto_merge = ( + RNA_boolean_get(op->ptr, "use_auto_merge") && + (dupli == false) && + (steps >= 3) && + fabsf((fabsf(angle) - (M_PI * 2))) <= 1e-6f); if (is_zero_v3(axis)) { BKE_report(op->reports, RPT_ERROR, "Invalid/unset axis"); @@ -78,15 +80,20 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) } /* keep the values in worldspace since we're passing the obmat */ - if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b", - BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, dupli)) + if (!EDBM_op_init( + em, &spinop, op, + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 " + "use_normal_flip=%b use_duplicate=%b use_merge=%b", + BM_ELEM_SELECT, cent, axis, d, steps, -angle, obedit->obmat, + use_normal_flip, dupli, use_auto_merge)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &spinop); - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + if (use_auto_merge == false) { + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + } if (!EDBM_op_finish(em, &spinop, op, true)) { return OPERATOR_CANCELLED; } @@ -118,6 +125,21 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e return edbm_spin_exec(C, op); } +static bool edbm_spin_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + const bool dupli = RNA_boolean_get(op->ptr, "dupli"); + + if (dupli) { + if (STREQ(prop_id, "use_auto_merge") || + STREQ(prop_id, "use_normal_flip")) + { + return false; + } + } + return true; +} + void MESH_OT_spin(wmOperatorType *ot) { PropertyRNA *prop; @@ -131,6 +153,7 @@ void MESH_OT_spin(wmOperatorType *ot) ot->invoke = edbm_spin_invoke; ot->exec = edbm_spin_exec; ot->poll = ED_operator_editmesh; + ot->poll_property = edbm_spin_poll_property; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -141,6 +164,8 @@ void MESH_OT_spin(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "angle", DEG2RADF(90.0f), -1e12f, 1e12f, "Angle", "Rotation for each step", DEG2RADF(-360.0f), DEG2RADF(360.0f)); RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_boolean(ot->srna, "use_auto_merge", true, "Auto Merge", "Merge first/last when the angle is a full revolution"); + RNA_def_boolean(ot->srna, "use_normal_flip", 0, "Flip Normals", ""); RNA_def_float_vector(ot->srna, "center", 3, NULL, -1e12f, 1e12f, "Center", "Center in global view space", -1e4f, 1e4f); |