Commit: 1f94830d6e4d23b19f5cb981de1e883b0d8a04c0
Author: Campbell Barton
Date:   Tue Mar 13 23:51:57 2018 +1100
Branches: temp-object-multi-mode
https://developer.blender.org/rB1f94830d6e4d23b19f5cb981de1e883b0d8a04c0

Move to using arrays of objects/bases

This avoids stepping over the same obdata multiple times for linked
duplicates.

Also support select-linked for UV editmode.

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

M       source/blender/blenkernel/BKE_layer.h
M       source/blender/blenkernel/intern/editmesh.c
M       source/blender/editors/include/ED_mesh.h
M       source/blender/editors/include/ED_uvedit.h
M       source/blender/editors/mesh/editmesh_select.c
M       source/blender/editors/mesh/editmesh_tools.c
M       source/blender/editors/mesh/meshtools.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/editors/uvedit/uvedit_intern.h
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 2091da79dbb..cdc71963993 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -346,7 +346,6 @@ struct ObjectsRenderableIteratorData {
        ITER_END;                                                               
  \
 } ((void)0)
 
-
 /* Array utilities. */
 
 struct ObjectsInModeParams {
@@ -367,6 +366,10 @@ struct Object 
**BKE_view_layer_array_from_objects_in_mode_params(
                view_layer, r_len, \
                &(const struct ObjectsInModeParams){__VA_ARGS__})
 
+#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, r_len, ...) \
+       BKE_view_layer_array_from_bases_in_mode_params( \
+               view_layer, r_len, \
+               &(const struct ObjectsInModeParams){ .object_mode = 
OB_MODE_EDIT, __VA_ARGS__})
 
 #define BKE_view_layer_array_from_objects_in_edit_mode(view_layer, r_len, ...) 
\
        BKE_view_layer_array_from_objects_in_mode_params( \
diff --git a/source/blender/blenkernel/intern/editmesh.c 
b/source/blender/blenkernel/intern/editmesh.c
index c95da3b2569..ab542d9aab0 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -89,15 +89,16 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
        /* sanity check */
+#if 0 /* disable in mutlti-object edit. */
 #ifndef NDEBUG
        if (((Mesh *)ob->data)->edit_btmesh) {
                BLI_assert(((Mesh *)ob->data)->edit_btmesh->ob == ob);
        }
+#endif
 #endif
        return ((Mesh *)ob->data)->edit_btmesh;
 }
 
-
 static void editmesh_tessface_calc_intern(BMEditMesh *em)
 {
        /* allocating space before calculating the tessellation */
diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index 7a01b8712dc..1a541a428cd 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -341,8 +341,8 @@ struct MDeformVert *ED_mesh_active_dvert_get_em(struct 
Object *ob, struct BMVert
 struct MDeformVert *ED_mesh_active_dvert_get_ob(struct Object *ob, int 
*r_index);
 struct MDeformVert *ED_mesh_active_dvert_get_only(struct Object *ob);
 
-void EDBM_mesh_stats_multi(struct ViewLayer *view_layer, int totelem[3], int 
totelem_sel[3]);
-void EDBM_mesh_elem_index_ensure_multi(struct ViewLayer *view_layer, const 
char htype);
+void EDBM_mesh_stats_multi(struct Object **objects, const uint objects_len, 
int totelem[3], int totelem_sel[3]);
+void EDBM_mesh_elem_index_ensure_multi(struct Object **objects, const uint 
objects_len, const char htype);
 
 #define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
 #define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
diff --git a/source/blender/editors/include/ED_uvedit.h 
b/source/blender/editors/include/ED_uvedit.h
index c3b9d43a54a..0a6f9345078 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -121,7 +121,8 @@ void ED_uvedit_live_unwrap(struct Scene *scene, struct 
Object *obedit);
 void ED_uvedit_pack_islands_single(
         struct Scene *scene, struct Object *ob, struct BMesh *bm, bool 
selected, bool correct_aspect, bool do_rotate);
 void ED_uvedit_pack_islands_multi(
-        struct Scene *scene, ViewLayer *view_layer, bool selected, bool 
correct_aspect, bool do_rotate);
+        struct Scene *scene, struct Object **objects, const uint objects_len,
+        bool selected, bool correct_aspect, bool do_rotate);
 void ED_uvedit_unwrap_cube_project(
         struct BMesh *bm, float cube_size, bool use_select, const float 
center[3]);
 
diff --git a/source/blender/editors/mesh/editmesh_select.c 
b/source/blender/editors/mesh/editmesh_select.c
index 08e7d288ed1..a317d59d8cb 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -915,11 +915,14 @@ static int unified_findnearest(
        float dist = dist_init;
        BMFace *efa_zbuf = NULL;
        BMEdge *eed_zbuf = NULL;
-       
+
        BMVert *eve = NULL;
        BMEdge *eed = NULL;
        BMFace *efa = NULL;
 
+       uint bases_len = 0;
+       Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(
+               eval_ctx->view_layer, &bases_len);
 
        /* no afterqueue (yet), so we check it now, otherwise the em_xxxofs 
indices are bad */
 
@@ -927,7 +930,8 @@ static int unified_findnearest(
                float dist_center = 0.0f;
                float *dist_center_p = (em->selectmode & (SCE_SELECT_EDGE | 
SCE_SELECT_VERTEX)) ? &dist_center : NULL;
 
-               FOREACH_BASE_IN_EDIT_MODE_BEGIN (eval_ctx->view_layer, 
base_iter) {
+               for (uint base_index = 0; base_index < bases_len; base_index++) 
{
+                       Base *base_iter = bases[base_index];
                        Object *obedit = base_iter->object;
                        ED_view3d_viewcontext_init_object(vc, obedit);
                        ED_view3d_backbuf_validate(eval_ctx, vc);
@@ -940,14 +944,15 @@ static int unified_findnearest(
                                *r_base = base_iter;
                                efa = efa_test;
                        }
-               } FOREACH_BASE_IN_EDIT_MODE_END;
+               } /* bases */
        }
 
        if ((dist > 0.0f) && (em->selectmode & SCE_SELECT_EDGE)) {
                float dist_center = 0.0f;
                float *dist_center_p = (em->selectmode & SCE_SELECT_VERTEX) ? 
&dist_center : NULL;
 
-               FOREACH_BASE_IN_EDIT_MODE_BEGIN (eval_ctx->view_layer, 
base_iter) {
+               for (uint base_index = 0; base_index < bases_len; base_index++) 
{
+                       Base *base_iter = bases[base_index];
                        Object *obedit = base_iter->object;
                        ED_view3d_viewcontext_init_object(vc, obedit);
                        ED_view3d_backbuf_validate(eval_ctx, vc);
@@ -959,11 +964,12 @@ static int unified_findnearest(
                                *r_base = base_iter;
                                eed = eed_test;
                        }
-               } FOREACH_BASE_IN_EDIT_MODE_END;
+               } /* bases */
        }
 
        if ((dist > 0.0f) && em->selectmode & SCE_SELECT_VERTEX) {
-               FOREACH_BASE_IN_EDIT_MODE_BEGIN (eval_ctx->view_layer, 
base_iter) {
+               for (uint base_index = 0; base_index < bases_len; base_index++) 
{
+                       Base *base_iter = bases[base_index];
                        Object *obedit = base_iter->object;
                        ED_view3d_viewcontext_init_object(vc, obedit);
                        ED_view3d_backbuf_validate(eval_ctx, vc);
@@ -972,9 +978,11 @@ static int unified_findnearest(
                                *r_base = base_iter;
                                eve = eve_test;
                        }
-               } FOREACH_BASE_IN_EDIT_MODE_END;
+               } /* bases */
        }
 
+       MEM_SAFE_FREE(bases);
+
        /* return only one of 3 pointers, for frontbuffer redraws */
        if (eve) {
                efa = NULL; eed = NULL;
@@ -1799,19 +1807,25 @@ static int edbm_select_all_exec(bContext *C, wmOperator 
*op)
        ViewLayer *view_layer = CTX_data_view_layer(C);
        int action = RNA_enum_get(op->ptr, "action");
 
+       uint objects_len = 0;
+       Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
+               view_layer, &objects_len,
+               .no_dupe_data = true);
+
        if (action == SEL_TOGGLE) {
                action = SEL_SELECT;
-               FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (view_layer, obedit) {
+               for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+                       Object *obedit = objects[ob_index];
                        BMEditMesh *em = BKE_editmesh_from_object(obedit);
                        if (em->bm->totvertsel || em->bm->totedgesel || 
em->bm->totfacesel) {
                                action = SEL_DESELECT;
                                break;
                        }
                }
-               FOREACH_OBJECT_IN_MODE_END;
        }
 
-       FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (view_layer, obedit) {
+       for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+               Object *obedit = objects[ob_index];
                BMEditMesh *em = BKE_editmesh_from_object(obedit);
                switch (action) {
                        case SEL_SELECT:
@@ -1827,7 +1841,8 @@ static int edbm_select_all_exec(bContext *C, wmOperator 
*op)
                }
                WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
        }
-       FOREACH_OBJECT_IN_MODE_END;
+
+       MEM_SAFE_FREE(objects);
 
        return OPERATOR_FINISHED;
 }
@@ -1905,12 +1920,18 @@ bool EDBM_select_pick(bContext *C, const int mval[2], 
bool extend, bool deselect
 
                /* Deselect everything */
                if (extend == false && deselect == false && toggle == false) {
-                       FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (eval_ctx.view_layer, 
ob_iter) {
+                       uint objects_len = 0;
+                       Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode(
+                               eval_ctx.view_layer, &objects_len,
+                               .no_dupe_data = true);
+
+                       for (uint ob_index = 0; ob_index < objects_len; 
ob_index++) {
+                               Object *ob_iter = objects[ob_index];
                                
EDBM_flag_disable_all(BKE_editmesh_from_object(ob_iter), BM_ELEM_SELECT);
                                if (basact->object != ob_iter) {
                                        WM_event_add_notifier(C, NC_GEOM | 
ND_SELECT, ob_iter->data);
                                }
-                       } FOREACH_OBJECT_IN_MODE_END;
+                       }
                }
 
                if (efa) {
@@ -2293,24 +2314,32 @@ bool EDBM_selectmode_toggle(bContext *C, const short 
selectmode_new,
                        break;
        }
 
-       FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (eval_ctx.view_layer, ob_iter) {
+       uint objects_len = 0;
+       Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(
+               eval_ctx.view_layer, &objects_len,
+               .no_dupe_data = true);
+
+       for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+               Object *ob_iter = objects[ob_index];
                BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
                if (em_iter != em) {
                        em_iter->selectmode = em->selectmode;
                }
-       } FOREACH_OBJECT_IN_MODE_END;
+       }
 
        if (only_update) {
+               MEM_SAFE_FREE(objects);
                return false;
        }
 
        if (use_extend == 0 || em->selectmode == 0) {
                if (use_expand) {
                        const short selmode_max = 
highest_order_bit_s(ts->selectmode);
-                       FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (eval_ctx.view_layer, 
ob_iter) {
+                       for (uint ob_index = 0; ob_index < objects_len; 
ob_index++) {
+                               Object *ob_iter = objects[ob_index];
                                BMEditMesh *em_iter = 
BKE_editmesh_from_object(ob_iter);
                                EDBM_selectmode_convert(em_iter, selmode_max, 
selectmode_new);
-                       } FOREACH_OBJECT_IN_MODE_END;
+                       }
                }
        }
 
@@ -2341,14 +2370,16 @@ bool EDBM_selectmode_toggle(bContext *C, const short 
selectmode_new,
        if (ret == true) {
                ts->selectmode = em->selectmode;
                em = NULL;
-               FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (eval_ctx.view_layer, 
ob_iter) {
+               for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+                       Object *ob_iter = objects[ob_index];
                        BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
                        EDBM_selectmode_set(em_iter);
                        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, 
ob_iter->data);
-               } FOREACH_OBJECT_IN_MODE_END;
+               }
                WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
        }
 
+       MEM_SAFE_FREE(objects);
        return ret;
 }
 
@@ -2919,13 +2950

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to