From 12bc34b0b81b11186e3814f8a255f1226f0588c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 30 Aug 2020 17:39:12 +1000 Subject: Object: add ED_object_array_in_mode_or_selected Use this utility function for render-shading & weight paint modes. This adds support for edit-mode & pose-mode where all objects in the mode are used in this case instead of the selected objects. --- source/blender/editors/object/object_vgroup.c | 50 +-------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'source/blender/editors/object/object_vgroup.c') diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 41541288e07..a144632fc5f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -84,54 +84,6 @@ static bool vertex_group_supported_poll_ex(bContext *C, const Object *ob); /** \name Local Utility Functions * \{ */ -static Object **object_array_for_wpaint_impl(bContext *C, - bool (*filter_fn)(struct Object *ob, void *user_data), - void *filter_user_data, - uint *r_objects_len) -{ - Object **objects; - - Object *ob = NULL; - bool use_ob = true; - if (CTX_wm_space_properties(C)) { - /* May return pinned object. */ - ob = ED_object_context(C); - } - else if (CTX_data_mode_enum(C) == CTX_MODE_PAINT_WEIGHT) { - /* When painting, limit to active. */ - ob = CTX_data_active_object(C); - } - else { - /* Otherwise use full selection. */ - use_ob = false; - } - - if (use_ob) { - if (!filter_fn(ob, filter_user_data)) { - ob = NULL; - } - *r_objects_len = (ob != NULL) ? 1 : 0; - objects = MEM_mallocN(sizeof(*objects) * *r_objects_len, __func__); - if (ob != NULL) { - objects[0] = ob; - } - } - else { - ViewLayer *view_layer = CTX_data_view_layer(C); - const View3D *v3d = CTX_wm_view3d(C); /* may be NULL. */ - objects = BKE_view_layer_array_selected_objects_params( - view_layer, - v3d, - r_objects_len, - &((const struct ObjectsInViewLayerParams){ - .no_dup_data = true, - .filter_fn = filter_fn, - .filter_userdata = filter_user_data, - })); - } - return objects; -} - static bool object_array_for_wpaint_filter(Object *ob, void *user_data) { bContext *C = user_data; @@ -143,7 +95,7 @@ static bool object_array_for_wpaint_filter(Object *ob, void *user_data) static Object **object_array_for_wpaint(bContext *C, uint *r_objects_len) { - return object_array_for_wpaint_impl(C, object_array_for_wpaint_filter, C, r_objects_len); + return ED_object_array_in_mode_or_selected(C, object_array_for_wpaint_filter, C, r_objects_len); } static bool vertex_group_use_vert_sel(Object *ob) -- cgit v1.2.3