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:
authorCampbell Barton <campbell@blender.org>2022-03-11 07:18:14 +0300
committerCampbell Barton <campbell@blender.org>2022-03-11 07:21:30 +0300
commitd2222d5b2cac203f4ddaae5c99b96701587231e7 (patch)
tree014e61e54c579bda925b7843cb6460a20b30a611 /source/blender/makesrna/intern/rna_curve_api.c
parent8cc5483331d1a3d5c6eba055ae303788ba843526 (diff)
RNA: use a function to access the nurbs error message
It makes more sense to use a function in this case as this creates an error message which is not data associated with the NURBS curve.
Diffstat (limited to 'source/blender/makesrna/intern/rna_curve_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_curve_api.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c
index d0086a425a2..72c1182ada1 100644
--- a/source/blender/makesrna/intern/rna_curve_api.c
+++ b/source/blender/makesrna/intern/rna_curve_api.c
@@ -36,6 +36,39 @@ static float rna_Nurb_calc_length(Nurb *nu, int resolution_u)
return BKE_nurb_calc_length(nu, resolution_u);
}
+static void rna_Nurb_valid_message(Nurb *nu, int direction, int *result_len, const char **r_result)
+{
+ const bool is_surf = nu->pntsv > 1;
+ const short type = nu->type;
+
+ int pnts;
+ short order, flag;
+ const char *dir;
+ if (direction) {
+ pnts = nu->pntsu;
+ order = nu->orderu;
+ flag = nu->flagu;
+ dir = "U";
+ }
+ else {
+ pnts = nu->pntsv;
+ order = nu->orderv;
+ flag = nu->flagv;
+ dir = "V";
+ }
+
+ char buf[64];
+ if (BKE_nurb_valid_message(pnts, order, flag, type, is_surf, dir, buf, sizeof(buf))) {
+ const int buf_len = strlen(buf);
+ *r_result = BLI_strdupn(buf, buf_len);
+ *result_len = buf_len;
+ }
+ else {
+ *r_result = NULL;
+ *result_len = 0;
+ }
+}
+
#else
void RNA_api_curve(StructRNA *srna)
@@ -86,6 +119,22 @@ void RNA_api_curve_nurb(StructRNA *srna)
0.0f,
FLT_MAX);
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "valid_message", "rna_Nurb_valid_message");
+ RNA_def_function_ui_description(func, "Return the message");
+ parm = RNA_def_int(
+ func, "direction", 0, 0, 1, "Direction", "The direction where 0-1 maps to U-V", 0, 1);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return value */
+ parm = RNA_def_string(func,
+ "result",
+ "nothing",
+ 64,
+ "Return value",
+ "The message or an empty string when there is no error");
+
+ RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_OUTPUT);
+ RNA_def_property_clear_flag(parm, PROP_NEVER_NULL);
}
#endif