Blender V4.3
rna_curve_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdio>
10#include <cstdlib>
11
12#include "RNA_define.hh"
13
14#include "BLI_sys_types.h"
15
16#include "BLI_utildefines.h"
17
18#include "BKE_curve.hh"
19
20#include "rna_internal.hh" /* own include */
21
22#ifdef RNA_RUNTIME
23static void rna_Curve_transform(Curve *cu, const float mat[16], bool shape_keys)
24{
25 BKE_curve_transform(cu, (const float(*)[4])mat, shape_keys, true);
26
27 DEG_id_tag_update(&cu->id, 0);
28}
29
30static void rna_Curve_update_gpu_tag(Curve *cu)
31{
33}
34
35static float rna_Nurb_calc_length(Nurb *nu, int resolution_u)
36{
37 return BKE_nurb_calc_length(nu, resolution_u);
38}
39
40static void rna_Nurb_valid_message(Nurb *nu, int direction, const char **r_result, int *result_len)
41{
42 const bool is_surf = nu->pntsv > 1;
43 const short type = nu->type;
44
45 int pnts;
46 short order, flag;
47 if (direction == 0) {
48 pnts = nu->pntsu;
49 order = nu->orderu;
50 flag = nu->flagu;
51 }
52 else {
53 pnts = nu->pntsv;
54 order = nu->orderv;
55 flag = nu->flagv;
56 }
57
58 char buf[64];
59 if (BKE_nurb_valid_message(pnts, order, flag, type, is_surf, direction, buf, sizeof(buf))) {
60 const int buf_len = strlen(buf);
61 *r_result = BLI_strdupn(buf, buf_len);
62 *result_len = buf_len;
63 }
64 else {
65 *r_result = nullptr;
66 *result_len = 0;
67 }
68}
69
70#else
71
73{
74 FunctionRNA *func;
75 PropertyRNA *parm;
76
77 func = RNA_def_function(srna, "transform", "rna_Curve_transform");
78 RNA_def_function_ui_description(func, "Transform curve by a matrix");
79 parm = RNA_def_float_matrix(func, "matrix", 4, 4, nullptr, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
81 RNA_def_boolean(func, "shape_keys", false, "", "Transform Shape Keys");
82
83 func = RNA_def_function(srna, "validate_material_indices", "BKE_curve_material_index_validate");
85 func,
86 "Validate material indices of splines or letters, return True when the curve "
87 "has had invalid indices corrected (to default 0)");
88 parm = RNA_def_boolean(func, "result", false, "Result", "");
89 RNA_def_function_return(func, parm);
90
91 RNA_def_function(srna, "update_gpu_tag", "rna_Curve_update_gpu_tag");
92}
93
95{
96 FunctionRNA *func;
97 PropertyRNA *parm;
98
99 func = RNA_def_function(srna, "calc_length", "rna_Nurb_calc_length");
100 RNA_def_function_ui_description(func, "Calculate spline length");
101 RNA_def_int(func,
102 "resolution",
103 0,
104 0,
105 1024,
106 "Resolution",
107 "Spline resolution to be used, 0 defaults to the resolution_u",
108 0,
109 64);
110 parm = RNA_def_float_distance(func,
111 "length",
112 0.0f,
113 0.0f,
114 FLT_MAX,
115 "Length",
116 "Length of the polygonaly approximated spline",
117 0.0f,
118 FLT_MAX);
119 RNA_def_function_return(func, parm);
120
121 func = RNA_def_function(srna, "valid_message", "rna_Nurb_valid_message");
122 RNA_def_function_ui_description(func, "Return the message");
123 parm = RNA_def_int(
124 func, "direction", 0, 0, 1, "Direction", "The direction where 0-1 maps to U-V", 0, 1);
126 /* return value */
127 parm = RNA_def_string(func,
128 "result",
129 "nothing",
130 64,
131 "Return value",
132 "The message or an empty string when there is no error");
133
136}
137
138#endif
void BKE_curve_batch_cache_dirty_tag(Curve *cu, int mode)
Definition curve.cc:5511
float BKE_nurb_calc_length(const Nurb *nu, int resolution)
Definition curve.cc:761
@ BKE_CURVE_BATCH_DIRTY_ALL
Definition BKE_curve.hh:375
void BKE_curve_transform(Curve *cu, const float mat[4][4], bool do_keys, bool do_props)
Definition curve.cc:5239
bool BKE_nurb_valid_message(int pnts, short order, short flag, short type, bool is_surf, int dir, char *message_dst, size_t maxncpy)
Definition curve.cc:4729
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition string.c:29
void DEG_id_tag_update(ID *id, unsigned int flags)
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ PARM_OUTPUT
Definition RNA_types.hh:398
PropertyFlag
Definition RNA_types.hh:201
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
void RNA_api_curve_nurb(StructRNA *srna)
void RNA_api_curve(StructRNA *srna)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_def_float_distance(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, const int rows, const int columns, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
#define FLT_MAX
Definition stdcycles.h:14
short flagu
short orderu
short orderv
short type
short flagv
uint8_t flag
Definition wm_window.cc:138