1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * The Original Code is Copyright (C) 2009 Blender Foundation.
17 * All rights reserved.
18 */
19
20 /** \file
21 * \ingroup RNA
22 */
23
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include "RNA_define.h"
28
29 #include "BLI_sys_types.h"
30
31 #include "BLI_utildefines.h"
32
33 #include "BKE_curve.h"
34
35 #include "rna_internal.h" /* own include */
36
37 #ifdef RNA_RUNTIME
rna_Curve_transform(Curve * cu,float * mat,bool shape_keys)38 static void rna_Curve_transform(Curve *cu, float *mat, bool shape_keys)
39 {
40 BKE_curve_transform(cu, (const float(*)[4])mat, shape_keys, true);
41
42 DEG_id_tag_update(&cu->id, 0);
43 }
44
rna_Curve_update_gpu_tag(Curve * cu)45 static void rna_Curve_update_gpu_tag(Curve *cu)
46 {
47 BKE_curve_batch_cache_dirty_tag(cu, BKE_CURVE_BATCH_DIRTY_ALL);
48 }
49
rna_Nurb_calc_length(Nurb * nu,int resolution_u)50 static float rna_Nurb_calc_length(Nurb *nu, int resolution_u)
51 {
52 return BKE_nurb_calc_length(nu, resolution_u);
53 }
54
55 #else
56
RNA_api_curve(StructRNA * srna)57 void RNA_api_curve(StructRNA *srna)
58 {
59 FunctionRNA *func;
60 PropertyRNA *parm;
61
62 func = RNA_def_function(srna, "transform", "rna_Curve_transform");
63 RNA_def_function_ui_description(func, "Transform curve by a matrix");
64 parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
65 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
66 RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys");
67
68 func = RNA_def_function(srna, "validate_material_indices", "BKE_curve_material_index_validate");
69 RNA_def_function_ui_description(
70 func,
71 "Validate material indices of splines or letters, return True when the curve "
72 "has had invalid indices corrected (to default 0)");
73 parm = RNA_def_boolean(func, "result", 0, "Result", "");
74 RNA_def_function_return(func, parm);
75
76 RNA_def_function(srna, "update_gpu_tag", "rna_Curve_update_gpu_tag");
77 }
78
RNA_api_curve_nurb(StructRNA * srna)79 void RNA_api_curve_nurb(StructRNA *srna)
80 {
81 FunctionRNA *func;
82 PropertyRNA *parm;
83
84 func = RNA_def_function(srna, "calc_length", "rna_Nurb_calc_length");
85 RNA_def_function_ui_description(func, "Calculate spline length");
86 RNA_def_int(func,
87 "resolution",
88 0,
89 0,
90 1024,
91 "Resolution",
92 "Spline resolution to be used, 0 defaults to the resolution_u",
93 0,
94 64);
95 parm = RNA_def_float_distance(func,
96 "length",
97 0.0f,
98 0.0f,
99 FLT_MAX,
100 "Length",
101 "Length of the polygonaly approximated spline",
102 0.0f,
103 FLT_MAX);
104 RNA_def_function_return(func, parm);
105 }
106
107 #endif
108