diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-17 12:21:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-17 12:23:58 +0300 |
commit | 963b1c8e41edd6cfd400b1e1e19d073d88378013 (patch) | |
tree | 906ea6df89f2d0db9b3d2c2c18fb2cb373fb5f10 | |
parent | ad797ed39a49d8591d561eca71c170733f8a0c1a (diff) |
Pose: fix wpaint + pose mode pick & linked select
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 44 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_select.c | 15 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_select.c | 2 |
4 files changed, 58 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 5fa3399a07c..b51c4e17394 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -146,6 +146,10 @@ struct Object **BKE_object_pose_array_get_ex(struct ViewLayer *view_layer, uint struct Object **BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, uint *r_objects_len); struct Object **BKE_object_pose_array_get(struct ViewLayer *view_layer, uint *r_objects_len); +struct Base **BKE_object_pose_base_array_get_ex(struct ViewLayer *view_layer, uint *r_bases_len, bool unique); +struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer, uint *r_bases_len); +struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, uint *r_bases_len); + void BKE_object_get_parent_matrix( struct Scene *scene, struct Object *ob, struct Object *par, float parentmat[4][4]); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cbe4b0bf793..8b6ae075f9c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1259,17 +1259,57 @@ Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len } return objects; } - Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, uint *r_objects_len) { return BKE_object_pose_array_get_ex(view_layer, r_objects_len, true); } - Object **BKE_object_pose_array_get(ViewLayer *view_layer, uint *r_objects_len) { return BKE_object_pose_array_get_ex(view_layer, r_objects_len, false); } +Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_len, bool unique) +{ + Base *base_active = BASACT(view_layer); + Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : NULL; + Base *base_pose = NULL; + Base **bases = NULL; + + if (base_active) { + if (ob_pose == base_active->object) { + base_pose = base_active; + } + else { + base_pose = BKE_view_layer_base_find(view_layer, ob_pose); + } + } + + if (base_active && (base_pose == base_active)) { + bases = BKE_view_layer_array_from_bases_in_mode( + view_layer, r_bases_len, { + .object_mode = OB_MODE_POSE, + .no_dup_data = unique}); + } + else if (base_pose != NULL) { + *r_bases_len = 1; + bases = MEM_mallocN(sizeof(*bases), __func__); + bases[0] = base_pose; + } + else { + *r_bases_len = 0; + bases = MEM_mallocN(0, __func__); + } + return bases; +} +Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, uint *r_bases_len) +{ + return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, true); +} +Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, uint *r_bases_len) +{ + return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, false); +} + void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) { copy_v3_v3(ob_tar->loc, ob_src->loc); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 6ad33125a25..ce044d1cf48 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -41,6 +41,7 @@ #include "BKE_context.h" #include "BKE_action.h" +#include "BKE_object.h" #include "BKE_report.h" #include "BKE_layer.h" @@ -259,10 +260,16 @@ void *get_nearest_bone( if (hits > 0) { uint bases_len = 0; - Base **bases = BKE_view_layer_array_from_bases_in_mode( - vc.view_layer, &bases_len, { - .object_mode = vc.obedit ? OB_MODE_EDIT : OB_MODE_POSE, - .no_dup_data = true}); + Base **bases; + + if (vc.obedit != NULL) { + bases = BKE_view_layer_array_from_bases_in_mode( + vc.view_layer, &bases_len, { + .object_mode = OB_MODE_EDIT}); + } + else { + bases = BKE_object_pose_base_array_get(vc.view_layer, &bases_len); + } void *bone = get_bone_from_selectbuffer( bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base); diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index b6f1e101291..39dba82aaf1 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -171,7 +171,7 @@ bool ED_armature_pose_select_pick_with_buffer( if (!extend && !deselect && !toggle) { { uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len); ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true); MEM_SAFE_FREE(objects); } |