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