[Bf-blender-cvs] [dee286fc7ec] temp_bmesh_multires: clean up code a bit

Joseph Eagar noreply at git.blender.org
Fri Mar 26 01:18:41 CET 2021


Commit: dee286fc7ec9a7b26710c6a55f98c14f0fc12bba
Author: Joseph Eagar
Date:   Wed Mar 24 17:01:53 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBdee286fc7ec9a7b26710c6a55f98c14f0fc12bba

clean up code a bit

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index fddc6a06bfc..8a55d09bfe1 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -512,13 +512,10 @@ typedef struct PBVHVertexIter {
 
 void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode);
 
-#if 0
-#  include "../bmesh/bmesh.h"
-#  include "DNA_meshdata_types.h"
-
-#  define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode) \
-    pbvh_vertex_iter_init(pbvh, node, &vi, mode); \
-    vi.i = vi.g = 0; \
+#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode) \
+  pbvh_vertex_iter_init(pbvh, node, &vi, mode); \
+\
+  for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
     if (vi.grids) { \
       vi.width = vi.gridsize; \
       vi.height = vi.gridsize; \
@@ -532,203 +529,87 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
       vi.width = vi.totvert; \
       vi.height = 1; \
     } \
-    while (BKE_pbvh_vertex_iter_step(pbvh, node, &vi, mode))
-
-#  define BKE_pbvh_vertex_iter_end ((void)0)
-
-__attribute__((optnone)) static bool BKE_pbvh_vertex_iter_step(PBVH *pbvh,
-                                                               PBVHNode *node,
-                                                               PBVHVertexIter *vi,
-                                                               int mode)
-{
-  for (; vi->g < vi->totgrid; vi->g++) {
-    for (; vi->gy < vi->height; vi->gy++) {
-      for (; vi->gx < vi->width; vi->gx++, vi->i++) {
-        if (vi->grid) {
-          vi->co = CCG_elem_co(&vi->key, vi->grid);
-          vi->fno = CCG_elem_no(&vi->key, vi->grid);
-          vi->mask = vi->key.has_mask ? CCG_elem_mask(&vi->key, vi->grid) : NULL;
-          vi->grid = CCG_elem_next(&vi->key, vi->grid);
-          vi->index++;
-          vi->vertex.i++;
-          vi->visible = true;
-          if (vi->gh) {
-            if (BLI_BITMAP_TEST(vi->gh, vi->gy * vi->gridsize + vi->gx)) {
-              continue;
-            }
-          }
-
-          return true;
-        }
-        else if (vi->mverts) {
-          vi->mvert = &vi->mverts[vi->vert_indices[vi->gx]];
-          if (vi->respect_hide) {
-            vi->visible = !(vi->mvert->flag & ME_HIDE);
-            if (mode == PBVH_ITER_UNIQUE && !vi->visible) {
-              continue;
-            }
-          }
-          else {
-            BLI_assert(vi->visible);
-          }
-          vi->co = vi->mvert->co;
-          vi->no = vi->mvert->no;
-          vi->index = vi->vertex.i = vi->vert_indices[vi->i];
-          if (vi->vmask) {
-            vi->mask = &vi->vmask[vi->index];
-          }
-          if (vi->vcol) {
-            vi->col = vi->vcol[vi->index].color;
-          }
-
-          return true;
-        }
-        else {
-          struct BMVert *bv = 0;
-          while (!bv) {
-            if (!vi->bm_cur_set->elems || vi->bi >= vi->bm_cur_set->cur) {
-              if (vi->bm_cur_set != vi->bm_other_verts && mode != PBVH_ITER_UNIQUE) {
-                vi->bm_cur_set = vi->bm_other_verts;
-                vi->bi = 0;
-                if (!vi->bm_cur_set->elems || vi->bi >= vi->bm_other_verts->cur) {
-                  break;
-                }
-              }
-              else {
-                break;
-              }
-            }
-            else {
-              bv = (BMVert*) vi->bm_cur_set->elems[vi->bi++];
-            }
-          }
-          if (!bv) {
-            continue;
-          }
-          vi->bm_vert = bv;
-          if (vi->cd_vcol_offset >= 0) {
-            MPropCol *vcol = (MPropCol*) BM_ELEM_CD_GET_VOID_P(bv, vi->cd_vcol_offset);
-            vi->col = vcol->color;
-          }
-          vi->vertex.i = (intptr_t)bv;
-          vi->index = BM_elem_index_get(vi->bm_vert);
-          vi->visible = !BM_elem_flag_test_bool(vi->bm_vert, BM_ELEM_HIDDEN);
-          if (mode == PBVH_ITER_UNIQUE && !vi->visible) {
-            continue;
-          }
-
-          vi->co = vi->bm_vert->co;
-          vi->fno = vi->bm_vert->no;
-          vi->mask = &BKE_PBVH_DYNVERT(vi->cd_dyn_vert, vi->bm_vert)->mask;
-          return true;
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-#else
-#  define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode) \
-    pbvh_vertex_iter_init(pbvh, node, &vi, mode); \
 \
-    for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
-      if (vi.grids) { \
-        vi.width = vi.gridsize; \
-        vi.height = vi.gridsize; \
-        vi.vertex.i = vi.index = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
-        vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
-        if (mode == PBVH_ITER_UNIQUE) { \
-          vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
-        } \
-      } \
-      else { \
-        vi.width = vi.totvert; \
-        vi.height = 1; \
-      } \
-\
-      for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
-        for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
-          if (vi.grid) { \
-            vi.co = CCG_elem_co(&vi.key, vi.grid); \
-            vi.fno = CCG_elem_no(&vi.key, vi.grid); \
-            vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
-            vi.grid = CCG_elem_next(&vi.key, vi.grid); \
-            vi.index++; \
-            vi.vertex.i++; \
-            vi.visible = true; \
-            if (vi.gh) { \
-              if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \
-                continue; \
-              } \
+    for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
+      for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
+        if (vi.grid) { \
+          vi.co = CCG_elem_co(&vi.key, vi.grid); \
+          vi.fno = CCG_elem_no(&vi.key, vi.grid); \
+          vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
+          vi.grid = CCG_elem_next(&vi.key, vi.grid); \
+          vi.index++; \
+          vi.vertex.i++; \
+          vi.visible = true; \
+          if (vi.gh) { \
+            if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \
+              continue; \
             } \
           } \
-          else if (vi.mverts) { \
-            vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
-            if (vi.respect_hide) { \
-              vi.visible = !(vi.mvert->flag & ME_HIDE); \
-              if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
-                continue; \
-              } \
-            } \
-            else { \
-              BLI_assert(vi.visible); \
-            } \
-            vi.co = vi.mvert->co; \
-            vi.no = vi.mvert->no; \
-            vi.index = vi.vertex.i = vi.vert_indices[vi.i]; \
-            if (vi.vmask) { \
-              vi.mask = &vi.vmask[vi.index]; \
-            } \
-            if (vi.vcol) { \
-              vi.col = vi.vcol[vi.index].color; \
+        } \
+        else if (vi.mverts) { \
+          vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
+          if (vi.respect_hide) { \
+            vi.visible = !(vi.mvert->flag & ME_HIDE); \
+            if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
+              continue; \
             } \
           } \
           else { \
-            BMVert *bv = NULL; \
-            while (!bv) { \
-              if (!vi.bm_cur_set->elems || vi.bi >= vi.bm_cur_set->cur) { \
-                if (vi.bm_cur_set != vi.bm_other_verts && mode != PBVH_ITER_UNIQUE) { \
-                  vi.bm_cur_set = vi.bm_other_verts; \
-                  vi.bi = 0; \
-                  if (!vi.bm_cur_set->elems || vi.bi >= vi.bm_other_verts->cur) { \
-                    break; \
-                  } \
-                } \
-                else { \
+            BLI_assert(vi.visible); \
+          } \
+          vi.co = vi.mvert->co; \
+          vi.no = vi.mvert->no; \
+          vi.index = vi.vertex.i = vi.vert_indices[vi.i]; \
+          if (vi.vmask) { \
+            vi.mask = &vi.vmask[vi.index]; \
+          } \
+          if (vi.vcol) { \
+            vi.col = vi.vcol[vi.index].color; \
+          } \
+        } \
+        else { \
+          BMVert *bv = NULL; \
+          while (!bv) { \
+            if (!vi.bm_cur_set->elems || vi.bi >= vi.bm_cur_set->cur) { \
+              if (vi.bm_cur_set != vi.bm_other_verts && mode != PBVH_ITER_UNIQUE) { \
+                vi.bm_cur_set = vi.bm_other_verts; \
+                vi.bi = 0; \
+                if (!vi.bm_cur_set->elems || vi.bi >= vi.bm_other_verts->cur) { \
                   break; \
                 } \
               } \
               else { \
-                bv = vi.bm_cur_set->elems[vi.bi++]; \
+                break; \
               } \
             } \
-            if (!bv) { \
-              continue; \
-            } \
-            vi.bm_vert = bv; \
-            if (vi.cd_vcol_offset >= 0) { \
-              MPropCol *vcol = BM_ELEM_CD_GET_VOID_P(bv, vi.cd_vcol_offset); \
-              vi.col = vcol->color; \
-            } \
-            vi.vertex.i = (intptr_t)bv; \
-            vi.index = BM_elem_index_get(vi.bm_vert); \
-            vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
-            if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
-              continue; \
+            else { \
+              bv = vi.bm_cur_set->elems[vi.bi++]; \
             } \
-            vi.co = vi.bm_vert->co; \
-            vi.fno = vi.bm_vert->no; \
-            vi.mask = (float*) BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset);\
-          }
+          } \
+          if (!bv) { \
+            continue; \
+          } \
+          vi.bm_vert = bv; \
+          if (vi.cd_vcol_offset >= 0) { \
+            MPropCol *vcol = BM_ELEM_CD_GET_VOID_P(bv, vi.cd_vcol_offset); \
+            vi.col = vcol->color; \
+          } \
+          vi.vertex.i = (intptr_t)bv; \
+          vi.index = BM_elem_index_get(vi.bm_vert); \
+          vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
+          if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
+            continue; \
+          } \
+          vi.co = vi.bm_vert->co; \
+          vi.fno = vi.bm_vert->no; \
+          vi.mask = (float *)BM_ELEM_CD_GET_VOID_P(vi.bm_ve

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list