Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-07-15 16:53:16 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-07-15 16:53:16 +0400
commitb67b73e2d85d35ac0e0f6d4b5afe41a431200b01 (patch)
treeef34a7e36684d170fa9bd95115505138392dcb89 /source/blender/editors/object/object_relations.c
parent380c5d66a8717ebe7b0d124302a39c7068f04efb (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/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c43
1 files changed, 37 insertions, 6 deletions
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 ******************* */