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>2014-01-13 13:36:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-13 13:39:12 +0400
commit7ae1949517a41fbc46ca452f3fa40e7079273503 (patch)
tree64c329f903b2e9b70758c8dbf7789b71110bb94b /source/blender/editors/object/object_lattice.c
parentf0fb60f8c968f482cefd25db11d080c268c2045d (diff)
Select Random: add option to de-select
also made metaball operator behave like the others. Path originally from Walid Shouman, with own edits.
Diffstat (limited to 'source/blender/editors/object/object_lattice.c')
-rw-r--r--source/blender/editors/object/object_lattice.c29
1 files changed, 20 insertions, 9 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(&lt->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);
}