[Bf-blender-cvs] [19548040d91] blender2.8: Fix T51261: New objects aren't selected

Dalai Felinto noreply at git.blender.org
Fri Apr 21 15:28:38 CEST 2017


Commit: 19548040d91dedc2a63444f3277e4365837931e1
Author: Dalai Felinto
Date:   Fri Apr 21 14:53:19 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB19548040d91dedc2a63444f3277e4365837931e1

Fix T51261: New objects aren't selected

The original code was failing because the base to object flushing was
only happening as part of the depsgraph. However we can use the
evaluated values to set the initial values of the base.

In this particular case, we couldn't set the new object visible because
its selectability flag was not set yet.

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

M	source/blender/blenkernel/intern/layer.c

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

diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 0fb945b64ea..4b9b77e7b82 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -267,7 +267,7 @@ static Base *object_base_add(SceneLayer *sl, Object *ob)
 	if (base == NULL) {
 		base = MEM_callocN(sizeof(Base), "Object Base");
 
-		/* do not bump user count, leave it for SceneCollections */
+		/* Do not bump user count, leave it for SceneCollections. */
 		base->object = ob;
 		BLI_addtail(&sl->object_bases, base);
 
@@ -775,13 +775,24 @@ static void layer_collection_object_add(SceneLayer *sl, LayerCollection *lc, Obj
 {
 	Base *base = object_base_add(sl, ob);
 
-	/* only add an object once - prevent SceneCollection->objects and
-	 * SceneCollection->filter_objects to add the same object */
+	/* Only add an object once - prevent SceneCollection->objects and
+	 * SceneCollection->filter_objects to add the same object. */
 
 	if (BLI_findptr(&lc->object_bases, base, offsetof(LinkData, data))) {
 		return;
 	}
 
+	bool is_visible = (lc->flag & COLLECTION_VISIBLE) != 0;
+	bool is_selectable = is_visible && ((lc->flag & COLLECTION_SELECTABLE) != 0);
+
+	if (is_visible) {
+		base->flag |= BASE_VISIBLED;
+	}
+
+	if (is_selectable) {
+		base->flag |= BASE_SELECTABLED;
+	}
+
 	BLI_addtail(&lc->object_bases, BLI_genericNodeN(base));
 }




More information about the Bf-blender-cvs mailing list