Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / physics / particle_edit_undo.c
index 3d17b1a..fdf765e 100644 (file)
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
-#include "BKE_depsgraph.h"
-#include "BKE_main.h"
 #include "BKE_particle.h"
 #include "BKE_pointcache.h"
 #include "BKE_undo_system.h"
 
+#include "DEG_depsgraph.h"
+
 #include "ED_object.h"
 #include "ED_particle.h"
 #include "ED_physics.h"
@@ -229,27 +229,27 @@ typedef struct ParticleUndoStep {
 
 static bool particle_undosys_poll(struct bContext *C)
 {
-       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
-       Object *ob = OBACT;
-       PTCacheEdit *edit = PE_get_current(bmain, scene, ob);
+       ViewLayer *view_layer = CTX_data_view_layer(C);
+       Object *ob = OBACT(view_layer);
+       PTCacheEdit *edit = PE_get_current(scene, ob);
+
        return (edit != NULL);
 }
 
 static bool particle_undosys_step_encode(struct bContext *C, UndoStep *us_p)
 {
-       Main *bmain = CTX_data_main(C);
        ParticleUndoStep *us = (ParticleUndoStep *)us_p;
+       ViewLayer *view_layer = CTX_data_view_layer(C);
        us->scene_ref.ptr = CTX_data_scene(C);
-       us->object_ref.ptr = us->scene_ref.ptr->basact->object;
-       PTCacheEdit *edit = PE_get_current(bmain, us->scene_ref.ptr, us->object_ref.ptr);
+       us->object_ref.ptr = OBACT(view_layer);
+       PTCacheEdit *edit = PE_get_current(us->scene_ref.ptr, us->object_ref.ptr);
        undoptcache_from_editcache(&us->data, edit);
        return true;
 }
 
 static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir))
 {
-       Main *bmain = CTX_data_main(C);
        /* TODO(campbell): undo_system: use low-level API to set mode. */
        ED_object_mode_set(C, OB_MODE_PARTICLE_EDIT);
        BLI_assert(particle_undosys_poll(C));
@@ -257,10 +257,10 @@ static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
        ParticleUndoStep *us = (ParticleUndoStep *)us_p;
        Scene *scene = us->scene_ref.ptr;
        Object *ob = us->object_ref.ptr;
-       PTCacheEdit *edit = PE_get_current(bmain, scene, ob);
+       PTCacheEdit *edit = PE_get_current(scene, ob);
        if (edit) {
                undoptcache_to_editcache(&us->data, edit);
-               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+               DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
        }
        else {
                BLI_assert(0);