diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-17 11:13:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-17 11:22:40 +0300 |
commit | a04b551e40d1c0633ea6fd022483fd9ed3c81021 (patch) | |
tree | 72d77640fcd20983599e59fdbb6dd27b2d87a370 /source/blender/blenkernel/intern | |
parent | be3392e0f902a32e1077179743f23716f4dc19b0 (diff) |
BKE_object: utility functions for pose access
Pose objects may be from the active object,
or from the weight paint mesh.
Since this is such a common check move this to a function call.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f59a942c683..cbe4b0bf793 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1233,6 +1233,43 @@ Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer) } return NULL; } + +/** + * Access pose array with special check to get pose object when in weight paint mode. + */ +Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len, bool unique) +{ + Object *ob_active = OBACT(view_layer); + Object *ob_pose = BKE_object_pose_armature_get(ob_active); + Object **objects = NULL; + if (ob_pose == ob_active) { + objects = BKE_view_layer_array_from_objects_in_mode( + view_layer, r_objects_len, { + .object_mode = OB_MODE_POSE, + .no_dup_data = unique}); + } + else if (ob_pose != NULL) { + *r_objects_len = 1; + objects = MEM_mallocN(sizeof(*objects), __func__); + objects[0] = ob_pose; + } + else { + *r_objects_len = 0; + objects = MEM_mallocN(0, __func__); + } + 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); +} + void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) { copy_v3_v3(ob_tar->loc, ob_src->loc); |