diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-02-12 09:09:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-02-12 09:09:34 +0300 |
commit | c10ad8e9eabea8a10d35efea3860cc345977e4f9 (patch) | |
tree | 4567371b8464ffd392807d2512fd026b1d01e2e6 /source/blender/editors/space_view3d/space_view3d.c | |
parent | 631cc5d56ee9445ece0a9982ed58b1de1dcbbe5b (diff) |
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.
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); } } |