Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-12-13 03:41:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-12-13 03:41:45 +0300
commit5d09f5223e63591c080b7bfd6b2b48e5476205cf (patch)
tree5650c97704b77940ab15d54871374809743979fe
parent81ea815dcb6125288d25447fcab4b4390e14297a (diff)
Gizmo: multi-object pose-mode gizmo positioning
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 8b877c7ec23..11d8949750d 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1007,21 +1007,41 @@ int ED_transform_calc_gizmo_stats(
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- bPoseChannel *pchan;
- int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the gizmo mode, could be mixed
+ invert_m4_m4(ob->imat, ob->obmat);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_mode(
+ view_layer, v3d, &objects_len, {.object_mode = OB_MODE_POSE});
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ const bool use_mat_local = (ob_iter != ob);
+ bPoseChannel *pchan;
- totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
+ /* mislead counting bones... bah. We don't know the gizmo mode, could be mixed */
+ const int mode = TFM_ROTATION;
- if (totsel) {
- /* use channels to get stats */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- Bone *bone = pchan->bone;
- if (bone && (bone->flag & BONE_TRANSFORM)) {
- calc_tw_center(tbounds, pchan->pose_head);
- protectflag_to_drawflags_pchan(rv3d, pchan);
+ const int totsel_iter = count_set_pose_transflags(ob_iter, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
+
+ if (totsel_iter) {
+ float mat_local[4][4];
+ if (use_mat_local) {
+ mul_m4_m4m4(mat_local, ob_iter->imat, ob_iter->obmat);
}
+
+ /* use channels to get stats */
+ for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ Bone *bone = pchan->bone;
+ if (bone && (bone->flag & BONE_TRANSFORM)) {
+ calc_tw_center(tbounds, pchan->pose_head);
+ calc_tw_center_with_matrix(tbounds, pchan->pose_head, use_mat_local, mat_local);
+ protectflag_to_drawflags_pchan(rv3d, pchan);
+ }
+ }
+ totsel += totsel_iter;
}
+ }
+ MEM_freeN(objects);
+ if (totsel) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
mul_m4_v3(ob->obmat, tbounds->center);
mul_m4_v3(ob->obmat, tbounds->min);