[Bf-blender-cvs] [b0caae8e5af] soc-2019-bevel-profiles: Changes from Campbell and feedback from review.

Hans Goudey noreply at git.blender.org
Fri Nov 8 04:45:14 CET 2019


Commit: b0caae8e5aff51a38f92c3cba5c4a106890aef26
Author: Hans Goudey
Date:   Thu Nov 7 22:40:02 2019 -0500
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rBb0caae8e5aff51a38f92c3cba5c4a106890aef26

Changes from Campbell and feedback from review.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_curveprofile.h
M	source/blender/blenkernel/intern/curveprofile.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_query.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/mesh/editmesh_bevel.c
M	source/blender/makesdna/DNA_curveprofile_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_curveprofile.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 8638ce8789d..74c6158e25e 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -133,13 +133,14 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.prop(md, "end_cap")
 
     def BEVEL(self, layout, ob, md):
-        if md.offset_type == 'PERCENT':
+        offset_type = md.offset_type
+        if offset_type == 'PERCENT':
             layout.prop(md, "width_pct")
         else:
             offset_text = "Width"
-            if md.offset_type == 'DEPTH':
+            if offset_type == 'DEPTH':
                 offset_text = "Depth"
-            elif md.offset_type == 'OFFSET':
+            elif offset_type == 'OFFSET':
                 offset_text = "Offset"
             layout.prop(md, "width", text=offset_text)
         layout.row().prop(md, "offset_type", expand=True)
@@ -181,10 +182,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.enabled = md.use_custom_profile
         if md.use_custom_profile:
             layout.template_curveprofile(md, "custom_profile")
-            # If the number of segments has changed, update the table to show the new sampled
-            # segment locations on the widget
-            if md.custom_profile.totsegments != md.segments:
-                md.custom_profile.initialize(md.segments)
 
     def BOOLEAN(self, layout, _ob, md):
         split = layout.split()
diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h
index 1f11e5c406f..a7b53212476 100644
--- a/source/blender/blenkernel/BKE_curveprofile.h
+++ b/source/blender/blenkernel/BKE_curveprofile.h
@@ -52,11 +52,11 @@ void BKE_curveprofile_reverse(struct CurveProfile *profile);
 void BKE_curveprofile_reset(struct CurveProfile *profile);
 
 void BKE_curveprofile_create_samples(struct CurveProfile *profile,
-                                      int n_segments,
-                                      bool sample_straight_edges,
-                                      struct CurveProfilePoint *r_samples);
+                                     int segments_len,
+                                     bool sample_straight_edges,
+                                     struct CurveProfilePoint *r_samples);
 
-void BKE_curveprofile_initialize(struct CurveProfile *profile, short nsegments);
+void BKE_curveprofile_initialize(struct CurveProfile *profile, short segments_len);
 
 /* Called for a complete update of the widget after modifications */
 void BKE_curveprofile_update(struct CurveProfile *profile, const bool rem_doubles);
@@ -65,12 +65,12 @@ void BKE_curveprofile_update(struct CurveProfile *profile, const bool rem_double
 float BKE_curveprofile_total_length(const struct CurveProfile *profile);
 
 void BKE_curveprofile_create_samples_even_spacing(struct CurveProfile *profile,
-                                                   int n_segments,
+                                                   int segments_len,
                                                    struct CurveProfilePoint *r_samples);
 
 /* Length portion is the fraction of the total path length where we want the location */
 void BKE_curveprofile_evaluate_length_portion(const struct CurveProfile *profile,
-                                               float length_portion,
-                                               float *x_out,
-                                               float *y_out);
+                                              float length_portion,
+                                              float *x_out,
+                                              float *y_out);
 #endif
diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c
index 7d071f4b562..6689eca132d 100644
--- a/source/blender/blenkernel/intern/curveprofile.c
+++ b/source/blender/blenkernel/intern/curveprofile.c
@@ -82,26 +82,26 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi
   CurveProfilePoint *pts;
 
   /* Must have 2 points minimum. */
-  if (profile->totpoint <= 2) {
+  if (profile->path_len <= 2) {
     return false;
   }
 
   /* Input point must be within the array. */
-  if (!(point > profile->path && point < profile->path + profile->totpoint)) {
+  if (!(point > profile->path && point < profile->path + profile->path_len)) {
     return false;
   }
 
-  pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->totpoint, "path points");
+  pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->path_len, "path points");
 
   uint i_delete = (uint)(point - profile->path);
 
   /* Copy the before and after the deleted point. */
   memcpy(pts, profile->path, i_delete);
-  memcpy(pts + i_delete, profile->path + i_delete + 1, (size_t)profile->totpoint - i_delete - 1);
+  memcpy(pts + i_delete, profile->path + i_delete + 1, (size_t)profile->path_len - i_delete - 1);
 
   MEM_freeN(profile->path);
   profile->path = pts;
-  profile->totpoint -= 1;
+  profile->path_len -= 1;
   return true;
 }
 
@@ -113,12 +113,12 @@ void BKE_curveprofile_remove_by_flag(CurveProfile *profile, const short flag)
   int i_old, i_new, n_removed = 0;
 
   /* Copy every point without the flag into the new path. */
-  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->totpoint,
+  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->path_len,
                                            "profile path");
 
   /* Build the new list without any of the points with the flag. Keep the first and last points. */
   new_pts[0] = profile->path[0];
-  for (i_old = 1, i_new = 1; i_old < profile->totpoint - 1; i_old++) {
+  for (i_old = 1, i_new = 1; i_old < profile->path_len - 1; i_old++) {
     if (!(profile->path[i_old].flag & flag)) {
       new_pts[i_new] = profile->path[i_old];
       i_new++;
@@ -131,7 +131,7 @@ void BKE_curveprofile_remove_by_flag(CurveProfile *profile, const short flag)
 
   MEM_freeN(profile->path);
   profile->path = new_pts;
-  profile->totpoint -= n_removed;
+  profile->path_len -= n_removed;
 }
 
 /** Adds a new point at the specified location. The choice for which points to place the new vertex
@@ -144,7 +144,7 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
   float new_loc[2] = {x, y};
 
   /* Don't add more control points  than the maximum size of the higher resolution table. */
-  if (profile->totpoint == PROF_TABLE_MAX - 1) {
+  if (profile->path_len == PROF_TABLE_MAX - 1) {
     return NULL;
   }
 
@@ -152,7 +152,7 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
   float distance;
   float min_distance = FLT_MAX;
   int i_insert = 0;
-  for (int i = 0; i < profile->totpoint - 1; i++) {
+  for (int i = 0; i < profile->path_len - 1; i++) {
     float loc1[2] = {profile->path[i].x, profile->path[i].y};
     float loc2[2] = {profile->path[i + 1].x, profile->path[i + 1].y};
 
@@ -164,10 +164,10 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
   }
 
   /* Insert the new point at the location we found and copy all of the old points in as well. */
-  profile->totpoint++;
-  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->totpoint,
+  profile->path_len++;
+  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->path_len,
                                            "profile path");
-  for (int i_new = 0, i_old = 0; i_new < profile->totpoint; i_new++) {
+  for (int i_new = 0, i_old = 0; i_new < profile->path_len; i_new++) {
     if (i_new != i_insert) {
       /* Insert old points */
       new_pts[i_new].x = profile->path[i_old].x;
@@ -184,8 +184,7 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
       new_pts[i_new].flag = PROF_SELECT;
       new_pt = &new_pts[i_new];
       /* Set handles of new point based on its neighbors. */
-      if (new_pts[i_new - 1].h2 == HD_VECT &&
-          profile->path[i_insert].h1 == HD_VECT) {
+      if (new_pts[i_new - 1].h2 == HD_VECT && profile->path[i_insert].h1 == HD_VECT) {
         new_pt->h1 = new_pt->h2 = HD_VECT;
       }
       else {
@@ -205,7 +204,7 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
  * \note: Requires curveprofile_update call after. */
 void BKE_curveprofile_selected_handle_set(CurveProfile *profile, int type_1, int type_2)
 {
-  for (int i = 0; i < profile->totpoint; i++) {
+  for (int i = 0; i < profile->path_len; i++) {
     if (profile->path[i].flag & PROF_SELECT) {
       switch (type_1) {
         case HD_AUTO:
@@ -238,18 +237,18 @@ void BKE_curveprofile_selected_handle_set(CurveProfile *profile, int type_1, int
 void BKE_curveprofile_reverse(CurveProfile *profile)
 {
   /* When there are only two points, reversing shouldn't do anything. */
-  if (profile->totpoint == 2) {
+  if (profile->path_len == 2) {
     return;
   }
-  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->totpoint,
+  CurveProfilePoint *new_pts = MEM_mallocN(sizeof(CurveProfilePoint) * profile->path_len,
                                            "profile path");
   /* Mirror the new points across the y = x line */
-  for (int i = 0; i < profile->totpoint; i++) {
-    new_pts[profile->totpoint - i - 1].x = profile->path[i].y;
-    new_pts[profile->totpoint - i - 1].y = profile->path[i].x;
-    new_pts[profile->totpoint - i - 1].flag = profile->path[i].flag;
-    new_pts[profile->totpoint - i - 1].h1 = profile->path[i].h1;
-    new_pts[profile->totpoint - i - 1].h2 = profile->path[i].h2;
+  for (int i = 0; i < profile->path_len; i++) {
+    new_pts[profile->path_len - i - 1].x = profile->path[i].y;
+    new_pts[profile->path_len - i - 1].y = profile->path[i].x;
+    new_pts[profile->path_len - i - 1].flag = profile->path[i].flag;
+    new_pts[profile->path_len - i - 1].h1 = profile->path[i].h1;
+    new_pts[profile->path_len - i - 1].h2 = profile->path[i].h2;
   }
 
   /* Free the old points a

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list