Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_edit.c
| Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | static void PE_set_data(bContext *C, PEData *data) | ||||
| data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| data->edit = PE_get_current(data->depsgraph, data->scene, data->ob); | data->edit = PE_get_current(data->depsgraph, data->scene, data->ob); | ||||
| } | } | ||||
| static void PE_set_view3d_data(bContext *C, PEData *data) | static void PE_set_view3d_data(bContext *C, PEData *data) | ||||
| { | { | ||||
| PE_set_data(C, data); | PE_set_data(C, data); | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ED_view3d_viewcontext_init(C, &data->vc, data->depsgraph); | ||||
| ED_view3d_viewcontext_init(C, &data->vc, depsgraph); | |||||
| if (!XRAY_ENABLED(data->vc.v3d)) { | if (!XRAY_ENABLED(data->vc.v3d)) { | ||||
| if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) { | if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) { | ||||
| /* needed or else the draw matrix can be incorrect */ | /* needed or else the draw matrix can be incorrect */ | ||||
| view3d_operator_needs_opengl(C); | view3d_operator_needs_opengl(C); | ||||
| ED_view3d_backbuf_depth_validate(&data->vc); | ED_view3d_backbuf_depth_validate(&data->vc); | ||||
| /* we may need to force an update here by setting the rv3d as dirty | /* we may need to force an update here by setting the rv3d as dirty | ||||
| ▲ Show 20 Lines • Show All 1,323 Lines • ▼ Show 20 Lines | |||||
| /************************ pick select operator ************************/ | /************************ pick select operator ************************/ | ||||
| bool PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) | bool PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) | ||||
| { | { | ||||
| PEData data; | PEData data; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| PTCacheEdit *edit = PE_get_current(data.depsgraph, scene, ob); | |||||
| POINT_P; | POINT_P; | ||||
| KEY_K; | KEY_K; | ||||
| PE_set_view3d_data(C, &data); | |||||
| PTCacheEdit *edit = PE_get_current(data.depsgraph, scene, ob); | |||||
| if (!PE_start_edit(edit)) { | if (!PE_start_edit(edit)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!extend && !deselect && !toggle) { | if (!extend && !deselect && !toggle) { | ||||
| LOOP_VISIBLE_POINTS { | LOOP_VISIBLE_POINTS { | ||||
| LOOP_SELECTED_KEYS { | LOOP_SELECTED_KEYS { | ||||
| key->flag &= ~PEK_SELECT; | key->flag &= ~PEK_SELECT; | ||||
| point->flag |= PEP_EDIT_RECALC; | point->flag |= PEP_EDIT_RECALC; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| PE_set_view3d_data(C, &data); | |||||
| data.mval = mval; | data.mval = mval; | ||||
| data.rad = ED_view3d_select_dist_px(); | data.rad = ED_view3d_select_dist_px(); | ||||
| /* 1 = nearest only */ | /* 1 = nearest only */ | ||||
| if (extend) { | if (extend) { | ||||
| for_mouse_hit_keys(&data, extend_key_select, PSEL_NEAREST); | for_mouse_hit_keys(&data, extend_key_select, PSEL_NEAREST); | ||||
| } | } | ||||
| else if (deselect) { | else if (deselect) { | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | |||||
| static const EnumPropertyItem select_random_type_items[] = { | static const EnumPropertyItem select_random_type_items[] = { | ||||
| {RAN_HAIR, "HAIR", 0, "Hair", ""}, | {RAN_HAIR, "HAIR", 0, "Hair", ""}, | ||||
| {RAN_POINTS, "POINTS", 0, "Points", ""}, | {RAN_POINTS, "POINTS", 0, "Points", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static int select_random_exec(bContext *C, wmOperator *op) | static int select_random_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| PEData data; | PEData data; | ||||
| int type; | int type; | ||||
| /* used by LOOP_VISIBLE_POINTS, LOOP_VISIBLE_KEYS and LOOP_KEYS */ | /* used by LOOP_VISIBLE_POINTS, LOOP_VISIBLE_KEYS and LOOP_KEYS */ | ||||
| PTCacheEdit *edit; | PTCacheEdit *edit; | ||||
| PTCacheEditPoint *point; | PTCacheEditPoint *point; | ||||
| PTCacheEditKey *key; | PTCacheEditKey *key; | ||||
| int p; | int p; | ||||
| int k; | int k; | ||||
| 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); | ||||
| const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); | const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); | ||||
| RNG *rng; | RNG *rng; | ||||
| type = RNA_enum_get(op->ptr, "type"); | type = RNA_enum_get(op->ptr, "type"); | ||||
| PE_set_data(C, &data); | PE_set_data(C, &data); | ||||
| data.select_action = SEL_SELECT; | data.select_action = SEL_SELECT; | ||||
| edit = PE_get_current(depsgraph, data.scene, data.ob); | edit = PE_get_current(data.depsgraph, data.scene, data.ob); | ||||
| rng = BLI_rng_new_srandom(seed); | rng = BLI_rng_new_srandom(seed); | ||||
| switch (type) { | switch (type) { | ||||
| case RAN_HAIR: | case RAN_HAIR: | ||||
| LOOP_VISIBLE_POINTS { | LOOP_VISIBLE_POINTS { | ||||
| int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT; | int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT; | ||||
| LOOP_KEYS { | LOOP_KEYS { | ||||
| ▲ Show 20 Lines • Show All 2,906 Lines • ▼ Show 20 Lines | else { | ||||
| rekey_particle_to_time(data->context, data->scene, ob, pa_index, cut_time); | rekey_particle_to_time(data->context, data->scene, ob, pa_index, cut_time); | ||||
| edit->points[pa_index].flag |= PEP_EDIT_RECALC; | edit->points[pa_index].flag |= PEP_EDIT_RECALC; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) | static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| ParticleEditSettings *pset = PE_settings(scene); | ParticleEditSettings *pset = PE_settings(scene); | ||||
| PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); | PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); | ||||
| Object *shapeob = pset->shape_object; | Object *shapeob = pset->shape_object; | ||||
| int selected = count_selected_keys(scene, edit); | int selected = count_selected_keys(scene, edit); | ||||
| int lock_root = pset->flag & PE_LOCK_FIRST; | int lock_root = pset->flag & PE_LOCK_FIRST; | ||||
| ▲ Show 20 Lines • Show All 522 Lines • Show Last 20 Lines | |||||