Blender  V2.93
rna_curve_api.c
Go to the documentation of this file.
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 
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
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 
45 static void rna_Curve_update_gpu_tag(Curve *cu)
46 {
48 }
49 
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 
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);
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");
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 
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
@ BKE_CURVE_BATCH_DIRTY_ALL
Definition: BKE_curve.h:286
void BKE_curve_transform(struct Curve *cu, const float mat[4][4], const bool do_keys, const bool do_props)
Definition: curve.c:5338
float BKE_nurb_calc_length(const struct Nurb *nu, int resolution)
void BKE_curve_batch_cache_dirty_tag(struct Curve *cu, int mode)
Definition: curve.c:5618
void DEG_id_tag_update(struct ID *id, int flag)
@ PARM_REQUIRED
Definition: RNA_types.h:337
void RNA_api_curve_nurb(StructRNA *srna)
Definition: rna_curve_api.c:79
void RNA_api_curve(StructRNA *srna)
Definition: rna_curve_api.c:57
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
PropertyRNA * RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int rows, int columns, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3943
PropertyRNA * RNA_def_float_distance(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4041
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547