obscure feature: Display Custom Bone Shape at another bones transform.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 5 Jan 2010 11:47:43 +0000 (11:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 5 Jan 2010 11:47:43 +0000 (11:47 +0000)
Brecht and I took a fair bit of convincing on this one however Cessen was jumping through hoops to do without this feature.
Having the shape being an external mesh deformed by its own armature, which were both hidden but in the same layer *(so the depgraph would update them).
Without this some of the bones in the rig also dont make much sense when animating with.

release/scripts/ui/properties_data_bone.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/render/render_preview.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesrna/intern/rna_pose.c

index 3369adab5a8d9ff3019f0d3bc8c4b9cb3e25802b..e64b2e1a10da2927aa10cc66d5f909ea614acac8 100644 (file)
@@ -223,8 +223,11 @@ class BONE_PT_display(BoneButtonsPanel):
 
             if wide_ui:
                 col = split.column()
+
             col.label(text="Custom Shape:")
             col.prop(pchan, "custom_shape", text="")
+            if pchan.custom_shape:
+                col.prop_object(pchan, "custom_shape_transform", ob.pose, "bones", text="")
 
 
 class BONE_PT_inverse_kinematics(BoneButtonsPanel):
index 1eff6c8f8e3349d1a42a3c2f88e5a518bb49db06..8a38e575cfa5604c41bb9e193ca7cc2bf35a98d7 100644 (file)
@@ -3782,6 +3782,7 @@ static void direct_link_pose(FileData *fd, bPose *pose)
                pchan->bone= NULL;
                pchan->parent= newdataadr(fd, pchan->parent);
                pchan->child= newdataadr(fd, pchan->child);
+               pchan->custom_tx= newdataadr(fd, pchan->custom_tx);
                
                direct_link_constraints(fd, &pchan->constraints);
                
index 1e0393479b06a86b546bf5cccf510d7dfcfdb7af..3b21373139ed11f7dfa73c9cc4a4cae3dec0aa49 100644 (file)
@@ -1106,6 +1106,8 @@ static int preview_notifier_id(ShaderPreview *sp)
                case ID_LA:
                        return NC_LAMP;
        }
+
+       return 0;
 }
 
 /* use same function for icon & shader, so the job manager
index d8c2fb9d43e359d99704ae7e3c25d03a51f16801..c59c5cddb3fbcf5f5377852ee9f2e48aa084823a 100644 (file)
@@ -1622,8 +1622,14 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                        
                        if ( (bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG)) ) {
                                if (bone->layer & arm->layer) {
+                                       int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
                                        glPushMatrix();
-                                       glMultMatrixf(pchan->pose_mat);
+
+                                       if(use_custom && pchan->custom_tx) {
+                                               glMultMatrixf(pchan->custom_tx->pose_mat);
+                                       } else {
+                                               glMultMatrixf(pchan->pose_mat);
+                                       }
                                        
                                        /* catch exception for bone with hidden parent */
                                        flag= bone->flag;
@@ -1637,7 +1643,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                                        /* set color-set to use */
                                        set_pchan_colorset(ob, pchan);
                                        
-                                       if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
+                                       if (use_custom) {
                                                /* if drawwire, don't try to draw in solid */
                                                if (pchan->bone->flag & BONE_DRAWWIRE) 
                                                        draw_wire= 1;
@@ -1687,7 +1693,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                                        if (pchan->custom) {
                                                if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) {
                                                        glPushMatrix();
-                                                       glMultMatrixf(pchan->pose_mat);
+
+                                                       if(pchan->custom_tx) {
+                                                               glMultMatrixf(pchan->custom_tx->pose_mat);
+                                                       } else {
+                                                               glMultMatrixf(pchan->pose_mat);
+                                                       }
                                                        
                                                        /* prepare colors */
                                                        if (arm->flag & ARM_POSEMODE)   
index aa3b921565ffb21336579f3a63f184051b1d53e0..b6af91a95708d20ea7d1d6808497e0a72c634774 100644 (file)
@@ -213,6 +213,7 @@ typedef struct bPoseChannel {
        float           *path;                          /* totpath x 3 x float */               // XXX depreceated... old animation system (armature only viz)
        bMotionPath *mpath;                             /* motion path cache for this bone */
        struct Object *custom;                  /* draws custom object instead of default bone shape */
+       struct bPoseChannel *custom_tx; /* odd feature, display with another bones transform. needed in rare cases for advanced rigs, since the alternative is highly complicated - campbell */
 } bPoseChannel;
 
 
index 07c4445872e080a351f4bdc0f0eeea0a3782e634..ff8f21028eb7c562fcde98cac97de169388b7173 100644 (file)
@@ -912,6 +912,13 @@ static void rna_def_pose_channel(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone.");
        RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
        
+       prop= RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "custom_tx");
+       RNA_def_property_struct_type(prop, "PoseBone");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Custom Shape Transform", "Bone that defines the display transform of this custom shape.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
+       
        /* bone groups */
        prop= RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "agrp_index");