[Bf-blender-cvs] [4a952395f20] soc-2019-bevel-profiles: Profile Widget: Fix UI fill bug

Hans Goudey noreply at git.blender.org
Wed Aug 7 23:41:51 CEST 2019


Commit: 4a952395f20d864fe5503be2cc1eef5eb91213b4
Author: Hans Goudey
Date:   Wed Aug 7 17:38:39 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB4a952395f20d864fe5503be2cc1eef5eb91213b4

Profile Widget: Fix UI fill bug

The end of the high resolution samples needs to be manually filled with
the location of the end of the profile.

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

M	source/blender/blenkernel/intern/profile_widget.c
M	source/blender/makesdna/DNA_profilewidget_types.h

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

diff --git a/source/blender/blenkernel/intern/profile_widget.c b/source/blender/blenkernel/intern/profile_widget.c
index ceda0d2e9e3..0818011257e 100644
--- a/source/blender/blenkernel/intern/profile_widget.c
+++ b/source/blender/blenkernel/intern/profile_widget.c
@@ -42,7 +42,7 @@
 #include "BKE_fcurve.h"
 
 #define DEBUG_PRWDGT 0
-#define DEBUG_PRWDGT_TABLE 1
+#define DEBUG_PRWDGT_TABLE 0
 #define DEBUG_PRWDGT_EVALUATE 0
 #define DEBUG_PRWDGT_REVERSE 0
 
@@ -559,11 +559,10 @@ static int compare_curvature_bezt_edge_i(const BezTriple *bezt, const int i_a, c
  * \param r_samples: An array of points to put the sampled positions. Must have length n_segments.
  * \return r_samples: Fill the array with the sampled locations and if the point corresponds
  *         to a control point, its handle type */
-/* HANS-TODO: This is getting called way too much: when the mouse moves over the bevel modifier UI */
 void BKE_profilewidget_create_samples(ProfileWidget *prwdgt,
-                                  int n_segments,
-                                  bool sample_straight_edges,
-                                  ProfilePoint *r_samples)
+                                      int n_segments,
+                                      bool sample_straight_edges,
+                                      ProfilePoint *r_samples)
 {
 #if DEBUG_PRWDGT
   printf("PROFILEWIDGET CREATE SAMPLES\n");
@@ -735,7 +734,18 @@ static void profilewidget_make_table(ProfileWidget *prwdgt)
   ProfilePoint *new_table = MEM_callocN((size_t)(n_samples + 1) * sizeof(ProfilePoint),
                                         "high-res table");
 
-  BKE_profilewidget_create_samples(prwdgt, n_samples, false, new_table);
+  BKE_profilewidget_create_samples(prwdgt, n_samples - 1, false, new_table);
+  /* Manually add last point at the end of the profile */
+  new_table[n_samples - 1].x = 0.0f;
+  new_table[n_samples - 1].y = 1.0f;
+
+#if DEBUG_PRWDGT_TABLE
+  printf("High-res table samples:\n");
+  for (int i = 0; i < n_samples; i++) {
+    printf("(%.3f, %.3f), ", new_table[i].x, new_table[i].y);
+  }
+  printf("\n");
+#endif
 
   if (prwdgt->table) {
     MEM_freeN(prwdgt->table);
@@ -790,7 +800,7 @@ void BKE_profilewidget_changed(ProfileWidget *prwdgt, const bool remove_double)
   ProfilePoint *points = prwdgt->path;
   rctf *clipr = &prwdgt->clip_rect;
   float thresh;
-  float dx = 0.0f, dy = 0.0f;
+  float dx, dy;
   int i;
 
   prwdgt->changed_timestamp++;
diff --git a/source/blender/makesdna/DNA_profilewidget_types.h b/source/blender/makesdna/DNA_profilewidget_types.h
index 4b6159455f0..0eea39921e2 100644
--- a/source/blender/makesdna/DNA_profilewidget_types.h
+++ b/source/blender/makesdna/DNA_profilewidget_types.h
@@ -31,7 +31,7 @@
 /** Number of table points per control point */
 #define PROF_RESOL 16
 /** Dynamic size of widget's high resolution table, input should be prwdgt->totpoint */
-#define PROF_N_TABLE(n_pts) min_ii(PROF_TABLE_MAX, (((n_pts) - 1) * PROF_RESOL))
+#define PROF_N_TABLE(n_pts) min_ii(PROF_TABLE_MAX, (((n_pts - 1)) * PROF_RESOL) + 1)
 
 typedef struct ProfilePoint {
   /** Location of the point, keep together */



More information about the Bf-blender-cvs mailing list