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 <ideasman42@gmail.com>2018-08-20 04:10:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-20 04:23:40 +0300
commit537bf6af0cd80ac0ef0f55f7ab68540a09db8f37 (patch)
tree21d9e429abb7eefd0ce47ae984e6d69eb809b029 /source/blender/makesrna/intern/rna_curve_api.c
parent2349273ade5b4c0362dce338462f02fcfdbfaebb (diff)
RNA: Spline.calc_length() utility function
D1810 by @Matpi w/ edits
Diffstat (limited to 'source/blender/makesrna/intern/rna_curve_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_curve_api.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c
index 695f1f75c16..d83a843c5c1 100644
--- a/source/blender/makesrna/intern/rna_curve_api.c
+++ b/source/blender/makesrna/intern/rna_curve_api.c
@@ -49,6 +49,11 @@ static void rna_Curve_transform(Curve *cu, float *mat, bool shape_keys)
DAG_id_tag_update(&cu->id, 0);
}
+static float rna_Nurb_calc_length(Nurb *nu, int resolution_u)
+{
+ return BKE_nurb_calc_length(nu, resolution_u);
+}
+
#else
void RNA_api_curve(StructRNA *srna)
@@ -69,4 +74,20 @@ void RNA_api_curve(StructRNA *srna)
RNA_def_function_return(func, parm);
}
+void RNA_api_curve_nurb(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ func = RNA_def_function(srna, "calc_length", "rna_Nurb_calc_length");
+ RNA_def_function_ui_description(func, "Calculate spline length");
+ RNA_def_int(
+ func, "resolution", 0, 0, 1024, "Resolution",
+ "Spline resolution to be used, 0 defaults to the resolution_u", 0, 64);
+ parm = RNA_def_float_distance(
+ func, "length", 0.0f, 0.0f, FLT_MAX, "Length",
+ "Length of the polygonaly approximated spline", 0.0f, FLT_MAX);
+ RNA_def_function_return(func, parm);
+}
+
#endif