[Bf-blender-cvs] [70116c39b61] refactor-mesh-selection-generic: Progress

Hans Goudey noreply at git.blender.org
Sun Aug 14 20:24:02 CEST 2022


Commit: 70116c39b6186919b744423527fd0c3b5f7b2d57
Author: Hans Goudey
Date:   Sun Aug 14 14:23:54 2022 -0400
Branches: refactor-mesh-selection-generic
https://developer.blender.org/rB70116c39b6186919b744423527fd0c3b5f7b2d57

Progress

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

M	source/blender/blenkernel/BKE_mesh_mapping.h
M	source/blender/blenkernel/intern/mesh_mapping.c
M	source/blender/blenkernel/intern/subdiv_converter_mesh.c
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh.hh
M	source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc
M	source/blender/editors/armature/meshlaplacian.c
M	source/blender/editors/mesh/mesh_data.cc
M	source/blender/editors/sculpt_paint/paint_vertex.cc
M	source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
M	source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M	source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc

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

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index abe590b6806..cab5670a2ca 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -93,6 +93,7 @@ typedef struct MeshElemMap {
 /* mapping */
 UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly,
                                        const bool *hide_poly,
+                                       const bool *selection_poly,
                                        const struct MLoop *mloop,
                                        const struct MLoopUV *mloopuv,
                                        unsigned int totpoly,
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 798fe087ea8..5d1acfcf8c7 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -30,6 +30,7 @@
 /* ngon version wip, based on BM_uv_vert_map_create */
 UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
                                        const bool *hide_poly,
+                                       const bool *selection_poly,
                                        const MLoop *mloop,
                                        const MLoopUV *mloopuv,
                                        uint totpoly,
@@ -52,7 +53,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
   /* generate UvMapVert array */
   mp = mpoly;
   for (a = 0; a < totpoly; a++, mp++) {
-    if (!selected || (!(hide_poly && hide_poly[a]) && (mp->flag & ME_FACE_SEL))) {
+    if (!selected || (!(hide_poly && hide_poly[a]) && (selection_poly && selection_poly[a]))) {
       totuv += mp->totloop;
     }
   }
@@ -75,7 +76,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
 
   mp = mpoly;
   for (a = 0; a < totpoly; a++, mp++) {
-    if (!selected || (!(hide_poly && hide_poly[a]) && (mp->flag & ME_FACE_SEL))) {
+    if (!selected || (!(hide_poly && hide_poly[a]) && (selection_poly && selection_poly[a]))) {
       float(*tf_uv)[2] = NULL;
 
       if (use_winding) {
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
index 9c6d507d42c..c8693123363 100644
--- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
@@ -207,6 +207,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la
   UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create(
       mpoly,
       (const bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly"),
+      (const bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".selection_poly"),
       mloop,
       mloopuv,
       num_poly,
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index f19aac68d35..c80f5b3e2c6 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -285,7 +285,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss,
    * Also, initially intention is to treat merged vertices from mirror modifier as seams.
    * This fixes a very old regression (2.49 was correct here) */
   vmap = BKE_mesh_uv_vert_map_create(
-      mpoly, NULL, mloop, mloopuv, totface, totvert, limit, false, true);
+      mpoly, NULL, NULL, mloop, mloopuv, totface, totvert, limit, false, true);
   if (!vmap) {
     return 0;
   }
@@ -879,7 +879,7 @@ static void ccgDM_getFinalVertNo(DerivedMesh *dm, int vertNum, float r_no[3])
 BLI_INLINE void ccgDM_to_MVert(MVert *mv, const CCGKey *key, CCGElem *elem)
 {
   copy_v3_v3(mv->co, CCG_elem_co(key, elem));
-  mv->flag = mv->bweight = 0;
+  mv->bweight = 0;
 }
 
 static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
index 0159c9fc86e..d81f965e203 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
@@ -585,6 +585,13 @@ MeshRenderData *mesh_render_data_create(Object *object,
         CustomData_get_layer_named(&me->edata, CD_PROP_BOOL, ".hide_edge"));
     mr->hide_poly = static_cast<const bool *>(
         CustomData_get_layer_named(&me->pdata, CD_PROP_BOOL, ".hide_poly"));
+
+    mr->selection_vert = static_cast<const bool *>(
+        CustomData_get_layer_named(&me->vdata, CD_PROP_BOOL, ".selection_vert"));
+    mr->selection_edge = static_cast<const bool *>(
+        CustomData_get_layer_named(&me->edata, CD_PROP_BOOL, ".selection_edge"));
+    mr->selection_poly = static_cast<const bool *>(
+        CustomData_get_layer_named(&me->pdata, CD_PROP_BOOL, ".selection_poly"));
   }
   else {
     /* #BMesh */
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh.hh b/source/blender/draw/intern/mesh_extractors/extract_mesh.hh
index 57abf088c16..54230c314b6 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh.hh
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh.hh
@@ -86,6 +86,9 @@ struct MeshRenderData {
   const bool *hide_vert;
   const bool *hide_edge;
   const bool *hide_poly;
+  const bool *selection_vert;
+  const bool *selection_edge;
+  const bool *selection_poly;
   float (*loop_normals)[3];
   int *lverts, *ledges;
 
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc
index 9f82cc56941..7016b81a8cf 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc
@@ -62,7 +62,7 @@ static void extract_edituv_tris_iter_looptri_mesh(const MeshRenderData *mr,
   const MPoly *mp = &mr->mpoly[mlt->poly];
   edituv_tri_add(data,
                  mr->hide_poly && mr->hide_poly[mlt->poly],
-                 (mp->flag & ME_FACE_SEL) != 0,
+                 mr->selection_poly && mr->selection_poly[mlt->poly],
                  mlt->tri[0],
                  mlt->tri[1],
                  mlt->tri[2]);
@@ -125,13 +125,23 @@ static void extract_edituv_tris_iter_subdiv_mesh(const DRWSubdivCache *UNUSED(su
   MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data);
   const uint loop_idx = subdiv_quad_index * 4;
 
-  const bool hidden = mr->hide_poly && mr->hide_poly[coarse_quad - mr->mpoly];
+  const int coarse_quad_index = coarse_quad - mr->mpoly;
 
-  edituv_tri_add(
-      data, hidden, (coarse_quad->flag & ME_FACE_SEL) != 0, loop_idx, loop_idx + 1, loop_idx + 2);
+  const bool hidden = mr->hide_poly && mr->hide_poly[coarse_quad_index];
 
-  edituv_tri_add(
-      data, hidden, (coarse_quad->flag & ME_FACE_SEL) != 0, loop_idx, loop_idx + 2, loop_idx + 3);
+  edituv_tri_add(data,
+                 hidden,
+                 mr->selection_poly && mr->selection_poly[coarse_quad_index],
+                 loop_idx,
+                 loop_idx + 1,
+                 loop_idx + 2);
+
+  edituv_tri_add(data,
+                 hidden,
+                 mr->selection_poly && mr->selection_poly[coarse_quad_index],
+                 loop_idx,
+                 loop_idx + 2,
+                 loop_idx + 3);
 }
 
 static void extract_edituv_tris_finish_subdiv(const struct DRWSubdivCache *UNUSED(subdiv_cache),
@@ -208,7 +218,7 @@ static void extract_edituv_lines_iter_poly_bm(const MeshRenderData *UNUSED(mr),
 
 static void extract_edituv_lines_iter_poly_mesh(const MeshRenderData *mr,
                                                 const MPoly *mp,
-                                                const int UNUSED(mp_index),
+                                                const int mp_index,
                                                 void *_data)
 {
   MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data);
@@ -223,8 +233,11 @@ static void extract_edituv_lines_iter_poly_mesh(const MeshRenderData *mr,
     const int ml_index_next = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1);
     const bool real_edge = (mr->e_origindex == nullptr ||
                             mr->e_origindex[ml->e] != ORIGINDEX_NONE);
-    edituv_edge_add(
-        data, hidden || !real_edge, (mp->flag & ME_FACE_SEL) != 0, ml_index, ml_index_next);
+    edituv_edge_add(data,
+                    hidden || !real_edge,
+                    mr->selection_poly && mr->selection_poly[mp_index],
+                    ml_index,
+                    ml_index_next);
   }
 }
 
@@ -281,7 +294,8 @@ static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_c
                                                   const MPoly *coarse_poly)
 {
   MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data);
-  const bool hidden = mr->hide_poly && mr->hide_poly[coarse_poly - mr->mpoly];
+  const int coarse_quad_index = coarse_poly - mr->mpoly;
+  const bool hidden = mr->hide_poly && mr->hide_poly[coarse_quad_index];
 
   int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index);
 
@@ -294,7 +308,7 @@ static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_c
                              mr->e_origindex[edge_origindex] != ORIGINDEX_NONE));
     edituv_edge_add(data,
                     hidden || !real_edge,
-                    (coarse_poly->flag & ME_FACE_SEL) != 0,
+                    mr->selection_poly && mr->selection_poly[coarse_quad_index],
                     loop_idx,
                     (loop_idx + 1 == end_loop_idx) ? start_loop_idx : (loop_idx + 1));
   }
@@ -373,7 +387,7 @@ static void extract_edituv_points_iter_poly_bm(const MeshRenderData *UNUSED(mr),
 
 static void extract_edituv_points_iter_poly_mesh(const MeshRenderData *mr,
                                                  const MPoly *mp,
-                                                 const int UNUSED(mp_index),
+                                       

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list