[Bf-blender-cvs] [862075bcb93] soc-2019-bevel-profiles: Bevel Custom Profile: Fixed sampling too many segments from widget.

Hans Goudey noreply at git.blender.org
Thu Aug 1 15:48:21 CEST 2019


Commit: 862075bcb930fc27758c441b7cbf05081cfa5cee
Author: Hans Goudey
Date:   Thu Aug 1 05:46:29 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB862075bcb930fc27758c441b7cbf05081cfa5cee

Bevel Custom Profile: Fixed sampling too many segments from widget.

Sampling too many segments meant the last one wasn't included which made
the last segment too long.

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

M	source/blender/blenkernel/intern/profile_widget.c
M	source/blender/bmesh/tools/bmesh_bevel.c

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

diff --git a/source/blender/blenkernel/intern/profile_widget.c b/source/blender/blenkernel/intern/profile_widget.c
index 6580ea907a3..5f86406ab8a 100644
--- a/source/blender/blenkernel/intern/profile_widget.c
+++ b/source/blender/blenkernel/intern/profile_widget.c
@@ -83,7 +83,6 @@ struct ProfileWidget *profilewidget_add(int preset)
   return prwdgt;
 }
 
-/* HANS-TODO: Double free error here with the prwdgt->table */
 void profilewidget_free_data(ProfileWidget *prwdgt)
 {
 #if DEBUG_PRWDGT
@@ -572,7 +571,6 @@ static void calchandle_profile(BezTriple *bezt, const BezTriple *prev, const Bez
  * curvature of the edge after each of them in the table. Works by comparing the angle between the
  * handles that make up the edge: the secong handle of the first point and the first handle
  * of the second. */
-/* HANS-TODO: This doesn't work so well, so maybe just assign the remainders to the longest edges */
 static int compare_curvature_bezt_edge_i(const BezTriple *bezt, const int i_a, const int i_b)
 {
   float handle_angle_a, handle_angle_b;
@@ -617,10 +615,6 @@ static int compare_curvature_bezt_edge_i(const BezTriple *bezt, const int i_a, c
  *        number of points used to define the profile (prwdgt->totpoint).
  * \param sample_straight_edges: Whether to sample points between vector handle control points. If
           this is true and there are only vector edges the straight edges will still be sampled. */
-/* HANS-TODO: The last segment is always a little too long. And in the non-sample_straight_edges
- * case the second to last point can sometimes be forgotten for the sampling. */
-/* HANS-TODO: Enable proper sampling with fewer segments than points, probably using older sampling
- * algorithms */
 void profilewidget_create_samples(const ProfileWidget *prwdgt,
                                   float *locations,
                                   int n_segments,
@@ -767,7 +761,7 @@ void profilewidget_create_samples(const ProfileWidget *prwdgt,
     n_added++;
   }
 
-  BLI_assert(n_added == n_segments); /* HANS-TODO: Remove n_added check */
+  BLI_assert(n_added == n_segments); /* n_added is just used for this assert, could remove */
 
   /* Sample the points and add them to the locations table */
   for (i_segment = 0, i = 0; i < totedges; i++) {
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index d7f5567d4f1..3d42501f320 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -7028,7 +7028,6 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo
   int seg, seg_2;
   float *temp_locs = NULL;
 
-
   /* Sample the input number of segments */
   seg = bp->seg;
   seg_2 = power_of_2_max_i(bp->seg);
@@ -7038,8 +7037,8 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo
     pro_spacing->yvals = (double *)BLI_memarena_alloc(bp->mem_arena,
                                                          (size_t)(seg + 1) * sizeof(double));
     if (custom) {
-      temp_locs = BLI_memarena_alloc(bp->mem_arena, (size_t)(2 * (seg_2 + 1)) * sizeof(float));
-      profilewidget_create_samples(bp->prwdgt, temp_locs, seg + 1,
+      temp_locs = BLI_memarena_alloc(bp->mem_arena, (size_t)(2 * (seg_2)) * sizeof(float));
+      profilewidget_create_samples(bp->prwdgt, temp_locs, seg,
                                    bp->prwdgt->flag & PROF_SAMPLE_STRAIGHT_EDGES);
       for (int i = 0; i < seg + 1; i++) {
         pro_spacing->xvals[i] = (double)temp_locs[2 * i + 1];



More information about the Bf-blender-cvs mailing list