diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 09:22:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 09:30:12 +0300 |
commit | 4f24808d08f47af661104f5976e17c57e8086ea9 (patch) | |
tree | 9eb2275276cb1b7c15e259b5c1b6534c042a6b22 /source/blender/editors/object | |
parent | 04c5471ceefb41c9e49bf7c86f07e9e7b8426bb3 (diff) |
Fix T82049: material select button now only works for active object
Include edit-mode objects from space-properties context
unless there is a pinned object.
Regression caused by change in 12bc34b0b81b.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 3e7f028bd95..df940d3fa25 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -163,13 +163,32 @@ Object **ED_object_array_in_mode_or_selected(bContext *C, ScrArea *area = CTX_wm_area(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob_active = OBACT(view_layer); + ID *id_pin = NULL; + const bool use_objects_in_mode = (ob_active != NULL) && + (ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE)); + const char space_type = area ? area->spacetype : SPACE_EMPTY; Object **objects; Object *ob = NULL; bool use_ob = true; - if (area && (area->spacetype == SPACE_PROPERTIES)) { - /* May return pinned object. */ - ob = ED_object_context(C); + + if (space_type == SPACE_PROPERTIES) { + SpaceProperties *sbuts = area->spacedata.first; + id_pin = sbuts->pinid; + } + + if (id_pin && (GS(id_pin->name) == ID_OB)) { + /* Pinned data takes priority, in this case ignore selection & other objects in the mode. */ + ob = (Object *)id_pin; + } + else if ((space_type == SPACE_PROPERTIES) && (use_objects_in_mode == false)) { + /* When using the space-properties, we don't want to use the entire selection + * as the current active object may not be selected. + * + * This is not the case when we're in a mode that supports multi-mode editing, + * since the active object and all other objects in the mode will be included + * irrespective of selection. */ + ob = ob_active; } else if (ob_active && (ob_active->mode & (OB_MODE_ALL_PAINT | OB_MODE_ALL_SCULPT | OB_MODE_ALL_PAINT_GPENCIL))) { @@ -192,10 +211,10 @@ Object **ED_object_array_in_mode_or_selected(bContext *C, } } else { - const View3D *v3d = (area && area->spacetype == SPACE_VIEW3D) ? area->spacedata.first : NULL; + const View3D *v3d = (space_type == SPACE_VIEW3D) ? area->spacedata.first : NULL; /* When in a mode that supports multiple active objects, use "objects in mode" * instead of the object's selection. */ - if ((ob_active != NULL) && (ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE))) { + if (use_objects_in_mode) { objects = BKE_view_layer_array_from_objects_in_mode(view_layer, v3d, r_objects_len, |