diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-03-28 17:20:45 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-04-05 11:36:09 +0300 |
commit | 0f5ca755fc0056341cbbe74f87cc2dce9fb4f299 (patch) | |
tree | 930a0dddfd61a431c5853c8473b77ce381686c76 /source/blender | |
parent | 611e544191fa7fa89ed299c5aa3ab9ea5a82bdfe (diff) |
Fix T47969: Select Random always uses same seed
Increment the seed on each use,
otherwise calling again selects the same order, unless you manually adjust the seed.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/curve/editcurve_select.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 2 | ||||
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 2 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 14 |
8 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 4855f9d1e6c..a29266294b4 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1045,7 +1045,7 @@ static int curve_select_random_exec(bContext *C, wmOperator *op) ListBase *editnurb = object_editcurve_get(obedit); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); curve_select_random(editnurb, randfac, seed, select); BKE_curve_nurb_vert_active_validate(obedit->data); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 83a1cdbedc6..17250fbfb09 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -3588,7 +3588,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); BMIter iter; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index f05414fbfa6..ed5bf4a92b4 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -373,7 +373,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) MetaElem *ml; const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); RNG *rng = BLI_rng_new_srandom(seed); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 5724e542f33..73ce1fae605 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -194,7 +194,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op) Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); RNG *rng = BLI_rng_new_srandom(seed); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 6b2c2bcd173..0cbbe46f461 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -1297,7 +1297,7 @@ void OBJECT_OT_select_less(wmOperatorType *ot) static int object_select_random_exec(bContext *C, wmOperator *op) { const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); RNG *rng = BLI_rng_new_srandom(seed); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 277189b4e81..29824a348f5 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1635,7 +1635,7 @@ static int select_random_exec(bContext *C, wmOperator *op) int k; const float randfac = RNA_float_get (op->ptr, "percent") / 100.0f; - const int seed = RNA_int_get(op->ptr, "seed"); + const int seed = WM_operator_properties_select_random_seed_increment_get(op); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); RNG *rng; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 0acd18126d9..7692afe4283 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -304,6 +304,7 @@ void WM_operator_properties_select_all(struct wmOperatorType *ot); void WM_operator_properties_select_action(struct wmOperatorType *ot, int default_action); void WM_operator_properties_select_action_simple(struct wmOperatorType *ot, int default_action); void WM_operator_properties_select_random(struct wmOperatorType *ot); +int WM_operator_properties_select_random_seed_increment_get(wmOperator *op); struct CheckerIntervalParams { int nth; /* bypass when set to zero */ int skip; diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 78d3dde7ba8..7ec2aea73e1 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -174,6 +174,20 @@ void WM_operator_properties_select_random(wmOperatorType *ot) WM_operator_properties_select_action_simple(ot, SEL_SELECT); } +int WM_operator_properties_select_random_seed_increment_get(wmOperator *op) +{ + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "seed"); + int value = RNA_property_int_get(op->ptr, prop); + + if (op->flag & OP_IS_INVOKE) { + if (!RNA_property_is_set(op->ptr, prop)) { + value += 1; + RNA_property_int_set(op->ptr, prop, value); + } + } + return value; +} + void WM_operator_properties_select_all(wmOperatorType *ot) { WM_operator_properties_select_action(ot, SEL_TOGGLE); |