Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-09-16 18:20:38 +0300
committerHans Goudey <h.goudey@me.com>2020-09-16 18:20:38 +0300
commit60fa80de0b2c7138fc86b8b688f22a9d2623e8ed (patch)
tree44d7acc6bf5022866f5369a0151c513d4dfd957e /source/blender/makesrna/intern/rna_curve.c
parent365271a5886e1678b41e636581616446766b5f85 (diff)
Curves: Add custom profile bevel support
This adds support for the same custom bevel profile widget used in the bevel tool and modifier to the geometry generation for curves. This is expecially useful for text and 2D curves with extrusion, as it works much better than a weld & bevel modifier combination. It can also be useful for adding quick detail to pipe-like objects. The curve holds the CurveProfile struct and a new "Bevel Mode" property decides which type of bevel to build, round, object, or custom profile. Although curves can already use another curve to make the bevel geometry, this is a quicker way, and it also defines the profile of just one corner of the bevel, so it isn't redundant. It's also nice to have the same custom profile functionality wherever there is bevel. Differential Revision: https://developer.blender.org/D8402
Diffstat (limited to 'source/blender/makesrna/intern/rna_curve.c')
-rw-r--r--source/blender/makesrna/intern/rna_curve.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 1768d79fe8f..854c8757d4d 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -167,6 +167,7 @@ static const EnumPropertyItem curve2d_fill_mode_items[] = {
# include "DNA_object_types.h"
# include "BKE_curve.h"
+# include "BKE_curveprofile.h"
# include "BKE_main.h"
# include "DEG_depsgraph.h"
@@ -463,6 +464,35 @@ static void rna_Curve_bevelObject_set(PointerRNA *ptr,
}
}
+/**
+ * Special update function for setting the number of segments of the curve
+ * that also resamples the segments in the custom profile.
+ */
+static void rna_Curve_bevel_resolution_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Curve *cu = (Curve *)ptr->data;
+
+ if (cu->bevel_mode == CU_BEV_MODE_CURVE_PROFILE) {
+ BKE_curveprofile_init(cu->bevel_profile, cu->bevresol + 1);
+ }
+
+ rna_Curve_update_data(bmain, scene, ptr);
+}
+
+static void rna_Curve_bevel_mode_set(PointerRNA *ptr, int value)
+{
+ Curve *cu = (Curve *)ptr->owner_id;
+
+ if (value == CU_BEV_MODE_CURVE_PROFILE) {
+ if (cu->bevel_profile == NULL) {
+ cu->bevel_profile = BKE_curveprofile_add(PROF_PRESET_LINE);
+ BKE_curveprofile_init(cu->bevel_profile, cu->bevresol + 1);
+ }
+ }
+
+ cu->bevel_mode = value;
+}
+
static bool rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value)
{
Curve *cu = (Curve *)ptr->owner_id;
@@ -1527,6 +1557,25 @@ static void rna_def_curve(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem bevel_mode_items[] = {
+ {CU_BEV_MODE_ROUND,
+ "ROUND",
+ 0,
+ "Round",
+ "Use circle for the section of the curve's bevel geometry"},
+ {CU_BEV_MODE_OBJECT,
+ "OBJECT",
+ 0,
+ "Object",
+ "Use an object for the section of the curve's bevel goemetry segment"},
+ {CU_BEV_MODE_CURVE_PROFILE,
+ "PROFILE",
+ 0,
+ "Profile",
+ "Use a custom profile for each quarter of curve's bevel geometry"},
+ {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);
@@ -1559,6 +1608,20 @@ static void rna_def_curve(BlenderRNA *brna)
rna_def_path(brna, srna);
+ prop = RNA_def_property(srna, "bevel_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "bevel_mode");
+ RNA_def_property_enum_items(prop, bevel_mode_items);
+ RNA_def_property_ui_text(
+ prop, "Bevel Mode", "Determine how to build the curve's bevel geometry");
+ RNA_def_property_enum_funcs(prop, NULL, "rna_Curve_bevel_mode_set", NULL);
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
+ prop = RNA_def_property(srna, "bevel_profile", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "CurveProfile");
+ RNA_def_property_pointer_sdna(prop, NULL, "bevel_profile");
+ RNA_def_property_ui_text(prop, "Custom Profile Path", "The path for the curve's custom profile");
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
/* Number values */
prop = RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "bevresol");
@@ -1568,7 +1631,7 @@ static void rna_def_curve(BlenderRNA *brna)
prop,
"Bevel Resolution",
"Bevel resolution when depth is non-zero and no specific bevel object has been defined");
- RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+ RNA_def_property_update(prop, 0, "rna_Curve_bevel_resolution_update");
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "width");