diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-16 12:57:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-16 16:01:25 +0300 |
commit | ce4d52c4f3ed1cfbe7c13eab0ec94e27a4ab6904 (patch) | |
tree | 00e2ca09746f0ad471009eab76b2cb7a46feec24 | |
parent | c28dea5e241a993ae9f3ca9f5208ad1e5010da63 (diff) |
Object Mode: exit vert/weight paint on selection
Was keeping data, since objects no longer store modes,
object mode can't be properly detected.
-rw-r--r-- | source/blender/editors/object/object_select.c | 49 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 18 |
2 files changed, 49 insertions, 18 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 69e0fd20b86..55c0b4c2bdd 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -56,7 +56,9 @@ #include "BKE_layer.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_object.h" #include "BKE_particle.h" +#include "BKE_paint.h" #include "BKE_property.h" #include "BKE_report.h" #include "BKE_scene.h" @@ -136,6 +138,53 @@ void ED_object_base_activate(bContext *C, Base *base) } eObjectMode object_mode = workspace->object_mode; + + { + Scene *scene = CTX_data_scene(C); + /* We don't know the previous active object in update. + * + * Not correct because it's possible other work-spaces use these. + * although that's a corner case. */ + if (workspace->object_mode & OB_MODE_EDIT) { + Object *obact = OBACT(view_layer); + FOREACH_OBJECT(view_layer, ob) { + if (ob != base->object) { + if (BKE_object_is_in_editmode(ob)) { + ED_object_editmode_exit_ex(NULL, workspace, scene, ob, EM_FREEDATA); + } + } + } + FOREACH_OBJECT_END; + } + else if (workspace->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT)) { + Object *obact = OBACT(view_layer); + FOREACH_OBJECT(view_layer, ob) { + if (ob != base->object) { + if (ob->sculpt) { + switch (ob->sculpt->mode_type) { + case OB_MODE_VERTEX_PAINT: + { + ED_object_vpaintmode_exit_ex(workspace, ob); + break; + } + case OB_MODE_WEIGHT_PAINT: + { + ED_object_wpaintmode_exit_ex(workspace, ob); + break; + } + case OB_MODE_SCULPT: + { + /* TODO */ + break; + } + } + } + } + } + FOREACH_OBJECT_END; + } + } + workspace->object_mode = OB_MODE_OBJECT; view_layer->basact = base; diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 7db3028a020..558b963a768 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -847,24 +847,6 @@ static void rna_LayerObjects_active_object_update(struct bContext *C, PointerRNA return; } ViewLayer *view_layer = (ViewLayer *)ptr->data; - - /* We don't know the previous active object in update. - * - * Not correct because it's possible other work-spaces use these. - * although that's a corner case. */ - WorkSpace *workspace = CTX_wm_workspace(C); - if (workspace->object_mode & OB_MODE_EDIT) { - Object *obact = OBACT(view_layer); - FOREACH_OBJECT(view_layer, ob) { - if (ob != obact) { - if (BKE_object_is_in_editmode(ob)) { - ED_object_editmode_exit_ex(NULL, workspace, scene, ob, EM_FREEDATA); - } - } - } - FOREACH_OBJECT_END; - } - ED_object_base_activate(C, view_layer->basact); } |