Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-12 20:24:33 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-12 20:28:49 +0300
commitc427590c4eb60a7187d9f340066ff837f9179cd5 (patch)
tree38d95e2825dedbe66692aea16c3798bf81092e0d /source
parent834d3962b99df675788021766679e7e889694926 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/layer.c26
-rw-r--r--source/blender/blenkernel/intern/object_update.c25
2 files changed, 27 insertions, 24 deletions
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. */