obscure feature: Display Custom Bone Shape at another bones transform.

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.
This commit is contained in:
Campbell Barton 2010-01-05 11:47:43 +00:00
parent 52a2b82852
commit cce1d178b8
6 changed files with 28 additions and 3 deletions

@ -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):

@ -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);

@ -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

@ -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();
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();
if(pchan->custom_tx) {
glMultMatrixf(pchan->custom_tx->pose_mat);
} else {
glMultMatrixf(pchan->pose_mat);
}
/* prepare colors */
if (arm->flag & ARM_POSEMODE)

@ -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;

@ -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");