diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-19 17:46:08 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-19 18:30:06 +0300 |
commit | 307059ed61c7529eaea22ac06d2bed93597d2677 (patch) | |
tree | 5665ae6129845790f78bfa9bf4122b7af0b6996f /source/blender/alembic | |
parent | 248946542dc795c498fb185d4dc082558d95c00f (diff) |
Alembic import: correctly linking objects to scene layer.
The import is always performed on the active LayerCollection. If there
is none, a new one is created.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r-- | source/blender/alembic/intern/alembic_capi.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index 7d0ceb7668a..e1c94cc556f 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -49,6 +49,7 @@ extern "C" { #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_global.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_scene.h" @@ -617,6 +618,7 @@ enum { struct ImportJobData { Main *bmain; Scene *scene; + SceneLayer *sl; char filename[1024]; ImportSettings settings; @@ -812,13 +814,28 @@ static void import_endjob(void *user_data) } else { /* Add object to scene. */ - BKE_scene_base_deselect_all(data->scene); + Base *base; + LayerCollection *lc; + SceneLayer *sl = data->sl; + + BKE_scene_layer_base_deselect_all(sl); + + lc = BKE_layer_collection_active(sl); + if (lc == NULL) { + BLI_assert(BLI_listbase_count_ex(&sl->layer_collections, 1) == 0); + /* when there is no collection linked to this SceneLayer, create one */ + SceneCollection *sc = BKE_collection_add(data->scene, NULL, NULL); + lc = BKE_collection_link(sl, sc); + } for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { Object *ob = (*iter)->object(); ob->lay = data->scene->lay; - BKE_scene_base_add(data->scene, ob); + BKE_collection_object_add(data->scene, lc->scene_collection, ob); + + base = BKE_scene_layer_base_find(sl, ob); + BKE_scene_layer_base_select(sl, base); DEG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } @@ -863,6 +880,7 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence ImportJobData *job = new ImportJobData(); job->bmain = CTX_data_main(C); job->scene = CTX_data_scene(C); + job->sl = CTX_data_scene_layer(C); job->import_ok = false; BLI_strncpy(job->filename, filepath, 1024); |