[Bf-blender-cvs] [c427590c4eb] master: Fix T62388: object.visible_get() not affected by object.hide_viewport.

Brecht Van Lommel noreply at git.blender.org
Tue Mar 12 18:29:09 CET 2019


Commit: c427590c4eb60a7187d9f340066ff837f9179cd5
Author: Brecht Van Lommel
Date:   Tue Mar 12 18:24:33 2019 +0100
Branches: master
https://developer.blender.org/rBc427590c4eb60a7187d9f340066ff837f9179cd5

Fix T62388: object.visible_get() not affected by object.hide_viewport.

After recent changes BASE_VISIBLE was not always disabled properly when the
object is hidden. This refactors the code a bit to hopefully be more clear.

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

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

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

diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index a5360f34312..9a6e570e03b 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1443,23 +1443,35 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
 /* Evaluation  */
 
 /* Applies object's restrict flags on top of flags coming from the collection
- * and stores those in base->flag. */
+ * and stores those in base->flag. BASE_VISIBLE is based on viewport visibility. */
 void BKE_base_eval_flags(Base *base)
 {
-	const int object_restrict = base->object->restrictflag;
+	/* Apply collection flags. */
 	base->flag &= ~g_base_collection_flags;
 	base->flag |= (base->flag_from_collection & g_base_collection_flags);
+
+	/* Apply object restrictions. */
+	const int object_restrict = base->object->restrictflag;
 	if (object_restrict & OB_RESTRICT_VIEW) {
-		base->flag &= ~(BASE_ENABLED_VIEWPORT | BASE_SELECTABLE);
+		base->flag &= ~BASE_ENABLED_VIEWPORT;
+	}
+	if (object_restrict & OB_RESTRICT_RENDER) {
+		base->flag &= ~BASE_ENABLED_RENDER;
 	}
 	if (object_restrict & OB_RESTRICT_SELECT) {
 		base->flag &= ~BASE_SELECTABLE;
 	}
-	if (object_restrict & OB_RESTRICT_RENDER) {
-		base->flag &= ~BASE_ENABLED_RENDER;
+
+	/* Apply viewport visibility by default. The dependency graph for render
+	 * can change these again, but for tools we always want the viewport
+	 * visibility to be in sync regardless if depsgraph was evaluated. */
+	if (!(base->flag & BASE_ENABLED_VIEWPORT) || (base->flag & BASE_HIDDEN)) {
+		base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE);
 	}
-	if (base->flag & BASE_HIDDEN) {
-		base->flag &= ~BASE_VISIBLE;
+
+	/* Deselect unselectable objects. */
+	if (!(base->flag & BASE_SELECTABLE)) {
+		base->flag &= ~BASE_SELECTED;
 	}
 }
 
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 304c9985f10..5558443afb8 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -425,27 +425,18 @@ void BKE_object_eval_eval_base_flags(Depsgraph *depsgraph,
 
 	DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
 
-	/* Visibility based on depsgraph mode. */
-	const eEvaluationMode mode = DEG_get_mode(depsgraph);
-	const int base_enabled_flag = (mode == DAG_EVAL_VIEWPORT)
-	        ? BASE_ENABLED_VIEWPORT
-	        : BASE_ENABLED_RENDER;
-
+	/* Set base flags based on collection and object restriction. */
 	BKE_base_eval_flags(base);
 
-	/* Compute visibility for depsgraph evaluation mode. */
-	if (base->flag & base_enabled_flag) {
-		/* When rendering, visibility is controlled by the enable/disable option. */
-		if (mode == DAG_EVAL_RENDER) {
+	/* For render, compute base visibility again since BKE_base_eval_flags
+	 * assumed viewport visibility. Selectability does not matter here. */
+	if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
+		if (base->flag & BASE_ENABLED_RENDER) {
 			base->flag |= BASE_VISIBLE;
 		}
-	}
-	else {
-		base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE);
-	}
-	/* If base is not selectable, clear select. */
-	if ((base->flag & BASE_SELECTABLE) == 0) {
-		base->flag &= ~BASE_SELECTED;
+		else {
+			base->flag &= ~BASE_VISIBLE;
+		}
 	}
 
 	/* Copy flags and settings from base. */



More information about the Bf-blender-cvs mailing list