diff options
author | Laurynas Duburas <laurynas> | 2022-03-11 03:34:27 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-11 03:34:27 +0300 |
commit | 0602852860dda7dfc0ea20c72e03b7f96c981f1a (patch) | |
tree | f6679aba0cfdfcda8e0e244549eb739e025953e0 /source/blender/makesrna | |
parent | 27fb63381e9b0963976237c58ca2cfc9bc5ddfd8 (diff) |
Curve: Improve NURBS knot generation modes
This patch enables all 8 combinations of Nurbs modes: Cyclic,
Bezier and Endpoint. Also removes restriction on Bezier Nurbs order.
The most significant changes are mode combinations bringing new
meaning. In D13891 is a scheme showing NURBS with same control
points in a modes, and also further description of each possible case.
Differential Revision: https://developer.blender.org/D13891
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 891de95a2a2..2c1ed483de6 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -562,6 +562,38 @@ static void rna_Curve_offset_set(PointerRNA *ptr, float value) cu->offset = 1.0f + value; } +static int rna_Nurb_valid_message_u_length(PointerRNA *ptr) +{ + char buff[64]; + Nurb *nu = (Nurb *)ptr->data; + BKE_nurb_valid_message( + nu->pntsu, nu->orderu, nu->flagu, nu->type, nu->pntsv > 1, "U", buff, sizeof(buff)); + return strlen(buff); +} + +static void rna_Nurb_valid_message_u(PointerRNA *ptr, char *value) +{ + Nurb *nu = (Nurb *)ptr->data; + BKE_nurb_valid_message( + nu->pntsu, nu->orderu, nu->flagu, nu->type, nu->pntsv > 1, "U", value, 64); +} + +static int rna_Nurb_valid_message_v_length(PointerRNA *ptr) +{ + char buff[64]; + Nurb *nu = (Nurb *)ptr->data; + BKE_nurb_valid_message( + nu->pntsv, nu->orderv, nu->flagv, nu->type, nu->pntsv > 1, "V", buff, sizeof(buff)); + return strlen(buff); +} + +static void rna_Nurb_valid_message_v(PointerRNA *ptr, char *value) +{ + Nurb *nu = (Nurb *)ptr->data; + BKE_nurb_valid_message( + nu->pntsv, nu->orderv, nu->flagv, nu->type, nu->pntsv > 1, "V", value, 64); +} + static int rna_Curve_body_length(PointerRNA *ptr); static void rna_Curve_body_get(PointerRNA *ptr, char *value) { @@ -1995,24 +2027,20 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction"); RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_v"); - /* NOTE: endpoint and bezier flags should never be on at the same time! */ prop = RNA_def_property(srna, "use_endpoint_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_ENDPOINT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text( prop, "Endpoint U", - "Make this nurbs curve or surface meet the endpoints in the U direction " - "(Cyclic U must be disabled)"); + "Make this nurbs curve or surface meet the endpoints in the U direction"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u"); prop = RNA_def_property(srna, "use_endpoint_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_ENDPOINT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, - "Endpoint V", - "Make this nurbs surface meet the endpoints in the V direction " - "(Cyclic V must be disabled)"); + RNA_def_property_ui_text( + prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction "); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v"); prop = RNA_def_property(srna, "use_bezier_u", PROP_BOOLEAN, PROP_NONE); @@ -2021,19 +2049,28 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Bezier U", - "Make this nurbs curve or surface act like a Bezier spline in the U direction " - "(Order U must be 3 or 4, Cyclic U must be disabled)"); + "Make this nurbs curve or surface act like a Bezier spline in the U direction"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u"); prop = RNA_def_property(srna, "use_bezier_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_BEZIER); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, - "Bezier V", - "Make this nurbs surface act like a Bezier spline in the V direction " - "(Order V must be 3 or 4, Cyclic V must be disabled)"); + RNA_def_property_ui_text( + prop, "Bezier V", "Make this nurbs surface act like a Bezier spline in the V direction"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v"); + prop = RNA_def_property(srna, "valid_message_u", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs( + prop, "rna_Nurb_valid_message_u", "rna_Nurb_valid_message_u_length", NULL); + RNA_def_property_ui_text(prop, "Valid U", "Validation message for NURBS definition in U"); + + prop = RNA_def_property(srna, "valid_message_v", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs( + prop, "rna_Nurb_valid_message_v", "rna_Nurb_valid_message_v_length", NULL); + RNA_def_property_ui_text(prop, "Valid V", "Validation message for NURBS definition in V"); + prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve"); |