Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-16 03:46:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-16 03:49:19 +0300
commit5861e1fa28140d6dfe73f1542c0e87c728b028ba (patch)
tree2369016c34064d0a1a1d009ee85976ccd2eae9c4 /source/blender/editors/util
parent976917e8cf7a1bb19aa961e0fd6c6be3c64f7987 (diff)
Object: avoid calling operators in ED_editors_init
Don't call operator when entering sculpt modes.
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/ed_util.c71
1 files changed, 47 insertions, 24 deletions
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 5cc1f15cb2e..abc4f20ac71 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -90,6 +90,7 @@
void ED_editors_init(bContext *C)
{
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -111,43 +112,65 @@ void ED_editors_init(bContext *C)
if (obact != NULL) {
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
int mode = ob->mode;
-
if (mode == OB_MODE_OBJECT) {
- /* pass */
+ continue;
+ }
+ else if (BKE_object_has_mode_data(ob, mode)) {
+ continue;
}
- else if (!BKE_object_has_mode_data(ob, mode)) {
+ else if (ob->type == OB_GPENCIL) {
/* For multi-edit mode we may already have mode data.
- * (grease pencil does not need it)
- */
- if (ob->type != OB_GPENCIL) {
- ID *data = ob->data;
- ob->mode = OB_MODE_OBJECT;
- if ((ob->type == obact->type) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
- if (mode == OB_MODE_EDIT) {
- ED_object_editmode_enter_ex(bmain, scene, ob, 0);
+ * (grease pencil does not need it) */
+ continue;
+ }
+
+ ID *ob_data = ob->data;
+ ob->mode = OB_MODE_OBJECT;
+ if ((ob->type == obact->type) &&
+ !ID_IS_LINKED(ob) &&
+ !(ob_data && ID_IS_LINKED(ob_data)))
+ {
+ if (mode == OB_MODE_EDIT) {
+ ED_object_editmode_enter_ex(bmain, scene, ob, 0);
+ }
+ else if (mode == OB_MODE_POSE) {
+ ED_object_posemode_enter_ex(bmain, ob);
+ }
+ else if (mode & OB_MODE_ALL_SCULPT) {
+ if (obact == ob) {
+ if (mode == OB_MODE_SCULPT) {
+ ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
+ }
+ else if (mode == OB_MODE_VERTEX_PAINT) {
+ ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
- else if (mode == OB_MODE_POSE) {
- ED_object_posemode_enter_ex(bmain, ob);
+ else if (mode == OB_MODE_WEIGHT_PAINT) {
+ ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
else {
- 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);
- }
- }
+ BLI_assert(0);
}
}
+ 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);
+ }
+ }
+ }
+ else {
+ /* TODO(campbell): avoid operator calls. */
+ if (obact == ob) {
+ ED_object_mode_toggle(C, mode);
+ }
}
}
}
}
+
/* image editor paint mode */
if (scene) {
ED_space_image_paint_update(bmain, wm, scene);