Blender V5.0
rna_key.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_key_types.h"
12#include "DNA_scene_types.h"
13
14#include "BLI_math_rotation.h"
15
16#include "RNA_define.hh"
17#include "RNA_enum_types.hh"
18
19#include "WM_types.hh"
20
21#include "rna_internal.hh"
22
24 {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
25 {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
26 {KEY_CATMULL_ROM, "KEY_CATMULL_ROM", 0, "Catmull-Rom", ""},
27 {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
28 {0, nullptr, 0, nullptr, nullptr},
29};
30
31#ifdef RNA_RUNTIME
32
33# include <algorithm>
34# include <cstddef>
35# include <fmt/format.h>
36
37# include "BLT_translation.hh"
38
39# include "DNA_curve_types.h"
40# include "DNA_lattice_types.h"
41# include "DNA_mesh_types.h"
42# include "DNA_object_types.h"
43
44# include "BLI_listbase.h"
45# include "BLI_string.h"
46# include "BLI_string_utf8.h"
47# include "BLI_string_utils.hh"
48
49# include "BKE_animsys.h"
50# include "BKE_key.hh"
51# include "BKE_main.hh"
52
53# include "DEG_depsgraph.hh"
54
55# include "WM_api.hh"
56# include "WM_types.hh"
57
58static Key *rna_ShapeKey_find_key(ID *id)
59{
60 switch (GS(id->name)) {
61 case ID_CU_LEGACY:
62 return ((Curve *)id)->key;
63 case ID_KE:
64 return (Key *)id;
65 case ID_LT:
66 return ((Lattice *)id)->key;
67 case ID_ME:
68 return ((Mesh *)id)->key;
69 case ID_OB:
70 return BKE_key_from_object((Object *)id);
71 default:
72 return nullptr;
73 }
74}
75
76static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
77{
78 KeyBlock *kb = static_cast<KeyBlock *>(ptr->data);
79 char oldname[sizeof(kb->name)];
80
81 /* make a copy of the old name first */
82 STRNCPY(oldname, kb->name);
83
84 /* copy the new name into the name slot */
85 STRNCPY_UTF8(kb->name, value);
86
87 /* make sure the name is truly unique */
88 if (ptr->owner_id) {
89 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
91 kb,
93 '.',
95 sizeof(kb->name));
96 }
97
98 /* fix all the animation data which may link to this */
99 BKE_animdata_fix_paths_rename_all(nullptr, "key_blocks", oldname, kb->name);
100}
101
102static float rna_ShapeKey_frame_get(PointerRNA *ptr)
103{
104 KeyBlock *kb = (KeyBlock *)ptr->data;
105 return kb->pos * 100.0f; /* Because pos is ctime/100... */
106}
107
108static void rna_ShapeKey_value_set(PointerRNA *ptr, float value)
109{
110 KeyBlock *data = (KeyBlock *)ptr->data;
111 CLAMP(value, data->slidermin, data->slidermax);
112 data->curval = value;
113}
114
115static void rna_ShapeKey_value_range(
116 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
117{
118 KeyBlock *data = (KeyBlock *)ptr->data;
119
120 *min = data->slidermin;
121 *max = data->slidermax;
122}
123
124/* epsilon for how close one end of shapekey range can get to the other */
125# define SHAPEKEY_SLIDER_TOL 0.001f
126
127static void rna_ShapeKey_slider_min_range(
128 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
129{
130 KeyBlock *data = (KeyBlock *)ptr->data;
131
132 *min = -10.0f;
133 *max = data->slidermax - SHAPEKEY_SLIDER_TOL;
134}
135
136static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value)
137{
138 KeyBlock *data = (KeyBlock *)ptr->data;
139 float min, max, softmin, softmax;
140
141 rna_ShapeKey_slider_min_range(ptr, &min, &max, &softmin, &softmax);
142 CLAMP(value, min, max);
143 data->slidermin = value;
144}
145
146static void rna_ShapeKey_slider_max_range(
147 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
148{
149 KeyBlock *data = (KeyBlock *)ptr->data;
150
151 *min = data->slidermin + SHAPEKEY_SLIDER_TOL;
152 *max = 10.0f;
153}
154
155static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value)
156{
157 KeyBlock *data = (KeyBlock *)ptr->data;
158 float min, max, softmin, softmax;
159
160 rna_ShapeKey_slider_max_range(ptr, &min, &max, &softmin, &softmax);
161 CLAMP(value, min, max);
162 data->slidermax = value;
163}
164
165# undef SHAPEKEY_SLIDER_TOL
166
167/* ***** Normals accessors for shape-keys. ***** */
168/* NOTE: with this we may recompute several times the same data, should we want to access verts,
169 * then faces, then loops normals... However,
170 * such case looks rather unlikely - and not worth adding some kind of caching in key-blocks.
171 */
172
173static Mesh *rna_KeyBlock_normals_get_mesh(const PointerRNA *ptr, ID *id)
174{
175 Key *key = rna_ShapeKey_find_key((id == nullptr && ptr != nullptr) ? ptr->owner_id : id);
176 id = key ? key->from : nullptr;
177
178 if (id != nullptr) {
179 switch (GS(id->name)) {
180 case ID_ME:
181 return (Mesh *)id;
182 case ID_OB: {
183 Object *ob = (Object *)id;
184 if (ob->type == OB_MESH) {
185 return static_cast<Mesh *>(ob->data);
186 }
187 }
188 default:
189 break;
190 }
191 }
192
193 return nullptr;
194}
195
196static int rna_KeyBlock_normals_vert_len(const PointerRNA *ptr,
198{
199 const Mesh *mesh = rna_KeyBlock_normals_get_mesh(ptr, nullptr);
200
201 length[0] = mesh ? mesh->verts_num : 0;
202 length[1] = 3;
203
204 return (length[0] * length[1]);
205}
206
207static void rna_KeyBlock_normals_vert_calc(ID *id,
208 KeyBlock *data,
209 float **normals,
210 int *normals_num)
211{
212 Mesh *mesh = rna_KeyBlock_normals_get_mesh(nullptr, id);
213
214 *normals_num = (mesh ? mesh->verts_num : 0) * 3;
215
216 if (ELEM(nullptr, mesh, data) || (mesh->verts_num == 0)) {
217 *normals = nullptr;
218 return;
219 }
220
221 *normals = MEM_malloc_arrayN<float>(size_t(*normals_num), __func__);
222
223 BKE_keyblock_mesh_calc_normals(data, mesh, (float (*)[3])(*normals), nullptr, nullptr);
224}
225
226static int rna_KeyBlock_normals_poly_len(const PointerRNA *ptr,
228{
229 const Mesh *mesh = rna_KeyBlock_normals_get_mesh(ptr, nullptr);
230
231 length[0] = mesh ? mesh->faces_num : 0;
232 length[1] = 3;
233
234 return (length[0] * length[1]);
235}
236
237static void rna_KeyBlock_normals_poly_calc(ID *id,
238 KeyBlock *data,
239 float **normals,
240 int *normals_num)
241{
242 Mesh *mesh = rna_KeyBlock_normals_get_mesh(nullptr, id);
243
244 *normals_num = (mesh ? mesh->faces_num : 0) * 3;
245
246 if (ELEM(nullptr, mesh, data) || (mesh->faces_num == 0)) {
247 *normals = nullptr;
248 return;
249 }
250
251 *normals = MEM_malloc_arrayN<float>(size_t(*normals_num), __func__);
252
253 BKE_keyblock_mesh_calc_normals(data, mesh, nullptr, (float (*)[3])(*normals), nullptr);
254}
255
256static int rna_KeyBlock_normals_loop_len(const PointerRNA *ptr,
258{
259 const Mesh *mesh = rna_KeyBlock_normals_get_mesh(ptr, nullptr);
260
261 length[0] = mesh ? mesh->corners_num : 0;
262 length[1] = 3;
263
264 return (length[0] * length[1]);
265}
266
267static void rna_KeyBlock_normals_loop_calc(ID *id,
268 KeyBlock *data,
269 float **normals,
270 int *normals_num)
271{
272 Mesh *mesh = rna_KeyBlock_normals_get_mesh(nullptr, id);
273
274 *normals_num = (mesh ? mesh->corners_num : 0) * 3;
275
276 if (ELEM(nullptr, mesh, data) || (mesh->corners_num == 0)) {
277 *normals = nullptr;
278 return;
279 }
280
281 *normals = MEM_malloc_arrayN<float>(size_t(*normals_num), __func__);
282
283 BKE_keyblock_mesh_calc_normals(data, mesh, nullptr, nullptr, (float (*)[3])(*normals));
284}
285
287{
288 Key *key = rna_ShapeKey_find_key(id);
289 KeyBlock *kb = nullptr;
290
291 if (key && value < key->totkey) {
292 kb = static_cast<KeyBlock *>(BLI_findlink(&key->block, value));
293 }
294
295 PointerRNA ptr = RNA_pointer_create_discrete(id, &RNA_ShapeKey, kb);
296 return ptr;
297}
298
299int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
300{
301 Key *key = rna_ShapeKey_find_key(id);
302
303 if (key) {
304 int a = BLI_findindex(&key->block, value.data);
305 if (a != -1) {
306 return a;
307 }
308 }
309
310 return current;
311}
312
313static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
314{
315 KeyBlock *kb = (KeyBlock *)ptr->data;
316
317 return rna_object_shapekey_index_get(ptr->owner_id, kb->relative);
318}
319
320static void rna_ShapeKey_relative_key_set(PointerRNA *ptr,
321 PointerRNA value,
322 ReportList * /*reports*/)
323{
324 KeyBlock *kb = (KeyBlock *)ptr->data;
325
326 kb->relative = rna_object_shapekey_index_set(ptr->owner_id, value, kb->relative);
327}
328
329static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)
330{
331 float *vec = (float *)ptr->data;
332
333 values[0] = vec[0];
334 values[1] = vec[1];
335 values[2] = vec[2];
336}
337
338static void rna_ShapeKeyPoint_co_set(PointerRNA *ptr, const float *values)
339{
340 float *vec = (float *)ptr->data;
341
342 vec[0] = values[0];
343 vec[1] = values[1];
344 vec[2] = values[2];
345}
346
347static float rna_ShapeKeyCurvePoint_tilt_get(PointerRNA *ptr)
348{
349 float *vec = (float *)ptr->data;
350 return vec[3];
351}
352
353static void rna_ShapeKeyCurvePoint_tilt_set(PointerRNA *ptr, float value)
354{
355 float *vec = (float *)ptr->data;
356 vec[3] = value;
357}
358
359static float rna_ShapeKeyCurvePoint_radius_get(PointerRNA *ptr)
360{
361 float *vec = (float *)ptr->data;
362 return vec[4];
363}
364
365static void rna_ShapeKeyCurvePoint_radius_set(PointerRNA *ptr, float value)
366{
367 float *vec = (float *)ptr->data;
368 CLAMP_MIN(value, 0.0f);
369 vec[4] = value;
370}
371
372static void rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, float *values)
373{
374 float *vec = (float *)ptr->data;
375
376 values[0] = vec[0 + 3];
377 values[1] = vec[1 + 3];
378 values[2] = vec[2 + 3];
379}
380
381static void rna_ShapeKeyBezierPoint_co_set(PointerRNA *ptr, const float *values)
382{
383 float *vec = (float *)ptr->data;
384
385 vec[0 + 3] = values[0];
386 vec[1 + 3] = values[1];
387 vec[2 + 3] = values[2];
388}
389
390static void rna_ShapeKeyBezierPoint_handle_1_co_get(PointerRNA *ptr, float *values)
391{
392 float *vec = (float *)ptr->data;
393
394 values[0] = vec[0];
395 values[1] = vec[1];
396 values[2] = vec[2];
397}
398
399static void rna_ShapeKeyBezierPoint_handle_1_co_set(PointerRNA *ptr, const float *values)
400{
401 float *vec = (float *)ptr->data;
402
403 vec[0] = values[0];
404 vec[1] = values[1];
405 vec[2] = values[2];
406}
407
408static void rna_ShapeKeyBezierPoint_handle_2_co_get(PointerRNA *ptr, float *values)
409{
410 float *vec = (float *)ptr->data;
411
412 values[0] = vec[6 + 0];
413 values[1] = vec[6 + 1];
414 values[2] = vec[6 + 2];
415}
416
417static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, const float *values)
418{
419 float *vec = (float *)ptr->data;
420
421 vec[6 + 0] = values[0];
422 vec[6 + 1] = values[1];
423 vec[6 + 2] = values[2];
424}
425
426static float rna_ShapeKeyBezierPoint_tilt_get(PointerRNA *ptr)
427{
428 float *vec = (float *)ptr->data;
429 return vec[9];
430}
431
432static void rna_ShapeKeyBezierPoint_tilt_set(PointerRNA *ptr, float value)
433{
434 float *vec = (float *)ptr->data;
435 vec[9] = value;
436}
437
438static float rna_ShapeKeyBezierPoint_radius_get(PointerRNA *ptr)
439{
440 float *vec = (float *)ptr->data;
441 return vec[10];
442}
443
444static void rna_ShapeKeyBezierPoint_radius_set(PointerRNA *ptr, float value)
445{
446 float *vec = (float *)ptr->data;
447 CLAMP_MIN(value, 0.0f);
448 vec[10] = value;
449}
450
451/* Indexing and iteration of Curve points through sub-curves. */
452struct NurbInfo {
453 Nurb *nu;
454 int nurb_size, nurb_elem_step;
455
456 /* Current index in the Nurb */
457 int nurb_index;
458
459 /* Total index as item and element. */
460 int item_index, elem_index;
461};
462
463StructRNA *rna_ShapeKey_curve_point_type(Nurb *nu)
464{
465 if (nu->bezt) {
466 return &RNA_ShapeKeyBezierPoint;
467 }
468 return &RNA_ShapeKeyCurvePoint;
469}
470
471static void rna_ShapeKey_NurbInfo_init(NurbInfo *r_info, Nurb *nu)
472{
473 r_info->nu = nu;
474
475 if (nu->bezt) {
476 r_info->nurb_size = nu->pntsu;
477 r_info->nurb_elem_step = KEYELEM_ELEM_LEN_BEZTRIPLE;
478 }
479 else {
480 r_info->nurb_size = nu->pntsu * nu->pntsv;
481 r_info->nurb_elem_step = KEYELEM_ELEM_LEN_BPOINT;
482 }
483}
484
485static void rna_ShapeKey_NurbInfo_step(NurbInfo *r_info,
486 Nurb *nu,
487 int *p_raw_index,
488 bool input_elem)
489{
490 rna_ShapeKey_NurbInfo_init(r_info, nu);
491
492 if (input_elem) {
493 r_info->nurb_index = std::min(r_info->nurb_size, *p_raw_index / r_info->nurb_elem_step);
494 *p_raw_index -= r_info->nurb_size * r_info->nurb_elem_step;
495 }
496 else {
497 r_info->nurb_index = std::min(r_info->nurb_size, *p_raw_index);
498 *p_raw_index -= r_info->nurb_size;
499 }
500
501 r_info->item_index += r_info->nurb_index;
502 r_info->elem_index += r_info->nurb_index * r_info->nurb_elem_step;
503}
504
505static void rna_ShapeKey_NurbInfo_find_index(Key *key,
506 int raw_index,
507 bool input_elem,
508 NurbInfo *r_info)
509{
510 Curve *cu = (Curve *)key->from;
511
512 memset(r_info, 0, sizeof(*r_info));
513
514 for (Nurb *nu = static_cast<Nurb *>(cu->nurb.first); nu && raw_index >= 0; nu = nu->next) {
515 rna_ShapeKey_NurbInfo_step(r_info, nu, &raw_index, input_elem);
516 }
517}
518
519static int rna_ShapeKey_curve_find_index(Key *key, int elem_index)
520{
521 NurbInfo info;
522 rna_ShapeKey_NurbInfo_find_index(key, elem_index, true, &info);
523 return info.item_index;
524}
525
526struct ShapeKeyCurvePoint {
527 StructRNA *type;
528 void *data;
529};
530
531/* Build a mapping array for Curve objects with mixed sub-curve types. */
532static void rna_ShapeKey_data_begin_mixed(
534{
535 int point_count = rna_ShapeKey_curve_find_index(key, kb->totelem);
536
537 ShapeKeyCurvePoint *points = MEM_malloc_arrayN<ShapeKeyCurvePoint>(size_t(point_count),
538 __func__);
539
540 char *databuf = static_cast<char *>(kb->data);
541 int items_left = point_count;
542 NurbInfo info = {nullptr};
543
544 for (Nurb *nu = static_cast<Nurb *>(cu->nurb.first); nu && items_left > 0; nu = nu->next) {
545 ShapeKeyCurvePoint *nurb_points = points + info.item_index;
546 char *nurb_data = databuf + info.elem_index * key->elemsize;
547
548 rna_ShapeKey_NurbInfo_step(&info, nu, &items_left, false);
549
550 StructRNA *type = rna_ShapeKey_curve_point_type(nu);
551
552 for (int i = 0; i < info.nurb_index; i++) {
553 nurb_points[i].type = type;
554 nurb_points[i].data = nurb_data + i * info.nurb_elem_step * key->elemsize;
555 }
556 }
557
558 rna_iterator_array_begin(iter, ptr, points, sizeof(*points), point_count, true, nullptr);
559}
560
561static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
562{
563 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
564 KeyBlock *kb = (KeyBlock *)ptr->data;
565 int tot = kb->totelem, size = key->elemsize;
566
567 if (GS(key->from->name) == ID_CU_LEGACY && tot > 0) {
568 Curve *cu = (Curve *)key->from;
569 StructRNA *type = nullptr;
570 NurbInfo info = {nullptr};
571
572 /* Check if all sub-curves have the same type. */
573 LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
574 if (type == nullptr) {
575 type = rna_ShapeKey_curve_point_type(nu);
576 rna_ShapeKey_NurbInfo_init(&info, nu);
577 }
578 else if (type != rna_ShapeKey_curve_point_type(nu)) {
579 type = nullptr;
580 break;
581 }
582 }
583
584 /* If types are mixed, build a mapping array. */
585 if (type == nullptr) {
586 rna_ShapeKey_data_begin_mixed(iter, ptr, key, kb, cu);
587 return;
588 }
589 tot /= info.nurb_elem_step;
590 size *= info.nurb_elem_step;
591 }
592
593 rna_iterator_array_begin(iter, ptr, kb->data, size, tot, false, nullptr);
594}
595
596static int rna_ShapeKey_data_length(PointerRNA *ptr)
597{
598 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
599 KeyBlock *kb = (KeyBlock *)ptr->data;
600 int tot = kb->totelem;
601
602 if (GS(key->from->name) == ID_CU_LEGACY) {
603 tot = rna_ShapeKey_curve_find_index(key, tot);
604 }
605
606 return tot;
607}
608
609static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
610{
611 Key *key = rna_ShapeKey_find_key(iter->parent.owner_id);
612 void *ptr = rna_iterator_array_get(iter);
613 StructRNA *type = &RNA_ShapeKeyPoint;
614
615 /* If data_begin allocated a mapping array, access it. */
616 if (iter->internal.array.free_ptr) {
617 ShapeKeyCurvePoint *point = static_cast<ShapeKeyCurvePoint *>(ptr);
618
619 return RNA_pointer_create_with_parent(iter->parent, point->type, point->data);
620 }
621
622 if (GS(key->from->name) == ID_CU_LEGACY) {
623 Curve *cu = (Curve *)key->from;
624
625 type = rna_ShapeKey_curve_point_type(static_cast<Nurb *>(cu->nurb.first));
626 }
627
628 return RNA_pointer_create_with_parent(iter->parent, type, ptr);
629}
630
631bool rna_ShapeKey_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
632{
633 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
634 KeyBlock *kb = (KeyBlock *)ptr->data;
635 int elemsize = key->elemsize;
636 char *databuf = static_cast<char *>(kb->data);
637
638 *r_ptr = {};
639
640 if (index < 0) {
641 return false;
642 }
643
644 if (GS(key->from->name) == ID_CU_LEGACY) {
645 NurbInfo info;
646 rna_ShapeKey_NurbInfo_find_index(key, index, false, &info);
647
648 if (info.nu && info.nurb_index < info.nurb_size) {
649 StructRNA *type = rna_ShapeKey_curve_point_type(info.nu);
650
651 rna_pointer_create_with_ancestors(*ptr, type, databuf + elemsize * info.elem_index, *r_ptr);
652 return true;
653 }
654 }
655 else {
656 if (index < kb->totelem) {
658 *ptr, &RNA_ShapeKeyPoint, databuf + elemsize * index, *r_ptr);
659 return true;
660 }
661 }
662
663 return false;
664}
665
666static void rna_ShapeKey_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
667{
668 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
669 KeyBlock *kb = (KeyBlock *)ptr->data;
670 int tot = kb->totelem;
671
672 if (GS(key->from->name) == ID_CU_LEGACY) {
673 /* Legacy curves have only curve points and bezier points. */
674 tot = 0;
675 }
676 rna_iterator_array_begin(iter, ptr, kb->data, key->elemsize, tot, false, nullptr);
677}
678
679static int rna_ShapeKey_points_length(PointerRNA *ptr)
680{
681 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
682 KeyBlock *kb = (KeyBlock *)ptr->data;
683 int tot = kb->totelem;
684
685 if (GS(key->from->name) == ID_CU_LEGACY) {
686 /* Legacy curves have only curve points and bezier points. */
687 tot = 0;
688 }
689
690 return tot;
691}
692
693bool rna_ShapeKey_points_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
694{
695 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
696 KeyBlock *kb = (KeyBlock *)ptr->data;
697 int elemsize = key->elemsize;
698 char *databuf = static_cast<char *>(kb->data);
699
700 *r_ptr = {};
701
702 if (index < 0) {
703 return false;
704 }
705
706 if (GS(key->from->name) == ID_CU_LEGACY) {
707 /* Legacy curves have only curve points and bezier points. */
708 return false;
709 }
710 else {
711 if (index < kb->totelem) {
713 *ptr, &RNA_ShapeKeyPoint, databuf + elemsize * index, *r_ptr);
714 return true;
715 }
716 }
717
718 return false;
719}
720
721static std::optional<std::string> rna_ShapeKey_path(const PointerRNA *ptr)
722{
723 const KeyBlock *kb = (KeyBlock *)ptr->data;
724 const ID *id = ptr->owner_id;
725 char name_esc[sizeof(kb->name) * 2];
726
727 BLI_str_escape(name_esc, kb->name, sizeof(name_esc));
728
729 if ((id) && (GS(id->name) != ID_KE)) {
730 return fmt::format("shape_keys.key_blocks[\"{}\"]", name_esc);
731 }
732 return fmt::format("key_blocks[\"{}\"]", name_esc);
733}
734
735static void rna_Key_update_data(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
736{
737 Key *key = (Key *)ptr->owner_id;
738 Object *ob;
739
740 for (ob = static_cast<Object *>(bmain->objects.first); ob;
741 ob = static_cast<Object *>(ob->id.next))
742 {
743 if (BKE_key_from_object(ob) == key) {
746 }
747 }
748}
749
750static void rna_ShapeKey_update_minmax(Main *bmain, Scene *scene, PointerRNA *ptr)
751{
752 KeyBlock *data = (KeyBlock *)ptr->data;
753 if (IN_RANGE_INCL(data->curval, data->slidermin, data->slidermax)) {
754 return;
755 }
756 CLAMP(data->curval, data->slidermin, data->slidermax);
757 rna_Key_update_data(bmain, scene, ptr);
758}
759
760static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, const float *point)
761{
762 KeyBlock *kb;
763
764 /* sanity checks */
765 if (ELEM(nullptr, key, point)) {
766 return nullptr;
767 }
768
769 /* We'll need to manually search through the key-blocks and check
770 * if the point is somewhere in the middle of each block's data. */
771 for (kb = static_cast<KeyBlock *>(key->block.first); kb; kb = kb->next) {
772 if (kb->data) {
773 float *start = (float *)kb->data;
774 float *end;
775
776 /* easy cases first */
777 if ((start == nullptr) || (start > point)) {
778 /* there's no chance point is in array */
779 continue;
780 }
781 if (start == point) {
782 /* exact match - point is first in array */
783 return kb;
784 }
785
786 /* determine where end of array is
787 * - elemsize is in bytes, so use (char *) cast to get array in terms of bytes
788 */
789 end = (float *)((char *)start + (key->elemsize * kb->totelem));
790
791 /* If point's address is less than the end,
792 * then it is somewhere between start and end, so in array. */
793 if (end > point) {
794 /* we've found the owner of the point data */
795 return kb;
796 }
797 }
798 }
799
800 return nullptr;
801}
802
803static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
804{
805 /* if we frame the data array and point pointers as (char *), then the difference between
806 * them will be in bytes. Thus, dividing through by key->elemsize (number of bytes per point)
807 * gives us the offset of point from start of array.
808 */
809 char *start = (char *)kb->data;
810 char *pt = (char *)point;
811
812 return int(pt - start) / key->elemsize;
813}
814
815static std::optional<std::string> rna_ShapeKeyPoint_path(const PointerRNA *ptr)
816{
817 ID *id = ptr->owner_id;
818 Key *key = rna_ShapeKey_find_key(ptr->owner_id);
819 KeyBlock *kb;
820 float *point = (float *)ptr->data;
821
822 /* if we can get a key block, we can construct a path */
823 kb = rna_ShapeKeyData_find_keyblock(key, point);
824
825 if (kb) {
826 char name_esc_kb[sizeof(kb->name) * 2];
827 int index;
828
829 index = rna_ShapeKeyPoint_get_index(key, kb, point);
830
831 if (ELEM(ptr->type, &RNA_ShapeKeyBezierPoint, &RNA_ShapeKeyCurvePoint)) {
832 index = rna_ShapeKey_curve_find_index(key, index);
833 }
834
835 BLI_str_escape(name_esc_kb, kb->name, sizeof(name_esc_kb));
836
837 if (GS(id->name) == ID_KE) {
838 return fmt::format("key_blocks[\"{}\"].data[{}]", name_esc_kb, index);
839 }
840 return fmt::format("shape_keys.key_blocks[\"{}\"].data[{}]", name_esc_kb, index);
841 }
842 return std::nullopt; /* XXX: there's really no way to resolve this... */
843}
844
845#else
846
847static const float tilt_limit = DEG2RADF(21600.0f);
848
849static void rna_def_keydata(BlenderRNA *brna)
850{
851 StructRNA *srna;
852 PropertyRNA *prop;
853
854 srna = RNA_def_struct(brna, "ShapeKeyPoint", nullptr);
855 RNA_def_struct_sdna(srna, "vec3f");
856 RNA_def_struct_ui_text(srna, "Shape Key Point", "Point in a shape key");
857 RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
858
859 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
860 RNA_def_property_float_sdna(prop, nullptr, "x");
861 RNA_def_property_array(prop, 3);
862 RNA_def_property_ui_text(prop, "Location", "");
863 RNA_def_property_update(prop, 0, "rna_Key_update_data");
864
865 srna = RNA_def_struct(brna, "ShapeKeyCurvePoint", nullptr);
866 RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves");
867 /* there's nothing type specific here, so this is fine for now */
868 RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
869
870 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
871 RNA_def_property_array(prop, 3);
873 prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", nullptr);
874 RNA_def_property_ui_text(prop, "Location", "");
875 RNA_def_property_update(prop, 0, "rna_Key_update_data");
876
877 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
879 prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", nullptr);
882 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
883 RNA_def_property_update(prop, 0, "rna_Key_update_data");
884
885 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
887 prop, "rna_ShapeKeyCurvePoint_radius_get", "rna_ShapeKeyCurvePoint_radius_set", nullptr);
888 RNA_def_property_range(prop, 0.0f, FLT_MAX);
889 RNA_def_property_ui_text(prop, "Radius", "Radius for beveling");
890 RNA_def_property_update(prop, 0, "rna_Key_update_data");
891
892 srna = RNA_def_struct(brna, "ShapeKeyBezierPoint", nullptr);
893 RNA_def_struct_ui_text(srna, "Shape Key Bézier Point", "Point in a shape key for Bézier curves");
894 /* there's nothing type specific here, so this is fine for now */
895 RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
896
897 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
898 RNA_def_property_array(prop, 3);
900 prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", nullptr);
901 RNA_def_property_ui_text(prop, "Location", "");
902 RNA_def_property_update(prop, 0, "rna_Key_update_data");
903
904 prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
905 RNA_def_property_array(prop, 3);
907 "rna_ShapeKeyBezierPoint_handle_1_co_get",
908 "rna_ShapeKeyBezierPoint_handle_1_co_set",
909 nullptr);
910 RNA_def_property_ui_text(prop, "Handle 1 Location", "");
911 RNA_def_property_update(prop, 0, "rna_Key_update_data");
912
913 prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
914 RNA_def_property_array(prop, 3);
916 "rna_ShapeKeyBezierPoint_handle_2_co_get",
917 "rna_ShapeKeyBezierPoint_handle_2_co_set",
918 nullptr);
919 RNA_def_property_ui_text(prop, "Handle 2 Location", "");
920 RNA_def_property_update(prop, 0, "rna_Key_update_data");
921
922 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
924 prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", nullptr);
927 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
928 RNA_def_property_update(prop, 0, "rna_Key_update_data");
929
930 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
932 prop, "rna_ShapeKeyBezierPoint_radius_get", "rna_ShapeKeyBezierPoint_radius_set", nullptr);
933 RNA_def_property_range(prop, 0.0f, FLT_MAX);
934 RNA_def_property_ui_text(prop, "Radius", "Radius for beveling");
935 RNA_def_property_update(prop, 0, "rna_Key_update_data");
936}
937
938static void rna_def_keyblock(BlenderRNA *brna)
939{
940 StructRNA *srna;
941 PropertyRNA *prop, *parm;
942 FunctionRNA *func;
943
944 srna = RNA_def_struct(brna, "ShapeKey", nullptr);
945 RNA_def_struct_ui_text(srna, "Shape Key", "Shape key in a shape keys data-block");
946 RNA_def_struct_sdna(srna, "KeyBlock");
947 RNA_def_struct_path_func(srna, "rna_ShapeKey_path");
948 RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
949
950 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
951 RNA_def_property_ui_text(prop, "Name", "Name of Shape Key");
952 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_ShapeKey_name_set");
953 RNA_def_property_update(prop, 0, "rna_Key_update_data");
955
956 /* keys need to be sorted to edit this */
957 prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
959 RNA_def_property_float_sdna(prop, nullptr, "pos");
960 RNA_def_property_float_funcs(prop, "rna_ShapeKey_frame_get", nullptr, nullptr);
961 RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys");
962 RNA_def_property_update(prop, 0, "rna_Key_update_data");
963
964 /* for now, this is editable directly, as users can set this even if they're not animating them
965 * (to test results) */
966 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_FACTOR);
967 RNA_def_property_float_sdna(prop, nullptr, "curval");
971 prop, nullptr, "rna_ShapeKey_value_set", "rna_ShapeKey_value_range");
972 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 10, 3);
973 RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame");
974 RNA_def_property_update(prop, ND_KEYS, "rna_Key_update_data");
975
976 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
977 RNA_def_property_enum_sdna(prop, nullptr, "type");
979 RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type for absolute shape keys");
980 RNA_def_property_update(prop, 0, "rna_Key_update_data");
981
982 prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
983 RNA_def_property_string_sdna(prop, nullptr, "vgroup");
984 RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape");
985 RNA_def_property_update(prop, 0, "rna_Key_update_data");
986
987 prop = RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
988 RNA_def_property_struct_type(prop, "ShapeKey");
991 prop, "rna_ShapeKey_relative_key_get", "rna_ShapeKey_relative_key_set", nullptr, nullptr);
992 RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key");
993 RNA_def_property_update(prop, 0, "rna_Key_update_data");
994
995 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
996 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KEYBLOCK_MUTE);
998 RNA_def_property_ui_text(prop, "Mute", "Toggle this shape key");
999 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1000 RNA_def_property_update(prop, 0, "rna_Key_update_data");
1001
1002 prop = RNA_def_property(srna, "lock_shape", PROP_BOOLEAN, PROP_NONE);
1005 prop, "Lock Shape", "Protect the shape key from accidental sculpting and editing");
1006 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1007 RNA_def_property_update(prop, 0, "rna_Key_update_data");
1008
1009 prop = RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE);
1010 RNA_def_property_float_sdna(prop, nullptr, "slidermin");
1011 RNA_def_property_range(prop, -10.0f, 10.0f);
1013 prop, nullptr, "rna_ShapeKey_slider_min_set", "rna_ShapeKey_slider_min_range");
1014 RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider");
1015 RNA_def_property_update(prop, 0, "rna_ShapeKey_update_minmax");
1016
1017 prop = RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
1018 RNA_def_property_float_sdna(prop, nullptr, "slidermax");
1019 RNA_def_property_range(prop, -10.0f, 10.0f);
1022 prop, nullptr, "rna_ShapeKey_slider_max_set", "rna_ShapeKey_slider_max_range");
1023 RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider");
1024 RNA_def_property_update(prop, 0, "rna_ShapeKey_update_minmax");
1025
1026 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1027 RNA_def_property_collection_sdna(prop, nullptr, "data", "totelem");
1028 RNA_def_property_struct_type(prop, "UnknownType");
1030 RNA_def_property_ui_text(prop, "Data", "");
1032 "rna_ShapeKey_data_begin",
1033 nullptr,
1034 nullptr,
1035 "rna_ShapeKey_data_get",
1036 "rna_ShapeKey_data_length",
1037 "rna_ShapeKey_data_lookup_int",
1038 nullptr,
1039 nullptr);
1040
1041 prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
1042 RNA_def_property_collection_sdna(prop, nullptr, "data", nullptr);
1043 RNA_def_property_struct_type(prop, "ShapeKeyPoint");
1046 "Points",
1047 "Optimized access to shape keys point data, when using "
1048 "foreach_get/foreach_set accessors. "
1049 "Warning: Does not support legacy Curve shape keys.");
1051 "rna_ShapeKey_points_begin",
1052 "rna_iterator_array_next",
1053 "rna_iterator_array_end",
1054 "rna_iterator_array_get",
1055 "rna_ShapeKey_points_length",
1056 "rna_ShapeKey_points_lookup_int",
1057 nullptr,
1058 nullptr);
1059
1060 /* XXX multi-dim dynamic arrays are very badly supported by (py)rna currently,
1061 * those are defined for the day it works better, for now user will get a 1D tuple.
1062 */
1063 func = RNA_def_function(srna, "normals_vertex_get", "rna_KeyBlock_normals_vert_calc");
1065 "Compute local space vertices' normals for this shape key");
1067 parm = RNA_def_property(func, "normals", PROP_FLOAT, /*PROP_DIRECTION*/ PROP_NONE);
1069 RNA_def_property_multi_array(parm, 2, nullptr);
1070 RNA_def_property_range(parm, -1.0f, 1.0f);
1071 RNA_def_property_dynamic_array_funcs(parm, "rna_KeyBlock_normals_vert_len");
1072
1073 func = RNA_def_function(srna, "normals_polygon_get", "rna_KeyBlock_normals_poly_calc");
1074 RNA_def_function_ui_description(func, "Compute local space faces' normals for this shape key");
1076 parm = RNA_def_property(func, "normals", PROP_FLOAT, /*PROP_DIRECTION*/ PROP_NONE);
1078 RNA_def_property_multi_array(parm, 2, nullptr);
1079 RNA_def_property_range(parm, -1.0f, 1.0f);
1080 RNA_def_property_dynamic_array_funcs(parm, "rna_KeyBlock_normals_poly_len");
1081
1082 func = RNA_def_function(srna, "normals_split_get", "rna_KeyBlock_normals_loop_calc");
1084 "Compute local space face corners' normals for this shape key");
1086 parm = RNA_def_property(func, "normals", PROP_FLOAT, /*PROP_DIRECTION*/ PROP_NONE);
1088 RNA_def_property_multi_array(parm, 2, nullptr);
1089 RNA_def_property_range(parm, -1.0f, 1.0f);
1090 RNA_def_property_dynamic_array_funcs(parm, "rna_KeyBlock_normals_loop_len");
1091}
1092
1093static void rna_def_key(BlenderRNA *brna)
1094{
1095 StructRNA *srna;
1096 PropertyRNA *prop;
1097
1098 srna = RNA_def_struct(brna, "Key", "ID");
1100 srna, "Key", "Shape keys data-block containing different shapes of geometric data-blocks");
1101 RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
1102
1103 prop = RNA_def_property(srna, "reference_key", PROP_POINTER, PROP_NONE);
1106 RNA_def_property_pointer_sdna(prop, nullptr, "refkey");
1107 RNA_def_property_ui_text(prop, "Reference Key", "");
1108
1109 prop = RNA_def_property(srna, "key_blocks", PROP_COLLECTION, PROP_NONE);
1110 RNA_def_property_collection_sdna(prop, nullptr, "block", nullptr);
1112 RNA_def_property_struct_type(prop, "ShapeKey");
1113 RNA_def_property_ui_text(prop, "Key Blocks", "Shape keys");
1114
1116
1117 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NONE);
1120 RNA_def_property_pointer_sdna(prop, nullptr, "from");
1121 RNA_def_property_ui_text(prop, "User", "Data-block using these shape keys");
1122
1123 prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
1124 RNA_def_property_boolean_sdna(prop, nullptr, "type", KEY_RELATIVE);
1126 prop,
1127 "Relative",
1128 "Make shape keys relative, "
1129 "otherwise play through shapes as a sequence using the evaluation time");
1130 RNA_def_property_update(prop, 0, "rna_Key_update_data");
1131
1132 prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
1133 RNA_def_property_float_sdna(prop, nullptr, "ctime");
1136 RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time for absolute shape keys");
1137 RNA_def_property_update(prop, 0, "rna_Key_update_data");
1138}
1139
1141{
1142 rna_def_key(brna);
1143 rna_def_keyblock(brna);
1144 rna_def_keydata(brna);
1145}
1146
1147#endif
void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName)
void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb, Mesh *mesh, float(*r_vert_normals)[3], float(*r_face_normals)[3], float(*r_loop_normals)[3])
Definition key.cc:2193
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1791
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
#define LISTBASE_FOREACH(type, var, list)
#define DEG2RADF(_deg)
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:693
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
void BLI_uniquename(const struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
#define CLAMP(a, b, c)
#define ELEM(...)
#define IN_RANGE_INCL(a, b, c)
#define CLAMP_MIN(a, b)
#define BLT_I18NCONTEXT_ID_SHAPEKEY
#define CTX_DATA_(context, msgid)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ ID_KE
@ ID_CU_LEGACY
@ ID_ME
@ ID_LT
@ ID_OB
struct Nurb Nurb
@ KEY_RELATIVE
@ KEYBLOCK_LOCKED_SHAPE
@ KEYBLOCK_MUTE
#define KEYELEM_ELEM_LEN_BPOINT
@ KEY_LINEAR
@ KEY_CARDINAL
@ KEY_BSPLINE
@ KEY_CATMULL_ROM
#define KEYELEM_ELEM_LEN_BEZTRIPLE
Object is a sort of wrapper for general info.
@ OB_MESH
#define MINFRAME
#define MAXFRAME
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:27
@ PARM_OUTPUT
Definition RNA_types.hh:546
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:511
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:523
@ PROP_DYNAMIC
Definition RNA_types.hh:428
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:395
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_ANGLE
Definition RNA_types.hh:252
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FACTOR
Definition RNA_types.hh:251
@ PROP_TRANSLATION
Definition RNA_types.hh:261
#define ND_MODIFIER
Definition WM_types.hh:462
#define ND_KEYS
Definition WM_types.hh:463
#define NC_OBJECT
Definition WM_types.hh:379
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define offsetof(t, d)
#define GS(x)
static float normals[][3]
float length(VecOp< float, D >) RET
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
const char * name
void * rna_iterator_array_get(CollectionPropertyIterator *iter)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void rna_def_animdata_common(StructRNA *srna)
static const float tilt_limit
Definition rna_curve.cc:882
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
PointerRNA rna_object_shapekey_index_get(ID *id, int value)
static void rna_def_keyblock(BlenderRNA *brna)
Definition rna_key.cc:938
static void rna_def_keydata(BlenderRNA *brna)
Definition rna_key.cc:849
static void rna_def_key(BlenderRNA *brna)
Definition rna_key.cc:1093
const EnumPropertyItem rna_enum_keyblock_type_items[]
Definition rna_key.cc:23
void RNA_def_key(BlenderRNA *brna)
Definition rna_key.cc:1140
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
void * free_ptr
Definition RNA_types.hh:576
union CollectionPropertyIterator::@220100362304005352221007113371015217044252346141 internal
ListBase nurb
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
void * next
Definition DNA_ID.h:417
char name[64]
struct KeyBlock * next
short relative
void * data
ID * from
int elemsize
ListBase block
void * first
int corners_num
int faces_num
int verts_num
struct Nurb * next
BezTriple * bezt
ID * owner_id
Definition RNA_types.hh:51
void * data
Definition RNA_types.hh:53
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238