Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_edit.c
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_bvhutils.h" | #include "BKE_bvhutils.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_physics.h" | #include "ED_physics.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| ▲ Show 20 Lines • Show All 4,702 Lines • ▼ Show 20 Lines | return (ob->particlesystem.first || | ||||
| modifiers_findByType(ob, eModifierType_Cloth) || | modifiers_findByType(ob, eModifierType_Cloth) || | ||||
| modifiers_findByType(ob, eModifierType_Softbody)); | modifiers_findByType(ob, eModifierType_Softbody)); | ||||
| } | } | ||||
| static int particle_edit_toggle_exec(bContext *C, wmOperator *op) | static int particle_edit_toggle_exec(bContext *C, wmOperator *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); | ||||
| struct WorkSpace *workspace = CTX_wm_workspace(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; | ||||
| BKE_report(op->reports, RPT_INFO, "Particles are changing, editing is not possible"); | BKE_report(op->reports, RPT_INFO, "Particles are changing, editing is not possible"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| 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; | ||||
| } | } | ||||
| } | } | ||||
| if (!is_mode_set) { | if (!is_mode_set) { | ||||
| PTCacheEdit *edit; | PTCacheEdit *edit; | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| CTX_data_eval_ctx(C, &eval_ctx); | CTX_data_eval_ctx(C, &eval_ctx); | ||||
| ob->mode |= mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode | mode_flag); | ||||
| edit= PE_create_current(&eval_ctx, scene, ob); | edit= PE_create_current(&eval_ctx, scene, ob); | ||||
| /* mesh may have changed since last entering editmode. | /* mesh may have changed since last entering editmode. | ||||
| * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ | * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ | ||||
| if (edit && edit->psys) | if (edit && edit->psys) | ||||
| recalc_emitter_field(ob, edit->psys); | recalc_emitter_field(ob, edit->psys); | ||||
| toggle_particle_cursor(C, 1); | toggle_particle_cursor(C, 1); | ||||
| WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); | WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| ob->mode &= ~mode_flag; | BKE_workspace_object_mode_for_object_set(workspace, scene, ob, ob->mode & ~mode_flag); | ||||
| toggle_particle_cursor(C, 0); | toggle_particle_cursor(C, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); | WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); | ||||
| } | } | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines | |||||