Curves: support more curve type conversion options in edit mode
This adds a new `Handles` checkbox to the conversion operator that affects how the conversion works in the following cases: `Bezier -> Catmull Rom / Poly / Nurbs` and `Catmull Rom -> Nurbs`. If enabled, three control points are added for each original control point, otherwise only one. ----- The images show the effect of the toggle. The top result is always the one with handles and the bottom one without. * `Bezier -> Poly`  * `Bezier -> Catmull Rom`  * `Bezier -> Nurbs`  * `Catmull Rom -> Nurbs`  Pull Request: https://projects.blender.org/blender/blender/pulls/120423
This commit is contained in:
@@ -1394,6 +1394,7 @@ namespace curve_type_set {
|
||||
static int exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const CurveType dst_type = CurveType(RNA_enum_get(op->ptr, "type"));
|
||||
const bool use_handles = RNA_boolean_get(op->ptr, "use_handles");
|
||||
|
||||
for (Curves *curves_id : get_unique_editable_curves(*C)) {
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
@@ -1403,7 +1404,13 @@ static int exec(bContext *C, wmOperator *op)
|
||||
continue;
|
||||
}
|
||||
|
||||
curves = geometry::convert_curves(curves, selection, dst_type, {});
|
||||
geometry::ConvertCurvesOptions options;
|
||||
options.convert_bezier_handles_to_poly_points = use_handles;
|
||||
options.convert_bezier_handles_to_catmull_rom_points = use_handles;
|
||||
options.keep_bezier_shape_as_nurbs = use_handles;
|
||||
options.keep_catmull_rom_shape_as_nurbs = use_handles;
|
||||
|
||||
curves = geometry::convert_curves(curves, selection, dst_type, {}, options);
|
||||
|
||||
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
|
||||
@@ -1426,6 +1433,12 @@ static void CURVES_OT_curve_type_set(wmOperatorType *ot)
|
||||
|
||||
ot->prop = RNA_def_enum(
|
||||
ot->srna, "type", rna_enum_curves_type_items, CURVE_TYPE_POLY, "Type", "Curve type");
|
||||
|
||||
RNA_def_boolean(ot->srna,
|
||||
"use_handles",
|
||||
false,
|
||||
"Handles",
|
||||
"Take handle information into account in the conversion");
|
||||
}
|
||||
|
||||
namespace switch_direction {
|
||||
|
||||
Reference in New Issue
Block a user