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/blenkernel/intern/modifier.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/blenkernel/intern/modifier.c')
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index afd02d7001e..6185644f5a0 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -34,6 +34,7 @@ #include "MEM_guardedalloc.h" #include "DNA_armature_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -53,6 +54,7 @@ #include "BKE_editmesh.h" #include "BKE_editmesh_cache.h" #include "BKE_global.h" +#include "BKE_gpencil_modifier.h" #include "BKE_idtype.h" #include "BKE_key.h" #include "BKE_lib_id.h" @@ -653,9 +655,7 @@ ModifierData *BKE_modifier_get_last_preview(struct Scene *scene, ModifierData *BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *virtualModifierData) { - ModifierData *md; - - md = ob->modifiers.first; + ModifierData *md = ob->modifiers.first; *virtualModifierData = virtualModifierCommonData; @@ -700,22 +700,46 @@ ModifierData *BKE_modifiers_get_virtual_modifierlist(const Object *ob, */ Object *BKE_modifiers_is_deformed_by_armature(Object *ob) { - VirtualModifierData virtualModifierData; - ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); - ArmatureModifierData *amd = NULL; - - /* return the first selected armature, this lets us use multiple armatures */ - for (; md; md = md->next) { - if (md->type == eModifierType_Armature) { - amd = (ArmatureModifierData *)md; - if (amd->object && (amd->object->base_flag & BASE_SELECTED)) { - return amd->object; + if (ob->type == OB_GPENCIL) { + GpencilVirtualModifierData gpencilvirtualModifierData; + ArmatureGpencilModifierData *agmd = NULL; + GpencilModifierData *gmd = BKE_gpencil_modifiers_get_virtual_modifierlist( + ob, &gpencilvirtualModifierData); + gmd = ob->greasepencil_modifiers.first; + + /* return the first selected armature, this lets us use multiple armatures */ + for (; gmd; gmd = gmd->next) { + if (gmd->type == eGpencilModifierType_Armature) { + agmd = (ArmatureGpencilModifierData *)gmd; + if (agmd->object && (agmd->object->base_flag & BASE_SELECTED)) { + return agmd->object; + } } } + /* If we're still here then return the last armature. */ + if (agmd) { + return agmd->object; + } } - - if (amd) { /* if we're still here then return the last armature */ - return amd->object; + else { + VirtualModifierData virtualModifierData; + ArmatureModifierData *amd = NULL; + ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); + md = ob->modifiers.first; + + /* return the first selected armature, this lets us use multiple armatures */ + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + amd = (ArmatureModifierData *)md; + if (amd->object && (amd->object->base_flag & BASE_SELECTED)) { + return amd->object; + } + } + } + /* If we're still here then return the last armature. */ + if (amd) { + return amd->object; + } } return NULL; |