[Bf-blender-cvs] [4f24808d08f] blender-v2.91-release: Fix T82049: material select button now only works for active object

Campbell Barton noreply at git.blender.org
Wed Oct 28 07:32:29 CET 2020


Commit: 4f24808d08f47af661104f5976e17c57e8086ea9
Author: Campbell Barton
Date:   Wed Oct 28 17:22:56 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rB4f24808d08f47af661104f5976e17c57e8086ea9

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.

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

M	source/blender/editors/object/object_edit.c

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

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,



More information about the Bf-blender-cvs mailing list