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/gpencil_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/gpencil_modifier.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_modifier.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index c2e330e8f04..bc74693bbb8 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -33,6 +33,7 @@ #include "BLT_translation.h" +#include "DNA_armature_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_meshdata_types.h" @@ -57,6 +58,10 @@ static CLG_LogRef LOG = {"bke.gpencil_modifier"}; static GpencilModifierTypeInfo *modifier_gpencil_types[NUM_GREASEPENCIL_MODIFIER_TYPES] = {NULL}; +#if 0 +/* Note that GPencil actually does not support these atm, but might do in the future. */ +static GpencilVirtualModifierData virtualModifierCommonData; +#endif /* Lattice Modifier ---------------------------------- */ /* Usually, evaluation of the lattice modifier is self-contained. @@ -110,6 +115,34 @@ void BKE_gpencil_lattice_clear(Object *ob) /* *************************************************** */ /* Modifier Methods - Evaluation Loops, etc. */ +/* This is to include things that are not modifiers in the evaluation of the modifier stack, for + * example parenting to an armature or lattice without having a real modifier. */ +GpencilModifierData *BKE_gpencil_modifiers_get_virtual_modifierlist( + const Object *ob, GpencilVirtualModifierData *UNUSED(virtualModifierData)) +{ + GpencilModifierData *md = ob->greasepencil_modifiers.first; + +#if 0 + /* Note that GPencil actually does not support these atm, but might do in the future. */ + *virtualModifierData = virtualModifierCommonData; + if (ob->parent) { + if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) { + virtualModifierData->amd.object = ob->parent; + virtualModifierData->amd.modifier.next = md; + virtualModifierData->amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag; + md = &virtualModifierData->amd.modifier; + } + else if (ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { + virtualModifierData->lmd.object = ob->parent; + virtualModifierData->lmd.modifier.next = md; + md = &virtualModifierData->lmd.modifier; + } + } +#endif + + return md; +} + /** * Check if object has grease pencil Geometry modifiers. * \param ob: Grease pencil object @@ -229,6 +262,22 @@ void BKE_gpencil_modifier_init(void) { /* Initialize modifier types */ gpencil_modifier_type_init(modifier_gpencil_types); /* MOD_gpencil_util.c */ + +#if 0 + /* Note that GPencil actually does not support these atm, but might do in the future. */ + /* Initialize global cmmon storage used for virtual modifier list */ + GpencilModifierData *md; + md = BKE_gpencil_modifier_new(eGpencilModifierType_Armature); + virtualModifierCommonData.amd = *((ArmatureGpencilModifierData *)md); + BKE_gpencil_modifier_free(md); + + md = BKE_gpencil_modifier_new(eGpencilModifierType_Lattice); + virtualModifierCommonData.lmd = *((LatticeGpencilModifierData *)md); + BKE_gpencil_modifier_free(md); + + virtualModifierCommonData.amd.modifier.mode |= eGpencilModifierMode_Virtual; + virtualModifierCommonData.lmd.modifier.mode |= eGpencilModifierMode_Virtual; +#endif } /** |