Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / transform / transform_conversions.c
index 34cc143f3a9816c66b1aa76b4e51af96338e39db..5e8c2e2c09acd7e6bf4db049b86b47a561a7b906 100644 (file)
 #include "BKE_context.h"
 #include "BKE_crazyspace.h"
 #include "BKE_curve.h"
-#include "BKE_depsgraph.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
+#include "BKE_layer.h"
 #include "BKE_key.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "RNA_access.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #include "transform.h"
 #include "bmesh.h"
@@ -285,13 +286,13 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
 
 static void createTransTexspace(TransInfo *t)
 {
-       Scene *scene = t->scene;
+       ViewLayer *view_layer = t->view_layer;
        TransData *td;
        Object *ob;
        ID *id;
        short *texflag;
 
-       ob = OBACT;
+       ob = OBACT(view_layer);
 
        if (ob == NULL) { // Shouldn't logically happen, but still...
                t->total = 0;
@@ -836,14 +837,9 @@ void transform_autoik_update(TransInfo *t, short mode)
                changed |= pchan_autoik_adjust(pchan, *chainlen);
        }
 
-#ifdef WITH_LEGACY_DEPSGRAPH
-       if (!DEG_depsgraph_use_legacy())
-#endif
-       {
-               if (changed) {
-                       /* TODO(sergey): Consider doing partial update only. */
-                       DAG_relations_tag_update(G.main);
-               }
+       if (changed) {
+               /* TODO(sergey): Consider doing partial update only. */
+               DEG_relations_tag_update(G.main);
        }
 }
 
@@ -853,9 +849,7 @@ static void pose_grab_with_ik_clear(Object *ob)
        bKinematicConstraint *data;
        bPoseChannel *pchan;
        bConstraint *con, *next;
-#ifdef WITH_LEGACY_DEPSGRAPH
-       bool need_dependency_update = false;
-#endif
+       bool relations_changed = false;
 
        for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                /* clear all temporary lock flags */
@@ -869,10 +863,9 @@ static void pose_grab_with_ik_clear(Object *ob)
                        if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
                                data = con->data;
                                if (data->flag & CONSTRAINT_IK_TEMP) {
+                                       relations_changed = true;
+
                                        /* iTaSC needs clear for removed constraints */
-#ifdef WITH_LEGACY_DEPSGRAPH
-                                       need_dependency_update = true;
-#endif
                                        BIK_clear_data(ob->pose);
 
                                        BLI_remlink(&pchan->constraints, con);
@@ -887,12 +880,9 @@ static void pose_grab_with_ik_clear(Object *ob)
                }
        }
 
-#ifdef WITH_LEGACY_DEPSGRAPH
-       if (!DEG_depsgraph_use_legacy() && need_dependency_update)
-#endif
-       {
+       if (relations_changed) {
                /* TODO(sergey): Consider doing partial update only. */
-               DAG_relations_tag_update(G.main);
+               DEG_relations_tag_update(G.main);
        }
 }
 
@@ -1046,13 +1036,8 @@ static short pose_grab_with_ik(Object *ob)
        /* iTaSC needs clear for new IK constraints */
        if (tot_ik) {
                BIK_clear_data(ob->pose);
-#ifdef WITH_LEGACY_DEPSGRAPH
-               if (!DEG_depsgraph_use_legacy())
-#endif
-               {
-                       /* TODO(sergey): Consuder doing partial update only. */
-                       DAG_relations_tag_update(G.main);
-               }
+               /* TODO(sergey): Consuder doing partial update only. */
+               DEG_relations_tag_update(G.main);
        }
 
        return (tot_ik) ? 1 : 0;
@@ -1907,7 +1892,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
        TransDataExtension *tx;
        Object *ob = CTX_data_active_object(C);
        ParticleEditSettings *pset = PE_settings(t->scene);
-       PTCacheEdit *edit = PE_get_current(t->scene, ob);
+       PTCacheEdit *edit = PE_get_current(t->scene, t->view_layer, ob);
        ParticleSystem *psys = NULL;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
@@ -2022,8 +2007,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
 void flushTransParticles(TransInfo *t)
 {
        Scene *scene = t->scene;
-       Object *ob = OBACT;
-       PTCacheEdit *edit = PE_get_current(scene, ob);
+       ViewLayer *view_layer = t->view_layer;
+       Object *ob = OBACT(view_layer);
+       PTCacheEdit *edit = PE_get_current(scene, view_layer, ob);
        ParticleSystem *psys = edit->psys;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
@@ -2062,7 +2048,9 @@ void flushTransParticles(TransInfo *t)
                        point->flag |= PEP_EDIT_RECALC;
        }
 
-       PE_update_object(scene, OBACT, 1);
+       EvaluationContext eval_ctx;
+       CTX_data_eval_ctx(t->context, &eval_ctx);
+       PE_update_object(&eval_ctx, scene, view_layer, OBACT(view_layer), 1);
 }
 
 /* ********************* mesh ****************** */
@@ -2474,6 +2462,7 @@ static void createTransEditVerts(TransInfo *t)
 {
        TransData *tob = NULL;
        TransDataExtension *tx = NULL;
+       EvaluationContext eval_ctx;
        BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
        Mesh *me = t->obedit->data;
        BMesh *bm = em->bm;
@@ -2492,6 +2481,10 @@ static void createTransEditVerts(TransInfo *t)
        int island_info_tot;
        int *island_vert_map = NULL;
 
+       DEG_evaluation_context_init_from_scene(&eval_ctx,
+                                              t->scene, t->view_layer, t->engine_type,
+                                              DAG_EVAL_VIEWPORT);
+
        /* Even for translation this is needed because of island-orientation, see: T51651. */
        const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
        /* Original index of our connected vertex when connected distances are calculated.
@@ -2575,7 +2568,7 @@ static void createTransEditVerts(TransInfo *t)
                if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
                        /* check if we can use deform matrices for modifier from the
                         * start up to stack, they are more accurate than quats */
-                       totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(t->scene, t->obedit, em, &defmats, &defcos);
+                       totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
                }
 
                /* if we still have more modifiers, also do crazyspace
@@ -2588,7 +2581,7 @@ static void createTransEditVerts(TransInfo *t)
                if (totleft > 0)
 #endif
                {
-                       mappedcos = BKE_crazyspace_get_mapped_editverts(t->scene, t->obedit);
+                       mappedcos = BKE_crazyspace_get_mapped_editverts(&eval_ctx, t->scene, t->obedit);
                        quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
                        BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
                        if (mappedcos)
@@ -2957,7 +2950,6 @@ static void createTransUVs(bContext *C, TransInfo *t)
        const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
        const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
        const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-       const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
 
        if (!ED_space_image_show_uvedit(sima, t->obedit))
                return;
@@ -2981,10 +2973,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
        }
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-               MTexPoly *tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
                BMLoop *l;
 
-               if (!uvedit_face_visible_test(scene, ima, efa, tf)) {
+               if (!uvedit_face_visible_test(scene, ima, efa)) {
                        BM_elem_flag_disable(efa, BM_ELEM_TAG);
                        continue;
                }
@@ -5416,6 +5407,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
        Scene *scene = t->scene;
        bool constinv;
        bool skip_invert = false;
+       EvaluationContext eval_ctx;
+
+       CTX_data_eval_ctx(t->context, &eval_ctx);
 
        if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
                float rot[3][3], scale[3];
@@ -5463,11 +5457,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
 
        if (skip_invert == false && constinv == false) {
                ob->transflag |= OB_NO_CONSTRAINTS;  /* BKE_object_where_is_calc_time checks this */
-               BKE_object_where_is_calc(t->scene, ob);
+               BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
                ob->transflag &= ~OB_NO_CONSTRAINTS;
        }
        else
-               BKE_object_where_is_calc(t->scene, ob);
+               BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
 
        td->ob = ob;
 
@@ -5539,12 +5533,15 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
 /* it deselects Bases, so we have to call the clear function always after */
 static void set_trans_object_base_flags(TransInfo *t)
 {
+       /* TODO(sergey): Get rid of global, use explicit main. */
+       Main *bmain = G.main;
+       ViewLayer *view_layer = t->view_layer;
        Scene *scene = t->scene;
-       View3D *v3d = t->view;
+       Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
 
        /*
         * if Base selected and has parent selected:
-        * base->flag = BA_WAS_SEL
+        * base->flag_legacy = BA_WAS_SEL
         */
        Base *base;
 
@@ -5553,32 +5550,36 @@ static void set_trans_object_base_flags(TransInfo *t)
                return;
 
        /* makes sure base flags and object flags are identical */
-       BKE_scene_base_flag_to_objects(t->scene);
+       BKE_scene_base_flag_to_objects(t->view_layer);
 
        /* Make sure depsgraph is here. */
-       DAG_scene_relations_update(G.main, t->scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
 
        /* handle pending update events, otherwise they got copied below */
-       for (base = scene->base.first; base; base = base->next) {
+       EvaluationContext eval_ctx;
+       DEG_evaluation_context_init_from_scene(&eval_ctx,
+                                              t->scene, t->view_layer, t->engine_type,
+                                              DAG_EVAL_VIEWPORT);
+       for (base = view_layer->object_bases.first; base; base = base->next) {
                if (base->object->recalc & OB_RECALC_ALL) {
                        /* TODO(sergey): Ideally, it's not needed. */
-                       BKE_object_handle_update(G.main->eval_ctx, t->scene, base->object);
+                       BKE_object_handle_update(&eval_ctx, t->scene, base->object);
                }
        }
 
-       for (base = scene->base.first; base; base = base->next) {
-               base->flag &= ~BA_WAS_SEL;
+       for (base = view_layer->object_bases.first; base; base = base->next) {
+               base->flag_legacy &= ~BA_WAS_SEL;
 
-               if (TESTBASELIB_BGMODE(v3d, scene, base)) {
+               if (TESTBASELIB_BGMODE(base)) {
                        Object *ob = base->object;
                        Object *parsel = ob->parent;
 
                        /* if parent selected, deselect */
                        while (parsel) {
-                               if (parsel->flag & SELECT) {
-                                       Base *parbase = BKE_scene_base_find(scene, parsel);
+                               if (parsel->base_flag & BASE_SELECTED) {
+                                       Base *parbase = BKE_view_layer_base_find(view_layer, parsel);
                                        if (parbase) { /* in rare cases this can fail */
-                                               if (TESTBASELIB_BGMODE(v3d, scene, parbase)) {
+                                               if (TESTBASELIB_BGMODE(parbase)) {
                                                        break;
                                                }
                                        }
@@ -5591,23 +5592,23 @@ static void set_trans_object_base_flags(TransInfo *t)
                                if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
                                    (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))
                                {
-                                       base->flag |= BA_TRANSFORM_CHILD;
+                                       base->flag_legacy |= BA_TRANSFORM_CHILD;
                                }
                                else {
-                                       base->flag &= ~SELECT;
-                                       base->flag |= BA_WAS_SEL;
+                                       base->flag &= ~BASE_SELECTED;
+                                       base->flag_legacy |= BA_WAS_SEL;
                                }
                        }
-                       DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
                }
        }
 
        /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
-       DAG_scene_flush_update(G.main, t->scene, -1, 0);
+       DEG_graph_flush_update(bmain, depsgraph);
 
        /* and we store them temporal in base (only used for transform code) */
        /* this because after doing updates, the object->recalc is cleared */
-       for (base = scene->base.first; base; base = base->next) {
+       for (base = view_layer->object_bases.first; base; base = base->next) {
                if (base->object->recalc & (OB_RECALC_OB | OB_RECALC_DATA)) {
                        base->flag |= BA_SNAP_FIX_DEPS_FIASCO;
                }
@@ -5632,8 +5633,11 @@ static bool mark_children(Object *ob)
 static int count_proportional_objects(TransInfo *t)
 {
        int total = 0;
+       /* TODO(sergey): Get rid of global, use explicit main. */
+       Main *bmain = G.main;
+       ViewLayer *view_layer = t->view_layer;
        Scene *scene = t->scene;
-       View3D *v3d = t->view;
+       Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
        Base *base;
 
        /* rotations around local centers are allowed to propagate, so we take all objects */
@@ -5641,8 +5645,8 @@ static int count_proportional_objects(TransInfo *t)
              (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL)))
        {
                /* mark all parents */
-               for (base = scene->base.first; base; base = base->next) {
-                       if (TESTBASELIB_BGMODE(v3d, scene, base)) {
+               for (base = view_layer->object_bases.first; base; base = base->next) {
+                       if (TESTBASELIB_BGMODE(base)) {
                                Object *parent = base->object->parent;
        
                                /* flag all parents */
@@ -5654,25 +5658,27 @@ static int count_proportional_objects(TransInfo *t)
                }
 
                /* mark all children */
-               for (base = scene->base.first; base; base = base->next) {
+               for (base = view_layer->object_bases.first; base; base = base->next) {
                        /* all base not already selected or marked that is editable */
-                       if ((base->object->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
-                           (BASE_EDITABLE_BGMODE(v3d, scene, base)))
+                       if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
+                           (base->flag & BASE_SELECTED) == 0 &&
+                           (BASE_EDITABLE_BGMODE(base)))
                        {
                                mark_children(base->object);
                        }
                }
        }
        
-       for (base = scene->base.first; base; base = base->next) {
+       for (base = view_layer->object_bases.first; base; base = base->next) {
                Object *ob = base->object;
 
                /* if base is not selected, not a parent of selection or not a child of selection and it is editable */
-               if ((ob->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
-                   (BASE_EDITABLE_BGMODE(v3d, scene, base)))
+               if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
+                   (base->flag & BASE_SELECTED) == 0 &&
+                   (BASE_EDITABLE_BGMODE(base)))
                {
 
-                       DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
 
                        total += 1;
                }
@@ -5680,12 +5686,12 @@ static int count_proportional_objects(TransInfo *t)
        
 
        /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
-       DAG_scene_relations_update(G.main, t->scene);
-       DAG_scene_flush_update(G.main, t->scene, -1, 0);
+       DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
+       DEG_graph_flush_update(bmain, depsgraph);
 
        /* and we store them temporal in base (only used for transform code) */
        /* this because after doing updates, the object->recalc is cleared */
-       for (base = scene->base.first; base; base = base->next) {
+       for (base = view_layer->object_bases.first; base; base = base->next) {
                if (base->object->recalc & (OB_RECALC_OB | OB_RECALC_DATA)) {
                        base->flag |= BA_SNAP_FIX_DEPS_FIASCO;
                }
@@ -5696,14 +5702,15 @@ static int count_proportional_objects(TransInfo *t)
 
 static void clear_trans_object_base_flags(TransInfo *t)
 {
-       Scene *sce = t->scene;
+       ViewLayer *view_layer = t->view_layer;
        Base *base;
 
-       for (base = sce->base.first; base; base = base->next) {
-               if (base->flag & BA_WAS_SEL)
-                       base->flag |= SELECT;
+       for (base = view_layer->object_bases.first; base; base = base->next) {
+               if (base->flag_legacy & BA_WAS_SEL) {
+                       base->flag |= BASE_SELECTED;
+               }
 
-               base->flag &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
+               base->flag_legacy &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
        }
 }
 
@@ -5711,7 +5718,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
  *  tmode: should be a transform mode
  */
 // NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
-void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode)
+void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *ob, int tmode)
 {
        ID *id = &ob->id;
        FCurve *fcu;
@@ -5760,7 +5767,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
                        }
                        else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
                                if (v3d->around == V3D_AROUND_ACTIVE) {
-                                       if (ob != OBACT)
+                                       if (ob != OBACT(view_layer))
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
@@ -5771,7 +5778,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
                        }
                        else if (tmode == TFM_RESIZE) {
                                if (v3d->around == V3D_AROUND_ACTIVE) {
-                                       if (ob != OBACT)
+                                       if (ob != OBACT(view_layer))
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
@@ -5949,7 +5956,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
                 */
                if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
                        //ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
-                       ED_pose_recalculate_paths(scene, ob);
+                       ED_pose_recalculate_paths(C, scene, ob);
                }
        }
        else {
@@ -6104,10 +6111,13 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
  * */
 void special_aftertrans_update(bContext *C, TransInfo *t)
 {
+       EvaluationContext eval_ctx;
        Object *ob;
 //     short redrawipo=0, resetslowpar=1;
        const bool canceled = (t->state == TRANS_CANCEL);
        const bool duplicate = (t->mode == TFM_TIME_DUPLICATE);
+
+       CTX_data_eval_ctx(C, &eval_ctx);
        
        /* early out when nothing happened */
        if (t->total == 0 || t->mode == TFM_DUMMY)
@@ -6259,9 +6269,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                        // fixme... some of this stuff is not good
                        if (ob) {
                                if (ob->pose || BKE_key_from_object(ob))
-                                       DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+                                       DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
                                else
-                                       DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+                                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
                        }
                        
                        /* 3 cases here for curve cleanups:
@@ -6447,7 +6457,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                         * we need to update the pose otherwise no updates get called during
                         * transform and the auto-ik is not applied. see [#26164] */
                        struct Object *pose_ob = t->poseobj;
-                       BKE_pose_where_is(t->scene, pose_ob);
+                       BKE_pose_where_is(&eval_ctx, t->scene, pose_ob);
                }
 
                /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
@@ -6471,24 +6481,24 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                /* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
                if (!canceled && (t->mode != TFM_DUMMY)) {
                        autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
-                       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
                }
                else if (arm->flag & ARM_DELAYDEFORM) {
                        /* old optimize trick... this enforces to bypass the depgraph */
-                       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        ob->recalc = 0;  // is set on OK position already by recalcData()
                }
                else
-                       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
        }
        else if (t->options & CTX_PAINT_CURVE) {
                /* pass */
        }
-       else if ((t->scene->basact) &&
-                (ob = t->scene->basact->object) &&
+       else if ((t->view_layer->basact) &&
+                (ob = t->view_layer->basact->object) &&
                 (ob->mode & OB_MODE_PARTICLE_EDIT) &&
-                PE_get_current(t->scene, ob))
+                PE_get_current(t->scene, t->view_layer, ob))
        {
                /* do nothing */
        }
@@ -6519,17 +6529,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
 
                        /* pointcache refresh */
                        if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
-                               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+                               DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
                        /* Needed for proper updating of "quick cached" dynamics. */
                        /* Creates troubles for moving animated objects without */
                        /* autokey though, probably needed is an anim sys override? */
                        /* Please remove if some other solution is found. -jahka */
-                       DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
 
                        /* Set autokey if necessary */
                        if (!canceled) {
-                               autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode);
+                               autokeyframe_ob_cb_func(C, t->scene, t->view_layer, (View3D *)t->view, ob, t->mode);
                        }
                        
                        /* restore rigid body transform */
@@ -6564,8 +6574,6 @@ int special_transform_moving(TransInfo *t)
 
 static void createTransObject(bContext *C, TransInfo *t)
 {
-       Scene *scene = t->scene;
-
        TransData *td = NULL;
        TransDataExtension *tx;
        const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
@@ -6615,15 +6623,16 @@ static void createTransObject(bContext *C, TransInfo *t)
        CTX_DATA_END;
        
        if (is_prop_edit) {
-               View3D *v3d = t->view;
+               ViewLayer *view_layer = t->view_layer;
                Base *base;
 
-               for (base = scene->base.first; base; base = base->next) {
+               for (base = view_layer->object_bases.first; base; base = base->next) {
                        Object *ob = base->object;
 
                        /* if base is not selected, not a parent of selection or not a child of selection and it is editable */
-                       if ((ob->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
-                           BASE_EDITABLE_BGMODE(v3d, scene, base))
+                       if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
+                           (base->flag & BASE_SELECTED) == 0 &&
+                           BASE_EDITABLE_BGMODE(base))
                        {
                                td->protectflag = ob->protectflag;
                                td->ext = tx;
@@ -8070,7 +8079,8 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 void createTransData(bContext *C, TransInfo *t)
 {
        Scene *scene = t->scene;
-       Object *ob = OBACT;
+       ViewLayer *view_layer = t->view_layer;
+       Object *ob = OBACT(view_layer);
 
        /* if tests must match recalcData for correct updates */
        if (t->options & CTX_TEXTURE) {
@@ -8235,17 +8245,16 @@ void createTransData(bContext *C, TransInfo *t)
                 * lines below just check is also visible */
                Object *ob_armature = modifiers_isDeformedByArmature(ob);
                if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
-                       Base *base_arm = BKE_scene_base_find(t->scene, ob_armature);
+                       Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
                        if (base_arm) {
-                               View3D *v3d = t->view;
-                               if (BASE_VISIBLE(v3d, base_arm)) {
+                               if (BASE_VISIBLE(base_arm)) {
                                        createTransPose(t, ob_armature);
                                }
                        }
                        
                }
        }
-       else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) {
+       else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, view_layer, ob))) {
                createTransParticleVerts(C, t);
                t->flag |= T_POINTS;