diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2012-07-15 16:53:16 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2012-07-15 16:53:16 +0400 |
commit | b67b73e2d85d35ac0e0f6d4b5afe41a431200b01 (patch) | |
tree | ef34a7e36684d170fa9bd95115505138392dcb89 /source | |
parent | 380c5d66a8717ebe7b0d124302a39c7068f04efb (diff) |
"Fix" [#32033] In the execution result of with_automatic_weight, the difference is seen right and left.
This auto/heat vgroup creation seems to be fuzzy/unstable (each run gives a slightly different result). I have not the competences (nor time) to investigate that laplacian stuff, so for now just adding an option when parenting to an armature with envelope/heat, to mirror weights along the X axis (as it is done by default when doing it from the Weight Paint mode).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 43 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_edit.c | 4 |
3 files changed, 41 insertions, 9 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 9209bbb2db7..38f0077c368 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -84,7 +84,8 @@ typedef enum eParentType { extern struct EnumPropertyItem prop_clear_parent_types[]; extern struct EnumPropertyItem prop_make_parent_types[]; -int ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct Object *par, int partype); +int ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, + struct Object *par, int partype, int xmirror); void ED_object_parent_clear(struct Object *ob, int type); struct Base *ED_object_scene_link(struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index d7c882ba51e..860ff24cafd 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -518,7 +518,8 @@ EnumPropertyItem prop_make_parent_types[] = { {0, NULL, 0, NULL, NULL} }; -int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, int partype) +int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, + int partype, int xmirror) { bPoseChannel *pchan = NULL; int pararm = ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); @@ -641,12 +642,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } else if (pararm && ob->type == OB_MESH && par->type == OB_ARMATURE) { if (partype == PAR_ARMATURE_NAME) - create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, 0); + create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, FALSE); else if (partype == PAR_ARMATURE_ENVELOPE) - create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_ENVELOPE, 0); + create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); else if (partype == PAR_ARMATURE_AUTO) { WM_cursor_wait(1); - create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_AUTO, 0); + create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_AUTO, xmirror); WM_cursor_wait(0); } /* get corrected inverse */ @@ -674,11 +675,12 @@ static int parent_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *par = ED_object_active_context(C); int partype = RNA_enum_get(op->ptr, "type"); + int xmirror = RNA_enum_get(op->ptr, "xmirror"); int ok = 1; CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { + if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, xmirror)) { ok = 0; break; } @@ -728,6 +730,33 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE return OPERATOR_CANCELLED; } +static int parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + int type = RNA_enum_get(ptr, "type"); + + /* Only show XMirror for PAR_ARMATURE_ENVELOPE and PAR_ARMATURE_AUTO! */ + if (strcmp(prop_id, "xmirror") == 0) { + if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO)) + return TRUE; + else + return FALSE; + } + + return TRUE; +} + +static void parent_set_ui(bContext *C, wmOperator *op) +{ + uiLayout *layout = op->layout; + wmWindowManager *wm = CTX_wm_manager(C); + PointerRNA ptr; + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + + /* Main auto-draw call. */ + uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, '\0'); +} void OBJECT_OT_parent_set(wmOperatorType *ot) { @@ -739,13 +768,15 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) /* api callbacks */ ot->invoke = parent_set_invoke; ot->exec = parent_set_exec; - ot->poll = ED_operator_object_active; + ot->ui = parent_set_ui; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "xmirror", FALSE, "X Mirror", + "Apply weights symmetrically along X axis, for Envelope/Automatic vertex groups creation"); } /* ************ Make Parent Without Inverse Operator ******************* */ diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 449914feae4..0388ba86b84 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1423,7 +1423,7 @@ static int parent_drop_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "child", childname); ob = (Object *)BKE_libblock_find_name(ID_OB, childname); - ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); + ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE); DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); @@ -1514,7 +1514,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) } if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { - if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { + if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE)) { DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); |