diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-01-23 17:20:35 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-01-23 17:21:28 +0300 |
commit | ac5278b682cfb090aafe93082e95349cb7d993d3 (patch) | |
tree | 05c73082f67bf5a4f0cd766a2986d971af854fe4 /source/blender | |
parent | db78a8ee2e8c365804c8a4a4adab9ebea6977307 (diff) |
Fix T60791: Don't show automatic weights option when not supported
There are probably many more cases in which the menu looks a little different.
However, I don't know them all and it's too easy to break something accidentally here.
Maybe a user could try the different combinations of object types and check if there are entries that should not be there.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4240
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_relations.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 05d968660f2..80ae81ba737 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -920,7 +920,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - Object *ob = ED_object_active_context(C); + Object *parent = ED_object_active_context(C); uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); @@ -940,26 +940,46 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", true); #endif - /* ob becomes parent, make the associated menus */ - if (ob->type == OB_ARMATURE) { + + struct { + bool mesh, gpencil; + } has_children_of_type = { 0 }; + + CTX_DATA_BEGIN (C, Object *, child, selected_editable_objects) + { + if (child == parent) { + continue; + } + if (child->type == OB_MESH) { + has_children_of_type.mesh = true; + } + if (child->type == OB_GPENCIL) { + has_children_of_type.gpencil = true; + } + } + CTX_DATA_END; + + if (parent->type == OB_ARMATURE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_NAME); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_ENVELOPE); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); + if (has_children_of_type.mesh || has_children_of_type.gpencil) { + uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); + } uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE_RELATIVE); } - else if (ob->type == OB_CURVE) { + else if (parent->type == OB_CURVE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_CURVE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_FOLLOW); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_PATH_CONST); } - else if (ob->type == OB_LATTICE) { + else if (parent->type == OB_LATTICE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_LATTICE); } /* vertex parenting */ - if (OB_TYPE_SUPPORT_PARVERT(ob->type)) { + if (OB_TYPE_SUPPORT_PARVERT(parent->type)) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX_TRI); } |