Object Mode: only toggle active object mode once
authorCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jan 2019 23:16:51 +0000 (10:16 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jan 2019 23:21:51 +0000 (10:21 +1100)
- When toggling a mode that doesn't support multi editing
  only do this once of the active object.

- For sculpt mode create sculpt data since this is needed
  for activating other sculpt objects on reload.

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/util/ed_util.c

index 329be17..3348131 100644 (file)
@@ -293,6 +293,8 @@ void BKE_object_handle_update_ex(
         const bool do_proxy_update);
 void BKE_object_sculpt_modifiers_changed(struct Object *ob);
 
+void BKE_object_sculpt_data_create(struct Object *ob);
+
 int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot);
 
 struct Mesh *BKE_object_get_evaluated_mesh(const struct Depsgraph *depsgraph, struct Object *ob);
index 78e22c2..62f5b01 100644 (file)
@@ -2959,6 +2959,13 @@ void BKE_object_handle_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
        BKE_object_handle_update_ex(depsgraph, scene, ob, NULL, true);
 }
 
+void BKE_object_sculpt_data_create(Object *ob)
+{
+       BLI_assert(ob->mode & OB_MODE_ALL_SCULPT);
+       ob->sculpt = MEM_callocN(sizeof(SculptSession), __func__);
+       ob->sculpt->mode_type = ob->mode;
+}
+
 void BKE_object_sculpt_modifiers_changed(Object *ob)
 {
        SculptSession *ss = ob->sculpt;
index bc3d38f..c7e9b8c 100644 (file)
@@ -5648,8 +5648,7 @@ static void direct_link_object(FileData *fd, Object *ob)
        if (ob->sculpt) {
                /* Only create data on undo, otherwise rely on editor mode switching. */
                if (fd->memfile && (ob->mode & OB_MODE_ALL_SCULPT)) {
-                       ob->sculpt = MEM_callocN(sizeof(SculptSession), "reload sculpt session");
-                       ob->sculpt->mode_type = ob->mode;
+                       BKE_object_sculpt_data_create(ob);
                }
                else {
                        ob->sculpt = NULL;
index b3ec0a4..188d06c 100644 (file)
@@ -130,7 +130,17 @@ void ED_editors_init(bContext *C)
                                                        ED_object_posemode_enter_ex(bmain, ob);
                                                }
                                                else {
-                                                       ED_object_mode_toggle(C, mode);
+                                                       if (obact == ob) {
+                                                               ED_object_mode_toggle(C, mode);
+                                                       }
+                                                       else {
+                                                               /* Create data for non-active objects which need it for
+                                                                * mode-switching but don't yet support multi-editing. */
+                                                               if (mode & OB_MODE_ALL_SCULPT) {
+                                                                       ob->mode = mode;
+                                                                       BKE_object_sculpt_data_create(ob);
+                                                               }
+                                                       }
                                                }
                                        }
                                }