[Bf-blender-cvs] [789d5ccc260] soc-2019-bevel-profiles: Rename variables and Cutoff vertex mesh method: New solution for corner vertex direction

Hans Goudey noreply at git.blender.org
Sat Jul 20 17:44:22 CEST 2019


Commit: 789d5ccc2608da3116171f4fdaea24219a4dd501
Author: Hans Goudey
Date:   Sat Jul 20 11:40:36 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB789d5ccc2608da3116171f4fdaea24219a4dd501

Rename variables and Cutoff vertex mesh method: New solution for corner vertex direction

This could be easily reverted but I changed some profile variable names to
something more intuitive IMO (coa -> start, cob -> end, midco -> middle)

The corner vertices are now placed along the simple solution of the cross of the
adjacent profile plane normals.

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

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 8a957b4762e..a0b2dbc1fd2 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -63,7 +63,7 @@
 #define DEBUG_CUSTOM_PROFILE_ADJ 0
 #define DEBUG_CUSTOM_PROFILE_ORIENTATION 0
 #define DEBUG_CUSTOM_PROFILE_ORIENTATION_DRAW DEBUG_CUSTOM_PROFILE_ORIENTATION | 0
-#define DEBUG_CUSTOM_PROFILE_CUTOFF 1
+#define DEBUG_CUSTOM_PROFILE_CUTOFF 0
 
 #if DEBUG_CUSTOM_PROFILE_ORIENTATION_DRAW
 extern void DRW_debug_sphere(const float center[3], const float radius, const float color[4]);
@@ -122,7 +122,7 @@ typedef struct EdgeHalf {
   char _pad[4];
 } EdgeHalf;
 
-/* Profile specification.
+/* Profile specification:
  * Many interesting profiles are in family of superellipses:
  *     (abs(x/a))^r + abs(y/b))^r = 1
  * r==2 => ellipse; r==1 => line; r < 1 => concave; r > 1 => bulging out.
@@ -131,19 +131,21 @@ typedef struct EdgeHalf {
  * projected onto a plane (plane_no is normal, plane_co is a point on it)
  * via lines in a given direction (proj_dir).
  * After the parameters are all set, the actual profile points are calculated
- * and point in prof_co. We also may need profile points for a higher resolution
- * number of segments, in order to make the vertex mesh pattern, and that goes
- * in prof_co_2.
+ * and pointed to by prof_co. We also may need profile points for a higher resolution
+ * number of segments for the subdivision while making the ADJ vertex mesh pattern,
+ * and that goes in prof_co_2.
  */
 typedef struct Profile {
   /** Superellipse r parameter */
   float super_r;
   /** Start control point for profile */
-  float coa[3];
+  /* HANS-QUESTION: How much would it be possible to change variable names? I think "coa" and "cob"
+   * would be much more intuitively named as "start" and "end," but notes would be out of date */
+  float start[3]; /* coa */
   /** Mid control point for profile */
-  float midco[3];
+  float middle[3]; /* midco */
   /** End control point for profile */
-  float cob[3];
+  float end[3]; /* cob */
   /** Normal of plane to project to */
   float plane_no[3];
   /** Coordinate on plane to project to */
@@ -161,7 +163,8 @@ typedef struct Profile {
 #define PRO_LINE_R 1.0f
 #define PRO_SQUARE_IN_R 0.0f
 
-/* Cache result of expensive calculation of u parameter values to
+/* The un-transformed 2D storage of profile vertex locations. Also for non-custom profiles
+ * this serves as a cache for the results of the expensive calculation of u parameter values to
  * get even spacing on superellipse for current BevelParams seg
  * and pro_super_r. */
 typedef struct ProfileSpacing {
@@ -203,8 +206,8 @@ typedef struct BoundVert {
   bool is_patch_start;
   /** Is this boundvert the side of the custom profile's start */
   bool is_profile_start;
-  /** Length of seam starting from current boundvert to next boundvert with ccw ordering */
   char _pad[3];
+  /** Length of seam starting from current boundvert to next boundvert with ccw ordering */
   int seam_len;
   /** Same as seam_len but defines length of sharp edges */
   int sharp_len;
@@ -1318,27 +1321,27 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
       negate_v3(pro->proj_dir);
     }
     normalize_v3(pro->proj_dir);
-    project_to_edge(e->e, co1, co2, pro->midco);
+    project_to_edge(e->e, co1, co2, pro->middle);
     if (DEBUG_OLD_PROJ_TO_PERP_PLANE) {
       /* put arc endpoints on plane with normal proj_dir, containing midco */
       add_v3_v3v3(co3, co1, pro->proj_dir);
-      if (!isect_line_plane_v3(pro->coa, co1, co3, pro->midco, pro->proj_dir)) {
+      if (!isect_line_plane_v3(pro->start, co1, co3, pro->middle, pro->proj_dir)) {
         /* shouldn't happen */
-        copy_v3_v3(pro->coa, co1);
+        copy_v3_v3(pro->start, co1);
       }
       add_v3_v3v3(co3, co2, pro->proj_dir);
-      if (!isect_line_plane_v3(pro->cob, co2, co3, pro->midco, pro->proj_dir)) {
+      if (!isect_line_plane_v3(pro->end, co2, co3, pro->middle, pro->proj_dir)) {
         /* shouldn't happen */
-        copy_v3_v3(pro->cob, co2);
+        copy_v3_v3(pro->end, co2);
       }
     }
     else {
-      copy_v3_v3(pro->coa, co1);
-      copy_v3_v3(pro->cob, co2);
+      copy_v3_v3(pro->start, co1);
+      copy_v3_v3(pro->end, co2);
     }
     /* default plane to project onto is the one with triangle co1 - midco - co2 in it */
-    sub_v3_v3v3(d1, pro->midco, co1);
-    sub_v3_v3v3(d2, pro->midco, co2);
+    sub_v3_v3v3(d1, pro->middle, co1);
+    sub_v3_v3v3(d2, pro->middle, co2);
     normalize_v3(d1);
     normalize_v3(d2);
     cross_v3_v3v3(pro->plane_no, d1, d2);
@@ -1358,14 +1361,14 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
       }
       else {
         if (DEBUG_OLD_PROJ_TO_PERP_PLANE) {
-          copy_v3_v3(pro->coa, co1);
-          copy_v3_v3(pro->cob, co2);
+          copy_v3_v3(pro->start, co1);
+          copy_v3_v3(pro->end, co2);
         }
         if (DEBUG_OLD_FLAT_MID) {
-          copy_v3_v3(pro->midco, bv->v->co);
+          copy_v3_v3(pro->middle, bv->v->co);
         }
         else {
-          copy_v3_v3(pro->midco, bv->v->co);
+          copy_v3_v3(pro->middle, bv->v->co);
           if (e->prev->is_bev && e->next->is_bev && bv->selcount >= 3) {
             /* want mid at the meet point of next and prev offset edges */
             float d3[3], d4[3], co4[3], meetco[3], isect2[3];
@@ -1377,7 +1380,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
             normalize_v3(d4);
             if (nearly_parallel(d3, d4)) {
               /* offset lines are collinear - want linear interpolation */
-              mid_v3_v3v3(pro->midco, co1, co2);
+              mid_v3_v3v3(pro->middle, co1, co2);
               do_linear_interp = true;
             }
             else {
@@ -1385,20 +1388,20 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
               add_v3_v3v3(co4, co2, d4);
               isect_kind = isect_line_line_v3(co1, co3, co2, co4, meetco, isect2);
               if (isect_kind != 0) {
-                copy_v3_v3(pro->midco, meetco);
+                copy_v3_v3(pro->middle, meetco);
               }
               else {
                 /* offset lines don't intersect - want linear interpolation */
-                mid_v3_v3v3(pro->midco, co1, co2);
+                mid_v3_v3v3(pro->middle, co1, co2);
                 do_linear_interp = true;
               }
             }
           }
         }
-        copy_v3_v3(pro->cob, co2);
-        sub_v3_v3v3(d1, pro->midco, co1);
+        copy_v3_v3(pro->end, co2);
+        sub_v3_v3v3(d1, pro->middle, co1);
         normalize_v3(d1);
-        sub_v3_v3v3(d2, pro->midco, co2);
+        sub_v3_v3v3(d2, pro->middle, co2);
         normalize_v3(d2);
         cross_v3_v3v3(pro->plane_no, d1, d2);
         normalize_v3(pro->plane_no);
@@ -1416,8 +1419,8 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
   }
   else if (bndv->is_arc_start) {
     /* assume pro->midco was alredy set */
-    copy_v3_v3(pro->coa, co1);
-    copy_v3_v3(pro->cob, co2);
+    copy_v3_v3(pro->start, co1);
+    copy_v3_v3(pro->end, co2);
     pro->super_r = PRO_CIRCLE_R;
     zero_v3(pro->plane_co);
     zero_v3(pro->plane_no);
@@ -1426,9 +1429,9 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
   }
   if (do_linear_interp) {
     pro->super_r = PRO_LINE_R;
-    copy_v3_v3(pro->coa, co1);
-    copy_v3_v3(pro->cob, co2);
-    mid_v3_v3v3(pro->midco, co1, co2);
+    copy_v3_v3(pro->start, co1);
+    copy_v3_v3(pro->end, co2);
+    mid_v3_v3v3(pro->middle, co1, co2);
     /* won't use projection for this line profile */
     zero_v3(pro->plane_co);
     zero_v3(pro->plane_no);
@@ -1450,9 +1453,9 @@ static void move_profile_plane(BoundVert *bndv, BMVert *bmv)
   if (is_zero_v3(pro->proj_dir)) {
     return;
   }
-  sub_v3_v3v3(d1, bmv->co, pro->coa);
+  sub_v3_v3v3(d1, bmv->co, pro->start);
   normalize_v3(d1);
-  sub_v3_v3v3(d2, bmv->co, pro->cob);
+  sub_v3_v3v3(d2, bmv->co, pro->end);
   normalize_v3(d2);
   cross_v3_v3v3(no, d1, d2);
   cross_v3_v3v3(no2, d1, pro->proj_dir);
@@ -1655,10 +1658,10 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
 
   if (bp->seg == 1) {
     if (i == 0) {
-      copy_v3_v3(r_co, pro->coa);
+      copy_v3_v3(r_co, pro->start);
     }
     else {
-      copy_v3_v3(r_co, pro->cob);
+      copy_v3_v3(r_co, pro->end);
     }
   }
 
@@ -1690,13 +1693,15 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
   float co[3], co2[3], p[3], m[4][4];
   float *prof_co, *prof_co_k;
   float r;
-  bool need_2, map_ok;
+  bool need_2, map_ok, use_normal_profile;
   Profile *pro = &bndv->profile;
 
   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,
@@ -1714,7 +1719,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
     map_ok = false;
   }
   else {
-    map_ok = make_unit_square_map(pro->coa, pro->midco, pro->cob, m);
+    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 */
   for (i = 0; i < 2; i++) {
@@ -1737,10 +1742,10 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
     /* Iterate over the vertices along the boundary arc */
     for (k = 0; k <= ns; k++) {
       if (k == 0) {
-        copy_v3_v3(co, pro->coa);
+        copy_v3_v3(co, pro->start);
       }
       else if (k == ns) {
-        copy_v3_v3(co, pro->cob);
+        copy_v3_v3(co, pro->end);
       }
       else {
         if (map_ok) {
@@ -1757,14 +1762,14 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed)
           mul_v3_m4v3(co, m, p);
         }
         else {
-          interp_v3_v3v3(co, pro->coa, pro->cob, (float)k 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list