Blender V4.3
rna_animation.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
9#include <cstdlib>
10
11#include "DNA_action_types.h"
12#include "DNA_anim_types.h"
13#include "DNA_scene_types.h"
14
16#include "BLI_utildefines.h"
17
18#include "BLT_translation.hh"
19
20#include "MEM_guardedalloc.h"
21
22#include "BKE_nla.hh"
23
24#include "RNA_access.hh"
25#include "RNA_define.hh"
26#include "RNA_enum_types.hh"
27
28#include "rna_internal.hh"
29
30#include "WM_api.hh"
31#include "WM_types.hh"
32
33#include "ED_keyframing.hh"
34
35#include "ANIM_action.hh"
36
37using namespace blender;
38
39/* exported for use in API */
41 {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""},
42 {KSP_GROUP_NONE, "NONE", 0, "None", ""},
43 {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""},
44 {0, nullptr, 0, nullptr, nullptr},
45};
46
47/* It would be cool to get rid of this 'INSERTKEY_' prefix in 'py strings' values,
48 * but it would break existing
49 * exported keyingset... :/
50 */
53 "INSERTKEY_NEEDED",
54 0,
55 "Only Needed",
56 "Only insert keyframes where they're needed in the relevant F-Curves"},
58 "INSERTKEY_VISUAL",
59 0,
60 "Visual Keying",
61 "Insert keyframes based on 'visual transforms'"},
62 {0,
63 "INSERTKEY_XYZ_TO_RGB",
64 0,
65 "XYZ=RGB Colors (ignored)",
66 "This flag is no longer in use, and is here so that code that uses it doesn't break. The "
67 "XYZ=RGB coloring is determined by the animation preferences."},
68 {0, nullptr, 0, nullptr, nullptr},
69};
70
71/* Contains additional flags suitable for use in Python API functions. */
74 "INSERTKEY_NEEDED",
75 0,
76 "Only Needed",
77 "Only insert keyframes where they're needed in the relevant F-Curves"},
79 "INSERTKEY_VISUAL",
80 0,
81 "Visual Keying",
82 "Insert keyframes based on 'visual transforms'"},
83 {0,
84 "INSERTKEY_XYZ_TO_RGB",
85 0,
86 "XYZ=RGB Colors (ignored)",
87 "This flag is no longer in use, and is here so that code that uses it doesn't break. The "
88 "XYZ=RGB coloring is determined by the animation preferences."},
90 "INSERTKEY_REPLACE",
91 0,
92 "Replace Existing",
93 "Only replace existing keyframes"},
95 "INSERTKEY_AVAILABLE",
96 0,
97 "Only Available",
98 "Don't create F-Curves when they don't already exist"},
100 "INSERTKEY_CYCLE_AWARE",
101 0,
102 "Cycle Aware Keying",
103 "When inserting into a curve with cyclic extrapolation, remap the keyframe inside "
104 "the cycle time range, and if changing an end key, also update the other one"},
105 {0, nullptr, 0, nullptr, nullptr},
106};
107
108#ifdef RNA_RUNTIME
109
110# include <algorithm>
111
112# include "BLI_math_base.h"
113
114# include "BKE_anim_data.hh"
115# include "BKE_animsys.h"
116# include "BKE_fcurve.hh"
117# include "BKE_nla.hh"
118
119# include "ANIM_action_legacy.hh"
120
121# include "DEG_depsgraph.hh"
122# include "DEG_depsgraph_build.hh"
123
124# include "DNA_object_types.h"
125
126# include "ED_anim_api.hh"
127
128# include "WM_api.hh"
129
130# include "UI_interface_icons.hh"
131
132static void rna_AnimData_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
133{
134 ID *id = ptr->owner_id;
135
136 ANIM_id_update(bmain, id);
137}
138
139static void rna_AnimData_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
140{
142
143 rna_AnimData_update(bmain, scene, ptr);
144}
145
146static int rna_AnimData_action_editable(const PointerRNA *ptr, const char ** /*r_info*/)
147{
148 BLI_assert(ptr->type == &RNA_AnimData);
149 AnimData *adt = static_cast<AnimData *>(ptr->data);
150 if (!adt) {
151 return PROP_EDITABLE;
152 }
154}
155
156static PointerRNA rna_AnimData_action_get(PointerRNA *ptr)
157{
158 ID &animated_id = *ptr->owner_id;
159 animrig::Action *action = animrig::get_action(animated_id);
160 if (!action) {
161 return PointerRNA_NULL;
162 };
163 return RNA_id_pointer_create(&action->id);
164}
165
166static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
167{
168# ifdef WITH_ANIM_BAKLAVA
169 using namespace blender::animrig;
171 ID &animated_id = *ptr->owner_id;
172
173 Action *action = static_cast<Action *>(value.data);
174 if (!assign_action(action, animated_id)) {
175 BKE_report(reports, RPT_ERROR, "Could not change action");
176 }
177 UNUSED_VARS(reports);
178# else
179 ID *ownerId = ptr->owner_id;
180 BKE_animdata_set_action(reports, ownerId, static_cast<bAction *>(value.data));
181# endif
182}
183
184static void rna_AnimData_tmpact_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
185{
186 ID *ownerId = ptr->owner_id;
187 BKE_animdata_set_tmpact(reports, ownerId, static_cast<bAction *>(value.data));
188}
189
190static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const bool value)
191{
192 ID *animated_id = ptr->owner_id;
193 AnimData *adt = (AnimData *)ptr->data;
194
195 /* NOTE: technically we should also set/unset SCE_NLA_EDIT_ON flag on the
196 * scene which is used to make polling tests faster, but this flag is weak
197 * and can easily break e.g. by changing layer visibility. This needs to be
198 * dealt with at some point. */
199
200 if (value) {
201 BKE_nla_tweakmode_enter({*animated_id, *adt});
202 }
203 else {
204 BKE_nla_tweakmode_exit({*animated_id, *adt});
205 }
206}
207
216bool rna_AnimData_tweakmode_override_apply(Main * /*bmain*/,
218{
219 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
220 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
221
222 AnimData *anim_data_dst = (AnimData *)ptr_dst->data;
223 AnimData *anim_data_src = (AnimData *)ptr_src->data;
224
225 anim_data_dst->flag = (anim_data_dst->flag & ~ADT_NLA_EDIT_ON) |
226 (anim_data_src->flag & ADT_NLA_EDIT_ON);
227
228 /* There are many more flags & pointers to deal with when switching NLA tweak mode. This has to
229 * be handled once all the NLA tracks & strips are available, though. It's done in a post-process
230 * step, see BKE_nla_liboverride_post_process(). */
231 return true;
232}
233
234# ifdef WITH_ANIM_BAKLAVA
235void rna_generic_action_slot_handle_set(blender::animrig::slot_handle_t slot_handle_to_assign,
236 ID &animated_id,
237 bAction *&action_ptr_ref,
238 blender::animrig::slot_handle_t &slot_handle_ref,
239 char *slot_name)
240{
241 using namespace blender::animrig;
242
244 slot_handle_to_assign, animated_id, action_ptr_ref, slot_handle_ref, slot_name);
245
246 /* Unfortunately setters for PROP_INT do not receive a `reports` parameter, so
247 * report to the Window Manager report list instead. */
248 switch (result) {
249 case ActionSlotAssignmentResult::OK:
250 break;
251 case ActionSlotAssignmentResult::SlotNotFromAction:
253 break;
254 case ActionSlotAssignmentResult::SlotNotSuitable:
256 "This slot is not suitable for this data-block type (%c%c)",
257 animated_id.name[0],
258 animated_id.name[1]);
259 break;
260 case ActionSlotAssignmentResult::MissingAction:
261 WM_report(RPT_ERROR, "Cannot set slot without an assigned Action.");
262 break;
263 }
264}
265
266static void rna_AnimData_action_slot_handle_set(
267 PointerRNA *ptr, const blender::animrig::slot_handle_t new_slot_handle)
268{
269 ID &animated_id = *ptr->owner_id;
270 AnimData *adt = BKE_animdata_from_id(&animated_id);
271
272 rna_generic_action_slot_handle_set(
273 new_slot_handle, animated_id, adt->action, adt->slot_handle, adt->slot_name);
274}
275
276static AnimData &rna_animdata(const PointerRNA *ptr)
277{
278 return *reinterpret_cast<AnimData *>(ptr->data);
279}
280
281PointerRNA rna_generic_action_slot_get(bAction *dna_action,
282 const animrig::slot_handle_t slot_handle)
283{
284 using namespace blender::animrig;
285
286 if (!dna_action || slot_handle == Slot::unassigned) {
287 return PointerRNA_NULL;
288 }
289
290 Action &action = dna_action->wrap();
291 Slot *slot = action.slot_for_handle(slot_handle);
292 if (!slot) {
293 return PointerRNA_NULL;
294 }
295 return RNA_pointer_create(&action.id, &RNA_ActionSlot, slot);
296}
297
298static PointerRNA rna_AnimData_action_slot_get(PointerRNA *ptr)
299{
300 AnimData &adt = rna_animdata(ptr);
301 return rna_generic_action_slot_get(adt.action, adt.slot_handle);
302}
303
304void rna_generic_action_slot_set(PointerRNA rna_slot_to_assign,
305 ID &animated_id,
306 bAction *&action_ptr_ref,
307 blender::animrig::slot_handle_t &slot_handle_ref,
308 char *slot_name,
309 ReportList *reports)
310{
311 using namespace blender::animrig;
312
313 ActionSlot *dna_slot = static_cast<ActionSlot *>(rna_slot_to_assign.data);
314 Slot *slot = dna_slot ? &dna_slot->wrap() : nullptr;
315
317 slot, animated_id, action_ptr_ref, slot_handle_ref, slot_name);
318
319 switch (result) {
320 case ActionSlotAssignmentResult::OK:
321 break;
322 case ActionSlotAssignmentResult::SlotNotFromAction:
324 reports, RPT_ERROR, "This slot (%s) does not belong to the assigned Action", slot->name);
325 break;
326 case ActionSlotAssignmentResult::SlotNotSuitable:
327 BKE_reportf(reports,
328 RPT_ERROR,
329 "This slot (%s) is not suitable for this data-block type (%c%c)",
330 slot->name,
331 animated_id.name[0],
332 animated_id.name[1]);
333 break;
334 case ActionSlotAssignmentResult::MissingAction:
335 BKE_report(reports, RPT_ERROR, "Cannot set slot without an assigned Action.");
336 break;
337 }
338}
339
340static void rna_AnimData_action_slot_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
341{
342 ID *animated_id = ptr->owner_id;
343 AnimData *adt = BKE_animdata_from_id(animated_id);
344 if (!adt) {
345 BKE_report(reports, RPT_ERROR, "Cannot set slot without an assigned Action.");
346 return;
347 }
348
349 rna_generic_action_slot_set(
350 value, *animated_id, adt->action, adt->slot_handle, adt->slot_name, reports);
351}
352
353static void rna_AnimData_action_slot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
354{
355 /* TODO: see if this is still necessary. */
357 rna_AnimData_dependency_update(bmain, scene, ptr);
358}
359
367bool rna_iterator_generic_action_slots_skip(CollectionPropertyIterator *iter, void *data)
368{
369 using animrig::Slot;
370
371 /* Get the current Slot being iterated over. */
372 const Slot **slot_ptr_ptr = static_cast<const Slot **>(data);
373 BLI_assert(slot_ptr_ptr);
374 BLI_assert(*slot_ptr_ptr);
375 const Slot &slot = **slot_ptr_ptr;
376
377 /* Get the animated ID. */
378 const ID *animated_id = iter->parent.owner_id;
379 BLI_assert(animated_id);
380
381 /* Skip this Slot if it's not suitable for the animated ID. */
382 return !slot.is_suitable_for(*animated_id);
383}
384
385void rna_iterator_generic_action_slots_begin(CollectionPropertyIterator *iter,
386 bAction *assigned_action)
387{
388 if (!assigned_action) {
389 /* No action means no slots. */
390 rna_iterator_array_begin(iter, nullptr, 0, 0, 0, nullptr);
391 return;
392 }
393
394 animrig::Action &action = assigned_action->wrap();
395 Span<animrig::Slot *> slots = action.slots();
397 (void *)slots.data(),
398 sizeof(animrig::Slot *),
399 slots.size(),
400 0,
401 rna_iterator_generic_action_slots_skip);
402}
403
404static void rna_iterator_animdata_action_slots_begin(CollectionPropertyIterator *iter,
406{
407 rna_iterator_generic_action_slots_begin(iter, rna_animdata(ptr).action);
408}
409
410# endif /* WITH_ANIM_BAKLAVA */
411
412/* ****************************** */
413
414/* wrapper for poll callback */
415static bool RKS_POLL_rna_internal(KeyingSetInfo *ksi, bContext *C)
416{
417 extern FunctionRNA rna_KeyingSetInfo_poll_func;
418
419 ParameterList list;
420 FunctionRNA *func;
421 void *ret;
422 int ok;
423
424 PointerRNA ptr = RNA_pointer_create(nullptr, ksi->rna_ext.srna, ksi);
425 func = &rna_KeyingSetInfo_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
426
427 RNA_parameter_list_create(&list, &ptr, func);
428 {
429 /* hook up arguments */
430 RNA_parameter_set_lookup(&list, "ksi", &ksi);
431 RNA_parameter_set_lookup(&list, "context", &C);
432
433 /* execute the function */
434 ksi->rna_ext.call(C, &ptr, func, &list);
435
436 /* read the result */
437 RNA_parameter_get_lookup(&list, "ok", &ret);
438 ok = *(bool *)ret;
439 }
441
442 return ok;
443}
444
445/* wrapper for iterator callback */
446static void RKS_ITER_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks)
447{
448 extern FunctionRNA rna_KeyingSetInfo_iterator_func;
449
450 ParameterList list;
451 FunctionRNA *func;
452
453 PointerRNA ptr = RNA_pointer_create(nullptr, ksi->rna_ext.srna, ksi);
454 func = &rna_KeyingSetInfo_iterator_func; /* RNA_struct_find_function(&ptr, "poll"); */
455
456 RNA_parameter_list_create(&list, &ptr, func);
457 {
458 /* hook up arguments */
459 RNA_parameter_set_lookup(&list, "ksi", &ksi);
460 RNA_parameter_set_lookup(&list, "context", &C);
461 RNA_parameter_set_lookup(&list, "ks", &ks);
462
463 /* execute the function */
464 ksi->rna_ext.call(C, &ptr, func, &list);
465 }
467}
468
469/* wrapper for generator callback */
470static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, PointerRNA *data)
471{
472 extern FunctionRNA rna_KeyingSetInfo_generate_func;
473
474 ParameterList list;
475 FunctionRNA *func;
476
477 PointerRNA ptr = RNA_pointer_create(nullptr, ksi->rna_ext.srna, ksi);
478 func = &rna_KeyingSetInfo_generate_func; /* RNA_struct_find_generate(&ptr, "poll"); */
479
480 RNA_parameter_list_create(&list, &ptr, func);
481 {
482 /* hook up arguments */
483 RNA_parameter_set_lookup(&list, "ksi", &ksi);
484 RNA_parameter_set_lookup(&list, "context", &C);
485 RNA_parameter_set_lookup(&list, "ks", &ks);
486 RNA_parameter_set_lookup(&list, "data", data);
487
488 /* execute the function */
489 ksi->rna_ext.call(C, &ptr, func, &list);
490 }
492}
493
494/* ------ */
495
496/* XXX: the exact purpose of this is not too clear...
497 * maybe we want to revise this at some point? */
498static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr)
499{
501 return (ksi->rna_ext.srna) ? ksi->rna_ext.srna : &RNA_KeyingSetInfo;
502}
503
504static bool rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
505{
506 KeyingSetInfo *ksi = static_cast<KeyingSetInfo *>(RNA_struct_blender_type_get(type));
507
508 if (ksi == nullptr) {
509 return false;
510 }
511
512 /* free RNA data referencing this */
515
517
518 /* unlink Blender-side data */
520 return true;
521}
522
523static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
524 ReportList *reports,
525 void *data,
526 const char *identifier,
527 StructValidateFunc validate,
530{
531 const char *error_prefix = "Registering keying set info class:";
532 KeyingSetInfo dummy_ksi = {nullptr};
533 KeyingSetInfo *ksi;
534 bool have_function[3];
535
536 /* setup dummy type info to store static properties in */
537 /* TODO: perhaps we want to get users to register
538 * as if they're using 'KeyingSet' directly instead? */
539 PointerRNA dummy_ksi_ptr = RNA_pointer_create(nullptr, &RNA_KeyingSetInfo, &dummy_ksi);
540
541 /* validate the python class */
542 if (validate(&dummy_ksi_ptr, data, have_function) != 0) {
543 return nullptr;
544 }
545
546 if (strlen(identifier) >= sizeof(dummy_ksi.idname)) {
547 BKE_reportf(reports,
548 RPT_ERROR,
549 "%s '%s' is too long, maximum length is %d",
550 error_prefix,
551 identifier,
552 int(sizeof(dummy_ksi.idname)));
553 return nullptr;
554 }
555
556 /* check if we have registered this info before, and remove it */
557 ksi = ANIM_keyingset_info_find_name(dummy_ksi.idname);
558 if (ksi) {
559 BKE_reportf(reports,
560 RPT_INFO,
561 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
562 error_prefix,
563 identifier,
564 dummy_ksi.idname);
565
566 StructRNA *srna = ksi->rna_ext.srna;
567 if (!(srna && rna_KeyingSetInfo_unregister(bmain, srna))) {
568 BKE_reportf(reports,
569 RPT_ERROR,
570 "%s '%s', bl_idname '%s' %s",
571 error_prefix,
572 identifier,
573 dummy_ksi.idname,
574 srna ? "is built-in" : "could not be unregistered");
575 return nullptr;
576 }
577 }
578
579 /* create a new KeyingSetInfo type */
580 ksi = static_cast<KeyingSetInfo *>(MEM_mallocN(sizeof(KeyingSetInfo), "python keying set info"));
581 memcpy(ksi, &dummy_ksi, sizeof(KeyingSetInfo));
582
583 /* set RNA-extensions info */
584 ksi->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ksi->idname, &RNA_KeyingSetInfo);
585 ksi->rna_ext.data = data;
586 ksi->rna_ext.call = call;
587 ksi->rna_ext.free = free;
589
590 /* set callbacks */
591 /* NOTE: we really should have all of these... */
592 ksi->poll = (have_function[0]) ? RKS_POLL_rna_internal : nullptr;
593 ksi->iter = (have_function[1]) ? RKS_ITER_rna_internal : nullptr;
594 ksi->generate = (have_function[2]) ? RKS_GEN_rna_internal : nullptr;
595
596 /* add and register with other info as needed */
598
600
601 /* return the struct-rna added */
602 return ksi->rna_ext.srna;
603}
604
605/* ****************************** */
606
607static StructRNA *rna_ksPath_id_typef(PointerRNA *ptr)
608{
609 KS_Path *ksp = (KS_Path *)ptr->data;
610 return ID_code_to_RNA_type(ksp->idtype);
611}
612
613static int rna_ksPath_id_editable(const PointerRNA *ptr, const char ** /*r_info*/)
614{
615 KS_Path *ksp = (KS_Path *)ptr->data;
616 return (ksp->idtype) ? PROP_EDITABLE : PropertyFlag(0);
617}
618
619static void rna_ksPath_id_type_set(PointerRNA *ptr, int value)
620{
621 KS_Path *data = (KS_Path *)(ptr->data);
622
623 /* set the driver type, then clear the id-block if the type is invalid */
624 data->idtype = value;
625 if ((data->id) && (GS(data->id->name) != data->idtype)) {
626 data->id = nullptr;
627 }
628}
629
630static void rna_ksPath_RnaPath_get(PointerRNA *ptr, char *value)
631{
632 KS_Path *ksp = (KS_Path *)ptr->data;
633
634 if (ksp->rna_path) {
635 strcpy(value, ksp->rna_path);
636 }
637 else {
638 value[0] = '\0';
639 }
640}
641
642static int rna_ksPath_RnaPath_length(PointerRNA *ptr)
643{
644 KS_Path *ksp = (KS_Path *)ptr->data;
645
646 if (ksp->rna_path) {
647 return strlen(ksp->rna_path);
648 }
649 else {
650 return 0;
651 }
652}
653
654static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
655{
656 KS_Path *ksp = (KS_Path *)ptr->data;
657
658 if (ksp->rna_path) {
659 MEM_freeN(ksp->rna_path);
660 }
661
662 if (value[0]) {
663 ksp->rna_path = BLI_strdup(value);
664 }
665 else {
666 ksp->rna_path = nullptr;
667 }
668}
669
670/* ****************************** */
671
672static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
673{
674 KeyingSet *ks = (KeyingSet *)ptr->data;
675
676 /* update names of corresponding groups if name changes */
677 if (!STREQ(ks->name, value)) {
678 KS_Path *ksp;
679
680 for (ksp = static_cast<KS_Path *>(ks->paths.first); ksp; ksp = ksp->next) {
681 if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
682 AnimData *adt = BKE_animdata_from_id(ksp->id);
683
684 /* TODO: NLA strips? */
685 /* lazy check - should really find the F-Curve for the affected path and check its
686 * group but this way should be faster and work well for most cases, as long as there
687 * are no conflicts
688 */
689 for (bActionGroup *agrp : animrig::legacy::channel_groups_for_assigned_slot(adt)) {
690 if (STREQ(ks->name, agrp->name)) {
691 /* there should only be one of these in the action, so can stop... */
692 STRNCPY(agrp->name, value);
693 break;
694 }
695 }
696 }
697 }
698 }
699
700 /* finally, update name to new value */
701 STRNCPY(ks->name, value);
702}
703
704static int rna_KeyingSet_active_ksPath_editable(const PointerRNA *ptr, const char ** /*r_info*/)
705{
706 KeyingSet *ks = (KeyingSet *)ptr->data;
707
708 /* only editable if there are some paths to change to */
709 return (BLI_listbase_is_empty(&ks->paths) == false) ? PROP_EDITABLE : PropertyFlag(0);
710}
711
712static PointerRNA rna_KeyingSet_active_ksPath_get(PointerRNA *ptr)
713{
714 KeyingSet *ks = (KeyingSet *)ptr->data;
716 ptr, &RNA_KeyingSetPath, BLI_findlink(&ks->paths, ks->active_path - 1));
717}
718
719static void rna_KeyingSet_active_ksPath_set(PointerRNA *ptr,
720 PointerRNA value,
721 ReportList * /*reports*/)
722{
723 KeyingSet *ks = (KeyingSet *)ptr->data;
724 KS_Path *ksp = (KS_Path *)value.data;
725 ks->active_path = BLI_findindex(&ks->paths, ksp) + 1;
726}
727
728static int rna_KeyingSet_active_ksPath_index_get(PointerRNA *ptr)
729{
730 KeyingSet *ks = (KeyingSet *)ptr->data;
731 return std::max(ks->active_path - 1, 0);
732}
733
734static void rna_KeyingSet_active_ksPath_index_set(PointerRNA *ptr, int value)
735{
736 KeyingSet *ks = (KeyingSet *)ptr->data;
737 ks->active_path = value + 1;
738}
739
740static void rna_KeyingSet_active_ksPath_index_range(
741 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
742{
743 KeyingSet *ks = (KeyingSet *)ptr->data;
744
745 *min = 0;
746 *max = max_ii(0, BLI_listbase_count(&ks->paths) - 1);
747}
748
749static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr)
750{
751 KeyingSet *ks = (KeyingSet *)ptr->data;
752 KeyingSetInfo *ksi = nullptr;
753
754 /* keying set info is only for builtin Keying Sets */
755 if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
757 }
758 return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetInfo, ksi);
759}
760
761static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset,
762 ReportList *reports,
763 ID *id,
764 const char rna_path[],
765 int index,
766 int group_method,
767 const char group_name[])
768{
769 KS_Path *ksp = nullptr;
770 short flag = 0;
771
772 /* Special case when index = -1, we key the whole array
773 * (as with other places where index is used). */
774 if (index == -1) {
776 index = 0;
777 }
778
779 /* if data is valid, call the API function for this */
780 if (keyingset) {
781 ksp = BKE_keyingset_add_path(keyingset, id, group_name, rna_path, index, flag, group_method);
782 keyingset->active_path = BLI_listbase_count(&keyingset->paths);
783 }
784 else {
785 BKE_report(reports, RPT_ERROR, "Keying set path could not be added");
786 }
787
788 /* return added path */
789 return ksp;
790}
791
792static void rna_KeyingSet_paths_remove(KeyingSet *keyingset,
793 ReportList *reports,
794 PointerRNA *ksp_ptr)
795{
796 KS_Path *ksp = static_cast<KS_Path *>(ksp_ptr->data);
797
798 /* if data is valid, call the API function for this */
799 if ((keyingset && ksp) == false) {
800 BKE_report(reports, RPT_ERROR, "Keying set path could not be removed");
801 return;
802 }
803
804 /* remove the active path from the KeyingSet */
805 BKE_keyingset_free_path(keyingset, ksp);
806 RNA_POINTER_INVALIDATE(ksp_ptr);
807
808 /* the active path number will most likely have changed */
809 /* TODO: we should get more fancy and actually check if it was removed,
810 * but this will do for now */
811 keyingset->active_path = 0;
812}
813
814static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports)
815{
816 /* if data is valid, call the API function for this */
817 if (keyingset) {
818 KS_Path *ksp, *kspn;
819
820 /* free each path as we go to avoid looping twice */
821 for (ksp = static_cast<KS_Path *>(keyingset->paths.first); ksp; ksp = kspn) {
822 kspn = ksp->next;
823 BKE_keyingset_free_path(keyingset, ksp);
824 }
825
826 /* reset the active path, since there aren't any left */
827 keyingset->active_path = 0;
828 }
829 else {
830 BKE_report(reports, RPT_ERROR, "Keying set paths could not be removed");
831 }
832}
833
834/* needs wrapper function to push notifier */
835static NlaTrack *rna_NlaTrack_new(ID *id, AnimData *adt, Main *bmain, bContext *C, NlaTrack *track)
836{
837 NlaTrack *new_track;
838
839 if (track == nullptr) {
841 }
842 else {
843 new_track = BKE_nlatrack_new_after(&adt->nla_tracks, track, ID_IS_OVERRIDE_LIBRARY(id));
844 }
845
846 BKE_nlatrack_set_active(&adt->nla_tracks, new_track);
847
849
852
853 return new_track;
854}
855
856static void rna_NlaTrack_remove(
857 ID *id, AnimData *adt, Main *bmain, bContext *C, ReportList *reports, PointerRNA *track_ptr)
858{
859 NlaTrack *track = static_cast<NlaTrack *>(track_ptr->data);
860
861 if (BLI_findindex(&adt->nla_tracks, track) == -1) {
862 BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' cannot be removed", track->name);
863 return;
864 }
865
866 BKE_nlatrack_remove_and_free(&adt->nla_tracks, track, true);
867 RNA_POINTER_INVALIDATE(track_ptr);
868
870
873}
874
875static PointerRNA rna_NlaTrack_active_get(PointerRNA *ptr)
876{
877 AnimData *adt = (AnimData *)ptr->data;
879 return rna_pointer_inherit_refine(ptr, &RNA_NlaTrack, track);
880}
881
882static void rna_NlaTrack_active_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
883{
884 AnimData *adt = (AnimData *)ptr->data;
885 NlaTrack *track = (NlaTrack *)value.data;
887}
888
889static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_driver)
890{
891 /* verify that we've got a driver to duplicate */
892 if (ELEM(nullptr, src_driver, src_driver->driver)) {
893 BKE_report(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of");
894 return nullptr;
895 }
896 else {
897 /* just make a copy of the existing one and add to self */
898 FCurve *new_fcu = BKE_fcurve_copy(src_driver);
899
900 /* XXX: if we impose any ordering on these someday, this will be problematic */
901 BLI_addtail(&adt->drivers, new_fcu);
902 return new_fcu;
903 }
904}
905
906static FCurve *rna_Driver_new(
907 ID *id, AnimData *adt, Main *bmain, ReportList *reports, const char *rna_path, int array_index)
908{
909 if (rna_path[0] == '\0') {
910 BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
911 return nullptr;
912 }
913
914 if (BKE_fcurve_find(&adt->drivers, rna_path, array_index)) {
915 BKE_reportf(reports, RPT_ERROR, "Driver '%s[%d]' already exists", rna_path, array_index);
916 return nullptr;
917 }
918
919 FCurve *fcu = verify_driver_fcurve(id, rna_path, array_index, DRIVER_FCURVE_KEYFRAMES);
920 BLI_assert(fcu != nullptr);
921
923
924 return fcu;
925}
926
927static void rna_Driver_remove(AnimData *adt, Main *bmain, ReportList *reports, FCurve *fcu)
928{
929 if (!BLI_remlink_safe(&adt->drivers, fcu)) {
930 BKE_report(reports, RPT_ERROR, "Driver not found in this animation data");
931 return;
932 }
933 BKE_fcurve_free(fcu);
935}
936
937static FCurve *rna_Driver_find(AnimData *adt,
938 ReportList *reports,
939 const char *data_path,
940 int index)
941{
942 if (data_path[0] == '\0') {
943 BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
944 return nullptr;
945 }
946
947 /* Returns nullptr if not found. */
948 return BKE_fcurve_find(&adt->drivers, data_path, index);
949}
950
951std::optional<std::string> rna_AnimData_path(const PointerRNA * /*ptr*/)
952{
953 return std::string{"animation_data"};
954}
955
957{
958 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
959 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
960 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
961 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
962 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
963 const int len_dst = rnaapply_ctx.len_src;
964 const int len_src = rnaapply_ctx.len_src;
965 const int len_storage = rnaapply_ctx.len_storage;
967
968 BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
970 "Unsupported RNA override operation on animdata pointer");
971 UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
972
973 /* AnimData is a special case, since you cannot edit/replace it, it's either existent or not.
974 * Further more, when an animdata is added to the linked reference later on, the one created
975 * for the liboverride needs to be 'merged', such that its overridable data is kept. */
976 AnimData *adt_dst = static_cast<AnimData *>(RNA_property_pointer_get(ptr_dst, prop_dst).data);
977 AnimData *adt_src = static_cast<AnimData *>(RNA_property_pointer_get(ptr_src, prop_src).data);
978
979 if (adt_dst == nullptr && adt_src != nullptr) {
980 /* Copy anim data from reference into final local ID. */
981 BKE_animdata_copy_id(nullptr, ptr_dst->owner_id, ptr_src->owner_id, 0);
982 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
983 return true;
984 }
985 else if (adt_dst != nullptr && adt_src == nullptr) {
986 /* Override has cleared/removed anim data from its reference. */
987 BKE_animdata_free(ptr_dst->owner_id, true);
988 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
989 return true;
990 }
991 else if (adt_dst != nullptr && adt_src != nullptr) {
992 /* Override had to create an anim data, but now its reference also has one, need to merge
993 * them by keeping the few overridable data from the liboverride, while using the animdata of
994 * the reference.
995 *
996 * Note that this case will not be encountered when the linked reference data already had
997 * anim data, since there will be no operation for the animdata pointer itself then, only
998 * potentially for its internal overridable data (NLA, action...). */
999 id_us_min(reinterpret_cast<ID *>(adt_dst->action));
1000 adt_dst->action = adt_src->action;
1001 id_us_plus(reinterpret_cast<ID *>(adt_dst->action));
1002 id_us_min(reinterpret_cast<ID *>(adt_dst->tmpact));
1003# ifdef WITH_ANIM_BAKLAVA
1004 adt_dst->slot_handle = adt_src->slot_handle;
1005 STRNCPY(adt_dst->slot_name, adt_src->slot_name);
1006# endif
1007 adt_dst->tmpact = adt_src->tmpact;
1008 id_us_plus(reinterpret_cast<ID *>(adt_dst->tmpact));
1009 adt_dst->act_blendmode = adt_src->act_blendmode;
1010 adt_dst->act_extendmode = adt_src->act_extendmode;
1011 adt_dst->act_influence = adt_src->act_influence;
1012 adt_dst->flag = adt_src->flag;
1013
1014 /* NLA tracks: since overrides are always after tracks from linked reference, we can 'just'
1015 * move the whole list from `src` to the end of the list of `dst` (which currently contains
1016 * tracks from linked reference). then active track and strip pointers can be kept as-is. */
1017 BLI_movelisttolist(&adt_dst->nla_tracks, &adt_src->nla_tracks);
1018 adt_dst->act_track = adt_src->act_track;
1019 adt_dst->actstrip = adt_src->actstrip;
1020
1022 ANIM_id_update(bmain, ptr_dst->owner_id);
1023 }
1024
1025 return false;
1026}
1027
1028bool rna_NLA_tracks_override_apply(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
1029{
1030 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
1031 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
1032 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
1034
1036 "Unsupported RNA override operation on constraints collection");
1037
1038 AnimData *anim_data_dst = (AnimData *)ptr_dst->data;
1039 AnimData *anim_data_src = (AnimData *)ptr_src->data;
1040
1041 /* Remember that insertion operations are defined and stored in correct order, which means that
1042 * even if we insert several items in a row, we always insert first one, then second one, etc.
1043 * So we should always find 'anchor' track in both _src *and* _dst.
1044 *
1045 * This is only true however is NLA tracks do not get removed from linked data. Otherwise, an
1046 * index-based reference may lead to lost data. */
1047 NlaTrack *nla_track_anchor = nullptr;
1048# if 0
1049 /* This is not working so well with index-based insertion, especially in case some tracks get
1050 * added to lib linked data. So we simply add locale tracks at the end of the list always, order
1051 * of override operations should ensure order of local tracks is preserved properly. */
1052 if (opop->subitem_reference_index >= 0) {
1053 nla_track_anchor = BLI_findlink(&anim_data_dst->nla_tracks, opop->subitem_reference_index);
1054 }
1055 /* Otherwise we just insert in first position. */
1056# else
1057 nla_track_anchor = static_cast<NlaTrack *>(anim_data_dst->nla_tracks.last);
1058# endif
1059
1060 NlaTrack *nla_track_src = nullptr;
1061 if (opop->subitem_local_index >= 0) {
1062 nla_track_src = static_cast<NlaTrack *>(
1063 BLI_findlink(&anim_data_src->nla_tracks, opop->subitem_local_index));
1064 }
1065
1066 if (nla_track_src == nullptr) {
1067 /* Can happen if tracks were removed from linked data. */
1068 return false;
1069 }
1070
1071 NlaTrack *nla_track_dst = BKE_nlatrack_copy(bmain, nla_track_src, true, 0);
1072
1073 /* This handles nullptr anchor as expected by adding at head of list. */
1074 BLI_insertlinkafter(&anim_data_dst->nla_tracks, nla_track_anchor, nla_track_dst);
1075
1076 // printf("%s: We inserted a NLA Track...\n", __func__);
1077
1078 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
1079 return true;
1080}
1081
1082#else
1083
1084/* helper function for Keying Set -> keying settings */
1085static void rna_def_common_keying_flags(StructRNA *srna, short reg)
1086{
1087 PropertyRNA *prop;
1088
1089 /* override scene/userpref defaults? */
1090 prop = RNA_def_property(srna, "use_insertkey_override_needed", PROP_BOOLEAN, PROP_NONE);
1091 RNA_def_property_boolean_sdna(prop, nullptr, "keyingoverride", INSERTKEY_NEEDED);
1093 "Override Insert Keyframes Default- Only Needed",
1094 "Override default setting to only insert keyframes where they're "
1095 "needed in the relevant F-Curves");
1096 if (reg) {
1098 }
1099
1100 prop = RNA_def_property(srna, "use_insertkey_override_visual", PROP_BOOLEAN, PROP_NONE);
1101 RNA_def_property_boolean_sdna(prop, nullptr, "keyingoverride", INSERTKEY_MATRIX);
1103 prop,
1104 "Override Insert Keyframes Default - Visual",
1105 "Override default setting to insert keyframes based on 'visual transforms'");
1106 if (reg) {
1108 }
1109
1110 /* value to override defaults with */
1111 prop = RNA_def_property(srna, "use_insertkey_needed", PROP_BOOLEAN, PROP_NONE);
1112 RNA_def_property_boolean_sdna(prop, nullptr, "keyingflag", INSERTKEY_NEEDED);
1114 "Insert Keyframes - Only Needed",
1115 "Only insert keyframes where they're needed in the relevant F-Curves");
1116 if (reg) {
1118 }
1119
1120 prop = RNA_def_property(srna, "use_insertkey_visual", PROP_BOOLEAN, PROP_NONE);
1121 RNA_def_property_boolean_sdna(prop, nullptr, "keyingflag", INSERTKEY_MATRIX);
1123 prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'");
1124 if (reg) {
1126 }
1127}
1128
1129/* --- */
1130
1131/* To avoid repeating it twice! */
1132# define KEYINGSET_IDNAME_DOC \
1133 "If this is set, the Keying Set gets a custom ID, otherwise it takes " \
1134 "the name of the class used to define the Keying Set (for example, " \
1135 "if the class name is \"BUILTIN_KSI_location\", and bl_idname is not " \
1136 "set by the script, then bl_idname = \"BUILTIN_KSI_location\")"
1137
1139{
1140 StructRNA *srna;
1141 PropertyRNA *prop;
1142 FunctionRNA *func;
1143 PropertyRNA *parm;
1144
1145 srna = RNA_def_struct(brna, "KeyingSetInfo", nullptr);
1146 RNA_def_struct_sdna(srna, "KeyingSetInfo");
1148 srna, "Keying Set Info", "Callback function defines for builtin Keying Sets");
1149 RNA_def_struct_refine_func(srna, "rna_KeyingSetInfo_refine");
1151 srna, "rna_KeyingSetInfo_register", "rna_KeyingSetInfo_unregister", nullptr);
1152
1153 /* Properties --------------------- */
1154
1155 RNA_define_verify_sdna(false); /* not in sdna */
1156
1157 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1158 RNA_def_property_string_sdna(prop, nullptr, "idname");
1161
1162 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1163 RNA_def_property_string_sdna(prop, nullptr, "name");
1164 RNA_def_property_ui_text(prop, "UI Name", "");
1165 RNA_def_struct_name_property(srna, prop);
1167
1168 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1169 RNA_def_property_string_sdna(prop, nullptr, "description");
1170 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1172 RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
1173
1174 /* Regarding why we don't use rna_def_common_keying_flags() here:
1175 * - Using it would keep this case in sync with the other places
1176 * where these options are exposed (which are optimized for being
1177 * used in the UI).
1178 * - Unlike all the other places, this case is used for defining
1179 * new "built in" Keying Sets via the Python API. In that case,
1180 * it makes more sense to expose these in a way more similar to
1181 * other places featuring bl_idname/label/description (i.e. operators)
1182 */
1183 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1184 RNA_def_property_enum_sdna(prop, nullptr, "keyingflag");
1187 RNA_def_property_ui_text(prop, "Options", "Keying Set options to use when inserting keyframes");
1188
1190
1191 /* Function Callbacks ------------- */
1192 /* poll */
1193 func = RNA_def_function(srna, "poll", nullptr);
1194 RNA_def_function_ui_description(func, "Test if Keying Set can be used or not");
1196 RNA_def_function_return(func, RNA_def_boolean(func, "ok", true, "", ""));
1197 parm = RNA_def_pointer(func, "context", "Context", "", "");
1199
1200 /* iterator */
1201 func = RNA_def_function(srna, "iterator", nullptr);
1203 func, "Call generate() on the structs which have properties to be keyframed");
1205 parm = RNA_def_pointer(func, "context", "Context", "", "");
1207 parm = RNA_def_pointer(func, "ks", "KeyingSet", "", "");
1209
1210 /* generate */
1211 func = RNA_def_function(srna, "generate", nullptr);
1213 func, "Add Paths to the Keying Set to keyframe the properties of the given data");
1215 parm = RNA_def_pointer(func, "context", "Context", "", "");
1217 parm = RNA_def_pointer(func, "ks", "KeyingSet", "", "");
1219 parm = RNA_def_pointer(func, "data", "AnyType", "", "");
1221}
1222
1224{
1225 StructRNA *srna;
1226 PropertyRNA *prop;
1227
1228 srna = RNA_def_struct(brna, "KeyingSetPath", nullptr);
1229 RNA_def_struct_sdna(srna, "KS_Path");
1230 RNA_def_struct_ui_text(srna, "Keying Set Path", "Path to a setting for use in a Keying Set");
1231
1232 /* ID */
1233 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1234 RNA_def_property_struct_type(prop, "ID");
1236 RNA_def_property_editable_func(prop, "rna_ksPath_id_editable");
1237 RNA_def_property_pointer_funcs(prop, nullptr, nullptr, "rna_ksPath_id_typef", nullptr);
1239 "ID-Block",
1240 "ID-Block that keyframes for Keying Set should be added to "
1241 "(for Absolute Keying Sets only)");
1243 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1244
1245 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
1246 RNA_def_property_enum_sdna(prop, nullptr, "idtype");
1249 RNA_def_property_enum_funcs(prop, nullptr, "rna_ksPath_id_type_set", nullptr);
1250 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
1253 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1254
1255 /* Group */
1256 prop = RNA_def_property(srna, "group", PROP_STRING, PROP_NONE);
1258 prop, "Group Name", "Name of Action Group to assign setting(s) for this path to");
1260 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1261
1262 /* Grouping */
1263 prop = RNA_def_property(srna, "group_method", PROP_ENUM, PROP_NONE);
1264 RNA_def_property_enum_sdna(prop, nullptr, "groupmode");
1267 prop, "Grouping Method", "Method used to define which Group-name to use");
1269 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1270
1271 /* Path + Array Index */
1272 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1274 prop, "rna_ksPath_RnaPath_get", "rna_ksPath_RnaPath_length", "rna_ksPath_RnaPath_set");
1275 RNA_def_property_ui_text(prop, "Data Path", "Path to property setting");
1276 RNA_def_struct_name_property(srna, prop); /* XXX this is the best indicator for now... */
1278
1279 /* called 'index' when given as function arg */
1280 prop = RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
1281 RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific setting if applicable");
1283 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1284
1285 /* Flags */
1286 prop = RNA_def_property(srna, "use_entire_array", PROP_BOOLEAN, PROP_NONE);
1289 prop,
1290 "Entire Array",
1291 "When an 'array/vector' type is chosen (Location, Rotation, Color, etc.), "
1292 "entire array is to be used");
1294 prop, NC_SCENE | ND_KEYINGSET | NA_EDITED, nullptr); /* XXX: maybe a bit too noisy */
1295
1296 /* Keyframing Settings */
1298}
1299
1300/* keyingset.paths */
1302{
1303 StructRNA *srna;
1304
1305 FunctionRNA *func;
1306 PropertyRNA *parm;
1307
1308 PropertyRNA *prop;
1309
1310 RNA_def_property_srna(cprop, "KeyingSetPaths");
1311 srna = RNA_def_struct(brna, "KeyingSetPaths", nullptr);
1312 RNA_def_struct_sdna(srna, "KeyingSet");
1313 RNA_def_struct_ui_text(srna, "Keying set paths", "Collection of keying set paths");
1314
1315 /* Add Path */
1316 func = RNA_def_function(srna, "add", "rna_KeyingSet_paths_add");
1317 RNA_def_function_ui_description(func, "Add a new path for the Keying Set");
1319 /* return arg */
1320 parm = RNA_def_pointer(
1321 func, "ksp", "KeyingSetPath", "New Path", "Path created and added to the Keying Set");
1322 RNA_def_function_return(func, parm);
1323 /* ID-block for target */
1324 parm = RNA_def_pointer(
1325 func, "target_id", "ID", "Target ID", "ID data-block for the destination");
1327 /* rna-path */
1328 /* XXX hopefully this is long enough */
1329 parm = RNA_def_string(
1330 func, "data_path", nullptr, 256, "Data-Path", "RNA-Path to destination property");
1332 /* index (defaults to -1 for entire array) */
1333 RNA_def_int(func,
1334 "index",
1335 -1,
1336 -1,
1337 INT_MAX,
1338 "Index",
1339 "The index of the destination property (i.e. axis of Location/Rotation/etc.), "
1340 "or -1 for the entire array",
1341 0,
1342 INT_MAX);
1343 /* grouping */
1344 RNA_def_enum(func,
1345 "group_method",
1348 "Grouping Method",
1349 "Method used to define which Group-name to use");
1351 func,
1352 "group_name",
1353 nullptr,
1354 64,
1355 "Group Name",
1356 "Name of Action Group to assign destination to (only if grouping mode is to use this name)");
1357
1358 /* Remove Path */
1359 func = RNA_def_function(srna, "remove", "rna_KeyingSet_paths_remove");
1360 RNA_def_function_ui_description(func, "Remove the given path from the Keying Set");
1362 /* path to remove */
1363 parm = RNA_def_pointer(func, "path", "KeyingSetPath", "Path", "");
1366
1367 /* Remove All Paths */
1368 func = RNA_def_function(srna, "clear", "rna_KeyingSet_paths_clear");
1369 RNA_def_function_ui_description(func, "Remove all the paths from the Keying Set");
1371
1372 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1373 RNA_def_property_struct_type(prop, "KeyingSetPath");
1375 RNA_def_property_editable_func(prop, "rna_KeyingSet_active_ksPath_editable");
1377 "rna_KeyingSet_active_ksPath_get",
1378 "rna_KeyingSet_active_ksPath_set",
1379 nullptr,
1380 nullptr);
1382 prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes");
1383
1384 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1385 RNA_def_property_int_sdna(prop, nullptr, "active_path");
1387 "rna_KeyingSet_active_ksPath_index_get",
1388 "rna_KeyingSet_active_ksPath_index_set",
1389 "rna_KeyingSet_active_ksPath_index_range");
1390 RNA_def_property_ui_text(prop, "Active Path Index", "Current Keying Set index");
1391}
1392
1394{
1395 StructRNA *srna;
1396 PropertyRNA *prop;
1397
1398 srna = RNA_def_struct(brna, "KeyingSet", nullptr);
1399 RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
1400
1401 /* Id/Label */
1402 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1403 RNA_def_property_string_sdna(prop, nullptr, "idname");
1406 /* NOTE: disabled, as ID name shouldn't be editable */
1407# if 0
1409# endif
1410
1411 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1412 RNA_def_property_string_sdna(prop, nullptr, "name");
1413 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_KeyingSet_name_set");
1414 RNA_def_property_ui_text(prop, "UI Name", "");
1415 RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
1416 RNA_def_struct_name_property(srna, prop);
1418
1419 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1420 RNA_def_property_string_sdna(prop, nullptr, "description");
1421 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1422 RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
1423
1424 /* KeyingSetInfo (Type Info) for Builtin Sets only. */
1425 prop = RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE);
1426 RNA_def_property_struct_type(prop, "KeyingSetInfo");
1427 RNA_def_property_pointer_funcs(prop, "rna_KeyingSet_typeinfo_get", nullptr, nullptr, nullptr);
1429 prop, "Type Info", "Callback function defines for built-in Keying Sets");
1430
1431 /* Paths */
1432 prop = RNA_def_property(srna, "paths", PROP_COLLECTION, PROP_NONE);
1433 RNA_def_property_collection_sdna(prop, nullptr, "paths", nullptr);
1434 RNA_def_property_struct_type(prop, "KeyingSetPath");
1436 prop, "Paths", "Keying Set Paths to define settings that get keyframed together");
1437 rna_def_keyingset_paths(brna, prop);
1438
1439 /* Flags */
1440 prop = RNA_def_property(srna, "is_path_absolute", PROP_BOOLEAN, PROP_NONE);
1442 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KEYINGSET_ABSOLUTE);
1444 "Absolute",
1445 "Keying Set defines specific paths/settings to be keyframed "
1446 "(i.e. is not reliant on context info)");
1447
1448 /* Keyframing Flags */
1450
1451 /* Keying Set API */
1452 RNA_api_keyingset(srna);
1453}
1454
1455# undef KEYINGSET_IDNAME_DOC
1456/* --- */
1457
1459{
1460 StructRNA *srna;
1461 PropertyRNA *parm;
1462 FunctionRNA *func;
1463
1464 PropertyRNA *prop;
1465
1466 RNA_def_property_srna(cprop, "NlaTracks");
1467 srna = RNA_def_struct(brna, "NlaTracks", nullptr);
1468 RNA_def_struct_sdna(srna, "AnimData");
1469 RNA_def_struct_ui_text(srna, "NLA Tracks", "Collection of NLA Tracks");
1470
1471 func = RNA_def_function(srna, "new", "rna_NlaTrack_new");
1473 RNA_def_function_ui_description(func, "Add a new NLA Track");
1474 RNA_def_pointer(func, "prev", "NlaTrack", "", "NLA Track to add the new one after");
1475 /* return type */
1476 parm = RNA_def_pointer(func, "track", "NlaTrack", "", "New NLA Track");
1477 RNA_def_function_return(func, parm);
1478
1479 func = RNA_def_function(srna, "remove", "rna_NlaTrack_remove");
1482 RNA_def_function_ui_description(func, "Remove a NLA Track");
1483 parm = RNA_def_pointer(func, "track", "NlaTrack", "", "NLA Track to remove");
1486
1487 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1488 RNA_def_property_struct_type(prop, "NlaTrack");
1490 prop, "rna_NlaTrack_active_get", "rna_NlaTrack_active_set", nullptr, nullptr);
1492 RNA_def_property_ui_text(prop, "Active Track", "Active NLA Track");
1494 /* XXX: should (but doesn't) update the active track in the NLA window */
1496}
1497
1499{
1500 StructRNA *srna;
1501 PropertyRNA *parm;
1502 FunctionRNA *func;
1503
1504 // PropertyRNA *prop;
1505
1506 RNA_def_property_srna(cprop, "AnimDataDrivers");
1507 srna = RNA_def_struct(brna, "AnimDataDrivers", nullptr);
1508 RNA_def_struct_sdna(srna, "AnimData");
1509 RNA_def_struct_ui_text(srna, "Drivers", "Collection of Driver F-Curves");
1510
1511 /* Match: ActionFCurves.new/remove */
1512
1513 /* AnimData.drivers.new(...) */
1514 func = RNA_def_function(srna, "new", "rna_Driver_new");
1516 parm = RNA_def_string(func, "data_path", nullptr, 0, "Data Path", "F-Curve data path to use");
1518 RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
1519 /* return type */
1520 parm = RNA_def_pointer(func, "driver", "FCurve", "", "Newly Driver F-Curve");
1521 RNA_def_function_return(func, parm);
1522
1523 /* AnimData.drivers.remove(...) */
1524 func = RNA_def_function(srna, "remove", "rna_Driver_remove");
1526 parm = RNA_def_pointer(func, "driver", "FCurve", "", "");
1528
1529 /* AnimData.drivers.from_existing(...) */
1530 func = RNA_def_function(srna, "from_existing", "rna_Driver_from_existing");
1532 RNA_def_function_ui_description(func, "Add a new driver given an existing one");
1533 RNA_def_pointer(func,
1534 "src_driver",
1535 "FCurve",
1536 "",
1537 "Existing Driver F-Curve to use as template for a new one");
1538 /* return type */
1539 parm = RNA_def_pointer(func, "driver", "FCurve", "", "New Driver F-Curve");
1540 RNA_def_function_return(func, parm);
1541
1542 /* AnimData.drivers.find(...) */
1543 func = RNA_def_function(srna, "find", "rna_Driver_find");
1545 func,
1546 "Find a driver F-Curve. Note that this function performs a linear scan "
1547 "of all driver F-Curves.");
1549 parm = RNA_def_string(func, "data_path", nullptr, 0, "Data Path", "F-Curve data path");
1551 RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
1552 /* return type */
1553 parm = RNA_def_pointer(
1554 func, "fcurve", "FCurve", "", "The found F-Curve, or None if it doesn't exist");
1555 RNA_def_function_return(func, parm);
1556}
1557
1559{
1560 PropertyRNA *prop;
1561
1562 prop = RNA_def_property(srna, "animation_data", PROP_POINTER, PROP_NONE);
1563 RNA_def_property_pointer_sdna(prop, nullptr, "adt");
1566 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_AnimaData_override_apply");
1567 RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this data-block");
1568}
1569
1571{
1572 StructRNA *srna;
1573 PropertyRNA *prop;
1574
1575 srna = RNA_def_struct(brna, "AnimData", nullptr);
1576 RNA_def_struct_ui_text(srna, "Animation Data", "Animation data for data-block");
1577 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
1578 RNA_def_struct_path_func(srna, "rna_AnimData_path");
1579
1580 /* NLA */
1581 prop = RNA_def_property(srna, "nla_tracks", PROP_COLLECTION, PROP_NONE);
1582 RNA_def_property_collection_sdna(prop, nullptr, "nla_tracks", nullptr);
1583 RNA_def_property_struct_type(prop, "NlaTrack");
1584 RNA_def_property_ui_text(prop, "NLA Tracks", "NLA Tracks (i.e. Animation Layers)");
1588 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_NLA_tracks_override_apply");
1589
1590 rna_api_animdata_nla_tracks(brna, prop);
1591
1593
1594 /* Active Action */
1595 prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
1596 RNA_def_property_struct_type(prop, "Action");
1597 /* this flag as well as the dynamic test must be defined for this to be editable... */
1601 prop,
1602 /* Define a getter that is NULL-safe, so that an RNA_AnimData prop with `ptr->data = nullptr`
1603 * can still be used to get the property. In that case it will always return nullptr, of
1604 * course, but it won't crash Blender. */
1605 "rna_AnimData_action_get",
1606 /* Similarly, for the setter, the NULL-safety allows constructing the AnimData struct on
1607 * assignment of this "action" property. This is possible because RNA has typed NULL
1608 * pointers, and thus it knows which setter to call even when `ptr->data` is NULL. */
1609 "rna_AnimData_action_set",
1610 nullptr,
1611 "rna_Action_id_poll");
1612 RNA_def_property_editable_func(prop, "rna_AnimData_action_editable");
1613 RNA_def_property_ui_text(prop, "Action", "Active Action for this data-block");
1614 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_AnimData_dependency_update");
1615
1616 /* Active Action Settings */
1617 prop = RNA_def_property(srna, "action_extrapolation", PROP_ENUM, PROP_NONE);
1618 RNA_def_property_enum_sdna(prop, nullptr, "act_extendmode");
1621 prop,
1622 "Action Extrapolation",
1623 "Action to take for gaps past the Active Action's range (when evaluating with NLA)");
1624 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update");
1625
1626 prop = RNA_def_property(srna, "action_blend_type", PROP_ENUM, PROP_NONE);
1627 RNA_def_property_enum_sdna(prop, nullptr, "act_blendmode");
1630 prop,
1631 "Action Blending",
1632 "Method used for combining Active Action's result with result of NLA stack");
1633 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); /* this will do? */
1634
1635 prop = RNA_def_property(srna, "action_influence", PROP_FLOAT, PROP_FACTOR);
1636 RNA_def_property_float_sdna(prop, nullptr, "act_influence");
1638 RNA_def_property_range(prop, 0.0f, 1.0f);
1640 "Action Influence",
1641 "Amount the Active Action contributes to the result of the NLA stack");
1642 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); /* this will do? */
1643
1644 /* Temporary action slot for tweak mode. */
1645 prop = RNA_def_property(srna, "action_tweak_storage", PROP_POINTER, PROP_NONE);
1646 RNA_def_property_pointer_sdna(prop, nullptr, "tmpact");
1649 prop, nullptr, "rna_AnimData_tmpact_set", nullptr, "rna_Action_id_poll");
1651 "Tweak Mode Action Storage",
1652 "Slot to temporarily hold the main action while in tweak mode");
1653 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_AnimData_dependency_update");
1654
1655 /* Drivers */
1656 prop = RNA_def_property(srna, "drivers", PROP_COLLECTION, PROP_NONE);
1657 RNA_def_property_collection_sdna(prop, nullptr, "drivers", nullptr);
1658 RNA_def_property_struct_type(prop, "FCurve");
1659 RNA_def_property_ui_text(prop, "Drivers", "The Drivers/Expressions for this data-block");
1660
1662
1663 rna_api_animdata_drivers(brna, prop);
1664
1666
1667 /* General Settings */
1668 prop = RNA_def_property(srna, "use_nla", PROP_BOOLEAN, PROP_NONE);
1671 prop, "NLA Evaluation Enabled", "NLA stack is evaluated when evaluating this block");
1672 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); /* this will do? */
1673
1674 prop = RNA_def_property(srna, "use_tweak_mode", PROP_BOOLEAN, PROP_NONE);
1675 RNA_def_property_boolean_sdna(prop, nullptr, "flag", ADT_NLA_EDIT_ON);
1676 RNA_def_property_boolean_funcs(prop, nullptr, "rna_AnimData_tweakmode_set");
1678 prop, "Use NLA Tweak Mode", "Whether to enable or disable tweak mode in NLA");
1679 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update");
1680 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_AnimData_tweakmode_override_apply");
1681
1682 prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
1685 RNA_def_property_ui_text(prop, "Pin in Graph Editor", "");
1687
1688# ifdef WITH_ANIM_BAKLAVA
1689 /* This property is not necessary for the Python API (that is better off using
1690 * slot references/pointers directly), but it is needed for library overrides
1691 * to work. */
1692 prop = RNA_def_property(srna, "action_slot_handle", PROP_INT, PROP_NONE);
1693 RNA_def_property_int_sdna(prop, nullptr, "slot_handle");
1694 RNA_def_property_int_funcs(prop, nullptr, "rna_AnimData_action_slot_handle_set", nullptr);
1696 "Action Slot Handle",
1697 "A number that identifies which sub-set of the Action is considered "
1698 "to be for this data-block");
1700 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_AnimData_dependency_update");
1701
1702 prop = RNA_def_property(srna, "action_slot_name", PROP_STRING, PROP_NONE);
1703 RNA_def_property_string_sdna(prop, nullptr, "slot_name");
1705 prop,
1706 "Action Slot Name",
1707 "The name of the action slot. The slot identifies which sub-set of the Action "
1708 "is considered to be for this data-block, and its name is used to find the right slot "
1709 "when assigning an Action.");
1710
1711 prop = RNA_def_property(srna, "action_slot", PROP_POINTER, PROP_NONE);
1712 RNA_def_property_struct_type(prop, "ActionSlot");
1716 prop,
1717 "Action Slot",
1718 "The slot identifies which sub-set of the Action is considered to be for this "
1719 "data-block, and its name is used to find the right slot when assigning an Action");
1721 prop, "rna_AnimData_action_slot_get", "rna_AnimData_action_slot_set", nullptr, nullptr);
1723 prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_AnimData_action_slot_update");
1724 /* `adt.action_slot` is exposed to RNA as a pointer for things like the action slot selector in
1725 * the GUI. The ground truth of the assigned slot, however, is `action_slot_handle` declared
1726 * above. That property is used for library override operations, and this pointer property should
1727 * just be ignored.
1728 *
1729 * This needs PROPOVERRIDE_IGNORE; PROPOVERRIDE_NO_COMPARISON is not suitable here. This property
1730 * should act as if it is an overridable property (as from the user's perspective, it is), but an
1731 * override operation should not be created for it. It will be created for `action_slot_handle`,
1732 * and that's enough. */
1734
1735 prop = RNA_def_property(srna, "action_slots", PROP_COLLECTION, PROP_NONE);
1736 RNA_def_property_struct_type(prop, "ActionSlot");
1738 "rna_iterator_animdata_action_slots_begin",
1739 "rna_iterator_array_next",
1740 "rna_iterator_array_end",
1741 "rna_iterator_array_dereference_get",
1742 nullptr,
1743 nullptr,
1744 nullptr,
1745 nullptr);
1746 RNA_def_property_ui_text(prop, "Slots", "The list of slots in this animation data-block");
1747# endif /* WITH_ANIM_BAKLAVA */
1748
1750
1751 /* Animation Data API */
1752 RNA_api_animdata(srna);
1753}
1754
1755/* --- */
1756
1758{
1759 rna_def_animdata(brna);
1760
1761 rna_def_keyingset(brna);
1764}
1765
1766#endif
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
bool BKE_animdata_action_editable(const AnimData *adt)
Definition anim_data.cc:224
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
Definition anim_data.cc:194
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, int flag)
Definition anim_data.cc:452
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:89
void BKE_animdata_free(ID *id, bool do_id_user)
Definition anim_data.cc:263
bool BKE_animdata_set_tmpact(ReportList *reports, ID *id, bAction *act)
Definition anim_data.cc:181
struct KS_Path * BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
Definition anim_sys.cc:164
void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp)
Definition anim_sys.cc:227
ReportList * CTX_wm_reports(const bContext *C)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
void BKE_fcurve_free(FCurve *fcu)
void id_us_plus(ID *id)
Definition lib_id.cc:351
void id_us_min(ID *id)
Definition lib_id.cc:359
void BKE_nla_tweakmode_exit(OwnedAnimData owned_adt)
NlaTrack * BKE_nlatrack_copy(Main *bmain, NlaTrack *nlt, bool use_same_actions, int flag)
void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt)
NlaTrack * BKE_nlatrack_new_after(ListBase *nla_tracks, NlaTrack *prev, bool is_liboverride)
NlaTrack * BKE_nlatrack_new_tail(ListBase *nla_tracks, const bool is_liboverride)
bool BKE_nla_tweakmode_enter(OwnedAnimData owned_adt)
NlaTrack * BKE_nlatrack_find_active(ListBase *tracks)
void BKE_nlatrack_remove_and_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
void BLI_kdtree_nd_ free(KDTree *tree)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:331
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
bool BLI_remlink_safe(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:153
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.c:40
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define UNUSED_VARS(...)
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define STREQ(a, b)
#define BLT_I18NCONTEXT_ID_ACTION
#define BLT_I18NCONTEXT_ID_ID
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1085
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1044
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:229
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:239
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:683
@ ID_OB
@ ADT_CURVES_ALWAYS_VISIBLE
@ ADT_NLA_EVAL_OFF
@ ADT_NLA_EDIT_ON
@ KEYINGSET_ABSOLUTE
@ INSERTKEY_CYCLE_AWARE
@ INSERTKEY_REPLACE
@ INSERTKEY_MATRIX
@ INSERTKEY_NEEDED
@ INSERTKEY_AVAILABLE
@ KSP_GROUP_KSNAME
@ KSP_GROUP_NAMED
@ KSP_GROUP_NONE
@ KSP_FLAG_WHOLE_ARRAY
Object is a sort of wrapper for general info.
@ DRIVER_FCURVE_KEYFRAMES
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
StructRNA * ID_code_to_RNA_type(short idcode)
#define RNA_DYN_DESCR_MAX
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_REGISTER
Definition RNA_types.hh:687
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
Definition RNA_types.hh:746
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
void(*)(void *data) StructFreeFunc
Definition RNA_types.hh:751
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
Definition RNA_types.hh:747
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:375
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition RNA_types.hh:380
@ PROPOVERRIDE_NO_PROP_NAME
Definition RNA_types.hh:388
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ENUM_FLAG
Definition RNA_types.hh:293
@ PROP_REGISTER_OPTIONAL
Definition RNA_types.hh:301
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:328
@ PROP_REGISTER
Definition RNA_types.hh:300
@ PROP_HIDDEN
Definition RNA_types.hh:239
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:253
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FACTOR
Definition RNA_types.hh:154
constexpr PointerRNA PointerRNA_NULL
Definition RNA_types.hh:45
#define NC_WINDOW
Definition WM_types.hh:342
#define ND_NLA_ACTCHANGE
Definition WM_types.hh:465
#define NC_ANIMATION
Definition WM_types.hh:355
#define ND_KEYINGSET
Definition WM_types.hh:415
#define NC_SCENE
Definition WM_types.hh:345
#define NA_ADDED
Definition WM_types.hh:552
#define NA_EDITED
Definition WM_types.hh:550
#define NA_REMOVED
Definition WM_types.hh:553
#define ND_NLA
Definition WM_types.hh:464
#define NA_RENAME
Definition WM_types.hh:554
#define ND_ANIMCHAN
Definition WM_types.hh:463
#define NA_SELECTED
Definition WM_types.hh:555
void ANIM_id_update(Main *bmain, ID *id)
Definition anim_deps.cc:102
constexpr const T * data() const
Definition BLI_span.hh:216
constexpr int64_t size() const
Definition BLI_span.hh:253
blender::Span< const Slot * > slots() const
Slot * slot_for_handle(slot_handle_t handle)
static void users_invalidate(Main &bmain)
bool is_suitable_for(const ID &animated_id) const
FCurve * verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
Definition drivers.cc:50
#define GS(x)
Definition iris.cc:202
KeyingSetInfo * ANIM_keyingset_info_find_name(const char name[])
void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *keyingset_info)
void ANIM_keyingset_info_register(KeyingSetInfo *keyingset_info)
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
Vector< bActionGroup * > channel_groups_for_assigned_slot(AnimData *adt)
ActionSlotAssignmentResult generic_assign_action_slot(Slot *slot_to_assign, ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_name) ATTR_WARN_UNUSED_RESULT
decltype(::ActionSlot::handle) slot_handle_t
Action * get_action(ID &animated_id)
ActionSlotAssignmentResult generic_assign_action_slot_handle(slot_handle_t slot_handle_to_assign, ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_name) ATTR_WARN_UNUSED_RESULT
bool assign_action(bAction *action, ID &animated_id)
return ret
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:35
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void * RNA_struct_blender_type_get(StructRNA *srna)
void RNA_parameter_list_free(ParameterList *parms)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **r_value)
PointerRNA RNA_id_pointer_create(ID *id)
static void rna_def_common_keying_flags(StructRNA *srna, short reg)
const EnumPropertyItem rna_enum_keying_flag_api_items[]
void RNA_def_animation(BlenderRNA *brna)
static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_animdata(BlenderRNA *brna)
static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
const EnumPropertyItem rna_enum_keying_flag_items[]
#define KEYINGSET_IDNAME_DOC
const EnumPropertyItem rna_enum_keyingset_path_grouping_items[]
static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_keyingset_path(BlenderRNA *brna)
static void rna_def_keyingset(BlenderRNA *brna)
void rna_def_animdata_common(StructRNA *srna)
static void rna_def_keyingset_info(BlenderRNA *brna)
void RNA_api_keyingset(StructRNA *srna)
void RNA_api_animdata(StructRNA *srna)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
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_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_define_verify_sdna(bool verify)
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_srna(PropertyRNA *prop, const char *type)
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_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
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_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
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)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
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_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
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_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
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_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
BlenderRNA BLENDER_RNA
bool rna_AnimaData_override_apply(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
const EnumPropertyItem rna_enum_nla_mode_blend_items[]
Definition rna_nla.cc:36
const EnumPropertyItem rna_enum_nla_mode_extend_items[]
Definition rna_nla.cc:67
#define min(a, b)
Definition sort.c:32
bAction * action
short act_blendmode
NlaStrip * actstrip
float act_influence
int32_t slot_handle
NlaTrack * act_track
bAction * tmpact
short act_extendmode
ListBase drivers
ListBase nla_tracks
char slot_name[66]
StructRNA * srna
Definition RNA_types.hh:780
StructCallbackFunc call
Definition RNA_types.hh:781
StructFreeFunc free
Definition RNA_types.hh:782
ChannelDriver * driver
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
struct KS_Path * next
short groupmode
cbKeyingSet_Generate generate
ExtensionRNA rna_ext
cbKeyingSet_Iterator iter
cbKeyingSet_Poll poll
char name[64]
char typeinfo[64]
ListBase paths
void * first
char name[64]
ID * owner_id
Definition RNA_types.hh:40
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
IDOverrideLibraryPropertyOperation * liboverride_operation
void WM_report(eReportType type, const char *message)
void WM_main_add_notifier(uint type, void *reference)
void WM_reportf(eReportType type, const char *format,...)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138