[Bf-blender-cvs] [218360a8921] master: Cleanup: Rename curve struct fields

Hans Goudey noreply at git.blender.org
Thu Dec 2 04:01:43 CET 2021


Commit: 218360a89217f4e8321319035bf4d9ff97fb2658
Author: Hans Goudey
Date:   Wed Dec 1 22:01:35 2021 -0500
Branches: master
https://developer.blender.org/rB218360a89217f4e8321319035bf4d9ff97fb2658

Cleanup: Rename curve struct fields

These existing names were unhelpful at best, actively confusing at
worst. This patch renames them to be consistent with the terms
used to refer to the values in the UI.
 - `width` -> `offset`
 - `ext1` -> `extrude`
 - `ext2` -> `bevel_radius`

Differential Revision: https://developer.blender.org/D9627

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

M	source/blender/blenkernel/BKE_curve.h
M	source/blender/blenkernel/intern/curve_bevel.c
M	source/blender/blenkernel/intern/displist.cc
M	source/blender/blenloader/intern/versioning_260.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/makesdna/DNA_curve_defaults.h
M	source/blender/makesdna/DNA_curve_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_curve.c

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

diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 5e474c0c5ac..2f7569b1f03 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -75,8 +75,8 @@ typedef struct CVKeyIndex {
 #define SEGMENTSV(nu) (((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv - 1)
 
 #define CU_DO_RADIUS(cu, nu) \
-  ((((cu)->flag & (CU_PATH_RADIUS | CU_3D)) || (cu)->bevobj || (cu)->ext1 != 0.0f || \
-    (cu)->ext2 != 0.0f) ? \
+  ((((cu)->flag & (CU_PATH_RADIUS | CU_3D)) || (cu)->bevobj || (cu)->extrude != 0.0f || \
+    (cu)->bevel_radius != 0.0f) ? \
        1 : \
        0)
 
diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c
index d205d8cca46..18e4ab3ade1 100644
--- a/source/blender/blenkernel/intern/curve_bevel.c
+++ b/source/blender/blenkernel/intern/curve_bevel.c
@@ -64,8 +64,8 @@ static void bevel_quarter_fill(const Curve *curve,
     float angle = 0.0f;
     const float dangle = (float)M_PI_2 / (curve->bevresol + 1);
     for (int i = 0; i < curve->bevresol + 1; i++) {
-      quarter_coords_x[i] = (float)(cosf(angle) * (curve->ext2));
-      quarter_coords_y[i] = (float)(sinf(angle) * (curve->ext2));
+      quarter_coords_x[i] = (float)(cosf(angle) * (curve->bevel_radius));
+      quarter_coords_y[i] = (float)(sinf(angle) * (curve->bevel_radius));
       angle += dangle;
     }
   }
@@ -76,11 +76,11 @@ static void bevel_quarter_fill(const Curve *curve,
 
     /* If there aren't enough samples, the curveprofile won't
      * sample the start vertex, so set it manually instead. */
-    quarter_coords_x[0] = curve->ext2;
+    quarter_coords_x[0] = curve->bevel_radius;
     quarter_coords_y[0] = 0.0f;
     for (int i = 1; i < curve->bevresol + 1; i++) {
-      quarter_coords_x[i] = (float)(curve->bevel_profile->segments[i].x * (curve->ext2));
-      quarter_coords_y[i] = (float)(curve->bevel_profile->segments[i].y * (curve->ext2));
+      quarter_coords_x[i] = (float)(curve->bevel_profile->segments[i].x * (curve->bevel_radius));
+      quarter_coords_y[i] = (float)(curve->bevel_profile->segments[i].y * (curve->bevel_radius));
     }
   }
 }
@@ -133,13 +133,13 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
     /* Add the bottom vertex. */
     fp[0] = 0.0f;
     fp[1] = 0.0f;
-    fp[2] = -cu->ext1 - cu->ext2;
+    fp[2] = -cu->extrude - cu->bevel_radius;
     fp += 3;
 
     for (int i = cu->bevresol; i >= 0; i--) {
       fp[0] = 0.0f;
       fp[1] = quarter_coords_x[i];
-      fp[2] = -quarter_coords_y[i] - cu->ext1;
+      fp[2] = -quarter_coords_y[i] - cu->extrude;
       fp += 3;
     }
   }
@@ -147,8 +147,8 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
   /* Add the extrusion if we're only building either the back or the front. */
   if (use_extrude && ELEM(fill_type, FRONT, BACK)) {
     fp[0] = 0.0f;
-    fp[1] = cu->ext2;
-    fp[2] = (fill_type == FRONT) ? -cu->ext1 : cu->ext1;
+    fp[1] = cu->bevel_radius;
+    fp[2] = (fill_type == FRONT) ? -cu->extrude : cu->extrude;
     fp += 3;
   }
 
@@ -159,13 +159,13 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
     for (int i = front_start; i < cu->bevresol + 1; i++) {
       fp[0] = 0.0f;
       fp[1] = quarter_coords_x[i];
-      fp[2] = quarter_coords_y[i] + cu->ext1;
+      fp[2] = quarter_coords_y[i] + cu->extrude;
       fp += 3;
     }
     /* Add the top vertex. */
     fp[0] = 0.0f;
     fp[1] = 0.0f;
-    fp[2] = cu->ext1 + cu->ext2;
+    fp[2] = cu->extrude + cu->bevel_radius;
     fp += 3;
   }
 
@@ -174,22 +174,22 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
     for (int i = cu->bevresol; i > 0; i--) {
       fp[0] = 0.0f;
       fp[1] = -quarter_coords_x[i];
-      fp[2] = quarter_coords_y[i] + cu->ext1;
+      fp[2] = quarter_coords_y[i] + cu->extrude;
       fp += 3;
     }
 
     if (use_extrude) {
       /* Add the extrusion. */
       fp[0] = 0.0f;
-      fp[1] = -cu->ext2;
-      fp[2] = cu->ext1;
+      fp[1] = -cu->bevel_radius;
+      fp[2] = cu->extrude;
       fp += 3;
     }
 
     for (int i = 0; i < cu->bevresol + 1; i++) {
       fp[0] = 0.0f;
       fp[1] = -quarter_coords_x[i];
-      fp[2] = -quarter_coords_y[i] - cu->ext1;
+      fp[2] = -quarter_coords_y[i] - cu->extrude;
       fp += 3;
     }
   }
@@ -213,8 +213,8 @@ static void curve_bevel_make_full_circle(const Curve *cu, ListBase *disp)
 
   for (int i = 0; i < nr; i++) {
     fp[0] = 0.0;
-    fp[1] = (cosf(angle) * (cu->ext2));
-    fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1;
+    fp[1] = (cosf(angle) * (cu->bevel_radius));
+    fp[2] = (sinf(angle) * (cu->bevel_radius)) - cu->extrude;
     angle += dangle;
     fp += 3;
   }
@@ -232,9 +232,9 @@ static void curve_bevel_make_only_extrude(const Curve *cu, ListBase *disp)
 
   float *fp = dl->verts;
   fp[0] = fp[1] = 0.0;
-  fp[2] = -cu->ext1;
+  fp[2] = -cu->extrude;
   fp[3] = fp[4] = 0.0;
-  fp[5] = cu->ext1;
+  fp[5] = cu->extrude;
 }
 
 static void curve_bevel_make_from_object(const Curve *cu, ListBase *disp)
@@ -247,7 +247,7 @@ static void curve_bevel_make_from_object(const Curve *cu, ListBase *disp)
   }
 
   Curve *bevcu = cu->bevobj->data;
-  if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
+  if (bevcu->extrude == 0.0f && bevcu->bevel_radius == 0.0f) {
     ListBase bevdisp = {NULL, NULL};
     float facx = cu->bevobj->scale[0];
     float facy = cu->bevobj->scale[1];
@@ -299,8 +299,8 @@ ListBase BKE_curve_bevel_make(const Curve *curve)
     }
   }
   else {
-    const bool use_extrude = curve->ext1 != 0.0f;
-    const bool use_bevel = curve->ext2 != 0.0f;
+    const bool use_extrude = curve->extrude != 0.0f;
+    const bool use_bevel = curve->bevel_radius != 0.0f;
     /* Pass. */
     if (use_extrude && !use_bevel) {
       curve_bevel_make_only_extrude(curve, &bevel_shape);
diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc
index 73aea944665..cae7a5fa65c 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -830,7 +830,7 @@ static bool do_curve_implicit_mesh_conversion(const Curve *curve,
   }
 
   /* Curve objects with implicit "tube" meshes should convert implicitly to a mesh. */
-  if (curve->ext1 != 0.0f || curve->ext2 != 0.0f) {
+  if (curve->extrude != 0.0f || curve->bevel_radius != 0.0f) {
     return true;
   }
 
@@ -1310,11 +1310,11 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph,
   ListBase dlbev = BKE_curve_bevel_make(cu);
 
   /* no bevel or extrude, and no width correction? */
-  if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
+  if (BLI_listbase_is_empty(&dlbev) && cu->offset == 1.0f) {
     curve_to_displist(cu, deformed_nurbs, for_render, r_dispbase);
   }
   else {
-    const float widfac = cu->width - 1.0f;
+    const float widfac = cu->offset - 1.0f;
 
     const BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
     const Nurb *nu = (Nurb *)deformed_nurbs->first;
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index c4d04392cba..8a22fd07c24 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -1892,7 +1892,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
     for (cu = bmain->curves.first; cu; cu = cu->id.next) {
       if (cu->flag & (CU_FRONT | CU_BACK)) {
-        if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
+        if (cu->extrude != 0.0f || cu->bevel_radius != 0.0f) {
           Nurb *nu;
 
           for (nu = cu->nurb.first; nu; nu = nu->next) {
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 3b05975d22d..f8977b835b3 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6856,9 +6856,9 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
           /* Compensate for different bevel depth. */
           bool do_radius = false;
           float compensate_radius = 0.0f;
-          if (cu->ext2 != 0.0f && cu_active->ext2 != 0.0f) {
+          if (cu->bevel_radius != 0.0f && cu_active->bevel_radius != 0.0f) {
             float compensate_scale = mat4_to_scale(cmat);
-            compensate_radius = cu->ext2 / cu_active->ext2 * compensate_scale;
+            compensate_radius = cu->bevel_radius / cu_active->bevel_radius * compensate_scale;
             do_radius = true;
           }
 
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 784f67ac4f1..403ace56e3b 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -144,7 +144,7 @@ static float stroke_elem_radius_from_pressure(const struct CurveDrawData *cdd,
                                               const float pressure)
 {
   const Curve *cu = cdd->vc.obedit->data;
-  return ((pressure * cdd->radius.range) + cdd->radius.min) * cu->ext2;
+  return ((pressure * cdd->radius.range) + cdd->radius.min) * cu->bevel_radius;
 }
 
 static float stroke_elem_radius(const struct CurveDrawData *cdd, const struct StrokeElem *selem)
@@ -364,7 +364,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C),
   Object *obedit = cdd->vc.obedit;
   Curve *cu = obedit->data;
 
-  if (cu->ext2 > 0.0f) {
+  if (cu->bevel_radius > 0.0f) {
     BLI_mempool_iter iter;
     const struct StrokeElem *selem;
 
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 656fec565df..bf414851aed 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1324,7 +1324,7 @@ static void gpencil_layer_to_curve(bContext *C,
 
   cu->flag |= CU_3D;
   cu->bevresol = gtd->bevel_resolution;
-  cu->ext2 = gtd->bevel_depth;
+  cu->bevel_radius = gtd->bevel_depth;
 
   gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime;
 
diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list