Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / transform / transform_conversions.c
index 1eb9b3caa3e8cd636b914bf65023ec72d73160ff..cfc648e1fd03e08d7f9f4f108baf3bb47bc17a08 100644 (file)
 #include "BKE_context.h"
 #include "BKE_crazyspace.h"
 #include "BKE_curve.h"
 #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_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 "BKE_key.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "RNA_access.h"
 
 #include "DEG_depsgraph.h"
 #include "RNA_access.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #include "transform.h"
 #include "bmesh.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)
 {
 
 static void createTransTexspace(TransInfo *t)
 {
-       Scene *scene = t->scene;
+       SceneLayer *sl = t->scene_layer;
        TransData *td;
        Object *ob;
        ID *id;
        short *texflag;
 
        TransData *td;
        Object *ob;
        ID *id;
        short *texflag;
 
-       ob = OBACT;
+       ob = OBACT_NEW;
 
        if (ob == NULL) { // Shouldn't logically happen, but still...
                t->total = 0;
 
        if (ob == NULL) { // Shouldn't logically happen, but still...
                t->total = 0;
@@ -828,9 +829,6 @@ static void pose_grab_with_ik_clear(Object *ob)
        bKinematicConstraint *data;
        bPoseChannel *pchan;
        bConstraint *con, *next;
        bKinematicConstraint *data;
        bPoseChannel *pchan;
        bConstraint *con, *next;
-#ifdef WITH_LEGACY_DEPSGRAPH
-       bool need_dependency_update = false;
-#endif
 
        for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                /* clear all temporary lock flags */
 
        for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                /* clear all temporary lock flags */
@@ -845,9 +843,6 @@ static void pose_grab_with_ik_clear(Object *ob)
                                data = con->data;
                                if (data->flag & CONSTRAINT_IK_TEMP) {
                                        /* iTaSC needs clear for removed constraints */
                                data = con->data;
                                if (data->flag & CONSTRAINT_IK_TEMP) {
                                        /* 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);
                                        BIK_clear_data(ob->pose);
 
                                        BLI_remlink(&pchan->constraints, con);
@@ -862,13 +857,8 @@ static void pose_grab_with_ik_clear(Object *ob)
                }
        }
 
                }
        }
 
-#ifdef WITH_LEGACY_DEPSGRAPH
-       if (!DEG_depsgraph_use_legacy() && need_dependency_update)
-#endif
-       {
-               /* TODO(sergey): Consider doing partial update only. */
-               DAG_relations_tag_update(G.main);
-       }
+       /* TODO(sergey): Consider doing partial update only. */
+       DEG_relations_tag_update(G.main);
 }
 
 /* adds the IK to pchan - returns if added */
 }
 
 /* adds the IK to pchan - returns if added */
@@ -1021,13 +1011,8 @@ static short pose_grab_with_ik(Object *ob)
        /* iTaSC needs clear for new IK constraints */
        if (tot_ik) {
                BIK_clear_data(ob->pose);
        /* 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;
        }
 
        return (tot_ik) ? 1 : 0;
@@ -1815,7 +1800,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
        Base *base = CTX_data_active_base(C);
        Object *ob = CTX_data_active_object(C);
        ParticleEditSettings *pset = PE_settings(t->scene);
        Base *base = CTX_data_active_base(C);
        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->scene_layer, ob);
        ParticleSystem *psys = NULL;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
        ParticleSystem *psys = NULL;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
@@ -1932,8 +1917,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
 void flushTransParticles(TransInfo *t)
 {
        Scene *scene = t->scene;
 void flushTransParticles(TransInfo *t)
 {
        Scene *scene = t->scene;
-       Object *ob = OBACT;
-       PTCacheEdit *edit = PE_get_current(scene, ob);
+       SceneLayer *sl = t->scene_layer;
+       Object *ob = OBACT_NEW;
+       PTCacheEdit *edit = PE_get_current(scene, sl, ob);
        ParticleSystem *psys = edit->psys;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
        ParticleSystem *psys = edit->psys;
        ParticleSystemModifierData *psmd = NULL;
        PTCacheEditPoint *point;
@@ -1972,7 +1958,7 @@ void flushTransParticles(TransInfo *t)
                        point->flag |= PEP_EDIT_RECALC;
        }
 
                        point->flag |= PEP_EDIT_RECALC;
        }
 
-       PE_update_object(scene, OBACT, 1);
+       PE_update_object(scene, sl, OBACT_NEW, 1);
 }
 
 /* ********************* mesh ****************** */
 }
 
 /* ********************* mesh ****************** */
@@ -2867,7 +2853,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 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;
 
        if (!ED_space_image_show_uvedit(sima, t->obedit))
                return;
@@ -2891,10 +2876,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
        }
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
        }
 
        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;
 
                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;
                }
                        BM_elem_flag_disable(efa, BM_ELEM_TAG);
                        continue;
                }
@@ -5449,12 +5433,11 @@ 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)
 {
 /* it deselects Bases, so we have to call the clear function always after */
 static void set_trans_object_base_flags(TransInfo *t)
 {
-       Scene *scene = t->scene;
-       View3D *v3d = t->view;
+       SceneLayer *sl = t->scene_layer;
 
        /*
         * if Base selected and has parent selected:
 
        /*
         * if Base selected and has parent selected:
-        * base->flag = BA_WAS_SEL
+        * base->flag_legacy = BA_WAS_SEL
         */
        Base *base;
 
         */
        Base *base;
 
@@ -5463,32 +5446,32 @@ static void set_trans_object_base_flags(TransInfo *t)
                return;
 
        /* makes sure base flags and object flags are identical */
                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->scene_layer);
 
        /* Make sure depsgraph is here. */
 
        /* Make sure depsgraph is here. */
-       DAG_scene_relations_update(G.main, t->scene);
+       DEG_scene_relations_update(G.main, t->scene);
 
        /* handle pending update events, otherwise they got copied below */
 
        /* handle pending update events, otherwise they got copied below */
-       for (base = scene->base.first; base; base = base->next) {
+       for (base = sl->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);
                }
        }
 
                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);
                }
        }
 
-       for (base = scene->base.first; base; base = base->next) {
-               base->flag &= ~BA_WAS_SEL;
+       for (base = sl->object_bases.first; base; base = base->next) {
+               base->flag_legacy &= ~BA_WAS_SEL;
 
 
-               if (TESTBASELIB_BGMODE(v3d, scene, base)) {
+               if (TESTBASELIB_BGMODE_NEW(base)) {
                        Object *ob = base->object;
                        Object *parsel = ob->parent;
 
                        /* if parent selected, deselect */
                        while (parsel) {
                        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_scene_layer_base_find(sl, parsel);
                                        if (parbase) { /* in rare cases this can fail */
                                        if (parbase) { /* in rare cases this can fail */
-                                               if (TESTBASELIB_BGMODE(v3d, scene, parbase)) {
+                                               if (TESTBASELIB_BGMODE_NEW(parbase)) {
                                                        break;
                                                }
                                        }
                                                        break;
                                                }
                                        }
@@ -5501,29 +5484,24 @@ static void set_trans_object_base_flags(TransInfo *t)
                                if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
                                    (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))
                                {
                                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 {
                                }
                                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 */
-#ifdef WITH_LEGACY_DEPSGRAPH
-       DAG_scene_flush_update(G.main, t->scene, -1, 0);
-#endif
-
        /* and we store them temporal in base (only used for transform code) */
        /* this because after doing updates, the object->recalc is cleared */
        /* 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 = sl->object_bases.first; base; base = base->next) {
                if (base->object->recalc & OB_RECALC_OB)
                if (base->object->recalc & OB_RECALC_OB)
-                       base->flag |= BA_HAS_RECALC_OB;
+                       base->flag_legacy |= BA_HAS_RECALC_OB;
                if (base->object->recalc & OB_RECALC_DATA)
                if (base->object->recalc & OB_RECALC_DATA)
-                       base->flag |= BA_HAS_RECALC_DATA;
+                       base->flag_legacy |= BA_HAS_RECALC_DATA;
        }
 }
 
        }
 }
 
@@ -5545,8 +5523,7 @@ static bool mark_children(Object *ob)
 static int count_proportional_objects(TransInfo *t)
 {
        int total = 0;
 static int count_proportional_objects(TransInfo *t)
 {
        int total = 0;
-       Scene *scene = t->scene;
-       View3D *v3d = t->view;
+       SceneLayer *sl = t->scene_layer;
        Base *base;
 
        /* rotations around local centers are allowed to propagate, so we take all objects */
        Base *base;
 
        /* rotations around local centers are allowed to propagate, so we take all objects */
@@ -5554,8 +5531,8 @@ static int count_proportional_objects(TransInfo *t)
              (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL)))
        {
                /* mark all parents */
              (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 = sl->object_bases.first; base; base = base->next) {
+                       if (TESTBASELIB_BGMODE_NEW(base)) {
                                Object *parent = base->object->parent;
        
                                /* flag all parents */
                                Object *parent = base->object->parent;
        
                                /* flag all parents */
@@ -5567,25 +5544,27 @@ static int count_proportional_objects(TransInfo *t)
                }
 
                /* mark all children */
                }
 
                /* mark all children */
-               for (base = scene->base.first; base; base = base->next) {
+               for (base = sl->object_bases.first; base; base = base->next) {
                        /* all base not already selected or marked that is editable */
                        /* 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_NEW(base)))
                        {
                                mark_children(base->object);
                        }
                }
        }
        
                        {
                                mark_children(base->object);
                        }
                }
        }
        
-       for (base = scene->base.first; base; base = base->next) {
+       for (base = sl->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 */
                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_NEW(base)))
                {
 
                {
 
-                       DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+                       DEG_id_tag_update(&ob->id, OB_RECALC_OB);
 
                        total += 1;
                }
 
                        total += 1;
                }
@@ -5593,18 +5572,15 @@ static int count_proportional_objects(TransInfo *t)
        
 
        /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
        
 
        /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
-       DAG_scene_relations_update(G.main, t->scene);
-#ifdef WITH_LEGACY_DEPSGRAPH
-       DAG_scene_flush_update(G.main, t->scene, -1, 0);
-#endif
+       DEG_scene_relations_update(G.main, t->scene);
 
        /* and we store them temporal in base (only used for transform code) */
        /* this because after doing updates, the object->recalc is cleared */
 
        /* 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 = sl->object_bases.first; base; base = base->next) {
                if (base->object->recalc & OB_RECALC_OB)
                if (base->object->recalc & OB_RECALC_OB)
-                       base->flag |= BA_HAS_RECALC_OB;
+                       base->flag_legacy |= BA_HAS_RECALC_OB;
                if (base->object->recalc & OB_RECALC_DATA)
                if (base->object->recalc & OB_RECALC_DATA)
-                       base->flag |= BA_HAS_RECALC_DATA;
+                       base->flag_legacy |= BA_HAS_RECALC_DATA;
        }
 
        return total;
        }
 
        return total;
@@ -5612,14 +5588,15 @@ static int count_proportional_objects(TransInfo *t)
 
 static void clear_trans_object_base_flags(TransInfo *t)
 {
 
 static void clear_trans_object_base_flags(TransInfo *t)
 {
-       Scene *sce = t->scene;
+       SceneLayer *sl = t->scene_layer;
        Base *base;
 
        Base *base;
 
-       for (base = sce->base.first; base; base = base->next) {
-               if (base->flag & BA_WAS_SEL)
-                       base->flag |= SELECT;
+       for (base = sl->object_bases.first; base; base = base->next) {
+               if (base->flag_legacy & BA_WAS_SEL) {
+                       base->flag |= BASE_SELECTED;
+               }
 
 
-               base->flag &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
+               base->flag_legacy &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
        }
 }
 
        }
 }
 
@@ -5627,7 +5604,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
  *  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, SceneLayer *sl, View3D *v3d, Object *ob, int tmode)
 {
        ID *id = &ob->id;
        FCurve *fcu;
 {
        ID *id = &ob->id;
        FCurve *fcu;
@@ -5676,7 +5653,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) {
                        }
                        else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
                                if (v3d->around == V3D_AROUND_ACTIVE) {
-                                       if (ob != OBACT)
+                                       if (ob != OBACT_NEW)
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
@@ -5687,7 +5664,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) {
                        }
                        else if (tmode == TFM_RESIZE) {
                                if (v3d->around == V3D_AROUND_ACTIVE) {
-                                       if (ob != OBACT)
+                                       if (ob != OBACT_NEW)
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
                                                do_loc = true;
                                }
                                else if (v3d->around == V3D_AROUND_CURSOR)
@@ -6180,9 +6157,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))
                        // 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
                                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:
                        }
                        
                        /* 3 cases here for curve cleanups:
@@ -6392,24 +6369,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);
                /* 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 */
                }
                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
                        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->options & CTX_PAINT_CURVE) {
                /* pass */
        }
-       else if ((t->scene->basact) &&
-                (ob = t->scene->basact->object) &&
+       else if ((t->scene_layer->basact) &&
+                (ob = t->scene_layer->basact->object) &&
                 (ob->mode & OB_MODE_PARTICLE_EDIT) &&
                 (ob->mode & OB_MODE_PARTICLE_EDIT) &&
-                PE_get_current(t->scene, ob))
+                PE_get_current(t->scene, t->scene_layer, ob))
        {
                /* do nothing */
        }
        {
                /* do nothing */
        }
@@ -6440,17 +6417,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
 
                        /* pointcache refresh */
                        if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
 
                        /* 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 */
 
                        /* 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) {
 
                        /* 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->scene_layer, (View3D *)t->view, ob, t->mode);
                        }
                        
                        /* restore rigid body transform */
                        }
                        
                        /* restore rigid body transform */
@@ -6485,8 +6462,6 @@ int special_transform_moving(TransInfo *t)
 
 static void createTransObject(bContext *C, 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;
        TransData *td = NULL;
        TransDataExtension *tx;
        const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
@@ -6536,15 +6511,16 @@ static void createTransObject(bContext *C, TransInfo *t)
        CTX_DATA_END;
        
        if (is_prop_edit) {
        CTX_DATA_END;
        
        if (is_prop_edit) {
-               View3D *v3d = t->view;
+               SceneLayer *sl = t->scene_layer;
                Base *base;
 
                Base *base;
 
-               for (base = scene->base.first; base; base = base->next) {
+               for (base = sl->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 */
                        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_NEW(base))
                        {
                                td->protectflag = ob->protectflag;
                                td->ext = tx;
                        {
                                td->protectflag = ob->protectflag;
                                td->ext = tx;
@@ -7991,7 +7967,8 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 void createTransData(bContext *C, TransInfo *t)
 {
        Scene *scene = t->scene;
 void createTransData(bContext *C, TransInfo *t)
 {
        Scene *scene = t->scene;
-       Object *ob = OBACT;
+       SceneLayer *sl = t->scene_layer;
+       Object *ob = OBACT_NEW;
 
        /* if tests must match recalcData for correct updates */
        if (t->options & CTX_TEXTURE) {
 
        /* if tests must match recalcData for correct updates */
        if (t->options & CTX_TEXTURE) {
@@ -8156,17 +8133,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) {
                 * 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_scene_layer_base_find(t->scene_layer, ob_armature);
                        if (base_arm) {
                        if (base_arm) {
-                               View3D *v3d = t->view;
-                               if (BASE_VISIBLE(v3d, base_arm)) {
+                               if (BASE_VISIBLE_NEW(base_arm)) {
                                        createTransPose(t, ob_armature);
                                }
                        }
                        
                }
        }
                                        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, sl, ob))) {
                createTransParticleVerts(C, t);
                t->flag |= T_POINTS;
 
                createTransParticleVerts(C, t);
                t->flag |= T_POINTS;