diff options
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 3d8a7bb1e30..b64b6f9a788 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -33,6 +33,7 @@ #include "BKE_anim.h" #include "BKE_colortools.h" +#include "BKE_context.h" #include "BKE_curve.h" #include "BKE_editmesh.h" #include "BKE_global.h" @@ -41,6 +42,7 @@ #include "BKE_main.h" #include "BKE_mball.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_paint.h" @@ -2204,24 +2206,43 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, drw_state_prepare_clean_for_draw(&DST); bool use_obedit = false; - int obedit_mode = 0; + /* obedit_ctx_mode is used for selecting the right draw engines */ + eContextObjectMode obedit_ctx_mode; + /* object_mode is used for filtering objects in the depsgraph */ + eObjectMode object_mode; + int object_type = 0; if (obedit != NULL) { + object_type = obedit->type; + object_mode = obedit->mode; if (obedit->type == OB_MBALL) { use_obedit = true; - obedit_mode = CTX_MODE_EDIT_METABALL; + obedit_ctx_mode = CTX_MODE_EDIT_METABALL; } else if (obedit->type == OB_ARMATURE) { use_obedit = true; - obedit_mode = CTX_MODE_EDIT_ARMATURE; + obedit_ctx_mode = CTX_MODE_EDIT_ARMATURE; } } if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) { if (!(v3d->flag2 & V3D_HIDE_OVERLAYS)) { /* Note: don't use "BKE_object_pose_armature_get" here, it breaks selection. */ Object *obpose = OBPOSE_FROM_OBACT(obact); + if (obpose == NULL) { + Object *obweight = OBWEIGHTPAINT_FROM_OBACT(obact); + if (obweight) { + /* Only use Armature pose selection, when connected armature is in pose mode. */ + Object *ob_armature = modifiers_isDeformedByArmature(obweight); + if (ob_armature && ob_armature->mode == OB_MODE_POSE) { + obpose = ob_armature; + } + } + } + if (obpose) { use_obedit = true; - obedit_mode = CTX_MODE_POSE; + object_type = obpose->type; + object_mode = obpose->mode; + obedit_ctx_mode = CTX_MODE_POSE; } } } @@ -2235,8 +2256,8 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, /* Get list of enabled engines */ if (use_obedit) { - drw_engines_enable_from_paint_mode(obedit_mode); - drw_engines_enable_from_mode(obedit_mode); + drw_engines_enable_from_paint_mode(obedit_ctx_mode); + drw_engines_enable_from_mode(obedit_ctx_mode); } else if (!draw_surface) { /* grease pencil selection */ @@ -2283,7 +2304,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, drw_engines_world_update(scene); if (use_obedit) { - FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, obact->type, obact->mode, ob_iter) { + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, object_type, object_mode, ob_iter) { drw_engines_cache_populate(ob_iter); } FOREACH_OBJECT_IN_MODE_END; |