diff options
author | Philipp Oeser <lichtwerk> | 2020-09-03 15:59:34 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-09-03 16:01:50 +0300 |
commit | f00cb93dbec7bf5dc05302c868f20fcd5aed7db7 (patch) | |
tree | 2631292eb3265ad366165ea0fe567d31a1f1f1b5 /source/blender/editors/armature | |
parent | a505a85873602a9e265bafb107d2ea356fc23a17 (diff) |
Fix T63125: Gpencil: bones cannot be selected in weightpaint mode
Some underlying functionality was not ready for greasepencil:
- BKE_modifiers_get_virtual_modifierlist (now introduce dedicated BKE_gpencil_modifiers_get_virtual_modifierlist)
- BKE_modifiers_is_deformed_by_armature
- checks in drawing code
- checks in (pose) selection code
A couple of changes to make this work:
- `eGpencilModifierType_Armature` has to be respected (not only `eModifierType_Armature`)
- `OB_MODE_WEIGHT_GPENCIL` has to be respected (not only `OB_MODE_WEIGHT_PAINT`) -- (now use new `OB_MODE_ALL_WEIGHT_PAINT`)
- `gpencil_weightmode_toggle_exec` now shares functionality from `wpaint_mode_toggle_exec` -- moved to new `ED_object_posemode_set_for_weight_paint`
This patch will also set the context member "weight_paint_object" for greasepencil (otherwise some appropriate pose operators wont work when in weightpaint mode)
Reviewed By: campbellbarton
Maniphest Tasks: T63125
Differential Revision: https://developer.blender.org/D8483
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/pose_select.c | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 0e766e6a75f..c63f2ff12c5 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -26,6 +26,7 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -37,6 +38,7 @@ #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_context.h" +#include "BKE_gpencil_modifier.h" #include "BKE_layer.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -172,7 +174,7 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer, * note, special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode - campbell */ - if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)) { + if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) == 0)) { /* when we are entering into posemode via toggle-select, * from another active object - always select the bone. */ if (!extend && !deselect && toggle) { @@ -225,7 +227,7 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer, if (ob_act) { /* in weightpaint we select the associated vertex group too */ - if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { + if (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) { if (nearBone == arm->act_bone) { ED_vgroup_select_by_name(ob_act, nearBone->name); DEG_id_tag_update(&ob_act->id, ID_RECALC_GEOMETRY); @@ -261,17 +263,39 @@ void ED_armature_pose_select_in_wpaint_mode(ViewLayer *view_layer, Base *base_se { BLI_assert(base_select && (base_select->object->type == OB_ARMATURE)); Object *ob_active = OBACT(view_layer); - BLI_assert(ob_active && (ob_active->mode & OB_MODE_WEIGHT_PAINT)); - VirtualModifierData virtualModifierData; - ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob_active, &virtualModifierData); - for (; md; md = md->next) { - if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData *)md; - Object *ob_arm = amd->object; - if (ob_arm != NULL) { - Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); - if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) { - ED_object_base_select(base_arm, BA_DESELECT); + BLI_assert(ob_active && (ob_active->mode & OB_MODE_ALL_WEIGHT_PAINT)); + + if (ob_active->type == OB_GPENCIL) { + GpencilVirtualModifierData virtualModifierData; + GpencilModifierData *md = BKE_gpencil_modifiers_get_virtual_modifierlist(ob_active, + &virtualModifierData); + for (; md; md = md->next) { + if (md->type == eGpencilModifierType_Armature) { + ArmatureGpencilModifierData *agmd = (ArmatureGpencilModifierData *)md; + Object *ob_arm = agmd->object; + if (ob_arm != NULL) { + Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); + if ((base_arm != NULL) && (base_arm != base_select) && + (base_arm->flag & BASE_SELECTED)) { + ED_object_base_select(base_arm, BA_DESELECT); + } + } + } + } + } + else { + VirtualModifierData virtualModifierData; + ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob_active, &virtualModifierData); + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *)md; + Object *ob_arm = amd->object; + if (ob_arm != NULL) { + Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); + if ((base_arm != NULL) && (base_arm != base_select) && + (base_arm->flag & BASE_SELECTED)) { + ED_object_base_select(base_arm, BA_DESELECT); + } } } } |