diff options
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 29 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 19 |
2 files changed, 25 insertions, 23 deletions
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index c5e2aff0bc2..2469737c76c 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -189,6 +189,18 @@ void ED_lattice_transform(Lattice *lt, float mat[4][4]) DAG_id_tag_update(<->id, 0); } +static void bpoint_select_set(BPoint *bp, bool select) +{ + if (select) { + if (!bp->hide) { + bp->f1 |= SELECT; + } + } + else { + bp->f1 &= ~SELECT; + } +} + /************************** Select Random Operator **********************/ static int lattice_select_random_exec(bContext *C, wmOperator *op) @@ -196,27 +208,26 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; + const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); + int tot; BPoint *bp; - if (!RNA_boolean_get(op->ptr, "extend")) { - ED_setflagsLatt(obedit, !SELECT); - } - else { - lt->actbp = LT_ACTBP_NONE; - } - tot = lt->pntsu * lt->pntsv * lt->pntsw; bp = lt->def; while (tot--) { if (!bp->hide) { if (BLI_frand() < randfac) { - bp->f1 |= SELECT; + bpoint_select_set(bp, select); } } bp++; } + if (select == false) { + lt->actbp = LT_ACTBP_NONE; + } + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -239,7 +250,7 @@ void LATTICE_OT_select_random(wmOperatorType *ot) /* props */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); - RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); + WM_operator_properties_select_action_simple(ot, SEL_SELECT); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index fc83919144f..8e7e97aad86 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -1128,23 +1128,14 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot) static int object_select_random_exec(bContext *C, wmOperator *op) { float percent; - bool extend; - - extend = RNA_boolean_get(op->ptr, "extend"); - - if (extend == false) { - CTX_DATA_BEGIN (C, Base *, base, visible_bases) - { - ED_base_object_select(base, BA_DESELECT); - } - CTX_DATA_END; - } + const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); + percent = RNA_float_get(op->ptr, "percent") / 100.0f; - CTX_DATA_BEGIN (C, Base *, base, visible_bases) + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (BLI_frand() < percent) { - ED_base_object_select(base, BA_SELECT); + ED_base_object_select(base, select); } } CTX_DATA_END; @@ -1171,5 +1162,5 @@ void OBJECT_OT_select_random(wmOperatorType *ot) /* properties */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); - RNA_def_boolean(ot->srna, "extend", FALSE, "Extend Selection", "Extend selection instead of deselecting everything first"); + WM_operator_properties_select_action_simple(ot, SEL_SELECT); } |