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>2015-10-10 15:47:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-10 15:52:11 +0300
commit05acf3d43a1d9655ee41d68470647d9409eaff40 (patch)
tree751802b51470d2225ec3442f031778553ba61482 /source/blender/editors/object/object_select.c
parent240f356166e70dc495b44a4628d36181c93ff1a0 (diff)
Random Select Seed Option
Add 'Seed' option for all random select operators D1508 by @mba105, w/ edits
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r--source/blender/editors/object/object_select.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index f69f76cbcc3..2f2eece8018 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -1179,19 +1179,22 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot)
static int object_select_random_exec(bContext *C, wmOperator *op)
{
- float percent;
+ const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
+ const int seed = RNA_int_get(op->ptr, "seed");
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
- percent = RNA_float_get(op->ptr, "percent") / 100.0f;
-
+ RNG *rng = BLI_rng_new_srandom(seed);
+
CTX_DATA_BEGIN (C, Base *, base, selectable_bases)
{
- if (BLI_frand() < percent) {
+ if (BLI_rng_get_float(rng) < randfac) {
ED_base_object_select(base, select);
}
}
CTX_DATA_END;
-
+
+ BLI_rng_free(rng);
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
@@ -1213,6 +1216,5 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* 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);
- WM_operator_properties_select_action_simple(ot, SEL_SELECT);
+ WM_operator_properties_select_random(ot);
}