Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_select.c
| Context not available. | |||||
| static int object_select_random_exec(bContext *C, wmOperator *op) | static int object_select_random_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| float percent; | float percent; | ||||
| bool extend; | const int action = RNA_enum_get(op->ptr, "action"); | ||||
| 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; | |||||
| } | |||||
| percent = RNA_float_get(op->ptr, "percent") / 100.0f; | percent = RNA_float_get(op->ptr, "percent") / 100.0f; | ||||
| CTX_DATA_BEGIN (C, Base *, base, visible_bases) | CTX_DATA_BEGIN (C, Base *, base, visible_bases) | ||||
| { | { | ||||
| if (BLI_frand() < percent) { | if (BLI_frand() < percent) { | ||||
| ED_base_object_select(base, BA_SELECT); | switch (action) { | ||||
| case SEL_SELECT: | |||||
| ED_base_object_select(base, BA_SELECT); | |||||
| break; | |||||
| case SEL_DESELECT: | |||||
| ED_base_object_select(base, BA_DESELECT); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| Context not available. | |||||
| void OBJECT_OT_select_random(wmOperatorType *ot) | void OBJECT_OT_select_random(wmOperatorType *ot) | ||||
| { | { | ||||
| static EnumPropertyItem select_actions[] = { | |||||
| {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | |||||
| {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Select Random"; | ot->name = "Select Random"; | ||||
| ot->description = "Set select on random visible objects"; | ot->description = "Set select on random visible objects"; | ||||
| Context not available. | |||||
| /* properties */ | /* 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_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"); | RNA_def_enum(ot->srna, "action", select_actions, SEL_SELECT, "Action", "Selection action to execute"); | ||||
| } | } | ||||
| Context not available. | |||||