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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2012-12-21 16:07:28 +0400
committerTon Roosendaal <ton@blender.org>2012-12-21 16:07:28 +0400
commit915f78af928d4ec0ec8cae5bca2710acee5cf3ea (patch)
tree53c5765b09eee641304cfb405903d1fbb4ae1d6b /source
parentb5054896c3e54c311ccd47f9f7ba254240cc87af (diff)
Armature bone feature:
New Bone option: "Relative Parenting". This makes Child-Objects of Bones transform similar to how deformations of bones are calculated. Allows to move bones in editmode to set pivot. The option is in Bone Panel, with clear label. It is ON now by default when you add new bones Requested by Kjartan, our famous robot designer :) For "hard body rigs" it's very useful.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/object.c5
-rw-r--r--source/blender/editors/armature/editarmature.c7
-rw-r--r--source/blender/makesdna/DNA_armature_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_armature.c5
4 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 28aa3a523cd..f9bbf0dcc53 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1839,7 +1839,10 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4])
}
/* get bone transform */
- copy_m4_m4(mat, pchan->pose_mat);
+ if (pchan->bone->flag & BONE_RELATIVE_PARENTING)
+ copy_m4_m4(mat, pchan->chan_mat);
+ else
+ copy_m4_m4(mat, pchan->pose_mat);
/* but for backwards compatibility, the child has to move to the tail */
copy_v3_v3(vec, mat[1]);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index ffe58be0139..ae405c0e113 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -2256,6 +2256,7 @@ void undo_push_armature(bContext *C, const char *name)
/* *************** Adding stuff in editmode *************** */
/* default bone add, returns it selected, but without tail set */
+/* XXX should be used everywhere, now it mallocs bones still locally in functions */
EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
{
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
@@ -2265,7 +2266,7 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
BLI_addtail(arm->edbo, bone);
- bone->flag |= BONE_TIPSEL;
+ bone->flag |= BONE_TIPSEL | BONE_RELATIVE_PARENTING;
bone->weight = 1.0f;
bone->dist = 0.25f;
bone->xwidth = 0.1f;
@@ -3410,7 +3411,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
copy_v3_v3(newbone->tail, newbone->head);
newbone->parent = ebone;
- newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
+ newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING); // copies it, in case mirrored bone
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
@@ -3419,7 +3420,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
copy_v3_v3(newbone->tail, ebone->head);
newbone->parent = ebone->parent;
- newbone->flag = BONE_TIPSEL;
+ newbone->flag = BONE_TIPSEL | BONE_RELATIVE_PARENTING;
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED;
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index fd68a6d9a27..8fcb079cd4f 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -198,7 +198,9 @@ typedef enum eBone_Flag {
BONE_EDITMODE_LOCKED = (1 << 19), /* bone transforms are locked in EditMode */
BONE_TRANSFORM_CHILD = (1 << 20), /* Indicates that a parent is also being transformed */
BONE_UNSELECTABLE = (1 << 21), /* bone cannot be selected */
- BONE_NO_LOCAL_LOCATION = (1 << 22) /* bone location is in armature space */
+ BONE_NO_LOCAL_LOCATION = (1 << 22), /* bone location is in armature space */
+ BONE_RELATIVE_PARENTING = (1 << 23) /* object child will use relative transform (like deform) */
+
} eBone_Flag;
#define MAXBONENAME 64
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 4c566d71981..f800e7b9e48 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -529,6 +529,11 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_LOCAL_LOCATION);
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
+ prop = RNA_def_property(srna, "use_relative_parenting", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Relative Parenting", "Object children will use relative transform, like deform");
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_RELATIVE_PARENTING);
+ RNA_def_property_update(prop, 0, "rna_Armature_update_data");
+
prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE);
RNA_def_property_ui_text(prop, "Draw Wire",