diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-03 21:18:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-03 21:23:18 +0300 |
commit | c3fef001ee926fc183255b623f56da9fc5fcbb73 (patch) | |
tree | 493dcccebf779cb52f462a01c79407350da65286 /source/blender/blenkernel/intern/armature.c | |
parent | 54ad5766669a23976b9a9fab379bb44ba740c9be (diff) |
View-Selected: use custom bones boundbox
Support using custom pose-bone transform and object when calculating view bounds.
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 232d0e21490..9bb8726cdb3 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2209,6 +2209,45 @@ BoundBox *BKE_armature_boundbox_get(Object *ob) return ob->bb; } +bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select) +{ + bool changed = false; + + if (ob->pose) { + bArmature *arm = ob->data; + bPoseChannel *pchan; + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + /* XXX pchan->bone may be NULL for duplicated bones, see duplicateEditBoneObjects() comment + * (editarmature.c:2592)... Skip in this case too! */ + if (pchan->bone && + (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) && + !((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) + { + bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan; + BoundBox *bb_custom = pchan->custom ? BKE_object_boundbox_get(pchan->custom) : NULL; + + if (bb_custom) { + float mat[4][4]; + mul_m4_m4m4(mat, ob->obmat, pchan_tx->pose_mat); + BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); + } + else { + float vec[3]; + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); + minmax_v3v3_v3(r_min, r_max, vec); + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); + minmax_v3v3_v3(r_min, r_max, vec); + } + + changed = true; + } + } + } + + return changed; +} + /************** Graph evaluation ********************/ bPoseChannel *BKE_armature_ik_solver_find_root( |