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