[Bf-blender-cvs] [191b8951f7a] master: Outliner visibility: Prevent changing linked objects and collections

Dalai Felinto noreply at git.blender.org
Fri Feb 8 23:11:53 CET 2019


Commit: 191b8951f7afae26117cc5386b979557b84dc437
Author: Dalai Felinto
Date:   Fri Feb 8 20:09:37 2019 -0200
Branches: master
https://developer.blender.org/rB191b8951f7afae26117cc5386b979557b84dc437

Outliner visibility: Prevent changing linked objects and collections

We still change their base/layer collection visibility, just not what would change the
original ID datablock.

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

M	source/blender/blenkernel/intern/layer.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_draw.c

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

diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 993df715218..d660e5e6424 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1005,9 +1005,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
 	bool depsgraph_need_update = false;
 	LayerCollection *lc_master = view_layer->layer_collections.first;
 
-	if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) {
-		lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
-		depsgraph_need_update = true;
+	if (lc->collection->id.lib == NULL) {
+		if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) {
+			lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+			depsgraph_need_update = true;
+		}
 	}
 
 	if (!extend) {
@@ -1027,9 +1029,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
 	}
 
 	while (lc_parent != lc) {
-		if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) {
-			lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
-			depsgraph_need_update = true;
+		if (lc_parent->collection->id.lib == NULL) {
+			if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) {
+				lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+				depsgraph_need_update = true;
+			}
 		}
 
 		lc_parent->flag &= ~LAYER_COLLECTION_RESTRICT_VIEW;
@@ -1084,7 +1088,10 @@ bool BKE_layer_collection_set_visible(ViewLayer *view_layer, LayerCollection *lc
 {
 	bool depsgraph_changed = false;
 
-	if (visible && ((lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0)) {
+	if (visible &&
+	    (lc->collection->id.lib == NULL) &&
+	    ((lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0))
+	{
 		lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
 		depsgraph_changed = true;
 	}
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index a07fe4b9e15..92c68681a54 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -1065,7 +1065,9 @@ static int collection_flag_exec(bContext *C, wmOperator *op)
 		GSET_ITER(collections_to_edit_iter, data.collections_to_edit) {
 			LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
 			Collection *collection = layer_collection->collection;
-
+			if (collection->id.lib != NULL) {
+				continue;
+			}
 			if (clear) {
 				collection->flag &= ~flag;
 			}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 1b7ec4cb722..5ab06fabb89 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -276,13 +276,16 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
 	bool do_isolate = (win->eventstate->ctrl != 0) && !do_disable;
 	bool extend = (win->eventstate->shift != 0);
 	bool depsgraph_changed = false;
+	const bool is_editable = BASE_EDITABLE((View3D *)NULL, base);
 
 	if (do_disable) {
-		ob->restrictflag |= OB_RESTRICT_VIEW;
-		depsgraph_changed = true;
+		if (is_editable) {
+			ob->restrictflag |= OB_RESTRICT_VIEW;
+			depsgraph_changed = true;
+		}
 	}
 	else if (do_isolate) {
-		depsgraph_changed = (ob->restrictflag & OB_RESTRICT_VIEW) != 0;
+		depsgraph_changed = is_editable && ((ob->restrictflag & OB_RESTRICT_VIEW) != 0);
 
 		if (!extend) {
 			/* Make only one base visible. */
@@ -296,11 +299,16 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
 			/* Toggle visibility of one base. */
 			base->flag ^= BASE_HIDDEN;
 		}
-		ob->restrictflag &= ~OB_RESTRICT_VIEW;
+
+		if (is_editable) {
+			ob->restrictflag &= ~OB_RESTRICT_VIEW;
+		}
 	}
 	else if (ob->restrictflag & OB_RESTRICT_VIEW) {
-		ob->restrictflag &= ~OB_RESTRICT_VIEW;
-		base->flag &= ~BASE_HIDDEN;
+		if (is_editable) {
+			ob->restrictflag &= ~OB_RESTRICT_VIEW;
+			base->flag &= ~BASE_HIDDEN;
+		}
 		depsgraph_changed = true;
 	}
 	else {
@@ -334,8 +342,10 @@ static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *p
 	bool depsgraph_changed = false;
 
 	if (do_disable) {
-		collection->flag |= COLLECTION_RESTRICT_VIEW;
-		depsgraph_changed = true;
+		if (collection->id.lib == NULL) {
+			collection->flag |= COLLECTION_RESTRICT_VIEW;
+			depsgraph_changed = true;
+		}
 	}
 	else if (do_isolate) {
 		depsgraph_changed |= BKE_layer_collection_isolate(scene, view_layer, lc, extend);



More information about the Bf-blender-cvs mailing list