[Bf-blender-cvs] [4bfc528fc9c] soc-2019-bevel-profiles: Initial work towards vertex mesh ADJ patterns using custom profiles.

Hans Goudey noreply at git.blender.org
Thu Jun 27 07:39:30 CEST 2019


Commit: 4bfc528fc9cf0dbb03015ab103e172ab51226e23
Author: Hans Goudey
Date:   Thu Jun 27 01:37:54 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB4bfc528fc9cf0dbb03015ab103e172ab51226e23

Initial work towards vertex mesh ADJ patterns using custom profiles.

In it's current state this doesn't add much, it's far too buggy at this point.
But it lays down some structure (and comments) that are the start of the vertex
meshes using the custom profile.

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

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 e674d55f6d8..31d4e50c676 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -58,8 +58,9 @@
 #define BEVEL_MATCH_SPEC_WEIGHT 0.2
 
 #define DEBUG_CUSTOM_PROFILE_SAMPLE 0
-#define DEBUG_CUSTOM_PROFILE 0
+#define DEBUG_CUSTOM_PROFILE_ORIGINAL 0
 #define DEBUG_CUSTOM_PROFILE_WELD 0
+#define DEBUG_CUSTOM_PROFILE_ADJ 1
 #define DEBUG_CUSTOM_PROFILE_ORIENTATION 0
 
 #if DEBUG_CUSTOM_PROFILE_ORIENTATION
@@ -126,8 +127,8 @@ typedef struct Profile {
   float plane_co[3]; /* coordinate on plane to project to */
   float proj_dir[3]; /* direction of projection line */
   int _pad;
-  float *prof_co;                      /* seg+1 profile coordinates (triples of floats) */
-  float *prof_co_2;                    /* like prof_co, but for seg power of 2 >= seg */
+  float *prof_co;    /* seg+1 profile coordinates (triples of floats) */
+  float *prof_co_2;  /* like prof_co, but for seg power of 2 >= seg */
 } Profile;
 #define PRO_SQUARE_R 1e4f
 #define PRO_CIRCLE_R 2.0f
@@ -144,10 +145,6 @@ typedef struct ProfileSpacing {
   double *yvals_2; /* seg_2+1 y values, seg_2 = power of 2 >= seg */
   int seg_2;       /* the seg_2 value */
   int _pad;
-  double *xvals_custom;   /* HANS-TODO: These will eventually be merged with the original */
-  double *yvals_custom;   /* value list as everything is converted to custom profile locations */
-  double *xvals_2_custom; /* HANS-TODO: These will eventually be merged with the original */
-  double *yvals_2_custom; /* value list as everything is converted to custom profile locations */
 } ProfileSpacing;
 
 /* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
@@ -170,8 +167,6 @@ typedef struct BoundVert {
   struct BoundVert *adjchain;
   /** Edge profile between this and next BoundVert. */
   Profile profile;
-  /* HANS-QUESTION: Why is the profile stored in the BoundVert? There are two boundverts
-   * for every beveled EdgeHalf, so it seems that there would be duplicate information */
   /** Are any of the edges attached here seams? */
   bool any_seam;
   /** Used during delta adjust pass */
@@ -195,6 +190,7 @@ typedef struct VMesh {
   NewVert *mesh;         /* allocated array - size and structure depends on kind */
   BoundVert *boundstart; /* start of boundary double-linked list */
   int count;             /* number of vertices in the boundary */
+  /* HANS-QUESTION: Does that mean the number of points in the profile so far? */
   int seg;               /* common # of segments for segmented edges */
   enum {
     M_NONE,    /* no polygon mesh needed */
@@ -311,7 +307,7 @@ typedef struct BevelParams {
 
 // #pragma GCC diagnostic ignored "-Wpadded"
 
-// #include "bevdebug.c" /* HANS-TODO: Uncomment this before commit! */
+// #include "bevdebug.c" /* HANS-TODO: Comment this before commit! */
 
 /* Some flags to re-enable old behavior for a while,
  * in case fixes broke things not caught by regression tests. */
@@ -1272,6 +1268,7 @@ static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3],
 /* If there is a bndv->ebev edge, find the mid control point if necessary.
  * It is the closest point on the beveled edge to the line segment between
  * bndv and bndv->next.  */
+/* HANS-QUESTION: Will I need to change this? */
 static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
 {
   EdgeHalf *e;
@@ -1414,6 +1411,8 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
 /* Maybe move the profile plane for bndv->ebev to the plane its profile's coa, cob and the
  * original beveled vert, bmv. This will usually be the plane containing its adjacent
  * non-beveled edges, but sometimes coa and cob are not on those edges.
+ *
+ * Currently just used in build boundary terminal edge
  */
 static void move_profile_plane(BoundVert *bndv, BMVert *bmv)
 {
@@ -1623,6 +1622,8 @@ static double superellipse_co(double x, float r, bool rbig)
  * In the latter case, we subsample the profile for seg_2, which will not necessarily
  * give equal spaced chords, but is in fact more what is desired by the cubic subdivision
  * method used to make the vmesh pattern. */
+/* HANS-TODO: Probably should just give this a reversed parameter instead of changing the call
+ * when the boundvert isn't the profile start boundvert */
 static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n, float r_co[3])
 {
   int d;
@@ -1654,8 +1655,10 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
  * custom profile points instead of the normal ones. Eventually, when the custom and normal
  * profile spacings are merged, this function will be redundant, but for now, I will call this
  * function in certain cases where I am working on the custom profile. This also checks for
- * is_profile_start and flips the profile if it isn't the start of the boundary
- * HANS-TODO: Get rid of this function when all custom profile cases are completed */
+ * is_profile_start and flips the profile if it isn't the start of the boundary */
+/* HANS-TODO: Get rid of this function when all custom profile cases are completed */
+/* HANS-TODO: Change the reverse case so that I don't have to sample the points backwards in
+ * get_profile_point. This would simplify the rest of the code a lot */
 static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reversed)
 {
   int i, k, ns;
@@ -1693,8 +1696,8 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reve
   for (i = 0; i < 2; i++) {
     if (i == 0) {
       ns = bp->seg;
-      xvals = bp->pro_spacing.xvals_custom;
-      yvals = bp->pro_spacing.yvals_custom;
+      xvals = bp->pro_spacing.xvals;
+      yvals = bp->pro_spacing.yvals;
       prof_co = pro->prof_co;
     }
     else {
@@ -1702,11 +1705,11 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reve
         break; /* shares coords with pro->prof_co */
       }
       ns = bp->pro_spacing.seg_2;
-      xvals = bp->pro_spacing.xvals_2_custom;
-      yvals = bp->pro_spacing.yvals_2_custom;
+      xvals = bp->pro_spacing.xvals_2;
+      yvals = bp->pro_spacing.yvals_2;
       prof_co = pro->prof_co_2;
     }    
-    /* HANS-TODO: Why this assert? BECAUSE IT SIGABRTs IF YOU DON'T!!!! */
+    /* HANS-TODO: Why this assert? */
     BLI_assert((r == PRO_LINE_R || (xvals != NULL && yvals != NULL)) && prof_co != NULL);
 
     /* Iterate over the vertices along the boundary arc */
@@ -1720,6 +1723,9 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reve
       else {
         if (map_ok) {
           if (reversed) {
+#if DEBUG_CUSTOM_PROFILE_ORIENTATION
+            printf("Using reversed custom profile orientation\n");
+#endif
             p[0] = (float)yvals[k];
             p[1] = (float)xvals[k];
           }
@@ -1736,7 +1742,7 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reve
         }
       }
       /* project co onto final profile plane */
-      prof_co_k = prof_co + 3 * k; /* 3 times deeper because each coord takes up 3 spaces */
+      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);
         /* pro->plane_co and pro->plane_no are built in "set_profile_params" */
@@ -1833,7 +1839,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
         }
       }
       /* project co onto final profile plane */
-      prof_co_k = prof_co + 3 * k; /* 3 times deeper because each coord takes up 3 spaces */
+      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);
         /* pro->plane_co and pro->plane_no are built in "set_profile_params" */
@@ -1850,11 +1856,15 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
 }
 
 /* Snap a direction co to a superellipsoid with parameter super_r.
- * For square profiles, midline says whether or not to snap to both planes. */
+ * For square profiles, midline says whether or not to snap to both planes.
+ *
+ * Only currently used for the pipe and cube corner special cases */
 static void snap_to_superellipsoid(float co[3], const float super_r, bool midline)
 {
+#if DEBUG_CUSTOM_PROFILE_ADJ
+  printf("SNAP TO SUPERELLIPSOID\n");
+#endif
   float a, b, c, x, y, z, r, rinv, dx, dy;
-
   r = super_r;
   if (r == PRO_CIRCLE_R) {
     normalize_v3(co);
@@ -1920,6 +1930,16 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin
   co[2] = z;
 }
 
+/* This is meant to be the "custom" equivalent to the snap_to_superellipsoid function.
+ * It has to be more complex because it's not as a simple as just snapping to a superellipsoid
+ * function because the custom profile can't be parametrized. There are (seg_2 - 1) edges defining
+ * the custom profile that could be the closest edge to snap to */
+/* HANS-TODO: Finish this. And params probably need to change */
+//static void snap_to_custom_profile(float co[3], Profile *pro)
+//{
+
+//}
+
 #define BEV_EXTEND_EDGE_DATA_CHECK(eh, flag) (BM_elem_flag_test(eh->e, flag))
 
 static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg)
@@ -2394,7 +2414,12 @@ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool constr
     }
   } while ((e = e->next) != efirst);
 
-  calculate_vm_profiles(bp, bv, vm);
+  if (bp->use_custom_profile){
+    calculate_vm_profiles_custom(bp, bv, vm);
+  }
+  else {
+    calculate_vm_profiles(bp, bv, vm);
+  }
 
   if (construct) {
     set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
@@ -2866,7 +2891,12 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
     adjust_miter_coords(bp, bv, emiter);
   }
 
-  calculate_vm_profiles(bp, bv, vm);
+  if (bp->use_custom_profile) {
+    calculate_vm_profiles_custom(bp, bv, vm);
+  }
+  else {
+    calculate_vm_profiles(bp, bv, vm);
+  }
 
   if (construct) {
     set_bound_vert_seams(bv, bp->mark_seam, bp->ma

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list