Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_edit.c
| Show First 20 Lines • Show All 459 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| memset(data, 0, sizeof(*data)); | memset(data, 0, sizeof(*data)); | ||||
| data->context = C; | data->context = C; | ||||
| data->bmain = CTX_data_main(C); | data->bmain = CTX_data_main(C); | ||||
| data->scene = CTX_data_scene(C); | data->scene = CTX_data_scene(C); | ||||
| data->view_layer = CTX_data_view_layer(C); | data->view_layer = CTX_data_view_layer(C); | ||||
| data->ob = CTX_data_active_object(C); | data->ob = CTX_data_active_object(C); | ||||
| data->depsgraph = CTX_data_depsgraph(C); | data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| data->edit = PE_get_current(data->scene, data->ob); | data->edit = PE_get_current(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); | ||||
| ED_view3d_viewcontext_init(C, &data->vc); | ED_view3d_viewcontext_init(C, &data->vc); | ||||
| ▲ Show 20 Lines • Show All 1,296 Lines • ▼ Show 20 Lines | case SEL_INVERT: | ||||
| break; | break; | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| static int pe_select_all_exec(bContext *C, wmOperator *op) | static int pe_select_all_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(scene, ob); | ||||
| POINT_P; | POINT_P; | ||||
| KEY_K; | KEY_K; | ||||
| int action = RNA_enum_get(op->ptr, "action"); | int action = RNA_enum_get(op->ptr, "action"); | ||||
| if (action == SEL_TOGGLE) { | if (action == SEL_TOGGLE) { | ||||
| action = SEL_SELECT; | action = SEL_SELECT; | ||||
| ▲ Show 20 Lines • Show All 553 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /*************************** hide operator **************************/ | /*************************** hide operator **************************/ | ||||
| static int hide_exec(bContext *C, wmOperator *op) | static int hide_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(scene, ob); | ||||
| POINT_P; | POINT_P; | ||||
| KEY_K; | KEY_K; | ||||
| if (RNA_enum_get(op->ptr, "unselected")) { | if (RNA_enum_get(op->ptr, "unselected")) { | ||||
| LOOP_UNSELECTED_POINTS | LOOP_UNSELECTED_POINTS | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /*************************** reveal operator **************************/ | /*************************** reveal operator **************************/ | ||||
| static int reveal_exec(bContext *C, wmOperator *op) | static int reveal_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(scene, ob); | ||||
| const bool select = RNA_boolean_get(op->ptr, "select"); | const bool select = RNA_boolean_get(op->ptr, "select"); | ||||
| POINT_P; | POINT_P; | ||||
| KEY_K; | KEY_K; | ||||
| LOOP_POINTS | LOOP_POINTS | ||||
| { | { | ||||
| if (point->flag & PEP_HIDE) { | if (point->flag & PEP_HIDE) { | ||||
| ▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | static void rekey_particle_to_time( | ||||
| int k; | int k; | ||||
| if (!edit || !edit->psys) { | if (!edit || !edit->psys) { | ||||
| return; | return; | ||||
| } | } | ||||
| psys = edit->psys; | psys = edit->psys; | ||||
| sim.depsgraph = CTX_data_depsgraph(C); | sim.depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| sim.scene = scene; | sim.scene = scene; | ||||
| sim.ob = ob; | sim.ob = ob; | ||||
| sim.psys = psys; | sim.psys = psys; | ||||
| pa = psys->particles + pa_index; | pa = psys->particles + pa_index; | ||||
| pa->flag |= PARS_REKEY; | pa->flag |= PARS_REKEY; | ||||
| ▲ Show 20 Lines • Show All 793 Lines • ▼ Show 20 Lines | |||||
| static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) | static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| 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(scene, ob); | PTCacheEdit *edit = PE_get_current(scene, ob); | ||||
| PE_mirror_x(scene, ob, 0); | PE_mirror_x(scene, ob, 0); | ||||
| update_world_cos(ob, edit); | update_world_cos(ob, edit); | ||||
brecht: `update_world_cos` doesn't even use the depsgraph parameter, maybe just remove it? | |||||
| WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void PARTICLE_OT_mirror(wmOperatorType *ot) | void PARTICLE_OT_mirror(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 675 Lines • ▼ Show 20 Lines | static void brush_add_count_iter_finalize(void *__restrict userdata_v, | ||||
| iter_data->num_added += tls->num_added; | iter_data->num_added += tls->num_added; | ||||
| if (tls->rng != NULL) { | if (tls->rng != NULL) { | ||||
| BLI_rng_free(tls->rng); | BLI_rng_free(tls->rng); | ||||
| } | } | ||||
| } | } | ||||
| static int brush_add(const bContext *C, PEData *data, short number) | static int brush_add(const bContext *C, PEData *data, short number) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| Scene *scene = data->scene; | Scene *scene = data->scene; | ||||
| Object *ob = data->ob; | Object *ob = data->ob; | ||||
| Mesh *mesh; | Mesh *mesh; | ||||
| PTCacheEdit *edit = data->edit; | PTCacheEdit *edit = data->edit; | ||||
| ParticleSystem *psys = edit->psys; | ParticleSystem *psys = edit->psys; | ||||
| ParticleData *add_pars; | ParticleData *add_pars; | ||||
| ParticleSystemModifierData *psmd_eval = edit->psmd_eval; | ParticleSystemModifierData *psmd_eval = edit->psmd_eval; | ||||
| ParticleSimulationData sim = {0}; | ParticleSimulationData sim = {0}; | ||||
| ▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | static int brush_edit_init(bContext *C, wmOperator *op) | ||||
| PE_create_random_generator(&bedit->data); | PE_create_random_generator(&bedit->data); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) | static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) | ||||
| { | { | ||||
| BrushEdit *bedit = op->customdata; | BrushEdit *bedit = op->customdata; | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| Scene *scene = bedit->scene; | Scene *scene = bedit->scene; | ||||
| Object *ob = bedit->ob; | Object *ob = bedit->ob; | ||||
| PTCacheEdit *edit = bedit->edit; | PTCacheEdit *edit = bedit->edit; | ||||
| ParticleEditSettings *pset = PE_settings(scene); | ParticleEditSettings *pset = PE_settings(scene); | ||||
| ParticleSystemModifierData *psmd_eval = edit->psmd_eval; | ParticleSystemModifierData *psmd_eval = edit->psmd_eval; | ||||
| ParticleBrushData *brush = &pset->brush[pset->brushtype]; | ParticleBrushData *brush = &pset->brush[pset->brushtype]; | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| float vec[3], mousef[2]; | float vec[3], mousef[2]; | ||||
| ▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | if (psys->edit != NULL) { | ||||
| psys->edit = NULL; | psys->edit = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int particle_edit_toggle_exec(bContext *C, wmOperator *op) | static int particle_edit_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| struct wmMsgBus *mbus = CTX_wm_message_bus(C); | struct wmMsgBus *mbus = CTX_wm_message_bus(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(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); | ||||
| const int mode_flag = OB_MODE_PARTICLE_EDIT; | const int mode_flag = OB_MODE_PARTICLE_EDIT; | ||||
| const bool is_mode_set = (ob->mode & mode_flag) != 0; | const bool is_mode_set = (ob->mode & mode_flag) != 0; | ||||
| if (!is_mode_set) { | if (!is_mode_set) { | ||||
| if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { | if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | static void scale_points_to_length(PTCacheEdit *edit, float length) | ||||
| } | } | ||||
| recalc_lengths(edit); | recalc_lengths(edit); | ||||
| } | } | ||||
| static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) | static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(scene, ob); | ||||
| float average_length = calculate_average_length(edit); | float average_length = calculate_average_length(edit); | ||||
| if (average_length == 0.0f) { | if (average_length == 0.0f) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| scale_points_to_length(edit, average_length); | scale_points_to_length(edit, average_length); | ||||
| Show All 27 Lines | |||||
update_world_cos doesn't even use the depsgraph parameter, maybe just remove it?