[Bf-blender-cvs] [307059ed61c] blender2.8: Alembic import: correctly linking objects to scene layer.

Sybren A. Stüvel noreply at git.blender.org
Wed Apr 19 17:33:37 CEST 2017


Commit: 307059ed61c7529eaea22ac06d2bed93597d2677
Author: Sybren A. Stüvel
Date:   Wed Apr 19 16:46:08 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB307059ed61c7529eaea22ac06d2bed93597d2677

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.

===================================================================

M	source/blender/alembic/intern/alembic_capi.cc

===================================================================

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);




More information about the Bf-blender-cvs mailing list