Farewell Scene->base
authorDalai Felinto <dfelinto@gmail.com>
Wed, 8 Nov 2017 14:16:49 +0000 (12:16 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 8 Nov 2017 20:39:01 +0000 (18:39 -0200)
While getting rid of Scene->base we got the following fixes:

* Fix "Convert To" operator
* Fix "NLA allowing to selected objects that are not selectable
* Fix scene.objects (readonly, no option to link/unlink)

Note: Collada needs to use the context SceneLayer for adding objects
however I added a placeholder, so Collada maintainers can fix this
properly.

41 files changed:
source/blender/blenkernel/BKE_layer.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/blender_copybuffer.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/layer.c
source/blender/blenkernel/intern/library_query.c
source/blender/blenkernel/intern/library_remap.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_250.c
source/blender/blenloader/intern/writefile.c
source/blender/collada/DocumentImporter.cpp
source/blender/collada/EffectExporter.cpp
source/blender/collada/collada_utils.cpp
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_screen.h
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_select.c
source/blender/editors/scene/scene_edit.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_scene.c
source/blender/render/intern/source/pipeline.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Ketsji/KX_Light.cpp

index 1585742729c785958e199d609aed735a9e55ed5f..aa2a2167b95381f18c07add0a67b6150aed18a37 100644 (file)
@@ -67,8 +67,10 @@ void BKE_scene_layer_free(struct SceneLayer *sl);
 
 void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);
 
+struct Object *BKE_scene_layer_camera_find(struct SceneLayer *sl);
 struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc);
 struct Base *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob);
+struct Base *BKE_scene_layer_base_find_by_name(struct SceneLayer *sl, struct Object *ob);
 void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl);
 void BKE_scene_layer_base_select(struct SceneLayer *sl, struct Base *selbase);
 
index 5dcd22190ac6b2fbb11c8ce9e55822a45002d3df..380da4530b9e5ff4e4baf41ed18e5e34a76262b9 100644 (file)
@@ -63,7 +63,6 @@ void BKE_object_free_particlesystems(struct Object *ob);
 void BKE_object_free_softbody(struct Object *ob);
 void BKE_object_free_bulletsoftbody(struct Object *ob);
 void BKE_object_free_curve_cache(struct Object *ob);
-void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob);
 
 void BKE_object_free(struct Object *ob);
 void BKE_object_free_derived_caches(struct Object *ob);
index b9e88d02efcbfc3d235382d1552629c81cc73007..04761b3fa9e953bdfab7ea7b0930c8a02dfc2b3a 100644 (file)
@@ -88,13 +88,8 @@ struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
 
 void BKE_scene_remove_rigidbody_object(struct Scene *scene, struct Object *ob);
 
-/* base functions */
-struct BaseLegacy *BKE_scene_base_find_by_name(struct Scene *scene, const char *name);
-struct BaseLegacy *BKE_scene_base_find(struct Scene *scene, struct Object *ob);
-struct BaseLegacy *BKE_scene_base_add(struct Scene *sce, struct Object *ob);
-void         BKE_scene_base_unlink(struct Scene *sce, struct BaseLegacy *base);
-void         BKE_scene_base_deselect_all(struct Scene *sce);
-void         BKE_scene_base_select(struct Scene *sce, struct BaseLegacy *selbase);
+bool BKE_scene_object_find(struct Scene *scene, struct Object *ob);
+struct Object *BKE_scene_object_find_by_name(struct Scene *scene, const char *name);
 
 /* Scene base iteration function.
  * Define struct here, so no need to bother with alloc/free it.
@@ -129,7 +124,6 @@ void BKE_scene_make_local(struct Main *bmain, struct Scene *sce, const bool lib_
 
 struct Scene *BKE_scene_find_from_collection(const struct Main *bmain, const struct SceneCollection *scene_collection);
 
-struct Object *BKE_scene_camera_find(struct Scene *sc);
 #ifdef DURIAN_CAMERA_SWITCH
 struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH
 #endif
index 2d37f3ab0cbe78e5cf78eabdcc7d10acf98f665b..f249765e016f2f14efb8b03e4e6e785eb1c41b0c 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_blendfile.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_scene.h"
@@ -119,7 +120,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
-       SceneLayer *sl = CTX_data_scene_layer(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        Main *mainl = NULL;
        Library *lib;
        BlendHandle *bh;
@@ -131,7 +132,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
                return false;
        }
 
-       BKE_scene_base_deselect_all(scene);
+       BKE_scene_layer_base_deselect_all(scene_layer);
 
        /* tag everything, all untagged data can be made local
         * its also generally useful to know what is new
@@ -144,7 +145,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
 
        BLO_library_link_copypaste(mainl, bh);
 
-       BLO_library_link_end(mainl, &bh, flag, scene, sl);
+       BLO_library_link_end(mainl, &bh, flag, scene, scene_layer);
 
        /* mark all library linked objects to be updated */
        BKE_main_lib_objects_recalc_all(bmain);
index ac004e587859d53e6d62005cccfc7f69a5efad89..d9280a84678cb5c2f0cc06e01315e09f8f4cecdc 100644 (file)
@@ -49,6 +49,7 @@
 #include "BKE_camera.h"
 #include "BKE_object.h"
 #include "BKE_global.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
 #include "BKE_library_remap.h"
@@ -885,9 +886,9 @@ static Object *camera_multiview_advanced(Scene *scene, Object *camera, const cha
        }
 
        if (name[0] != '\0') {
-               BaseLegacy *base = BKE_scene_base_find_by_name(scene, name);
-               if (base) {
-                       return base->object;
+               Object *ob = BKE_scene_object_find_by_name(scene, name);
+               if (ob != NULL) {
+                       return ob;
                }
        }
 
@@ -1018,4 +1019,4 @@ void BKE_camera_background_image_clear(Camera *cam)
 
                bgpic = next_bgpic;
        }
-}
\ No newline at end of file
+}
index 5ccbe9f705449bfd2774e9c0c3e12186874b332d..5e5f8114ead0336fba04a4a999e3258a616c1704 100644 (file)
@@ -51,7 +51,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
-#include "BKE_scene.h" /* BKE_scene_base_find */
+#include "BKE_scene.h"
 
 static void free_group_object(GroupObject *go)
 {
index 3544cf02afb73b71bba623476dba00bf64bdab8a..c6ee00c58397b3d84d0c74fea84324a22fef9c82 100644 (file)
@@ -203,6 +203,24 @@ static bool find_scene_collection_in_scene_collections(ListBase *lb, const Layer
        return false;
 }
 
+/**
+ * Fallback for when a Scene has no camera to use
+ *
+ * \param scene_layer: in general you want to use the same SceneLayer that is used
+ * for depsgraph. If rendering you pass the scene active layer, when viewing in the viewport
+ * you want to get SceneLayer from context.
+ */
+Object *BKE_scene_layer_camera_find(SceneLayer *scene_layer)
+{
+       for (Base *base = scene_layer->object_bases.first; base; base = base->next) {
+               if (base->object->type == OB_CAMERA) {
+                       return base->object;
+               }
+       }
+
+       return NULL;
+}
+
 /**
  * Find the SceneLayer a LayerCollection belongs to
  */
index c59fd1b4085e13075c91d1e8788917567b88b95d..3b870fbc234e9fbcd7c4f8141b4316f3694e0485 100644 (file)
@@ -408,7 +408,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
                                Scene *scene = (Scene *) id;
                                ToolSettings *toolsett = scene->toolsettings;
                                SceneRenderLayer *srl;
-                               BaseLegacy *legacy_base;
 
                                CALLBACK_INVOKE(scene->camera, IDWALK_CB_NOP);
                                CALLBACK_INVOKE(scene->world, IDWALK_CB_USER);
@@ -466,10 +465,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
 
                                CALLBACK_INVOKE(scene->gpd, IDWALK_CB_USER);
 
-                               for (legacy_base = scene->base.first; legacy_base; legacy_base = legacy_base->next) {
-                                       CALLBACK_INVOKE(legacy_base->object, IDWALK_CB_USER);
-                               }
-
                                FOREACH_SCENE_COLLECTION(scene, sc)
                                {
                                        for (LinkData *link = sc->objects.first; link; link = link->next) {
index 13975dbcdebb3401d57486f1ed91f12aa88ba21d..e897f3c5330191e1724d39b2f9c977ababb7ed3c 100644 (file)
@@ -85,6 +85,7 @@
 #include "BKE_key.h"
 #include "BKE_lamp.h"
 #include "BKE_lattice.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
 #include "BKE_library_remap.h"
@@ -256,24 +257,6 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
        return IDWALK_RET_NOP;
 }
 
-/* Some remapping unfortunately require extra and/or specific handling, tackle those here. */
-static void libblock_remap_data_preprocess_scene_base_unlink(
-        IDRemap *r_id_remap_data, Scene *sce, BaseLegacy *base, const bool skip_indirect, const bool is_indirect)
-{
-       if (skip_indirect && is_indirect) {
-               r_id_remap_data->skipped_indirect++;
-               r_id_remap_data->skipped_refcounted++;
-       }
-       else {
-               id_us_min((ID *)base->object);
-               BKE_scene_base_unlink(sce, base);
-               MEM_freeN(base);
-               if (!is_indirect) {
-                       r_id_remap_data->status |= ID_REMAP_IS_LINKED_DIRECT;
-               }
-       }
-}
-
 /* Some remapping unfortunately require extra and/or specific handling, tackle those here. */
 static void libblock_remap_data_preprocess_scene_object_unlink(
         IDRemap *r_id_remap_data, Scene *sce, Object *ob, const bool skip_indirect, const bool is_indirect)
@@ -310,27 +293,12 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
                                                            r_id_remap_data, sce, ob_iter, skip_indirect, is_indirect);
                                        }
                                        FOREACH_SCENE_OBJECT_END
-
-
-                                       BaseLegacy *base, *base_next;
-                                       for (base = sce->base.first; base; base = base_next) {
-                                               base_next = base->next;
-                                               libblock_remap_data_preprocess_scene_base_unlink(
-                                                           r_id_remap_data, sce, base, skip_indirect, is_indirect);
-                                       }
                                }
                                else if (GS(r_id_remap_data->old_id->name) == ID_OB) {
                                        /* ... a specific object from scene. */
                                        Object *old_ob = (Object *)r_id_remap_data->old_id;
-
                                        libblock_remap_data_preprocess_scene_object_unlink(
                                                    r_id_remap_data, sce, old_ob, skip_indirect, is_indirect);
-
-                                       BaseLegacy *base = BKE_scene_base_find(sce, old_ob);
-                                       if (base) {
-                                               libblock_remap_data_preprocess_scene_base_unlink(
-                                                           r_id_remap_data, sce, base, skip_indirect, is_indirect);
-                                       }
                                }
                        }
                        break;
@@ -392,8 +360,8 @@ static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmai
 {
        /* Note that here we assume no object has no base (i.e. all objects are assumed instanced
         * in one scene...). */
-       for (BaseLegacy *base = sce->base.first; base; base = base->next) {
-               Object *ob = base->object;
+       FOREACH_SCENE_OBJECT(sce, ob)
+       {
                if (ob->flag & OB_FROMGROUP) {
                        Group *grp = BKE_group_object_find(NULL, ob);
 
@@ -406,6 +374,7 @@ static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmai
                        }
                }
        }
+       FOREACH_SCENE_OBJECT_END
 }
 
 static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), Object *ob, ID *new_id)
index 379b65e044cd179be3ea58f1b50c114c53da9b8a..39228891d51316074a8ec0afaefba90b6e4d7a87 100644 (file)
@@ -159,16 +159,6 @@ void BKE_object_workob_clear(Object *workob)
        workob->rotmode = ROT_MODE_EUL;
 }
 
-void BKE_object_update_base_layer(struct Scene *scene, Object *ob)
-{
-       BaseLegacy *base = scene->base.first;
-
-       while (base) {
-               if (base->object == ob) base->lay = ob->lay;
-               base = base->next;
-       }
-}
-
 void BKE_object_free_particlesystems(Object *ob)
 {
        ParticleSystem *psys;
index ce2e4e62be1f3bdce4797047f907d30cfb95522c..95f10cc9846c10722ad4f05335d09a8b179661a5 100644 (file)
@@ -242,16 +242,6 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
        sce_dst->obedit = NULL;
        sce_dst->fps_info = NULL;
 
-       BLI_duplicatelist(&(sce_dst->base), &(sce_src->base));
-       for (BaseLegacy *base_dst = sce_dst->base.first, *base_src = sce_src->base.first;
-            base_dst;
-            base_dst = base_dst->next, base_src = base_src->next)
-       {
-               if (base_src == sce_src->basact) {
-                       sce_dst->basact = base_dst;
-               }
-       }
-
        /* layers and collections */
        sce_dst->collection = MEM_dupallocN(sce_src->collection);
        SceneCollection *mc_src = BKE_collection_master(sce_src);
@@ -590,7 +580,6 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
        BKE_sequencer_clear_scene_in_allseqs(G.main, sce);
 
        sce->basact = NULL;
-       BLI_freelistN(&sce->base);
        BKE_sequencer_editing_free(sce);
 
        BKE_keyingsets_free(&sce->keyingsets);
@@ -1081,22 +1070,29 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
        return sce;
 }
 
-BaseLegacy *BKE_scene_base_find_by_name(struct Scene *scene, const char *name)
+/**
+ * Check if there is any intance of the object in the scene
+ */
+bool BKE_scene_object_find(Scene *scene, Object *ob)
 {
-       BaseLegacy *base;
-
-       for (base = scene->base.first; base; base = base->next) {
-               if (STREQ(base->object->id.name + 2, name)) {
-                       break;
+       for (SceneLayer *scene_layer = scene->render_layers.first; scene_layer; scene_layer = scene_layer->next) {
+               if (BLI_findptr(&scene_layer->object_bases, ob, offsetof(Base, object))) {
+                   return true;
                }
        }
-
-       return base;
+       return false;
 }
 
-BaseLegacy *BKE_scene_base_find(Scene *scene, Object *ob)
+Object *BKE_scene_object_find_by_name(Scene *scene, const char *name)
 {
-       return BLI_findptr(&scene->base, ob, offsetof(BaseLegacy, object));
+       for (SceneLayer *scene_layer = scene->render_layers.first; scene_layer; scene_layer = scene_layer->next) {
+               for (Base *base = scene_layer->object_bases.first; base; base = base->next) {
+                       if (STREQ(base->object->id.name + 2, name)) {
+                               return base->object;
+                       }
+               }
+       }
+       return NULL;
 }
 
 /**
@@ -1106,7 +1102,6 @@ BaseLegacy *BKE_scene_base_find(Scene *scene, Object *ob)
  */
 void BKE_scene_set_background(Main *bmain, Scene *scene)
 {
-       BaseLegacy *base;
        Object *ob;
        Group *group;
        GroupObject *go;
@@ -1132,12 +1127,12 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
        }
 
        /* copy layers and flags from bases to objects */
-       for (base = scene->base.first; base; base = base->next) {
-               ob = base->object;
-               ob->lay = base->lay;
-               
-               /* group patch... */
-               BKE_scene_base_flag_sync_from_base(base);
+       for (SceneLayer *scene_layer = scene->render_layers.first; scene_layer; scene_layer = scene_layer->next) {
+               for (Base *base = scene_layer->object_bases.first; base; base = base->next) {
+                       ob = base->object;
+                       /* group patch... */
+                       BKE_scene_object_base_flag_sync_from_base(base);
+               }
        }
        /* no full animation update, this to enable render code to work (render code calls own animation updates) */
 }
@@ -1177,17 +1172,19 @@ int BKE_scene_base_iter_next(
 
                        /* the first base */
                        if (iter->phase == F_START) {
-                               *base = (*scene)->base.first;
+                               SceneLayer *scene_layer = eval_ctx->scene_layer;
+                               *base = scene_layer->object_bases.first;
                                if (*base) {
                                        *ob = (*base)->object;
                                        iter->phase = F_SCENE;
                                }
                                else {
-                                       /* exception: empty scene */
+                                       /* exception: empty scene layer */
                                        while ((*scene)->set) {
                                                (*scene) = (*scene)->set;
-                                               if ((*scene)->base.first) {
-                                                       *base = (*scene)->base.first;
+                                               SceneLayer *scene_layer_set = BKE_scene_layer_from_scene_get((*scene));
+                                               if (scene_layer_set->object_bases.first) {
+                                                       *base = scene_layer_set->object_bases.first;
                                                        *ob = (*base)->object;
                                                        iter->phase = F_SCENE;
                                                        break;
@@ -1206,8 +1203,9 @@ int BKE_scene_base_iter_next(
                                                        /* (*scene) is finished, now do the set */
                                                        while ((*scene)->set) {
                                                                (*scene) = (*scene)->set;
-                                                               if ((*scene)->base.first) {
-                                                                       *base = (*scene)->base.first;
+                                                               SceneLayer *scene_layer_set = BKE_scene_layer_from_scene_get((*scene));
+                                                               if (scene_layer_set->object_bases.first) {
+                                                                       *base = scene_layer_set->object_bases.first;
                                                                        *ob = (*base)->object;
                                                                        break;
                                                                }
@@ -1298,17 +1296,6 @@ Scene *BKE_scene_find_from_collection(const Main *bmain, const SceneCollection *
        return NULL;
 }
 
-Object *BKE_scene_camera_find(Scene *sc)
-{
-       BaseLegacy *base;
-       
-       for (base = sc->base.first; base; base = base->next)
-               if (base->object->type == OB_CAMERA)
-                       return base->object;
-
-       return NULL;
-}
-
 #ifdef DURIAN_CAMERA_SWITCH
 Object *BKE_scene_camera_switch_find(Scene *scene)
 {
@@ -1412,48 +1399,6 @@ void BKE_scene_remove_rigidbody_object(Scene *scene, Object *ob)
                BKE_rigidbody_remove_object(scene, ob);
 }
 
-BaseLegacy *BKE_scene_base_add(Scene *sce, Object *ob)
-{
-       BaseLegacy *b = MEM_callocN(sizeof(*b), __func__);
-       BLI_addhead(&sce->base, b);
-
-       b->object = ob;
-       b->flag_legacy = ob->flag;
-       b->lay = ob->lay;
-
-       return b;
-}
-
-void BKE_scene_base_unlink(Scene *sce, BaseLegacy *base)
-{
-       BKE_scene_remove_rigidbody_object(sce, base->object);
-
-       BLI_remlink(&sce->base, base);
-       if (sce->basact == base)
-               sce->basact = NULL;
-}
-
-/* deprecated, use BKE_scene_layer_base_deselect_all */
-void BKE_scene_base_deselect_all(Scene *sce)
-{
-       BaseLegacy *b;
-
-       for (b = sce->base.first; b; b = b->next) {
-               b->flag_legacy &= ~SELECT;
-               int flag = b->object->flag & (OB_FROMGROUP);
-               b->object->flag = b->flag_legacy;
-               b->object->flag |= flag;
-       }
-}
-
-void BKE_scene_base_select(Scene *sce, BaseLegacy *selbase)
-{
-       selbase->flag_legacy |= SELECT;
-       selbase->object->flag = selbase->flag_legacy;
-
-       sce->basact = selbase;
-}
-
 /* checks for cycle, returns 1 if it's all OK */
 bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
 {
index b4ef381534f18e67837c7c2d4c65e0df48839120..6ebd8e6ae36776fbe8dbb9e4dea509e3726a1a4d 100644 (file)
@@ -61,6 +61,7 @@
 #include "BKE_movieclip.h"
 #include "BKE_object.h"
 #include "BKE_scene.h"
+#include "BKE_layer.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -400,7 +401,7 @@ void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4
                if (scene->camera)
                        ob = scene->camera;
                else
-                       ob = BKE_scene_camera_find(scene);
+                       ob = BKE_scene_layer_camera_find(BKE_scene_layer_from_scene_get(scene));
        }
 
        if (ob)
index c88deeca126b67dd598bef451559f2941ebab27b..8bdaa1d91bb30f0267c3176530fdc1a4e23c0001 100644 (file)
@@ -5831,7 +5831,7 @@ static void lib_link_scene(FileData *fd, Main *main)
                        
                        sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object);
                        
-                       for (BaseLegacy *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) {
+                       for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) {
                                base_legacy_next = base_legacy->next;
                                
                                base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object);
@@ -9778,13 +9778,12 @@ static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection
 
 static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
 {
-       BaseLegacy *base;
        SceneRenderLayer *srl;
        FreestyleModuleConfig *module;
        FreestyleLineSet *lineset;
        
-       for (base = sce->base.first; base; base = base->next) {
-               expand_doit(fd, mainvar, base->object);
+       for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) {
+               expand_doit(fd, mainvar, base_legacy->object);
        }
        expand_doit(fd, mainvar, sce->camera);
        expand_doit(fd, mainvar, sce->world);
@@ -10108,7 +10107,7 @@ static bool object_in_any_scene(Main *mainvar, Object *ob)
        Scene *sce;
        
        for (sce = mainvar->scene.first; sce; sce = sce->id.next) {
-               if (BKE_scene_base_find(sce, ob)) {
+               if (BKE_scene_object_find(sce, ob)) {
                        return true;
                }
        }
index 0895b956563d1b408bffdd6c90f6de157a9c22c4..3ee6891f17fcf84539f4102178a9d3353b649c9f 100644 (file)
@@ -736,7 +736,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
        if (main->versionfile < 250) {
                bScreen *screen;
                Scene *scene;
-               BaseLegacy *base;
+               Base *base;
                Material *ma;
                Camera *cam;
                Mesh *me;
index da41433f6bc58b2e7ec3a6efd456673c4fe058a4..2ad996f197d83dfc4c5b80c9419f2b24f5f2b3ba 100644 (file)
@@ -2604,10 +2604,6 @@ static void write_scene(WriteData *wd, Scene *sce)
        write_keyingsets(wd, &sce->keyingsets);
 
        /* direct data */
-       for (BaseLegacy *base = sce->base.first; base; base = base->next) {
-               writestruct(wd, DATA, BaseLegacy, 1, base);
-       }
-
        ToolSettings *tos = sce->toolsettings;
        writestruct(wd, DATA, ToolSettings, 1, tos);
        if (tos->vpaint) {
index 39a36781e0e310c208ddd161dfd3731a168e2632..bc986f1139447101de0c7167eb41ceb8c2cc146f 100644 (file)
@@ -59,6 +59,7 @@ extern "C" {
 #include "BKE_camera.h"
 #include "BKE_collection.h"
 #include "BKE_main.h"
+#include "BKE_layer.h"
 #include "BKE_lamp.h"
 #include "BKE_library.h"
 #include "BKE_texture.h"
@@ -133,7 +134,7 @@ bool DocumentImporter::import()
        loader.registerExtraDataCallbackHandler(ehandler);
 
        // deselect all to select new objects
-       BKE_scene_base_deselect_all(CTX_data_scene(mContext));
+       BKE_scene_layer_base_deselect_all(CTX_data_scene_layer(mContext));
 
        std::string mFilename = std::string(this->import_settings->filepath);
        const std::string encodedFilename = bc_url_encode(mFilename);
@@ -266,15 +267,7 @@ void DocumentImporter::finish()
                std::vector<Object *>::iterator it;
                for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
                        Object *ob = *it;
-
-                       BaseLegacy *base = (BaseLegacy *)BKE_scene_base_find(sce, ob);
-                       if (base) {
-                               BLI_remlink(&sce->base, base);
-                               BKE_libblock_free_us(G.main, base->object);
-                               if (sce->basact == base)
-                                       sce->basact = NULL;
-                               MEM_freeN(base);
-                       }
+                       BKE_collections_object_remove(G.main, sce, ob, true);
                }
                libnode_ob.clear();
 
index 978d79077fe64f60d0b96b4169e8745fbb25b5ac..87392352a48e181ab1f4066711b15394a46cb59c 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
        #include "DNA_texture_types.h"
        #include "DNA_world_types.h"
 
+       #include "BKE_collection.h"
        #include "BKE_customdata.h"
        #include "BKE_mesh.h"
        #include "BKE_material.h"
@@ -66,10 +67,8 @@ EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettin
 
 bool EffectsExporter::hasEffects(Scene *sce)
 {
-       BaseLegacy *base = (BaseLegacy *)sce->base.first;
-       
-       while (base) {
-               Object *ob = base->object;
+       FOREACH_SCENE_OBJECT(scene, ob)
+       {
                int a;
                for (a = 0; a < ob->totcol; a++) {
                        Material *ma = give_current_material(ob, a + 1);
@@ -79,8 +78,8 @@ bool EffectsExporter::hasEffects(Scene *sce)
 
                        return true;
                }
-               base = base->next;
        }
+       FOREACH_SCENE_OBJECT_END
        return false;
 }
 
index 3bdd22a53f8f22a73b87203a7743fc17b6ba5a4f..85976c64b5f6481d302440870143c6d3b9eb508b 100644 (file)
@@ -47,6 +47,7 @@ extern "C" {
 #include "BKE_customdata.h"
 #include "BKE_object.h"
 #include "BKE_global.h"
+#include "BKE_layer.h"
 #include "BKE_mesh.h"
 #include "BKE_scene.h"
 #include "BKE_DerivedMesh.h"
@@ -142,7 +143,14 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
        ob->lay = scene->lay;
        DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
 
-       BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob));
+       /* XXX Collada should use the context scene layer, not the scene one. (dfelinto/gaia). */
+       SceneLayer *scene_layer = BKE_scene_layer_context_active_PLACEHOLDER(scene);
+
+       LayerCollection *layer_collection = BKE_layer_collection_get_active_ensure(scene, scene_layer);
+       BKE_collection_object_add(scene, layer_collection->scene_collection, ob);
+
+       Base *base = BKE_scene_layer_base_find(scene_layer, ob);
+       BKE_scene_layer_base_select(scene_layer, base);
 
        return ob;
 }
index 26ba61f0f200fb97a2fd0a45838fe4f50e1494c7..e705d0268e34d600b25e71e1072a91b862b74b0c 100644 (file)
@@ -2684,6 +2684,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
                {
                        bDopeSheet *ads = (bDopeSheet *)ac->data;
                        Scene *sce = (Scene *)ads->source;
+                       SceneLayer *scene_layer = ac->scene_layer;
                        BaseLegacy *base = (BaseLegacy *)ale->data;
                        Object *ob = base->object;
                        AnimData *adt = ob->adt;
@@ -2691,30 +2692,30 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
                        /* set selection status */
                        if (selectmode == SELECT_INVERT) {
                                /* swap select */
-                               base->flag_legacy ^= SELECT;
-                               BKE_scene_base_flag_sync_from_base(base);
+                               ED_object_base_select(base, BA_INVERT);
+                               BKE_scene_object_base_flag_sync_from_base(base);
                                
                                if (adt) adt->flag ^= ADT_UI_SELECTED;
                        }
                        else {
-                               BaseLegacy *b;
+                               Base *b;
                                
                                /* deselect all */
                                /* TODO: should this deselect all other types of channels too? */
-                               for (b = sce->base.first; b; b = b->next) {
-                                       b->flag_legacy &= ~SELECT;
-                                       BKE_scene_base_flag_sync_from_base(b);
+                               for (b = scene_layer->object_bases.first; b; b = b->next) {
+                                       ED_object_base_select(b, BA_DESELECT);
+                                       BKE_scene_object_base_flag_sync_from_base(b);
                                        if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
                                }
                                
                                /* select object now */
-                               base->flag_legacy |= SELECT;
-                               ob->flag |= SELECT;
+                               ED_object_base_select(base, BA_SELECT);
+                               BKE_scene_object_base_flag_sync_from_base(base);
                                if (adt) adt->flag |= ADT_UI_SELECTED;
                        }
                        
                        /* change active object - regardless of whether it is now selected [T37883] */
-                       ED_base_object_activate(C, base); /* adds notifier */
+                       ED_object_base_activate(C, base); /* adds notifier */
                        
                        if ((adt) && (adt->flag & ADT_UI_SELECTED))
                                adt->flag |= ADT_UI_ACTIVE;
index b24f48a10f9dc8c20319e71b4a4d1af8f1388a66..4821fdd6af73ebdc47f94363937ad98e6a6cab9a 100644 (file)
@@ -1143,13 +1143,13 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
 
        if (camera) {
                Scene *scene = CTX_data_scene(C);
-               SceneLayer *sl = CTX_data_scene_layer(C);
+               SceneLayer *scene_layer = CTX_data_scene_layer(C);
                Base *base;
                TimeMarker *marker;
                int sel = 0;
                
                if (!extend)
-                       BKE_scene_base_deselect_all(scene);
+                       BKE_scene_layer_base_deselect_all(scene_layer);
                
                for (marker = markers->first; marker; marker = marker->next) {
                        if (marker->frame == cfra) {
@@ -1161,7 +1161,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
                for (marker = markers->first; marker; marker = marker->next) {
                        if (marker->camera) {
                                if (marker->frame == cfra) {
-                                       base = BKE_scene_layer_base_find(sl, marker->camera);
+                                       base = BKE_scene_layer_base_find(scene_layer, marker->camera);
                                        if (base) {
                                                ED_object_base_select(base, sel);
                                                if (sel)
index 5e3c91e15ab2393a5b8bed1ceb30635395ea82a4..19c1588fe7e9f1d60531eb9a41ca97e0210ca333 100644 (file)
@@ -83,6 +83,12 @@ typedef enum eParentType {
        PAR_VERTEX_TRI,
 } eParentType;
 
+typedef enum eObjectSelect_Mode{
+       BA_DESELECT = 0,
+       BA_SELECT = 1,
+       BA_INVERT = 2,
+} eObjectSelect_Mode;
+
 #ifdef __RNA_TYPES_H__
 extern struct EnumPropertyItem prop_clear_parent_types[];
 extern struct EnumPropertyItem prop_make_parent_types[];
@@ -104,7 +110,7 @@ void ED_base_object_select(struct BaseLegacy *base, short mode);
 /* includes notifier */
 void ED_base_object_activate(struct bContext *C, struct BaseLegacy *base);
 
-void ED_object_base_select(struct Base *base, short mode);
+void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode);
 void ED_object_base_activate(struct bContext *C, struct Base *base);
 
 void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Object *ob);
index 8a1c7239955ef7475790c22b9aaf2a10c57d940e..f7219ce6846a37740126e2a1ca7485facd18edfd 100644 (file)
@@ -49,6 +49,7 @@ struct WorkSpace;
 struct WorkSpaceInstanceHook;
 struct bContext;
 struct Scene;
+struct SceneLayer;
 struct bScreen;
 struct ARegion;
 struct uiBlock;
@@ -113,7 +114,10 @@ void    ED_screen_draw(struct wmWindow *win);
 void    ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
 void    ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
 bool    ED_screen_change(struct bContext *C, struct bScreen *sc);
-void    ED_screen_update_after_scene_change(const struct bScreen *screen, struct Scene *scene_new);
+void    ED_screen_update_after_scene_change(
+        const struct bScreen *screen,
+        struct Scene *scene_new,
+        struct SceneLayer *scene_layer);
 void    ED_screen_set_subwinactive(struct bContext *C, const struct wmEvent *event);
 void    ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
 void    ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable);
index e5705d2d3e793dad0bec32209bc4a9792c6b3874..8d60a94ee349a80a751a70f80921f30c65ca34b2 100644 (file)
@@ -40,6 +40,7 @@
 #include "BLI_math_vector.h"
 #include "BLI_linklist.h"
 
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_context.h"
 #include "BKE_mesh.h"
@@ -337,7 +338,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
        int i, j, k;
        unsigned short *v;
        int face[3];
-       Scene *scene = CTX_data_scene(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        Object *obedit;
        int createob = base == NULL;
        int nverts, nmeshes, nvp;
@@ -355,8 +356,8 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
        }
        else {
                obedit = base->object;
-               BKE_scene_base_deselect_all(scene);
-               BKE_scene_base_select(scene, base);
+               BKE_scene_layer_base_deselect_all(scene_layer);
+               BKE_scene_layer_base_select(scene_layer, base);
                copy_v3_v3(obedit->loc, co);
                copy_v3_v3(obedit->rot, rot);
        }
index a761caab29bd9ecd71c4ea3e543920fdde84a824..ac24b106383dbe43aa3855af1b62ea404a29d92a 100644 (file)
@@ -1665,11 +1665,12 @@ static void curvetomesh(EvaluationContext *eval_ctx, Main *bmain, Scene *scene,
 
 static int convert_poll(bContext *C)
 {
-       Object *obact = CTX_data_active_object(C);
        Scene *scene = CTX_data_scene(C);
+       Base *base_act = CTX_data_active_base(C);
+       Object *obact = base_act ? base_act->object : NULL;
 
        return (!ID_IS_LINKED(scene) && obact && scene->obedit != obact &&
-               (obact->flag & SELECT) && !ID_IS_LINKED(obact));
+               (base_act->flag & BASE_SELECTED) && !ID_IS_LINKED(obact));
 }
 
 /* Helper for convert_exec */
@@ -1699,7 +1700,7 @@ static int convert_exec(bContext *C, wmOperator *op)
        SceneLayer *sl = CTX_data_scene_layer(C);
        EvaluationContext eval_ctx;
        Base *basen = NULL, *basact = NULL;
-       Object *ob, *ob1, *newob, *obact = CTX_data_active_object(C);
+       Object *ob1, *newob, *obact = CTX_data_active_object(C);
        DerivedMesh *dm;
        Curve *cu;
        Nurb *nu;
@@ -1714,10 +1715,8 @@ static int convert_exec(bContext *C, wmOperator *op)
        /* don't forget multiple users! */
 
        {
-               BaseLegacy *base;
-
-               for (base = scene->base.first; base; base = base->next) {
-                       ob = base->object;
+               FOREACH_SCENE_OBJECT(scene, ob)
+               {
                        ob->flag &= ~OB_DONE;
 
                        /* flag data thats not been edited (only needed for !keep_original) */
@@ -1736,6 +1735,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                                }
                        }
                }
+               FOREACH_SCENE_OBJECT_END
        }
 
        ListBase selected_editable_bases = CTX_data_collection_get(C, "selected_editable_bases");
@@ -1745,8 +1745,8 @@ static int convert_exec(bContext *C, wmOperator *op)
         * on other objects data masks too, see: T50950. */
        {
                for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
-                       BaseLegacy *base = link->ptr.data;
-                       ob = base->object;
+                       Base *base = link->ptr.data;
+                       Object *ob = base->object;
 
                        /* The way object type conversion works currently (enforcing conversion of *all* objetcs using converted
                         * obdata, even some un-selected/hidden/inother scene ones, sounds totally bad to me.
@@ -1770,8 +1770,8 @@ static int convert_exec(bContext *C, wmOperator *op)
        }
 
        for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
-               BaseLegacy *base = link->ptr.data;
-               ob = base->object;
+               Base *base = link->ptr.data;
+               Object *ob = base->object;
 
                if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) {
                        if (ob->type != target) {
@@ -1941,8 +1941,8 @@ static int convert_exec(bContext *C, wmOperator *op)
                else if (ob->type == OB_MBALL && target == OB_MESH) {
                        Object *baseob;
 
-                       base->flag &= ~SELECT;
-                       ob->flag &= ~SELECT;
+                       base->flag &= ~BASE_SELECTED;
+                       ob->base_flag &= ~BASE_SELECTED;
 
                        baseob = BKE_mball_basis_find(scene, ob);
 
@@ -2007,8 +2007,8 @@ static int convert_exec(bContext *C, wmOperator *op)
                if (mballConverted) {
                        FOREACH_SCENE_OBJECT(scene, ob_mball)
                        {
-                               if (ob->type == OB_MBALL) {
-                                       if (ob->flag & OB_DONE) {
+                               if (ob_mball->type == OB_MBALL) {
+                                       if (ob_mball->flag & OB_DONE) {
                                                Object *ob_basis = NULL;
                                                if (BKE_mball_is_basis(ob_mball) ||
                                                    ((ob_basis = BKE_mball_basis_find(scene, ob_mball)) && (ob_basis->flag & OB_DONE)))
index b9848a0cb4adda614a0e6e16b6d8ebbbf6a6498c..e2815bf228276a08b89fcff6fab3ac2e8c457932 100644 (file)
@@ -355,7 +355,6 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
 
        if (ob) {
                Object *newob;
-               Base *newbase, *oldbase = BASACT_NEW(scene_layer);
                char name[MAX_ID_NAME + 4];
 
                BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2);
@@ -364,16 +363,6 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
                newob = BKE_object_add_from(bmain, scene, scene_layer, OB_EMPTY, name, gob ? gob : ob);
 
                /* set layers OK */
-               newbase = BASACT_NEW(scene_layer);    /* BKE_object_add sets active... */
-               newbase->lay = oldbase->lay;
-               newob->lay = newbase->lay;
-
-               /* remove base, leave user count of object, it gets linked in BKE_object_make_proxy */
-               if (gob == NULL) {
-                       BKE_scene_base_unlink(scene, oldbase);
-                       MEM_freeN(oldbase);
-               }
-
                BKE_object_make_proxy(newob, ob, gob);
 
                /* Set back pointer immediately so dependency graph knows that this is
@@ -2048,12 +2037,13 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
        {
                IDP_RelinkProperty(scene->id.properties);
 
-               for (Base *base = scene->base.first; base; base = base->next) {
-                       Object *ob = base->object;
+               FOREACH_SCENE_OBJECT(scene, ob)
+               {
                        if (!ID_IS_LINKED(ob)) {
                                IDP_RelinkProperty(ob->id.properties);
                        }
                }
+               FOREACH_SCENE_OBJECT_END
 
                if (scene->nodetree) {
                        IDP_RelinkProperty(scene->nodetree->id.properties);
@@ -2236,15 +2226,15 @@ static int make_local_exec(bContext *C, wmOperator *op)
 
        /* Note: we (ab)use LIB_TAG_PRE_EXISTING to cherry pick which ID to make local... */
        if (mode == MAKE_LOCAL_ALL) {
-               SceneLayer *sl = CTX_data_scene_layer(C);
-               SceneCollection *sc = CTX_data_scene_collection(C);
+               SceneLayer *scene_layer = CTX_data_scene_layer(C);
+               SceneCollection *scene_collection = CTX_data_scene_collection(C);
 
                BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
 
-               /* de-select so the user can differentiate newly instanced from existing objects */
-               BKE_scene_base_deselect_all(scene);
+               /* De-select so the user can differentiate newly instanced from existing objects. */
+               BKE_scene_layer_base_deselect_all(scene_layer);
 
-               if (make_local_all__instance_indirect_unused(bmain, scene, sl, sc)) {
+               if (make_local_all__instance_indirect_unused(bmain, scene, scene_layer, scene_collection)) {
                        BKE_report(op->reports, RPT_INFO, "Orphan library objects added to the current scene to avoid loss");
                }
        }
index d0c37fc108a606611358eaf33b9747dc9e864cf0..9da7154ae8d05ec8f7a027b2105f28bcc9ed9666 100644 (file)
@@ -127,16 +127,25 @@ void ED_base_object_activate(bContext *C, BaseLegacy *base)
                WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, NULL);
 }
 
-void ED_object_base_select(Base *base, short mode)
+void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
 {
+       if (mode == BA_INVERT) {
+               mode = (base->flag & BASE_SELECTED) != 0 ? BA_DESELECT : BA_SELECT;
+       }
+
        if (base) {
-               if (mode == BA_SELECT) {
-                       if ((base->flag & BASE_SELECTABLED) != 0) {
-                               base->flag |= BASE_SELECTED;
-                       }
-               }
-               else if (mode == BA_DESELECT) {
-                       base->flag &= ~BASE_SELECTED;
+               switch (mode) {
+                       case BA_SELECT:
+                               if ((base->flag & BASE_SELECTABLED) != 0) {
+                                       base->flag |= BASE_SELECTED;
+                               }
+                               break;
+                       case BA_DESELECT:
+                               base->flag &= ~BASE_SELECTED;
+                               break;
+                       case BA_INVERT:
+                               /* Never happens. */
+                               break;
                }
        }
 }
index 4a104a330a423fca956562b3c49f3d1389ee8d09..dca4cc77e5b0be98811f66195a36e3640f30c5f6 100644 (file)
@@ -132,7 +132,7 @@ void ED_scene_changed_update(Main *bmain, bContext *C, Scene *scene_new, const b
        DEG_graph_relations_update(depsgraph, bmain, scene_new);
        DEG_on_visible_update(bmain, false);
 
-       ED_screen_update_after_scene_change(active_screen, scene_new);
+       ED_screen_update_after_scene_change(active_screen, scene_new, layer_new);
        ED_render_engine_changed(bmain);
        ED_update_for_newframe(bmain, scene_new, depsgraph);
 
index 5e0afe0ec392d92cd7c8b5070f27517a1e35ae1a..749a857fdaa672043735ec05927cbffe8e9cfca9 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_icons.h"
 #include "BKE_image.h"
 #include "BKE_global.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_library_remap.h"
 #include "BKE_main.h"
@@ -1302,13 +1303,13 @@ bool ED_screen_change(bContext *C, bScreen *sc)
        return false;
 }
 
-static void screen_set_3dview_camera(Scene *scene, ScrArea *sa, View3D *v3d)
+static void screen_set_3dview_camera(Scene *scene, SceneLayer *scene_layer, ScrArea *sa, View3D *v3d)
 {
        /* fix any cameras that are used in the 3d view but not in the scene */
        BKE_screen_view3d_sync(v3d, scene);
 
-       if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) {
-               v3d->camera = BKE_scene_camera_find(scene);
+       if (!v3d->camera || !BKE_scene_layer_base_find(scene_layer, v3d->camera)) {
+               v3d->camera = BKE_scene_layer_camera_find(scene_layer);
                // XXX if (sc == curscreen) handle_view3d_lock();
                if (!v3d->camera) {
                        ARegion *ar;
@@ -1332,13 +1333,13 @@ static void screen_set_3dview_camera(Scene *scene, ScrArea *sa, View3D *v3d)
        }
 }
 
-void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new)
+void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new, SceneLayer *scene_layer)
 {
        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
                        if (sl->spacetype == SPACE_VIEW3D) {
                                View3D *v3d = (View3D *)sl;
-                               screen_set_3dview_camera(scene_new, sa, v3d);
+                               screen_set_3dview_camera(scene_new, scene_layer, sa, v3d);
                        }
                }
        }
index 48e822ef876da95830f497910d191ae153145bf7..c1c9326b4ef8316459c57181734492ec727f0b94 100644 (file)
@@ -124,9 +124,8 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
                }
                case ANIMTYPE_OBJECT:
                {
-                       bDopeSheet *ads = (bDopeSheet *)ac->data;
-                       Scene *sce = (Scene *)ads->source;
-                       BaseLegacy *base = (BaseLegacy *)ale->data;
+                       SceneLayer *scene_layer = ac->scene_layer;
+                       Base *base = (Base *)ale->data;
                        Object *ob = base->object;
                        AnimData *adt = ob->adt;
                        
@@ -134,30 +133,28 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe
                                /* set selection status */
                                if (selectmode == SELECT_INVERT) {
                                        /* swap select */
-                                       base->flag_legacy ^= SELECT;
-                                       BKE_scene_base_flag_sync_from_base(base);
+                                       ED_object_base_select(base, BA_INVERT);
+                                       BKE_scene_object_base_flag_sync_from_base(base);
                                        
                                        if (adt) adt->flag ^= ADT_UI_SELECTED;
                                }
                                else {
-                                       BaseLegacy *b;
-                                       
                                        /* deselect all */
                                        /* TODO: should this deselect all other types of channels too? */
-                                       for (b = sce->base.first; b; b = b->next) {
-                                               b->flag_legacy &= ~SELECT;
-                                               BKE_scene_base_flag_sync_from_base(b);
+                                       for (Base *b = scene_layer->object_bases.first; b; b = b->next) {
+                                               ED_object_base_select(b, BA_DESELECT);
+                                               BKE_scene_object_base_flag_sync_from_base(b);
                                                if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
                                        }
                                        
                                        /* select object now */
-                                       base->flag_legacy |= SELECT;
-                                       ob->flag |= SELECT;
+                                       ED_object_base_select(base, BA_SELECT);
+                                       BKE_scene_object_base_flag_sync_from_base(base);
                                        if (adt) adt->flag |= ADT_UI_SELECTED;
                                }
                                
                                /* change active object - regardless of whether it is now selected [T37883] */
-                               ED_base_object_activate(C, base); /* adds notifier */
+                               ED_object_base_activate(C, base); /* adds notifier */
                                
                                if ((adt) && (adt->flag & ADT_UI_SELECTED))
                                        adt->flag |= ADT_UI_ACTIVE;
index 346e567dd8d1d2a7618d9d5f7e49742333469c44..229d999eb9e5fe71827f6cb3daf616c612655add 100644 (file)
@@ -39,6 +39,7 @@
 #include "BLI_mempool.h"
 
 #include "BKE_context.h"
+#include "BKE_layer.h"
 #include "BKE_screen.h"
 #include "BKE_scene.h"
 #include "BKE_outliner_treehash.h"
@@ -122,8 +123,17 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *e
                                 * element for object it means that all displayed objects belong to
                                 * active scene and parenting them is allowed (sergey)
                                 */
-                               if (!scene || BKE_scene_base_find(scene, (Object *)id)) {
+                               if (!scene) {
                                        return 1;
+                               } else {
+                                       for (SceneLayer *scene_layer = scene->render_layers.first;
+                                            scene_layer;
+                                            scene_layer = scene_layer->next)
+                                       {
+                                               if (BKE_scene_layer_base_find(scene_layer, (Object *)id)) {
+                                                       return 1;
+                                               }
+                                       }
                                }
                        }
                        else if (ELEM(tselem->type, TSE_LAYER_COLLECTION, TSE_SCENE_COLLECTION)) {
index 9fe35d571686ff180b1bfae42728e498eb453e7a..0ec41fed13fda6a1f4b3c23441c128621859cadc 100644 (file)
@@ -787,24 +787,13 @@ static void *view3d_main_region_duplicate(void *poin)
        return NULL;
 }
 
-static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, const Scene *scene)
+static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene))
 {
        wmWindow *win = wmn->wm->winactive;
        unsigned int lay_used = 0;
-       BaseLegacy *base;
 
        if (!win) return;
 
-       base = scene->base.first;
-       while (base) {
-               lay_used |= base->lay & ((1 << 20) - 1); /* ignore localview */
-
-               if (lay_used == (1 << 20) - 1)
-                       break;
-
-               base = base->next;
-       }
-
        const bScreen *screen = WM_window_get_active_screen(win);
        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                if (sa->spacetype == SPACE_VIEW3D) {
index b157dd7f1e89d39a4e8325b3e751d61873f59511..15ac7ec1174b9031e2a9fc1c907042086c4eff07 100644 (file)
@@ -52,6 +52,7 @@
 #include "BKE_camera.h"
 #include "BKE_context.h"
 #include "BKE_font.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
@@ -3914,7 +3915,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
        ARegion *ar;
        RegionView3D *rv3d;
        Scene *scene = CTX_data_scene(C);
-       SceneLayer *sl = CTX_data_scene_layer(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        static int perspo = RV3D_PERSP;
        int viewnum, nextperspo;
        bool align_active;
@@ -3949,7 +3950,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        /* lastview -  */
 
                        if (rv3d->persp != RV3D_CAMOB) {
-                               Object *ob = OBACT_NEW(sl);
+                               Object *ob = OBACT_NEW(scene_layer);
 
                                if (!rv3d->smooth_timer) {
                                        /* store settings of current view before allowing overwriting with camera view
@@ -3984,7 +3985,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                                        v3d->camera = ob;
 
                                if (v3d->camera == NULL)
-                                       v3d->camera = BKE_scene_camera_find(scene);
+                                       v3d->camera = BKE_scene_layer_camera_find(scene_layer);
 
                                /* couldnt find any useful camera, bail out */
                                if (v3d->camera == NULL)
index 3f9c3293f8ddc51707eff4e64c7f2f4d9750cf19..6f79b90fd8a9881be0c116da1fde9c29194bb865 100644 (file)
@@ -209,7 +209,6 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
        }
        FOREACH_SCENE_COLLECTION_END
        BLI_freelistN(&scene_layer->object_bases);
-       BLI_freelistN(&freestyle_scene->base);
 
        // release materials
        Link *lnk = (Link *)freestyle_bmain->mat.first;
@@ -951,8 +950,6 @@ Object *BlenderStrokeRenderer::NewMesh() const
 
        SceneCollection *sc_master = BKE_collection_master(freestyle_scene);
        BKE_collection_object_add(freestyle_scene, sc_master, ob);
-
-       BKE_scene_base_add(freestyle_scene, ob);
        DEG_graph_tag_relations_update(freestyle_depsgraph);
 
        DEG_graph_id_tag_update(freestyle_bmain,
index ea3af3834b45646a671c190dd0716e346f432baa..6187a46dcd75be46bda6ce6f23eb0ca0aa391666 100644 (file)
@@ -543,12 +543,6 @@ enum {
 #define BA_TRANSFORM_CHILD  (1 << 8)  /* child of a transformed object */
 #define BA_TRANSFORM_PARENT (1 << 13)  /* parent of a transformed object */
 
-
-/* an initial attempt as making selection more specific! */
-#define BA_DESELECT     0
-#define BA_SELECT       1
-
-
 #define OB_FROMDUPLI        (1 << 9)
 #define OB_DONE             (1 << 10)  /* unknown state, clear before use */
 /* #define OB_RADIO            (1 << 11) */  /* deprecated */
index 0c491af8eeb5bff14e819f98c6d15de474228604..f05369a0d5867a699aea37842fff473b86e701d9 100644 (file)
@@ -1614,7 +1614,7 @@ typedef struct Scene {
        
        struct Scene *set;
        
-       ListBase base;
+       ListBase base DNA_DEPRECATED;
        struct BaseLegacy *basact;              /* active base */
        struct Object *obedit;          /* name replaces old G.obedit */
        
index 313cc08c415140bd31e2f9f9f305c844df2501fc..5effcc39ee2de410fd018e311e4296ae8265dccd 100644 (file)
@@ -57,6 +57,7 @@
 
 #include "BLI_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
 #include "ED_mesh.h"
+#include "ED_object.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -311,61 +312,6 @@ static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), Poin
        WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
 }
 
-/* when changing the selection flag the scene needs updating */
-static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
-       BaseLegacy *base = (BaseLegacy *)ptr->data;
-       short mode = (base->flag_legacy & BA_SELECT) ? BA_SELECT : BA_DESELECT;
-       ED_base_object_select(base, mode);
-}
-
-static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, BaseLegacy *base, Object *ob)
-{
-       /* try to avoid scene sort */
-       if (scene == NULL) {
-               /* pass - unlikely but when running scripts on startup it happens */
-       }
-       else if ((ob->lay & scene->lay) && (base->lay & scene->lay)) {
-               /* pass */
-       }
-       else if ((ob->lay & scene->lay) == 0 && (base->lay & scene->lay) == 0) {
-               /* pass */
-       }
-       else {
-               DEG_relations_tag_update(bmain);
-       }
-
-       DEG_id_type_tag(bmain, ID_OB);
-}
-
-static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-       Object *ob = (Object *)ptr->id.data;
-       BaseLegacy *base;
-
-       base = scene ? BKE_scene_base_find(scene, ob) : NULL;
-       if (!base)
-               return;
-       
-       SWAP(unsigned int, base->lay, ob->lay);
-
-       rna_Object_layer_update__internal(bmain, scene, base, ob);
-       ob->lay = base->lay;
-
-       WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
-}
-
-static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-       BaseLegacy *base = (BaseLegacy *)ptr->data;
-       Object *ob = (Object *)base->object;
-
-       rna_Object_layer_update__internal(bmain, scene, base, ob);
-       ob->lay = base->lay;
-
-       WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
-}
-
 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
 {
        Object *ob = (Object *)ptr->data;
@@ -1200,49 +1146,6 @@ static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
 }
 
-
-static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay)
-{
-       int i, tot = 0;
-
-       /* ensure we always have some layer selected */
-       for (i = 0; i < 20; i++)
-               if (values[i])
-                       tot++;
-
-       if (tot == 0)
-               return 0;
-
-       for (i = 0; i < 20; i++) {
-               if (values[i]) lay |=  (1 << i);
-               else           lay &= ~(1 << i);
-       }
-
-       return lay;
-}
-
-static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
-{
-       Object *ob = (Object *)ptr->data;
-       unsigned int lay;
-
-       lay = rna_Object_layer_validate__internal(values, ob->lay);
-       if (lay)
-               ob->lay = lay;
-}
-
-static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
-{
-       BaseLegacy *base = (BaseLegacy *)ptr->data;
-
-       unsigned int lay;
-       lay = rna_Object_layer_validate__internal(values, base->lay);
-       if (lay)
-               base->lay = lay;
-
-       /* rna_Base_layer_update updates the objects layer */
-}
-
 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
 {
        Object *ob = (Object *)ptr->data;
@@ -2502,15 +2405,6 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
 
-       prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
-       RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
-       RNA_def_property_array(prop, 20);
-       RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
-       RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
-       RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update");
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-
        prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
        RNA_def_property_array(prop, 8);
@@ -3186,49 +3080,12 @@ static void rna_def_dupli_object(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object");
 }
 
-static void rna_def_object_base_legacy(BlenderRNA *brna)
-{
-       StructRNA *srna;
-       PropertyRNA *prop;
-
-       srna = RNA_def_struct(brna, "ObjectBaseLegacy", NULL);
-       RNA_def_struct_sdna(srna, "Base");
-       RNA_def_struct_ui_text(srna, "Object Base Legacy", "An object instance in a scene (deprecated)");
-       RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
-
-       prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "object");
-       RNA_def_property_ui_text(prop, "Object", "Object this base links to");
-
-       /* same as object layer */
-       prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
-       RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
-       RNA_def_property_array(prop, 20);
-       RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
-       RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update");
-
-       prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
-       RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
-       RNA_def_property_array(prop, 8);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on");
-
-       prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag_legacy", BA_SELECT);
-       RNA_def_property_ui_text(prop, "Select", "Object base selection state");
-       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_select_update");
-
-       RNA_api_object_base_legacy(srna);
-}
-
 void RNA_def_object(BlenderRNA *brna)
 {
        rna_def_object(brna);
 
        RNA_define_animate_sdna(false);
        rna_def_object_game_settings(brna);
-       rna_def_object_base_legacy(brna);
        rna_def_vertex_group(brna);
        rna_def_face_map(brna);
        rna_def_material_slot(brna);
index 5486db84b0b7a6d8cca36cc447e76dd9c00035e6..01370412978b9d54f6af65c68f26a01f4cc6c175 100644 (file)
@@ -476,13 +476,6 @@ finally:
        free_bvhtree_from_mesh(&treeData);
 }
 
-/* ObjectBaseLegacy */
-
-static void rna_ObjectBaseLegacy_layers_from_view(BaseLegacy *base, View3D *v3d)
-{
-       base->lay = base->object->lay = v3d->lay;
-}
-
 static int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
 {
        return BKE_object_is_modified(scene, ob) & settings;
index a5645f362b9c63c83fea8f922743abeb23a1199b..26f1ac845d41ce19fa5b1ba954d1996e6b749cf0 100644 (file)
@@ -618,87 +618,39 @@ static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, Poi
        ED_space_image_uv_sculpt_update(bmain->wm.first, scene);
 }
 
-static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
+
+/* Read-only Iterator of all the scene objects. */
+
+static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Scene *scene = (Scene *)ptr->data;
-       BaseLegacy *base;
-
-       for (base = scene->base.first; base; base = base->next) {
-               if (STREQLEN(base->object->id.name + 2, key, sizeof(base->object->id.name) - 2)) {
-                       *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ObjectBaseLegacy, base);
-                       return true;
-               }
-       }
+       iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
 
-       return false;
+       ((BLI_Iterator *)iter->internal.custom)->valid = true;
+       BKE_scene_objects_iterator_begin(iter->internal.custom, (void *)scene);
+       iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
 }
 
-static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
+static void rna_Scene_objects_next(CollectionPropertyIterator *iter)
 {
-       ListBaseIterator *internal = &iter->internal.listbase;
-
-       /* we are actually iterating a Base list, so override get */
-       return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((BaseLegacy *)internal->link)->object);
+       BKE_scene_objects_iterator_next(iter->internal.custom);
+       iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
 }
 
-static BaseLegacy *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *reports, Object *ob)
+static void rna_Scene_objects_end(CollectionPropertyIterator *iter)
 {
-       Scene *scene_act = CTX_data_scene(C);
-       BaseLegacy *base;
-
-       if (BKE_scene_base_find(scene, ob)) {
-               BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in scene '%s'", ob->id.name + 2, scene->id.name + 2);
-               return NULL;
-       }
-
-       base = BKE_scene_base_add(scene, ob);
-       id_us_plus(&ob->id);
-
-       /* this is similar to what object_add_type and BKE_object_add do */
-       base->lay = scene->lay;
-
-       /* when linking to an inactive scene don't touch the layer */
-       if (scene == scene_act)
-               ob->lay = base->lay;
-
-       /* TODO(sergey): Only update relations for the current scene. */
-       DEG_relations_tag_update(CTX_data_main(C));
-       DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
-
-       /* slows down importers too much, run scene.update() */
-       /* DEG_srelations_tag_update(G.main); */
-
-       WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene);
-
-       return base;
+       BKE_scene_objects_iterator_end(iter->internal.custom);
+       MEM_freeN(iter->internal.custom);
 }
 
-static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *ob)
+static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
 {
-       BaseLegacy *base = BKE_scene_base_find(scene, ob);
-       if (!base) {
-               BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in this scene '%s'", ob->id.name + 2, scene->id.name + 2);
-               return;
-       }
-       if (base == scene->basact && ob->mode != OB_MODE_OBJECT) {
-               BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in object mode to unlink", ob->id.name + 2);
-               return;
-       }
-       if (scene->basact == base) {
-               scene->basact = NULL;
-       }
-
-       BKE_scene_base_unlink(scene, base);
-       MEM_freeN(base);
-
-       id_us_min(&ob->id);
-
-       /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */
-       DEG_relations_tag_update(G.main);
-
-       WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene);
+       Object *ob = ((BLI_Iterator *)iter->internal.custom)->current;
+       return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob);
 }
 
+/* End of read-only Iterator of all the scene objects. */
+
 static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
 {
        ToolSettings *ts = (ToolSettings *)ptr->data;
@@ -708,21 +660,6 @@ static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
                ts->skgen_template = NULL;
 }
 
-static PointerRNA rna_Scene_active_object_get(PointerRNA *ptr)
-{
-       Scene *scene = (Scene *)ptr->data;
-       return rna_pointer_inherit_refine(ptr, &RNA_Object, scene->basact ? scene->basact->object : NULL);
-}
-
-static void rna_Scene_active_object_set(PointerRNA *ptr, PointerRNA value)
-{
-       Scene *scene = (Scene *)ptr->data;
-       if (value.data)
-               scene->basact = BKE_scene_base_find(scene, (Object *)value.data);
-       else
-               scene->basact = NULL;
-}
-
 static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value)
 {
        Scene *scene = (Scene *)ptr->data;
@@ -6658,60 +6595,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
 static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop)
 {
        StructRNA *srna;
-       PropertyRNA *prop;
 
-       FunctionRNA *func;
-       PropertyRNA *parm;
-       
        RNA_def_property_srna(cprop, "SceneObjects");
        srna = RNA_def_struct(brna, "SceneObjects", NULL);
        RNA_def_struct_sdna(srna, "Scene");
-       RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects");
-
-       func = RNA_def_function(srna, "link", "rna_Scene_object_link");
-       RNA_def_function_ui_description(func, "Link object to scene, run scene.update() after");
-       RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
-       parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to scene");
-       RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-       parm = RNA_def_pointer(func, "base", "ObjectBaseLegacy", "", "The newly created base");
-       RNA_def_function_return(func, parm);
-
-       func = RNA_def_function(srna, "unlink", "rna_Scene_object_unlink");
-       RNA_def_function_ui_description(func, "Unlink object from scene");
-       RNA_def_function_flag(func, FUNC_USE_REPORTS);
-       parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene");
-       RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-
-       prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "Object");
-       RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL, NULL);
-       RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
-       RNA_def_property_ui_text(prop, "Active Object", "Active object for this scene");
-       /* Could call: ED_base_object_activate(C, scene->basact);
-        * but would be a bad level call and it seems the notifier is enough */
-       RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
-}
-
-/* scene.bases.* */
-static void rna_def_scene_bases(BlenderRNA *brna, PropertyRNA *cprop)
-{
-       StructRNA *srna;
-       PropertyRNA *prop;
-
-/*     FunctionRNA *func; */
-/*     PropertyRNA *parm; */
-
-       RNA_def_property_srna(cprop, "SceneBases");
-       srna = RNA_def_struct(brna, "SceneBases", NULL);
-       RNA_def_struct_sdna(srna, "Scene");
-       RNA_def_struct_ui_text(srna, "Scene Bases", "Collection of scene bases");
-
-       prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "ObjectBaseLegacy");
-       RNA_def_property_pointer_sdna(prop, NULL, "basact");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Active Base", "Active object base in the scene");
-       RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
+       RNA_def_struct_ui_text(srna, "Scene Objects", "All the of scene objects");
 }
 
 /* scene.timeline_markers */
@@ -6946,21 +6834,16 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location");
        RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
        RNA_def_property_update(prop, NC_WINDOW, NULL);
-       
-       /* Bases/Objects */
-       prop = RNA_def_property(srna, "object_bases", PROP_COLLECTION, PROP_NONE);
-       RNA_def_property_collection_sdna(prop, NULL, "base", NULL);
-       RNA_def_property_struct_type(prop, "ObjectBaseLegacy");
-       RNA_def_property_ui_text(prop, "Bases", "");
-       RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL,
-                                         "rna_Scene_object_bases_lookup_string", NULL);
-       rna_def_scene_bases(brna, prop);
 
        prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
-       RNA_def_property_collection_sdna(prop, NULL, "base", NULL);
        RNA_def_property_struct_type(prop, "Object");
        RNA_def_property_ui_text(prop, "Objects", "");
-       RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_Scene_objects_get", NULL, NULL, NULL, NULL);
+       RNA_def_property_collection_funcs(prop,
+                                         "rna_Scene_objects_begin",
+                                         "rna_Scene_objects_next",
+                                         "rna_Scene_objects_end",
+                                         "rna_Scene_objects_get",
+                                         NULL, NULL, NULL, NULL);
        rna_def_scene_objects(brna, prop);
 
        /* Layers */
index f351a990dba231c22b55fea190651e83ca443a0a..cac17dcd86e49981bf3c4e472cdc1c2e31306ac7 100644 (file)
@@ -2899,7 +2899,7 @@ static bool check_valid_compositing_camera(Scene *scene, Object *camera_override
                        if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0) {
                                Scene *sce = node->id ? (Scene *)node->id : scene;
                                if (sce->camera == NULL) {
-                                       sce->camera = BKE_scene_camera_find(sce);
+                                       sce->camera = BKE_scene_layer_camera_find(BKE_scene_layer_from_scene_get(sce));
                                }
                                if (sce->camera == NULL) {
                                        /* all render layers nodes need camera */
@@ -2957,7 +2957,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
        const char *err_msg = "No camera found in scene \"%s\"";
 
        if (camera_override == NULL && scene->camera == NULL)
-               scene->camera = BKE_scene_camera_find(scene);
+               scene->camera = BKE_scene_layer_camera_find(BKE_scene_layer_from_scene_get(scene));
 
        if (!check_valid_camera_multiview(scene, scene->camera, reports))
                return false;
@@ -2972,7 +2972,9 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
                                    (seq->scene != NULL))
                                {
                                        if (!seq->scene_camera) {
-                                               if (!seq->scene->camera && !BKE_scene_camera_find(seq->scene)) {
+                                               if (!seq->scene->camera &&
+                                                   !BKE_scene_layer_camera_find(BKE_scene_layer_from_scene_get(seq->scene)))
+                                               {
                                                        /* camera could be unneeded due to composite nodes */
                                                        Object *override = (seq->scene == scene) ? camera_override : NULL;
 
index 9255fdf308da0b1ccba00618020dcc7af0341390..6d64588ce66bd7e14c3acff5c813001120fe6b92 100644 (file)
@@ -551,7 +551,7 @@ struct bScreen *ED_screen_animation_playing(const struct wmWindowManager *wm) RE
 struct Scene *ED_screen_scene_find(const struct bScreen *screen, const struct wmWindowManager *wm) RET_NULL
 bool ED_scene_render_layer_delete(struct Main *bmain, Scene *scene, SceneLayer *layer, ReportList *reports) RET_ZERO
 void ED_base_object_select(struct BaseLegacy *base, short mode) RET_NONE
-void ED_object_base_select(struct Base *base, short mode) RET_NONE
+void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode) RET_NONE
 bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Object *ob, struct ModifierData *md) RET_ZERO
 struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type) RET_ZERO
 void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) RET_NONE
index b2a480e99cafd92673770ea785cd4f8b1f9d233a..6b66a4c75993ca4302fa4b0c1820196c000a2c4c 100644 (file)
@@ -65,7 +65,6 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
        m_rasterizer->AddLight(m_lightobj);
        m_lightobj->m_glsl = glsl;
        m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
-       m_base = NULL;
 };
 
 
@@ -75,11 +74,6 @@ KX_LightObject::~KX_LightObject()
                m_rasterizer->RemoveLight(m_lightobj);
                delete(m_lightobj);
        }
-
-       if (m_base) {
-               BKE_scene_base_unlink(m_blenderscene, m_base);
-               MEM_freeN(m_base);
-       }
 }
 
 
@@ -103,7 +97,6 @@ void KX_LightObject::UpdateScene(KX_Scene *kxscene)
 {
        m_lightobj->m_scene = (void*)kxscene;
        m_blenderscene = kxscene->GetBlenderScene();
-       m_base = BKE_scene_base_add(m_blenderscene, GetBlenderObject());
 }
 
 void KX_LightObject::SetLayer(int layer)