[Bf-blender-cvs] [ec97450ac61] master: Curves: add taper mode option

Omar Emara noreply at git.blender.org
Tue Mar 23 08:35:34 CET 2021


Commit: ec97450ac6160a8892a339a746a507e40b7d2fce
Author: Omar Emara
Date:   Tue Mar 23 18:26:13 2021 +1100
Branches: master
https://developer.blender.org/rBec97450ac6160a8892a339a746a507e40b7d2fce

Curves: add taper mode option

Currently, when a taper object is specified, the radius of the spline is
ignored. This patch adds a new option to control how the taper object
affect the effective radius of the spline. The option allow three modes
of operation:

- Override: The old method. The radius of the spline is ignored and
  overridden.
- Multiply: The radius of the spline is multiplied by the taper radius.
- Add: The radius of the spline is added to the taper radius.

Ref D10779

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

M	release/scripts/startup/bl_ui/properties_data_curve.py
M	source/blender/blenkernel/intern/displist.c
M	source/blender/makesdna/DNA_curve_defaults.h
M	source/blender/makesdna/DNA_curve_types.h
M	source/blender/makesrna/intern/rna_curve.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 394e2270227..4bd2d66e257 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -175,6 +175,7 @@ class DATA_PT_geometry_curve(CurveButtonsPanelCurve, Panel):
         sub.prop(curve, "extrude")
 
         col.prop(curve, "taper_object")
+        col.prop(curve, "taper_radius_mode")
 
         if type(curve) is not TextCurve:
             # This setting makes no sense for texts, since we have no control over start/end of the bevel object curve.
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 708b1971bd5..d4581991566 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1650,6 +1650,13 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
                 }
 
                 radius_factor = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_factor);
+
+                if (cu->taper_radius_mode == CU_TAPER_RADIUS_MULTIPLY) {
+                  radius_factor *= bevp->radius;
+                }
+                else if (cu->taper_radius_mode == CU_TAPER_RADIUS_ADD) {
+                  radius_factor += bevp->radius;
+                }
               }
 
               if (bevp->split_tag) {
diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender/makesdna/DNA_curve_defaults.h
index 07dd0aeb08d..557615fd047 100644
--- a/source/blender/makesdna/DNA_curve_defaults.h
+++ b/source/blender/makesdna/DNA_curve_defaults.h
@@ -50,6 +50,7 @@
     .bevfac2_mapping = CU_BEVFAC_MAP_RESOLU, \
     .bevresol = 4, \
     .bevel_mode = CU_BEV_MODE_ROUND, \
+    .taper_radius_mode = CU_TAPER_RADIUS_OVERRIDE, \
   }
 
 /** \} */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index b3f0708539a..4f914089347 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -269,7 +269,12 @@ typedef struct Curve {
   char overflow;
   char spacemode, align_y;
   char bevel_mode;
-  char _pad[2];
+  /**
+   * Determine how the effective radius of the bevel point is computed when a taper object is
+   * specified. The effective radius is a function of the bevel point radius and the taper radius.
+   */
+  char taper_radius_mode;
+  char _pad;
 
   /* font part */
   short lines;
@@ -400,6 +405,16 @@ enum {
   CU_BEV_MODE_CURVE_PROFILE = 2,
 };
 
+/** #Curve.taper_radius_mode */
+enum {
+  /** Override the radius of the bevel point with the taper radius. */
+  CU_TAPER_RADIUS_OVERRIDE = 0,
+  /** Multiply the radius of the bevel point by the taper radius. */
+  CU_TAPER_RADIUS_MULTIPLY = 1,
+  /** Add the radius of the bevel point to the taper radius. */
+  CU_TAPER_RADIUS_ADD = 2,
+};
+
 /* Curve.overflow. */
 enum {
   CU_OVERFLOW_NONE = 0,
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 50c18cf1dae..3e90b4bd9d4 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1576,6 +1576,25 @@ static void rna_def_curve(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem curve_taper_radius_mode_items[] = {
+      {CU_TAPER_RADIUS_OVERRIDE,
+       "OVERRIDE",
+       0,
+       "Override",
+       "Override the radius of the spline point with the taper radius"},
+      {CU_TAPER_RADIUS_MULTIPLY,
+       "MULTIPLY",
+       0,
+       "Multiply",
+       "Multiply the radius of the spline point by the taper radius"},
+      {CU_TAPER_RADIUS_ADD,
+       "ADD",
+       0,
+       "Add",
+       "Add the radius of the bevel point to the taper radius"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "Curve", "ID");
   RNA_def_struct_ui_text(srna, "Curve", "Curve data-block storing curves, splines and NURBS");
   RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA);
@@ -1757,6 +1776,15 @@ static void rna_def_curve(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Twist Method", "The type of tilt calculation for 3D Curves");
   RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 
+  prop = RNA_def_property(srna, "taper_radius_mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "taper_radius_mode");
+  RNA_def_property_enum_items(prop, curve_taper_radius_mode_items);
+  RNA_def_property_ui_text(prop,
+                           "Taper Radius",
+                           "Determine how the effective radius of the spline point is computed "
+                           "when a taper object is specified");
+  RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
   prop = RNA_def_property(srna, "bevel_factor_mapping_start", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "bevfac1_mapping");
   RNA_def_property_enum_items(prop, bevfac_mapping_items);



More information about the Bf-blender-cvs mailing list