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