[Bf-blender-cvs] [c10ad8e9eab] master: UI: expose the 3D views active object, even when hidden

Campbell Barton noreply at git.blender.org
Fri Feb 12 07:35:09 CET 2021


Commit: c10ad8e9eabea8a10d35efea3860cc345977e4f9
Author: Campbell Barton
Date:   Fri Feb 12 17:09:34 2021 +1100
Branches: master
https://developer.blender.org/rBc10ad8e9eabea8a10d35efea3860cc345977e4f9

UI: expose the 3D views active object, even when hidden

The previous behavior meant that changing an objects visibility
effectively changed the current mode - which missed necessary
updates for the tool-system (for example).

There was already a check for edit-mode, now expected to all modes.

This makes the test-case described in T83013 work as expected.

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

M	source/blender/editors/space_view3d/space_view3d.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 26441bde6b6..98e1d927daf 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1591,7 +1591,8 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
     if (view_layer->basact) {
       Object *ob = view_layer->basact->object;
       /* if hidden but in edit mode, we still display, can happen with animation */
-      if ((view_layer->basact->flag & BASE_VISIBLE_DEPSGRAPH) != 0 || (ob->mode & OB_MODE_EDIT)) {
+      if ((view_layer->basact->flag & BASE_VISIBLE_DEPSGRAPH) != 0 ||
+          (ob->mode != OB_MODE_OBJECT)) {
         CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
       }
     }
@@ -1599,12 +1600,25 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
     return 1;
   }
   else if (CTX_data_equals(member, "active_object")) {
+    /* In most cases the active object is the `view_layer->basact->object`.
+     * For the 3D view however it can be NULL when hidden.
+     *
+     * This is ignored in the case the object is in any mode (besides object-mode),
+     * since the object's mode impacts the current tool, cursor, gizmos etc.
+     * If we didn't have this exception, changing visibility would need to perform
+     * many of the the same updates as changing the objects mode.
+     *
+     * Further, there are multiple ways to hide objects - by collection, by object type, etc.
+     * it's simplest if all these methods behave consistently - respecting the object-mode
+     * without showing the object.
+     *
+     * See T85532 for alternatives that were considered. */
     ViewLayer *view_layer = CTX_data_view_layer(C);
     if (view_layer->basact) {
       Object *ob = view_layer->basact->object;
       /* if hidden but in edit mode, we still display, can happen with animation */
       if ((view_layer->basact->flag & BASE_VISIBLE_DEPSGRAPH) != 0 ||
-          (ob->mode & OB_MODE_EDIT) != 0) {
+          (ob->mode != OB_MODE_OBJECT)) {
         CTX_data_id_pointer_set(result, &ob->id);
       }
     }



More information about the Bf-blender-cvs mailing list