Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/particle_edit_undo.c
| Show First 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | typedef struct ParticleUndoStep { | ||||
| UndoStep step; | UndoStep step; | ||||
| UndoRefID_Scene scene_ref; | UndoRefID_Scene scene_ref; | ||||
| UndoRefID_Object object_ref; | UndoRefID_Object object_ref; | ||||
| PTCacheUndo data; | PTCacheUndo data; | ||||
| } ParticleUndoStep; | } ParticleUndoStep; | ||||
| static bool particle_undosys_poll(struct bContext *C) | static bool particle_undosys_poll(struct bContext *C) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); | ||||
| return (edit != NULL); | return (edit != NULL); | ||||
| } | } | ||||
| static bool particle_undosys_step_encode(struct bContext *C, | static bool particle_undosys_step_encode(struct bContext *C, | ||||
| struct Main *UNUSED(bmain), | struct Main *UNUSED(bmain), | ||||
| UndoStep *us_p) | UndoStep *us_p) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| ParticleUndoStep *us = (ParticleUndoStep *)us_p; | ParticleUndoStep *us = (ParticleUndoStep *)us_p; | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| us->scene_ref.ptr = CTX_data_scene(C); | us->scene_ref.ptr = CTX_data_scene(C); | ||||
| us->object_ref.ptr = OBACT(view_layer); | us->object_ref.ptr = OBACT(view_layer); | ||||
| PTCacheEdit *edit = PE_get_current(us->scene_ref.ptr, us->object_ref.ptr); | PTCacheEdit *edit = PE_get_current(depsgraph, us->scene_ref.ptr, us->object_ref.ptr); | ||||
| undoptcache_from_editcache(&us->data, edit); | undoptcache_from_editcache(&us->data, edit); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void particle_undosys_step_decode(struct bContext *C, | static void particle_undosys_step_decode(struct bContext *C, | ||||
| struct Main *UNUSED(bmain), | struct Main *UNUSED(bmain), | ||||
| UndoStep *us_p, | UndoStep *us_p, | ||||
| int UNUSED(dir), | int UNUSED(dir), | ||||
| bool UNUSED(is_final)) | bool UNUSED(is_final)) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| /* TODO(campbell): undo_system: use low-level API to set mode. */ | /* TODO(campbell): undo_system: use low-level API to set mode. */ | ||||
| ED_object_mode_set(C, OB_MODE_PARTICLE_EDIT); | ED_object_mode_set(C, OB_MODE_PARTICLE_EDIT); | ||||
| BLI_assert(particle_undosys_poll(C)); | BLI_assert(particle_undosys_poll(C)); | ||||
| ParticleUndoStep *us = (ParticleUndoStep *)us_p; | ParticleUndoStep *us = (ParticleUndoStep *)us_p; | ||||
| Scene *scene = us->scene_ref.ptr; | Scene *scene = us->scene_ref.ptr; | ||||
| Object *ob = us->object_ref.ptr; | Object *ob = us->object_ref.ptr; | ||||
| PTCacheEdit *edit = PE_get_current(scene, ob); | PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); | ||||
| if (edit) { | if (edit) { | ||||
| undoptcache_to_editcache(&us->data, edit); | undoptcache_to_editcache(&us->data, edit); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| } | } | ||||
| Show All 33 Lines | |||||