Revision: 53245
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53245
Author:   ton
Date:     2012-12-21 12:07:28 +0000 (Fri, 21 Dec 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_bone.py
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/makesdna/DNA_armature_types.h
    trunk/blender/source/blender/makesrna/intern/rna_armature.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_bone.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_bone.py 
2012-12-21 11:56:02 UTC (rev 53244)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_bone.py 
2012-12-21 12:07:28 UTC (rev 53245)
@@ -170,6 +170,8 @@
         if ob and pchan:
             col.label(text="Bone Group:")
             col.prop_search(pchan, "bone_group", ob.pose, "bone_groups", 
text="")
+            col.label(text="Object Children:")
+            col.prop(bone, "use_relative_parenting")
 
         col = split.column()
         col.label(text="Parent:")
@@ -181,11 +183,11 @@
         sub = col.column()
         sub.active = (bone.parent is not None)
         sub.prop(bone, "use_connect")
-        sub.prop(bone, "use_inherit_rotation", text="Inherit Rotation")
-        sub.prop(bone, "use_inherit_scale", text="Inherit Scale")
+        sub.prop(bone, "use_inherit_rotation")
+        sub.prop(bone, "use_inherit_scale")
         sub = col.column()
         sub.active = (not bone.parent or not bone.use_connect)
-        sub.prop(bone, "use_local_location", text="Local Location")
+        sub.prop(bone, "use_local_location")
 
 
 class BONE_PT_display(BoneButtonsPanel, Panel):

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c     2012-12-21 
11:56:02 UTC (rev 53244)
+++ trunk/blender/source/blender/blenkernel/intern/object.c     2012-12-21 
12:07:28 UTC (rev 53245)
@@ -1839,7 +1839,10 @@
        }
 
        /* 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]);

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c        
2012-12-21 11:56:02 UTC (rev 53244)
+++ trunk/blender/source/blender/editors/armature/editarmature.c        
2012-12-21 12:07:28 UTC (rev 53245)
@@ -2256,6 +2256,7 @@
 /* *************** 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 @@
        
        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 @@
                                                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 @@
                                                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;

Modified: trunk/blender/source/blender/makesdna/DNA_armature_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_armature_types.h  2012-12-21 
11:56:02 UTC (rev 53244)
+++ trunk/blender/source/blender/makesdna/DNA_armature_types.h  2012-12-21 
12:07:28 UTC (rev 53245)
@@ -198,7 +198,9 @@
        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

Modified: trunk/blender/source/blender/makesrna/intern/rna_armature.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_armature.c 2012-12-21 
11:56:02 UTC (rev 53244)
+++ trunk/blender/source/blender/makesrna/intern/rna_armature.c 2012-12-21 
12:07:28 UTC (rev 53245)
@@ -529,6 +529,11 @@
        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",

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to