[Bf-blender-cvs] [5a6145f32cc] master: Cleanup: use designated initializes for mesh extract structs

Campbell Barton noreply at git.blender.org
Mon Jun 29 12:55:32 CEST 2020


Commit: 5a6145f32cc05abf82520b4d047b8fefd5e2c3ed
Author: Campbell Barton
Date:   Mon Jun 29 15:09:43 2020 +1000
Branches: master
https://developer.blender.org/rB5a6145f32cc05abf82520b4d047b8fefd5e2c3ed

Cleanup: use designated initializes for mesh extract structs

Better readability and allows adding new struct members without
adding empty slots to every 'MeshExtract' struct.

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

M	source/blender/draw/intern/draw_cache_extract_mesh.c

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

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 39797af40c7..d455e86f499 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -511,29 +511,55 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *e
  * \{ */
 
 typedef void *(ExtractInitFn)(const MeshRenderData *mr, void *buffer);
-typedef void(ExtractEditTriFn)(const MeshRenderData *mr, int t, BMLoop **e, void *data);
-typedef void(ExtractEditLoopFn)(const MeshRenderData *mr, int l, BMLoop *el, void *data);
-typedef void(ExtractEditLedgeFn)(const MeshRenderData *mr, int e, BMEdge *ed, void *data);
-typedef void(ExtractEditLvertFn)(const MeshRenderData *mr, int v, BMVert *ev, void *data);
-typedef void(ExtractTriFn)(const MeshRenderData *mr, int t, const MLoopTri *mlt, void *data);
-typedef void(ExtractLoopFn)(
-    const MeshRenderData *mr, int l, const MLoop *mloop, int p, const MPoly *mpoly, void *data);
-typedef void(ExtractLedgeFn)(const MeshRenderData *mr, int e, const MEdge *medge, void *data);
-typedef void(ExtractLvertFn)(const MeshRenderData *mr, int v, const MVert *mvert, void *data);
+
+typedef void(ExtractTriBMeshFn)(const MeshRenderData *mr,
+                                int tri_index,
+                                BMLoop **ltri,
+                                void *data);
+typedef void(ExtractTriMeshFn)(const MeshRenderData *mr,
+                               int tri_index,
+                               const MLoopTri *mlt,
+                               void *data);
+
+typedef void(ExtractLoopBMeshFn)(const MeshRenderData *mr, int loop_index, BMLoop *el, void *data);
+typedef void(ExtractLoopMeshFn)(const MeshRenderData *mr,
+                                int loop_index,
+                                const MLoop *mloop,
+                                int poly_index,
+                                const MPoly *mpoly,
+                                void *data);
+
+typedef void(ExtractLEdgeBMeshFn)(const MeshRenderData *mr,
+                                  int ledge_index,
+                                  BMEdge *eed,
+                                  void *data);
+typedef void(ExtractLEdgeMeshFn)(const MeshRenderData *mr,
+                                 int ledge_index,
+                                 const MEdge *medge,
+                                 void *data);
+
+typedef void(ExtractLVertBMeshFn)(const MeshRenderData *mr,
+                                  int lvert_index,
+                                  BMVert *eve,
+                                  void *data);
+typedef void(ExtractLVertFn)(const MeshRenderData *mr,
+                             int lvert_index,
+                             const MVert *mvert,
+                             void *data);
 typedef void(ExtractFinishFn)(const MeshRenderData *mr, void *buffer, void *data);
 
 typedef struct MeshExtract {
   /** Executed on main thread and return user data for iteration functions. */
   ExtractInitFn *init;
   /** Executed on one (or more if use_threading) worker thread(s). */
-  ExtractEditTriFn *iter_looptri_bm;
-  ExtractTriFn *iter_looptri;
-  ExtractEditLoopFn *iter_loop_bm;
-  ExtractLoopFn *iter_loop;
-  ExtractEditLedgeFn *iter_ledge_bm;
-  ExtractLedgeFn *iter_ledge;
-  ExtractEditLvertFn *iter_lvert_bm;
-  ExtractLvertFn *iter_lvert;
+  ExtractTriBMeshFn *iter_looptri_bm;
+  ExtractTriMeshFn *iter_looptri_mesh;
+  ExtractLoopBMeshFn *iter_loop_bm;
+  ExtractLoopMeshFn *iter_loop_mesh;
+  ExtractLEdgeBMeshFn *iter_ledge_bm;
+  ExtractLEdgeMeshFn *iter_ledge_mesh;
+  ExtractLVertBMeshFn *iter_lvert_bm;
+  ExtractLVertFn *iter_lvert_mesh;
   /** Executed on one worker thread after all elements iterations. */
   ExtractFinishFn *finish;
   /** Used to request common data. */
@@ -545,10 +571,10 @@ typedef struct MeshExtract {
 BLI_INLINE eMRIterType mesh_extract_iter_type(const MeshExtract *ext)
 {
   eMRIterType type = 0;
-  SET_FLAG_FROM_TEST(type, (ext->iter_looptri_bm || ext->iter_looptri), MR_ITER_LOOPTRI);
-  SET_FLAG_FROM_TEST(type, (ext->iter_loop_bm || ext->iter_loop), MR_ITER_LOOP);
-  SET_FLAG_FROM_TEST(type, (ext->iter_ledge_bm || ext->iter_ledge), MR_ITER_LEDGE);
-  SET_FLAG_FROM_TEST(type, (ext->iter_lvert_bm || ext->iter_lvert), MR_ITER_LVERT);
+  SET_FLAG_FROM_TEST(type, (ext->iter_looptri_bm || ext->iter_looptri_mesh), MR_ITER_LOOPTRI);
+  SET_FLAG_FROM_TEST(type, (ext->iter_loop_bm || ext->iter_loop_mesh), MR_ITER_LOOP);
+  SET_FLAG_FROM_TEST(type, (ext->iter_ledge_bm || ext->iter_ledge_mesh), MR_ITER_LEDGE);
+  SET_FLAG_FROM_TEST(type, (ext->iter_lvert_bm || ext->iter_lvert_mesh), MR_ITER_LVERT);
   return type;
 }
 
@@ -664,18 +690,12 @@ static void extract_tris_finish(const MeshRenderData *mr, void *ibo, void *_data
 }
 
 static const MeshExtract extract_tris = {
-    extract_tris_init,
-    extract_tris_looptri_bmesh,
-    extract_tris_looptri_mesh,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    extract_tris_finish,
-    0,
-    false,
+    .init = extract_tris_init,
+    .iter_looptri_bm = extract_tris_looptri_bmesh,
+    .iter_looptri_mesh = extract_tris_looptri_mesh,
+    .finish = extract_tris_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -767,18 +787,14 @@ static void extract_lines_finish(const MeshRenderData *UNUSED(mr), void *ibo, vo
 }
 
 static const MeshExtract extract_lines = {
-    extract_lines_init,
-    NULL,
-    NULL,
-    extract_lines_loop_bmesh,
-    extract_lines_loop_mesh,
-    extract_lines_ledge_bmesh,
-    extract_lines_ledge_mesh,
-    NULL,
-    NULL,
-    extract_lines_finish,
-    0,
-    false,
+    .init = extract_lines_init,
+    .iter_loop_bm = extract_lines_loop_bmesh,
+    .iter_loop_mesh = extract_lines_loop_mesh,
+    .iter_ledge_bm = extract_lines_ledge_bmesh,
+    .iter_ledge_mesh = extract_lines_ledge_mesh,
+    .finish = extract_lines_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 /** \} */
 
@@ -805,18 +821,14 @@ static void extract_lines_with_lines_loose_finish(const MeshRenderData *mr, void
 }
 
 static const MeshExtract extract_lines_with_lines_loose = {
-    extract_lines_init,
-    NULL,
-    NULL,
-    extract_lines_loop_bmesh,
-    extract_lines_loop_mesh,
-    extract_lines_ledge_bmesh,
-    extract_lines_ledge_mesh,
-    NULL,
-    NULL,
-    extract_lines_with_lines_loose_finish,
-    0,
-    false,
+    .init = extract_lines_init,
+    .iter_loop_bm = extract_lines_loop_bmesh,
+    .iter_loop_mesh = extract_lines_loop_mesh,
+    .iter_ledge_bm = extract_lines_ledge_bmesh,
+    .iter_ledge_mesh = extract_lines_ledge_mesh,
+    .finish = extract_lines_with_lines_loose_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -912,18 +924,16 @@ static void extract_points_finish(const MeshRenderData *UNUSED(mr), void *ibo, v
 }
 
 static const MeshExtract extract_points = {
-    extract_points_init,
-    NULL,
-    NULL,
-    extract_points_loop_bmesh,
-    extract_points_loop_mesh,
-    extract_points_ledge_bmesh,
-    extract_points_ledge_mesh,
-    extract_points_lvert_bmesh,
-    extract_points_lvert_mesh,
-    extract_points_finish,
-    0,
-    false,
+    .init = extract_points_init,
+    .iter_loop_bm = extract_points_loop_bmesh,
+    .iter_loop_mesh = extract_points_loop_mesh,
+    .iter_ledge_bm = extract_points_ledge_bmesh,
+    .iter_ledge_mesh = extract_points_ledge_mesh,
+    .iter_lvert_bm = extract_points_lvert_bmesh,
+    .iter_lvert_mesh = extract_points_lvert_mesh,
+    .finish = extract_points_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -977,18 +987,12 @@ static void extract_fdots_finish(const MeshRenderData *UNUSED(mr), void *ibo, vo
 }
 
 static const MeshExtract extract_fdots = {
-    extract_fdots_init,
-    NULL,
-    NULL,
-    extract_fdots_loop_bmesh,
-    extract_fdots_loop_mesh,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    extract_fdots_finish,
-    0,
-    false,
+    .init = extract_fdots_init,
+    .iter_loop_bm = extract_fdots_loop_bmesh,
+    .iter_loop_mesh = extract_fdots_loop_mesh,
+    .finish = extract_fdots_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -1059,18 +1063,11 @@ static void extract_lines_paint_mask_finish(const MeshRenderData *UNUSED(mr),
 }
 
 static const MeshExtract extract_lines_paint_mask = {
-    extract_lines_paint_mask_init,
-    NULL,
-    NULL,
-    NULL,
-    extract_lines_paint_mask_loop_mesh,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    extract_lines_paint_mask_finish,
-    0,
-    false,
+    .init = extract_lines_paint_mask_init,
+    .iter_loop_mesh = extract_lines_paint_mask_loop_mesh,
+    .finish = extract_lines_paint_mask_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -1211,18 +1208,12 @@ static void extract_lines_adjacency_finish(const MeshRenderData *mr, void *ibo,
 #undef NO_EDGE
 
 static const MeshExtract extract_lines_adjacency = {
-    extract_lines_adjacency_init,
-    extract_lines_adjacency_looptri_bmesh,
-    extract_lines_adjacency_looptri_mesh,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    extract_lines_adjacency_finish,
-    0,
-    false,
+    .init = extract_lines_adjacency_init,
+    .iter_looptri_bm = extract_lines_adjacency_looptri_bmesh,
+    .iter_looptri_mesh = extract_lines_adjacency_looptri_mesh,
+    .finish = extract_lines_adjacency_finish,
+    .data_flag = 0,
+    .use_threading = false,
 };
 
 /** \} */
@@ -1287,18 +1278,12 @@ static void extract_edituv_tris_finish(const MeshRenderData *UNUSED(mr), void *i
 }
 
 static const MeshExtract extract_edituv_tris = {
-    extract_edituv_tris_init,
-    extract_edituv_tris_looptri_bmesh,
-    extract_edituv_tris_looptri_mesh,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    extract_edituv_tris_finish,
-    0,
-    false,
+    .init = extract_edituv_tris_init,
+    .iter_looptri_bm = extract_edituv_tris_looptri_bmesh,
+    .iter_looptri_mesh = extract_edituv_tris_looptri_mesh,
+    .finish = extract_edituv_tris_finish,
+    .data_flag = 0,
+ 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list