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/space_view3d/view3d_view.c | |
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/space_view3d/view3d_view.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 7000a4d89cd..0d350d0e7d4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -22,6 +22,7 @@ */ #include "DNA_camera_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -37,6 +38,7 @@ #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_gpencil_modifier.h" #include "BKE_idprop.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -949,7 +951,7 @@ static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data) eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const Object *obact) { if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { - if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT) && + if (obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT) && BKE_object_pose_armature_get((Object *)obact)) { return VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK; } @@ -1053,18 +1055,33 @@ int view3d_opengl_select(ViewContext *vc, } case VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK: { Object *obact = vc->obact; - BLI_assert(obact && (obact->mode & OB_MODE_WEIGHT_PAINT)); - + BLI_assert(obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT)); /* While this uses 'alloca' in a loop (which we typically avoid), * the number of items is nearly always 1, maybe 2..3 in rare cases. */ LinkNode *ob_pose_list = NULL; - VirtualModifierData virtualModifierData; - const ModifierData *md = BKE_modifiers_get_virtual_modifierlist(obact, &virtualModifierData); - for (; md; md = md->next) { - if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData *)md; - if (amd->object && (amd->object->mode & OB_MODE_POSE)) { - BLI_linklist_prepend_alloca(&ob_pose_list, amd->object); + if (obact->type == OB_GPENCIL) { + GpencilVirtualModifierData virtualModifierData; + const GpencilModifierData *md = BKE_gpencil_modifiers_get_virtual_modifierlist( + obact, &virtualModifierData); + for (; md; md = md->next) { + if (md->type == eGpencilModifierType_Armature) { + ArmatureGpencilModifierData *agmd = (ArmatureGpencilModifierData *)md; + if (agmd->object && (agmd->object->mode & OB_MODE_POSE)) { + BLI_linklist_prepend_alloca(&ob_pose_list, agmd->object); + } + } + } + } + else { + VirtualModifierData virtualModifierData; + const ModifierData *md = BKE_modifiers_get_virtual_modifierlist(obact, + &virtualModifierData); + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *)md; + if (amd->object && (amd->object->mode & OB_MODE_POSE)) { + BLI_linklist_prepend_alloca(&ob_pose_list, amd->object); + } } } } |