Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/metaball/mball_edit.c
| Context not available. | |||||
| /* Random metaball selection */ | /* Random metaball selection */ | ||||
| static int select_random_metaelems_exec(bContext *C, wmOperator *op) | static int select_random_metaelems_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | |||||
| MetaBall *mb = (MetaBall *)obedit->data; | |||||
| MetaElem *ml; | MetaElem *ml; | ||||
| const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); | const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); | ||||
| const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; | const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; | ||||
| const int seed = WM_operator_properties_select_random_seed_increment_get(op); | const int seed = WM_operator_properties_select_random_seed_increment_get(op); | ||||
| RNG *rng = BLI_rng_new_srandom(seed); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| uint objects_len = 0; | |||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); | |||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | |||||
| Object *obedit = objects[ob_index]; | |||||
| MetaBall *mb = (MetaBall *)obedit->data; | |||||
| RNG *rng = BLI_rng_new_srandom(seed + ob_index); | |||||
| for (ml = mb->editelems->first; ml; ml = ml->next) { | for (ml = mb->editelems->first; ml; ml = ml->next) { | ||||
| if (BLI_rng_get_float(rng) < randfac) { | if (BLI_rng_get_float(rng) < randfac) { | ||||
| Context not available. | |||||
| BLI_rng_free(rng); | BLI_rng_free(rng); | ||||
| WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); | WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); | ||||
| } | |||||
| MEM_freeN(objects); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Context not available. | |||||