Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_edit.c
| Context not available. | |||||
| WM_operator_properties_select_action(ot, SEL_SELECT); | WM_operator_properties_select_action(ot, SEL_SELECT); | ||||
| } | } | ||||
| /******************** select random hairs operator **********************/ | |||||
| static int select_random_hairs_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| PEData data; | |||||
| Scene *scene; | |||||
| Object *ob; | |||||
| PTCacheEdit *edit; | |||||
| PTCacheEditPoint *point; | |||||
| PTCacheEditKey *key; | |||||
| int p; | |||||
| int k; | |||||
kevindietrich: Unused variables | |||||
| const float randf = RNA_float_get (op->ptr, "percent") / 100.0f; | |||||
| PE_set_data(C, &data); | |||||
| data.select_action = SEL_SELECT; | |||||
kevindietrichUnsubmitted Not Done Inline ActionsThere's a trailing whitespace here. kevindietrich: There's a trailing whitespace here. | |||||
| scene = CTX_data_scene(C); | |||||
| ob = CTX_data_active_object(C); | |||||
| edit = PE_get_current(scene, ob); | |||||
| LOOP_VISIBLE_POINTS | |||||
| { | |||||
| if (BLI_frand() < randf) | |||||
| { | |||||
| LOOP_KEYS | |||||
| { | |||||
| select_action_apply (point, key, SEL_SELECT); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| LOOP_KEYS | |||||
| { | |||||
| select_action_apply (point, key, SEL_DESELECT); | |||||
| } | |||||
| } | |||||
| } | |||||
| PE_update_selection(data.scene, data.ob, 1); | |||||
| WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| void PARTICLE_OT_select_random_hairs(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Select Random Hairs"; | |||||
| ot->idname = "PARTICLE_OT_select_random_hairs"; | |||||
| ot->description = "Select or deselect a randomly distributed set of hairs"; | |||||
| /* api callbacks */ | |||||
| ot->exec = select_random_hairs_exec; | |||||
| ot->poll = PE_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | |||||
| /* properties */ | |||||
| RNA_def_float_percentage(ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", | |||||
| "Percentage (mean) of elements in randomly selected set", | |||||
| 0.0f, 100.0f); | |||||
| } | |||||
| /******************** select random points operator *********************/ | |||||
| static int select_random_points_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| PEData data; | |||||
| Scene *scene; | |||||
| Object *ob; | |||||
| PTCacheEdit *edit; | |||||
| PTCacheEditPoint *point; | |||||
| PTCacheEditKey *key; | |||||
| int p; | |||||
| int k; | |||||
kevindietrichUnsubmitted Not Done Inline ActionsUnused variables kevindietrich: Unused variables | |||||
| const float randf = RNA_float_get (op->ptr, "percent") / 100.0f; | |||||
| PE_set_data(C, &data); | |||||
| data.select_action = SEL_SELECT; | |||||
| scene = CTX_data_scene(C); | |||||
| ob = CTX_data_active_object(C); | |||||
| edit = PE_get_current(scene, ob); | |||||
| LOOP_VISIBLE_POINTS | |||||
| { | |||||
| LOOP_VISIBLE_KEYS | |||||
| { | |||||
| if (BLI_frand() < randf) | |||||
| select_action_apply (point, key, SEL_SELECT); | |||||
| else | |||||
| select_action_apply (point, key, SEL_DESELECT); | |||||
kevindietrichUnsubmitted Not Done Inline ActionsThis could be done in one go, like int flag = (BLI_frand() < randf) ? SEL_SELECT : SEL_DESELECT and then pass flag to select_action_apply(). Same above. kevindietrich: This could be done in one go, like int flag = (BLI_frand() < randf) ? SEL_SELECT : SEL_DESELECT… | |||||
| } | |||||
| } | |||||
| PE_update_selection(data.scene, data.ob, 1); | |||||
| WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| void PARTICLE_OT_select_random_points(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Select Random Points"; | |||||
| ot->idname = "PARTICLE_OT_select_random_points"; | |||||
| ot->description = "Select or deselect a randomly distributed set of control points"; | |||||
| /* api callbacks */ | |||||
| ot->exec = select_random_points_exec; | |||||
| ot->poll = PE_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; | |||||
| /* properties */ | |||||
| RNA_def_float_percentage(ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", | |||||
| "Percentage (mean) of elements in randomly selected set", | |||||
| 0.0f, 100.0f); | |||||
| } | |||||
| /************************ select linked operator ************************/ | /************************ select linked operator ************************/ | ||||
| static int select_linked_exec(bContext *C, wmOperator *op) | static int select_linked_exec(bContext *C, wmOperator *op) | ||||
| Context not available. | |||||
Unused variables