[Bf-blender-cvs] [1dd275b660a] soc-2019-bevel-profiles: Bevel tool: Miter profiles use normal profile instead of custom profile.

Hans Goudey noreply at git.blender.org
Sat Jul 20 20:00:03 CEST 2019


Commit: 1dd275b660a3251aa3db96f5016cb7441347b6a1
Author: Hans Goudey
Date:   Sat Jul 20 13:57:27 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB1dd275b660a3251aa3db96f5016cb7441347b6a1

Bevel tool: Miter profiles use normal profile instead of custom profile.

Also disabled special miters with the cutoff vertex mesh method.

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

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 a0b2dbc1fd2..fd1b7cdf4a0 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -285,8 +285,10 @@ typedef struct BevelParams {
   GHash *face_hash;
   /** Use for all allocs while bevel runs, if we need to free we can switch to mempool. */
   MemArena *mem_arena;
-  /** Parameter values for evenly spaced profiles. */
+  /** Profile vertex location and spacings */
   ProfileSpacing pro_spacing;
+  /** Parameter values for evenly spaced profile points for the miter profiles */
+  ProfileSpacing pro_spacing_miter;
   /** Blender units to offset each side of a beveled edge. */
   float offset;
   /** How offset is measured; enum defined in bmesh_operators.h */
@@ -315,8 +317,8 @@ typedef struct BevelParams {
   bool harden_normals;
   /** Should we use the custom profiles feature? */
   bool use_custom_profile;
-  /** The struct used to store the custom profile input */
   char _pad[3];
+  /** The struct used to store the custom profile input */
   const struct ProfileWidget *prwdgt;
   /** Vertex group array, maybe set if vertex_only. */
   const struct MDeformVert *dvert;
@@ -1686,22 +1688,21 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
  * the coordinate values for the power of 2 >= bp->seg,
  * because the ADJ pattern needs power-of-2 boundaries
  * during construction. */
-static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
+static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, bool miter)
 {
   int i, k, ns;
   const double *xvals, *yvals;
   float co[3], co2[3], p[3], m[4][4];
   float *prof_co, *prof_co_k;
   float r;
-  bool need_2, map_ok, use_normal_profile;
+  bool need_2, map_ok;
   Profile *pro = &bndv->profile;
+  ProfileSpacing *pro_spacing = (miter) ? &bp->pro_spacing_miter : &bp->pro_spacing;
 
   if (bp->seg == 1) {
     return;
   }
 
-  use_normal_profile = bndv->is_arc_start & bndv->is_patch_start;
-
   need_2 = bp->seg != bp->pro_spacing.seg_2;
   if (!pro->prof_co) {
     pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena,
@@ -1721,12 +1722,12 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
   else {
     map_ok = make_unit_square_map(pro->start, pro->middle, pro->end, m);
   }
-  /* The first iteration is the nseg case, the second is the seg_2 case if it's needed */
+  /* The first iteration is the nseg case, the second is the seg_2 case (if it's needed) */
   for (i = 0; i < 2; i++) {
     if (i == 0) {
       ns = bp->seg;
-      xvals = bp->pro_spacing.xvals;
-      yvals = bp->pro_spacing.yvals;
+      xvals = pro_spacing->xvals;
+      yvals = pro_spacing->yvals;
       prof_co = pro->prof_co;
     }
     else {
@@ -1734,8 +1735,8 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
         break; /* shares coords with pro->prof_co */
       }
       ns = bp->pro_spacing.seg_2;
-      xvals = bp->pro_spacing.xvals_2;
-      yvals = bp->pro_spacing.yvals_2;
+      xvals = pro_spacing->xvals_2;
+      yvals = pro_spacing->yvals_2;
       prof_co = pro->prof_co_2;
     }
 
@@ -1758,14 +1759,14 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
             p[1] = (float)yvals[k];
           }
           p[2] = 0.0f;
-          /* Do the 2D->3D transformation */
+          /* Do the 2D->3D transformation of the profile coordinates */
           mul_v3_m4v3(co, m, p);
         }
         else {
           interp_v3_v3v3(co, pro->start, pro->end, (float)k / (float)ns);
         }
       }
-      /* Project co onto final profile plane (First transformation wasn't enough) */
+      /* Finish the 2D->3D transformation by projecting onto the final profile plane */
       prof_co_k = prof_co + 3 * k; /* Each coord takes up 3 spaces */
       if (!is_zero_v3(pro->proj_dir)) {
         add_v3_v3v3(co2, co, pro->proj_dir);
@@ -2296,14 +2297,14 @@ static bool eh_on_plane(EdgeHalf *e)
 /* Calculate the profiles for all the BoundVerts of VMesh vm */
 static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm)
 {
-  BoundVert *v;
+  BoundVert *bndv;
 
-  v = vm->boundstart;
+  bndv = vm->boundstart;
   do {
-    set_profile_params(bp, bv, v);
+    set_profile_params(bp, bv, bndv);
     /* We probably don't know to orientation at this point, so don't reverse the profiles */
-    calculate_profile(bp, v, false);
-  } while ((v = v->next) != vm->boundstart);
+    calculate_profile(bp, bndv, false, bp->use_custom_profile && (bndv->is_arc_start || bndv->is_patch_start));
+  } while ((bndv = bndv->next) != vm->boundstart);
 }
 
 /* Implements build_boundary for vertex-only case */
@@ -2360,7 +2361,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
 {
   MemArena *mem_arena = bp->mem_arena;
   VMesh *vm = bv->vmesh;
-  BoundVert *v;
+  BoundVert *bndv;
   EdgeHalf *e;
   const float *no;
   float co[3], d;
@@ -2371,9 +2372,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
     offset_in_plane(e, no, true, co);
     if (construct) {
-      v = add_new_bound_vert(mem_arena, vm, co);
-      v->efirst = v->elast = v->ebev = e;
-      e->leftv = v;
+      bndv = add_new_bound_vert(mem_arena, vm, co);
+      bndv->efirst = bndv->elast = bndv->ebev = e;
+      e->leftv = bndv;
     }
     else {
       adjust_bound_vert(e->leftv, co);
@@ -2381,9 +2382,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
     offset_in_plane(e, no, false, co);
     if (construct) {
-      v = add_new_bound_vert(mem_arena, vm, co);
-      v->efirst = v->elast = e;
-      e->rightv = v;
+      bndv = add_new_bound_vert(mem_arena, vm, co);
+      bndv->efirst = bndv->elast = e;
+      e->rightv = bndv;
     }
     else {
       adjust_bound_vert(e->rightv, co);
@@ -2391,9 +2392,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     /* make artifical extra point along unbeveled edge, and form triangle */
     slide_dist(e->next, bv->v, e->offset_l, co);
     if (construct) {
-      v = add_new_bound_vert(mem_arena, vm, co);
-      v->efirst = v->elast = e->next;
-      e->next->leftv = e->next->rightv = v;
+      bndv = add_new_bound_vert(mem_arena, vm, co);
+      bndv->efirst = bndv->elast = e->next;
+      e->next->leftv = e->next->rightv = bndv;
       /* could use M_POLY too, but tri-fan looks nicer)*/
       vm->mesh_kind = M_TRI_FAN;
       set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
@@ -2409,11 +2410,11 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     /* TODO: should do something else if angle between e and e->prev > 180 */
     offset_meet(e->prev, e, bv->v, e->fprev, false, co);
     if (construct) {
-      v = add_new_bound_vert(mem_arena, vm, co);
-      v->efirst = e->prev;
-      v->elast = v->ebev = e;
-      e->leftv = v;
-      e->prev->leftv = e->prev->rightv = v;
+      bndv = add_new_bound_vert(mem_arena, vm, co);
+      bndv->efirst = e->prev;
+      bndv->elast = bndv->ebev = e;
+      e->leftv = bndv;
+      e->prev->leftv = e->prev->rightv = bndv;
     }
     else {
       adjust_bound_vert(e->leftv, co);
@@ -2421,11 +2422,11 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     e = e->next;
     offset_meet(e->prev, e, bv->v, e->fprev, false, co);
     if (construct) {
-      v = add_new_bound_vert(mem_arena, vm, co);
-      v->efirst = e->prev;
-      v->elast = e;
-      e->leftv = e->rightv = v;
-      e->prev->rightv = v;
+      bndv = add_new_bound_vert(mem_arena, vm, co);
+      bndv->efirst = e->prev;
+      bndv->elast = e;
+      e->leftv = e->rightv = bndv;
+      e->prev->rightv = bndv;
     }
     else {
       adjust_bound_vert(e->leftv, co);
@@ -2435,9 +2436,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
     for (e = e->next; e->next != efirst; e = e->next) {
       slide_dist(e, bv->v, d, co);
       if (construct) {
-        v = add_new_bound_vert(mem_arena, vm, co);
-        v->efirst = v->elast = e;
-        e->leftv = e->rightv = v;
+        bndv = add_new_bound_vert(mem_arena, vm, co);
+        bndv->efirst = bndv->elast = e;
+        e->leftv = e->rightv = bndv;
       }
       else {
         adjust_bound_vert(e->leftv, co);
@@ -2448,10 +2449,11 @@ static void build_boundary_terminal_edge(BevelParams *bp,
 
   if (bv->edgecount >= 3) {
     /* special case: snap profile to plane of adjacent two edges */
-    v = vm->boundstart;
-    BLI_assert(v->ebev != NULL);
-    move_profile_plane(v, bv->v);
-    calculate_profile(bp, v, false);
+    bndv = vm->boundstart;
+    BLI_assert(bndv->ebev != NULL);
+    move_profile_plane(bndv, bv->v);
+    /* This step happens before profile orientation regularization, so don't reverse the profile */
+    calculate_profile(bp, bndv, false, false);
   }
 
   if (construct) {
@@ -2756,7 +2758,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
         }
       }
     }
-    else {
+    else { /* construct == false */
       ang_kind = edges_angle_kind(e, e2, bv->v);
       if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == 1) ||
           (miter_inner != BEVEL_MITER_SHARP && ang_kind == -1)) {
@@ -4241,7 +4243,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
     copy_v3_v3(bndv->profile.plane_co, bndv->profile.start);
     cross_v3_v3v3(bndv->profile.plane_no, bndv->profile.start, bndv->profile.end);
     copy_v3_v3(bndv->profile.proj_dir, bndv->profile.plane_no);
-    calculate_profile(bp, bndv, !bndv->is_profile_start);
+    calculate_profile(bp, bndv, !bndv->is_profile_start, false);
 
     /* Just building the boundaries here, so sample the profile halfway through */
     get_profile_point(bp, &bndv->profile, 1, 2, mesh_vert(vm0, i, 0, 1)->co);
@@ -4971,7 +4973,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
       Profile *pro = &v->profile;
       copy_v3_v3(pro->middle, bv->v->co);
       pro->super_r = bp->pro_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list