diff options
Diffstat (limited to 'source/blender/editors/space_view3d/space_view3d.c')
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 18 |
1 files changed, 16 insertions, 2 deletions
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); } } |