diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-21 16:49:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-21 16:57:08 +0300 |
commit | 84b074baedd9d472ff2f52759b15f119de4f69c2 (patch) | |
tree | 21b4b9c5f1dbb56c47a5cab796207526e2eaaee8 /source/blender | |
parent | 0dbde559cfff511e75ab44e2c3d7efe8321dc309 (diff) |
Armature drawing: custom shape scale options
- Custom scale:
Avoids having multiple custom-shapes at different sizes.
- Option not to use bones length:
So changes in edit-mode don't resize the custom-shape.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 14 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 11 |
6 files changed, 45 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5b1a6ea7a51..b77ae45e94d 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -485,6 +485,9 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel"); BLI_strncpy(chan->name, name, sizeof(chan->name)); + + chan->custom_scale = 1.0f; + /* init vars to prevent math errors */ unit_qt(chan->quat); unit_axis_angle(chan->rotAxis, &chan->rotAngle); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 29f2ad0d512..6afe7f1abe9 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2229,7 +2229,7 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden BKE_object_boundbox_get(pchan->custom) : NULL; if (bb_custom) { float mat[4][4], smat[4][4]; - scale_m4_fl(smat, pchan->bone->length); + scale_m4_fl(smat, PCHAN_CUSTOM_DRAW_SIZE(pchan)); mul_m4_series(mat, ob->obmat, pchan_tx->pose_mat, smat); BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 5518b1513f4..1f4aa3c9f3c 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -853,4 +853,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } #undef BRUSH_TORUS } + + if (!MAIN_VERSION_ATLEAST(main, 276, 2)) { + if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) { + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) { + if (ob->pose) { + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + pchan->custom_scale = 1.0f; + } + } + } + } + } } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 2579972cf0f..f7698b0e9f3 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1778,7 +1778,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } draw_custom_bone(scene, v3d, rv3d, pchan->custom, - OB_SOLID, arm->flag, flag, index, bone->length); + OB_SOLID, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); } } else { @@ -1869,7 +1869,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, flag |= BONE_DRAW_ACTIVE; draw_custom_bone(scene, v3d, rv3d, pchan->custom, - OB_WIRE, arm->flag, flag, index, bone->length); + OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); glPopMatrix(); } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index b8688e5e12a..d574694c70d 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -198,7 +198,8 @@ typedef struct bPoseChannel { short agrp_index; /* index of action-group this bone belongs to (0 = default/no group) */ char constflag; /* for quick detecting which constraints affect this channel */ char selectflag; /* copy of bone flag, so you can work with library armatures, not for runtime use */ - char pad0[6]; + char drawflag; + char pad0[5]; struct Bone *bone; /* set on read file or rebuild pose */ struct bPoseChannel *parent; /* set on read file or rebuild pose */ @@ -212,6 +213,9 @@ typedef struct bPoseChannel { 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 */ + float custom_scale; + + char pad1[4]; /* transforms - written in by actions or transform */ float loc[3]; @@ -306,6 +310,14 @@ typedef enum ePchan_IkFlag { BONE_IK_NO_ZDOF_TEMP = (1 << 12) } ePchan_IkFlag; +/* PoseChannel->drawflag */ +typedef enum ePchan_DrawFlag { + PCHAN_DRAW_NO_CUSTOM_BONE_SIZE = (1 << 0), +} ePchan_DrawFlag; + +#define PCHAN_CUSTOM_DRAW_SIZE(pchan) \ + (pchan)->custom_scale * (((pchan)->drawflag & PCHAN_DRAW_NO_CUSTOM_BONE_SIZE) ? 1.0f : (pchan)->bone->length) + /* PoseChannel->rotmode and Object->rotmode */ typedef enum eRotationModes { /* quaternion rotations (default, and for older Blender versions) */ diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index e65023132c9..27ff0a63e75 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -1062,6 +1062,17 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); + prop = RNA_def_property(srna, "custom_shape_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "custom_scale"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Custom Shape Scale", "Adjust the size of the custom shape"); + RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); + + prop = RNA_def_property(srna, "use_custom_shape_bone_size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", PCHAN_DRAW_NO_CUSTOM_BONE_SIZE); + RNA_def_property_ui_text(prop, "Use Bone Size", "Scale the custom object by the bone length"); + 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"); |