diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-11-08 17:16:49 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-11-08 23:39:01 +0300 |
commit | 206c94fea98d44ed9667607638c455c7c0e63822 (patch) | |
tree | ddc1f6f30c18d10674daaeeaee6b465550447709 /source/blender/collada | |
parent | 670e6cab4319b94c96c6a61cb76199f1054b935a (diff) |
Farewell Scene->base
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.
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 13 | ||||
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 9 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 10 |
3 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 39a36781e0e..bc986f11394 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -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(); diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 978d79077fe..87392352a48 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -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; } diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 3bdd22a53f8..85976c64b5f 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -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; } |