[Bf-blender-cvs] [2bbd7cc1612] soc-2019-bevel-profiles: Bevel Custom Profile: Better vertex mesh "bulge"

Hans Goudey noreply at git.blender.org
Wed Aug 7 19:08:15 CEST 2019


Commit: 2bbd7cc161240e9467277bb1084daeed32c543da
Author: Hans Goudey
Date:   Wed Aug 7 13:08:06 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB2bbd7cc161240e9467277bb1084daeed32c543da

Bevel Custom Profile: Better vertex mesh "bulge"

The initial mesh created before the subdivision process follows the
general shape of the profile so that the finished vertex mesh generally
bulges in if more of the profile points are lower down and out if they're
further up.

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

M	source/blender/bmesh/tools/bmesh_bevel.c

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

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 87987e15e11..62e209901f8 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -167,12 +167,18 @@ typedef struct Profile {
  * get even spacing on superellipse for current BevelParams seg
  * and pro_super_r. */
 typedef struct ProfileSpacing {
-  double *xvals;   /* seg+1 x values */
-  double *xvals_2; /* seg_2+1 x values, seg_2 = power of 2 >= seg */
-  double *yvals;   /* seg+1 y values */
-  double *yvals_2; /* seg_2+1 y values, seg_2 = power of 2 >= seg */
-  int seg_2;       /* the seg_2 value */
-  int _pad;
+  /** The profile's seg+1 x values */
+  double *xvals;
+  /** The profile's seg+1 y values */
+  double *yvals;
+  /** The profile's seg_2+1 x values, (seg_2 = power of 2 >= seg) */
+  double *xvals_2;
+  /** The profile's seg_2+1 y values, (seg_2 = power of 2 >= seg) */
+  double *yvals_2;
+  /** The power of two greater than or equal to the number of segments. */
+  int seg_2;
+  /** How far "out" the profile is, used at the start of subdivision */
+  float fullness;
 } ProfileSpacing;
 
 /* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
@@ -220,7 +226,7 @@ typedef struct VMesh {
   BoundVert *boundstart;
   /** Number of vertices in the boundary */
   int count;
-  /** Common # of segments for segmented edges (same as bp->seg) */
+  /** Common number of segments for segmented edges (same as bp->seg) */
   int seg;
   /** The kind of mesh to build at the corner vertex meshes */
   enum {
@@ -251,6 +257,7 @@ typedef struct BevVert {
   /** Used in graph traversal */
   bool visited;
   /** Array of size edgecount; CCW order from vertex normal side */
+  char _pad[6];
   EdgeHalf *edges;
   /** Array of size wirecount of wire edges */
   BMEdge **wire_edges;
@@ -2063,131 +2070,131 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
  * And at boundaries between #F_EDGE and #F_VERT faces, the normals should match the #F_EDGE ones.
  * Assumes custom loop normals are in use.
  */
-static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
+static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
 {
-  BMIter liter, fiter;
-  BMFace *f;
-  BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
-  BMEdge *estep;
-  FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
-  int cd_clnors_offset, l_index;
-  short *clnors;
-  float *pnorm, norm[3];
-
-  if (bp->offset == 0.0 || !bp->harden_normals) {
-    return;
-  }
+      BMIter liter, fiter;
+      BMFace *f;
+      BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
+      BMEdge *estep;
+      FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
+      int cd_clnors_offset, l_index;
+      short *clnors;
+      float *pnorm, norm[3];
 
-  /* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */
-  /* I suspect this is not necessary: TODO: test that guess */
-  BM_mesh_normals_update(bm);
+      if (bp->offset == 0.0 || !bp->harden_normals) {
+        return;
+      }
 
-  cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+      /* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */
+      /* I suspect this is not necessary: TODO: test that guess */
+      BM_mesh_normals_update(bm);
 
-  /* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
-   * will not respect the autosmooth angle between smooth faces. To get that to happen, we have
-   * to mark the sharpen the edges that are only sharp because
-   * of the angle test -- otherwise would be smooth.
-   */
-  if (cd_clnors_offset == -1) {
-    BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
-    bevel_edges_sharp_boundary(bm, bp);
-  }
+      cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
 
-  /* Ensure that bm->lnor_spacearr has properly stored loop normals;
-   * side effect: ensures loop indices. */
-  BM_lnorspace_update(bm);
+      /* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
+       * will not respect the autosmooth angle between smooth faces. To get that to happen, we have
+       * to mark the sharpen the edges that are only sharp because
+       * of the angle test -- otherwise would be smooth.
+       */
+      if (cd_clnors_offset == -1) {
+        BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
+        bevel_edges_sharp_boundary(bm, bp);
+      }
 
-  if (cd_clnors_offset == -1) {
-    cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
-  }
+      /* Ensure that bm->lnor_spacearr has properly stored loop normals;
+       * side effect: ensures loop indices. */
+      BM_lnorspace_update(bm);
 
-  BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
-    fkind = get_face_kind(bp, f);
-    if (fkind == F_ORIG || fkind == F_RECON) {
-      continue;
-    }
-    BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-      estep = l->prev->e; /* causes CW walk around l->v fan */
-      lprev = BM_vert_step_fan_loop(l, &estep);
-      estep = l->e; /* causes CCW walk around l->v fan */
-      lnext = BM_vert_step_fan_loop(l, &estep);
-      fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
-      fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
-      pnorm = NULL;
-      if (fkind == F_EDGE) {
-        if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
-          add_v3_v3v3(norm, f->no, lprev->f->no);
-          pnorm = norm;
-        }
-        else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
-          add_v3_v3v3(norm, f->no, lnext->f->no);
-          pnorm = norm;
-        }
-        else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
-          pnorm = lprev->f->no;
-        }
-        else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
-          pnorm = lnext->f->no;
-        }
-        else {
-          /* printf("unexpected harden case (edge)\n"); */
-        }
+      if (cd_clnors_offset == -1) {
+        cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
       }
-      else if (fkind == F_VERT) {
-        if (fprevkind == F_VERT && fnextkind == F_VERT) {
-          pnorm = l->v->no;
-        }
-        else if (fprevkind == F_RECON) {
-          pnorm = lprev->f->no;
-        }
-        else if (fnextkind == F_RECON) {
-          pnorm = lnext->f->no;
+
+      BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
+        fkind = get_face_kind(bp, f);
+        if (fkind == F_ORIG || fkind == F_RECON) {
+          continue;
         }
-        else {
-          if (lprev) {
-            estep = lprev->prev->e;
-            lprevprev = BM_vert_step_fan_loop(lprev, &estep);
-          }
-          else {
-            lprevprev = NULL;
-          }
-          if (lnext) {
-            estep = lnext->e;
-            lnextnext = BM_vert_step_fan_loop(lnext, &estep);
-          }
-          else {
-            lnextnext = NULL;
-          }
-          fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
-          fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
-          if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
-            pnorm = lprevprev->f->no;
-          }
-          else if (fprevkind == F_EDGE && fnextkind == F_VERT && fprevprevkind == F_EDGE) {
-            add_v3_v3v3(norm, lprev->f->no, lprevprev->f->no);
-            pnorm = norm;
+        BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+          estep = l->prev->e; /* causes CW walk around l->v fan */
+          lprev = BM_vert_step_fan_loop(l, &estep);
+          estep = l->e; /* causes CCW walk around l->v fan */
+          lnext = BM_vert_step_fan_loop(l, &estep);
+          fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
+          fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
+          pnorm = NULL;
+          if (fkind == F_EDGE) {
+            if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
+              add_v3_v3v3(norm, f->no, lprev->f->no);
+              pnorm = norm;
+            }
+            else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
+              add_v3_v3v3(norm, f->no, lnext->f->no);
+              pnorm = norm;
+            }
+            else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
+              pnorm = lprev->f->no;
+            }
+            else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
+              pnorm = lnext->f->no;
+            }
+            else {
+              /* printf("unexpected harden case (edge)\n"); */
+            }
           }
-          else if (fnextkind == F_EDGE && fprevkind == F_VERT && fnextnextkind == F_EDGE) {
-            add_v3_v3v3(norm, lnext->f->no, lnextnext->f->no);
-            pnorm = norm;
+          else if (fkind == F_VERT) {
+            if (fprevkind == F_VERT && fnextkind == F_VERT) {
+              pnorm = l->v->no;
+            }
+            else if (fprevkind == F_RECON) {
+              pnorm = lprev->f->no;
+            }
+            else if (fnextkind == F_RECON) {
+              pnorm = lnext->f->no;
+            }
+            else {
+              if (lprev) {
+                estep = lprev->prev->e;
+                lprevprev = BM_vert_step_fan_loop(lprev, &estep);
+              }
+              else {
+                lprevprev = NULL;
+              }
+              if (lnext) {
+                estep = lnext->e;
+                lnextnext = BM_vert_step_fan_loop(lnext, &estep);
+              }
+              else {
+                lnextnext = NULL;
+              }
+              fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
+              fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
+              if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
+                pnorm = lprevprev->f->no;
+              }
+              else if (fprevkind 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list