Commit: abdd54462434c37f67945961aa4da19595a55ff2
Author: Campbell Barton
Date:   Fri Feb 12 17:09:34 2021 +1100
Branches: pygpu_extensions
https://developer.blender.org/rBabdd54462434c37f67945961aa4da19595a55ff2

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);
       }
     }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to