Commit: 5855d4051f2b767aedd681ab18b7f2abf067d90a
Author: Campbell Barton
Date:   Wed Mar 14 03:08:55 2018 +1100
Branches: temp-object-multi-mode
https://developer.blender.org/rB5855d4051f2b767aedd681ab18b7f2abf067d90a

Filtering suppoert w/ BKE_view_layer_array_from_*

Fixes mixing non active objects w/o UVs, when using UV tools/selection.

===================================================================

M       source/blender/blenkernel/BKE_layer.h
M       source/blender/blenkernel/intern/layer.c
M       source/blender/editors/transform/transform_conversions.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/editors/uvedit/uvedit_ops.c
M       source/blender/editors/uvedit/uvedit_unwrap_ops.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index cdc71963993..69494bcf410 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -348,9 +348,15 @@ struct ObjectsRenderableIteratorData {
 
 /* Array utilities. */
 
+typedef bool (*ObjectsFilterFn)(
+        struct Object *ob, void *user_data);
+
 struct ObjectsInModeParams {
        int object_mode;
        uint no_dupe_data : 1;
+
+       ObjectsFilterFn  filter_fn;
+       void            *filter_userdata;
 };
 
 Base **BKE_view_layer_array_from_bases_in_mode_params(
@@ -376,6 +382,9 @@ struct Object 
**BKE_view_layer_array_from_objects_in_mode_params(
                view_layer, r_len, \
                &(const struct ObjectsInModeParams){ .object_mode = 
OB_MODE_EDIT, __VA_ARGS__})
 
+
+bool BKE_view_layer_filter_edit_mesh_has_uvs(struct Object *ob, void 
*user_data);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index 9b420127110..ea796f9f8f2 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -34,6 +34,7 @@
 #include "BLT_translation.h"
 
 #include "BKE_collection.h"
+#include "BKE_editmesh.h"
 #include "BKE_freestyle.h"
 #include "BKE_global.h"
 #include "BKE_group.h"
@@ -50,6 +51,7 @@
 #include "DNA_ID.h"
 #include "DNA_layer_types.h"
 #include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_node_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_windowmanager_types.h"
@@ -2427,6 +2429,11 @@ Base **BKE_view_layer_array_from_bases_in_mode_params(
        BLI_array_declare(base_array);
 
        FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+               if (params->filter_fn) {
+                       if (!params->filter_fn(base_iter->object, 
params->filter_userdata)) {
+                               continue;
+                       }
+               }
                if (params->no_dupe_data) {
                        ID *id = base_iter->object->data;
                        if (id) {
@@ -2462,6 +2469,18 @@ Object 
**BKE_view_layer_array_from_objects_in_mode_params(
        return (Object **)base_array;
 }
 
+bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void 
*UNUSED(user_data))
+{
+       if (ob->type == OB_MESH) {
+               Mesh *me = ob->data;
+               BMEditMesh *em = me->edit_btmesh;
+               if (em != NULL) {
+                       return CustomData_get_offset(&em->bm->ldata, 
CD_MLOOPUV) != -1;
+               }
+       }
+       return false;
+}
+
 /**
  * Free any static allocated memory.
  */
diff --git a/source/blender/editors/transform/transform_conversions.c 
b/source/blender/editors/transform/transform_conversions.c
index a3a9f4a50dd..888f2d22c7e 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -3041,6 +3041,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
        FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) {
        BMEditMesh *em = BKE_editmesh_from_object(ob_iter);
        const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, 
CD_MLOOPUV);
+       if (cd_loop_uv_offset == -1) {
+               continue;
+       }
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                BMLoop *l;
@@ -3109,6 +3112,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
        FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (t->eval_ctx.view_layer, ob_iter) {
        BMEditMesh *em = BKE_editmesh_from_object(ob_iter);
        const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, 
CD_MLOOPUV);
+       if (cd_loop_uv_offset == -1) {
+               continue;
+       }
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                BMLoop *l;
diff --git a/source/blender/editors/uvedit/uvedit_draw.c 
b/source/blender/editors/uvedit/uvedit_draw.c
index 5ea9796de3d..9d02c8589b2 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -1069,6 +1069,7 @@ void ED_uvedit_draw_main(
                        uint objects_len = 0;
                        Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode(
                                view_layer, &objects_len,
+                               .filter_fn = 
BKE_view_layer_filter_edit_mesh_has_uvs,
                                .no_dupe_data = true);
                        for (uint ob_index = 0; ob_index < objects_len; 
ob_index++) {
                                Object *ob_iter = objects[ob_index];
diff --git a/source/blender/editors/uvedit/uvedit_ops.c 
b/source/blender/editors/uvedit/uvedit_ops.c
index ff108ed9c69..8f051327265 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2140,6 +2140,7 @@ static int uv_select_all_exec(bContext *C, wmOperator *op)
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        uv_select_all_perform_multi(scene, ima, objects, objects_len, action);
@@ -2254,6 +2255,7 @@ static int uv_mouse_select(bContext *C, const float 
co[2], bool extend, bool loo
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        /* find nearest element */
@@ -2592,6 +2594,7 @@ static int uv_select_linked_internal(bContext *C, 
wmOperator *op, const wmEvent
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        if (pick) {
@@ -3058,6 +3061,7 @@ static int uv_border_select_exec(bContext *C, wmOperator 
*op)
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        /* don't indent to avoid diff noise! */
@@ -3330,6 +3334,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, const 
int mcords[][2], short mo
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        /* don't indent to avoid diff noise! */
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c 
b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index ff36336bb07..2a7c914878a 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -849,6 +849,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
        uint objects_len = 0;
        Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
                view_layer, &objects_len,
+               .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs,
                .no_dupe_data = true);
 
        if (!uvedit_have_selection_multi(scene, objects, objects_len, true)) {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to