Object Mode: only toggle active object mode once

- 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.
This commit is contained in:
Campbell Barton 2019-01-09 10:16:51 +11:00
parent 1b6b0fbd95
commit b536d1b95f
4 changed files with 21 additions and 3 deletions

View 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);

View 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;

View 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;

View 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);
}
}
}
}
}