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