Blender  V3.3
rna_curve_api.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include <stdio.h>
9 #include <stdlib.h>
10 
11 #include "RNA_define.h"
12 
13 #include "BLI_sys_types.h"
14 
15 #include "BLI_utildefines.h"
16 
17 #include "BKE_curve.h"
18 
19 #include "rna_internal.h" /* own include */
20 
21 #ifdef RNA_RUNTIME
22 static void rna_Curve_transform(Curve *cu, float mat[16], bool shape_keys)
23 {
24  BKE_curve_transform(cu, (const float(*)[4])mat, shape_keys, true);
25 
26  DEG_id_tag_update(&cu->id, 0);
27 }
28 
29 static void rna_Curve_update_gpu_tag(Curve *cu)
30 {
32 }
33 
34 static float rna_Nurb_calc_length(Nurb *nu, int resolution_u)
35 {
36  return BKE_nurb_calc_length(nu, resolution_u);
37 }
38 
39 static void rna_Nurb_valid_message(Nurb *nu, int direction, int *result_len, const char **r_result)
40 {
41  const bool is_surf = nu->pntsv > 1;
42  const short type = nu->type;
43 
44  int pnts;
45  short order, flag;
46  if (direction == 0) {
47  pnts = nu->pntsu;
48  order = nu->orderu;
49  flag = nu->flagu;
50  }
51  else {
52  pnts = nu->pntsv;
53  order = nu->orderv;
54  flag = nu->flagv;
55  }
56 
57  char buf[64];
58  if (BKE_nurb_valid_message(pnts, order, flag, type, is_surf, direction, buf, sizeof(buf))) {
59  const int buf_len = strlen(buf);
60  *r_result = BLI_strdupn(buf, buf_len);
61  *result_len = buf_len;
62  }
63  else {
64  *r_result = NULL;
65  *result_len = 0;
66  }
67 }
68 
69 #else
70 
72 {
73  FunctionRNA *func;
74  PropertyRNA *parm;
75 
76  func = RNA_def_function(srna, "transform", "rna_Curve_transform");
77  RNA_def_function_ui_description(func, "Transform curve by a matrix");
78  parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
80  RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys");
81 
82  func = RNA_def_function(srna, "validate_material_indices", "BKE_curve_material_index_validate");
84  func,
85  "Validate material indices of splines or letters, return True when the curve "
86  "has had invalid indices corrected (to default 0)");
87  parm = RNA_def_boolean(func, "result", 0, "Result", "");
88  RNA_def_function_return(func, parm);
89 
90  RNA_def_function(srna, "update_gpu_tag", "rna_Curve_update_gpu_tag");
91 }
92 
94 {
95  FunctionRNA *func;
96  PropertyRNA *parm;
97 
98  func = RNA_def_function(srna, "calc_length", "rna_Nurb_calc_length");
99  RNA_def_function_ui_description(func, "Calculate spline length");
100  RNA_def_int(func,
101  "resolution",
102  0,
103  0,
104  1024,
105  "Resolution",
106  "Spline resolution to be used, 0 defaults to the resolution_u",
107  0,
108  64);
109  parm = RNA_def_float_distance(func,
110  "length",
111  0.0f,
112  0.0f,
113  FLT_MAX,
114  "Length",
115  "Length of the polygonaly approximated spline",
116  0.0f,
117  FLT_MAX);
118  RNA_def_function_return(func, parm);
119 
120  func = RNA_def_function(srna, "valid_message", "rna_Nurb_valid_message");
121  RNA_def_function_ui_description(func, "Return the message");
122  parm = RNA_def_int(
123  func, "direction", 0, 0, 1, "Direction", "The direction where 0-1 maps to U-V", 0, 1);
125  /* return value */
126  parm = RNA_def_string(func,
127  "result",
128  "nothing",
129  64,
130  "Return value",
131  "The message or an empty string when there is no error");
132 
135 }
136 
137 #endif
@ BKE_CURVE_BATCH_DIRTY_ALL
Definition: BKE_curve.h:366
void BKE_curve_transform(struct Curve *cu, const float mat[4][4], bool do_keys, bool do_props)
Definition: curve.cc:5247
float BKE_nurb_calc_length(const struct Nurb *nu, int resolution)
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:4744
void BKE_curve_batch_cache_dirty_tag(struct Curve *cu, int mode)
Definition: curve.cc:5524
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:33
void DEG_id_tag_update(struct ID *id, int flag)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ PARM_OUTPUT
Definition: RNA_types.h:353
@ PROP_DYNAMIC
Definition: RNA_types.h:290
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
void RNA_api_curve_nurb(StructRNA *srna)
Definition: rna_curve_api.c:93
void RNA_api_curve(StructRNA *srna)
Definition: rna_curve_api.c:71
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
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:3954
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:4052
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
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:3597
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
short flagu
short orderu
short orderv
short type
short flagv