Blender V5.0
blenkernel/intern/action.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <cstddef>
11#include <cstdlib>
12#include <cstring>
13#include <optional>
14
15#include "MEM_guardedalloc.h"
16
17/* Allow using deprecated functionality for .blend file I/O. */
18#define DNA_DEPRECATED_ALLOW
19
20#include "DNA_anim_types.h"
21#include "DNA_armature_types.h"
23#include "DNA_defaults.h"
24#include "DNA_object_types.h"
25#include "DNA_scene_types.h"
26
27#include "BLI_ghash.h"
28#include "BLI_listbase.h"
29#include "BLI_math_color.h"
30#include "BLI_math_matrix.h"
31#include "BLI_math_rotation.h"
32#include "BLI_math_vector.h"
33#include "BLI_session_uid.h"
34#include "BLI_string.h"
35#include "BLI_string_utf8.h"
36#include "BLI_string_utils.hh"
37#include "BLI_utildefines.h"
38
39#include "BLT_translation.hh"
40
41#include "BKE_action.hh"
42#include "BKE_anim_data.hh"
44#include "BKE_animsys.h"
45#include "BKE_armature.hh"
46#include "BKE_asset.hh"
47#include "BKE_constraint.h"
48#include "BKE_deform.hh"
49#include "BKE_fcurve.hh"
50#include "BKE_idprop.hh"
51#include "BKE_idtype.hh"
52#include "BKE_lib_id.hh"
53#include "BKE_lib_query.hh"
54#include "BKE_main.hh"
55#include "BKE_object.hh"
56#include "BKE_object_types.hh"
57#include "BKE_preview_image.hh"
58
59#include "DEG_depsgraph.hh"
61
62#include "BIK_api.h"
63
64#include "RNA_access.hh"
65#include "RNA_path.hh"
66
67#include "BLO_read_write.hh"
68
69#include "ANIM_action.hh"
70#include "ANIM_action_legacy.hh"
71#include "ANIM_armature.hh"
73#include "ANIM_bonecolor.hh"
74#include "ANIM_versioning.hh"
75
76#include "CLG_log.h"
77
78static CLG_LogRef LOG = {"anim.action"};
79
80using namespace blender;
81
82/* *********************** NOTE ON POSE AND ACTION **********************
83 *
84 * - Pose is the local (object level) component of armature. The current
85 * object pose is saved in files, and (will be) is presorted for dependency
86 * - Actions have fewer (or other) channels, and write data to a Pose
87 * - Currently ob->pose data is controlled in BKE_pose_where_is only. The (recalc)
88 * event system takes care of calling that
89 * - The NLA system (here too) uses Poses as interpolation format for Actions
90 * - Therefore we assume poses to be static, and duplicates of poses have channels in
91 * same order, for quick interpolation reasons
92 *
93 * ****************************** (ton) ************************************ */
94
95/**************************** Action Datablock ******************************/
96
97/*********************** Armature Datablock ***********************/
98namespace blender::bke {
99
100static void action_init_data(ID *action_id)
101{
102 BLI_assert(GS(action_id->name) == ID_AC);
103 bAction *action = reinterpret_cast<bAction *>(action_id);
104
107}
108
119static void action_copy_data(Main * /*bmain*/,
120 std::optional<Library *> /*owner_library*/,
121 ID *id_dst,
122 const ID *id_src,
123 const int flag)
124{
125 bAction *dna_action_dst = reinterpret_cast<bAction *>(id_dst);
126 animrig::Action &action_dst = dna_action_dst->wrap();
127
128 const bAction *dna_action_src = reinterpret_cast<const bAction *>(id_src);
129 const animrig::Action &action_src = dna_action_src->wrap();
130
131 bActionGroup *group_dst, *group_src;
132 FCurve *fcurve_dst, *fcurve_src;
133
134 /* Duplicate the lists of groups and markers. */
135 BLI_duplicatelist(&action_dst.groups, &action_src.groups);
136 BKE_copy_time_markers(action_dst.markers, action_src.markers, flag);
137
138 /* Copy F-Curves, fixing up the links as we go. */
139 BLI_listbase_clear(&action_dst.curves);
140
141 for (fcurve_src = static_cast<FCurve *>(action_src.curves.first); fcurve_src;
142 fcurve_src = fcurve_src->next)
143 {
144 /* Duplicate F-Curve. */
145
146 /* XXX TODO: pass sub-data flag?
147 * But surprisingly does not seem to be doing any ID reference-counting. */
148 fcurve_dst = BKE_fcurve_copy(fcurve_src);
149
150 BLI_addtail(&action_dst.curves, fcurve_dst);
151
152 /* Fix group links (kind of bad list-in-list search, but this is the most reliable way). */
153 for (group_dst = static_cast<bActionGroup *>(action_dst.groups.first),
154 group_src = static_cast<bActionGroup *>(action_src.groups.first);
155 group_dst && group_src;
156 group_dst = group_dst->next, group_src = group_src->next)
157 {
158 if (fcurve_src->grp == group_src) {
159 fcurve_dst->grp = group_dst;
160
161 if (group_dst->channels.first == fcurve_src) {
162 group_dst->channels.first = fcurve_dst;
163 }
164 if (group_dst->channels.last == fcurve_src) {
165 group_dst->channels.last = fcurve_dst;
166 }
167 break;
168 }
169 }
170 }
171
172 /* Copy all simple properties. */
173 action_dst.layer_array_num = action_src.layer_array_num;
174 action_dst.layer_active_index = action_src.layer_active_index;
175 action_dst.slot_array_num = action_src.slot_array_num;
176 action_dst.last_slot_handle = action_src.last_slot_handle;
177
178 /* Layers, and (recursively) Strips. */
179 action_dst.layer_array = MEM_calloc_arrayN<ActionLayer *>(action_src.layer_array_num, __func__);
180 for (int i : action_src.layers().index_range()) {
181 action_dst.layer_array[i] = action_src.layer(i)->duplicate_with_shallow_strip_copies(__func__);
182 }
183
184 /* Strip data. */
186 action_src.strip_keyframe_data_array_num, __func__);
187 for (int i : action_src.strip_keyframe_data().index_range()) {
188 action_dst.strip_keyframe_data_array[i] = MEM_new<animrig::StripKeyframeData>(
189 __func__, *action_src.strip_keyframe_data()[i]);
190 }
191
192 /* Slots. */
193 action_dst.slot_array = MEM_calloc_arrayN<ActionSlot *>(action_src.slot_array_num, __func__);
194 for (int i : action_src.slots().index_range()) {
195 action_dst.slot_array[i] = MEM_new<animrig::Slot>(__func__, *action_src.slot(i));
196 }
197
199 action_dst.preview = nullptr;
200 }
201 else {
202 BKE_previewimg_id_copy(&action_dst.id, &action_src.id);
203 }
204}
205
207static void action_free_data(ID *id)
208{
209 animrig::Action &action = reinterpret_cast<bAction *>(id)->wrap();
210
211 /* Free keyframe data. */
212 for (animrig::StripKeyframeData *keyframe_data : action.strip_keyframe_data()) {
213 MEM_delete(keyframe_data);
214 }
217
218 /* Free layers. */
219 for (animrig::Layer *layer : action.layers()) {
220 MEM_delete(layer);
221 }
223 action.layer_array_num = 0;
224
225 /* Free slots. */
226 for (animrig::Slot *slot : action.slots()) {
227 MEM_delete(slot);
228 }
230 action.slot_array_num = 0;
231
232 /* Free legacy F-Curves & groups. */
233 BKE_fcurves_free(&action.curves);
234 BLI_freelistN(&action.groups);
235
236 /* Free markers & preview. */
237 BLI_freelistN(&action.markers);
239
240 BLI_assert(action.is_empty());
241}
242
244{
245 animrig::Action &action = reinterpret_cast<bAction *>(id)->wrap();
246
247 /* When this function is called without the IDWALK_READONLY flag, calls to
248 * BKE_LIB_FOREACHID_PROCESS_... macros can change ID pointers. ID remapping is the main example
249 * of such use.
250 *
251 * Those ID pointer changes are not guaranteed to be valid, though. For example, the remapping
252 * can be used to replace one Mesh with another, but that neither means that the new Mesh is
253 * animated with the same Action, nor that the old Mesh is no longer animated by that Action. In
254 * other words, the best that can be done is to invalidate the cache.
255 *
256 * NOTE: early-returns by BKE_LIB_FOREACHID_PROCESS_... macros are forbidden in non-readonly
257 * cases (see #IDWALK_RET_STOP_ITER documentation). */
258
260
261 /* Note that `bmain` can be `nullptr`. An example is in
262 * `deg_eval_copy_on_write.cc`, function `deg_expand_eval_copy_datablock`. */
264
265 /* This function should not rebuild the slot user map, because that in turn loops over all IDs.
266 * It is really up to the caller to ensure things are clean when the slot user pointers should be
267 * reported.
268 *
269 * For things like ID remapping it's fine to skip the pointers when they're dirty. The next time
270 * somebody tries to actually use them, they will be rebuilt anyway. */
271 const bool slot_user_cache_is_known_clean = bmain && !bmain->is_action_slot_to_id_map_dirty;
272
273 if (slot_user_cache_is_known_clean) {
274 bool should_invalidate = false;
275 for (animrig::Slot *slot : action.slots()) {
276 for (ID *&slot_user : slot->runtime_users()) {
277 ID *const old_pointer = slot_user;
278 BKE_LIB_FOREACHID_PROCESS_ID(data, slot_user, idwalk_flags);
279 /* If slot_user changed, the cache should be invalidated. Not all pointer changes are
280 * semantically correct for our use. For example, when ID-remapping is used to replace
281 * MECube with MESuzanne. If MECube is animated by some slot before the remap, it will
282 * remain animated by that slot after the remap, even when all `object->data` pointers now
283 * reference MESuzanne instead. */
284 should_invalidate |= (slot_user != old_pointer);
285 }
286 }
287
288 if (should_invalidate) {
290 }
291
292#ifndef NDEBUG
294 const bool is_readonly = flag & IDWALK_READONLY;
295 if (is_readonly) {
296 BLI_assert_msg(!should_invalidate,
297 "pointers were changed while IDWALK_READONLY flag was set");
298 }
299#endif
300 }
301
302 /* Note that, even though `BKE_fcurve_foreach_id()` exists, it is not called here. That function
303 * is only relevant for drivers, but the F-Curves stored in an Action are always just animation
304 * data, not drivers. */
305
306 LISTBASE_FOREACH (TimeMarker *, marker, &action.markers) {
308 }
309}
310
311static void write_channelbag(BlendWriter *writer, animrig::Channelbag &channelbag)
312{
313 BLO_write_struct(writer, ActionChannelbag, &channelbag);
314
315 Span<bActionGroup *> groups = channelbag.channel_groups();
316 BLO_write_pointer_array(writer, groups.size(), groups.data());
317 for (const bActionGroup *group : groups) {
318 BLO_write_struct(writer, bActionGroup, group);
319 }
320
321 Span<FCurve *> fcurves = channelbag.fcurves();
322 BLO_write_pointer_array(writer, fcurves.size(), fcurves.data());
323 for (FCurve *fcurve : fcurves) {
324 BLO_write_struct(writer, FCurve, fcurve);
325 BKE_fcurve_blend_write_data(writer, fcurve);
326 }
327}
328
330 animrig::StripKeyframeData &strip_keyframe_data)
331{
332 BLO_write_struct(writer, ActionStripKeyframeData, &strip_keyframe_data);
333
334 auto channelbags = strip_keyframe_data.channelbags();
335 BLO_write_pointer_array(writer, channelbags.size(), channelbags.data());
336
337 for (animrig::Channelbag *channelbag : channelbags) {
338 write_channelbag(writer, *channelbag);
339 }
340}
341
343 BlendWriter *writer, Span<animrig::StripKeyframeData *> strip_keyframe_data_array)
344{
346 writer, strip_keyframe_data_array.size(), strip_keyframe_data_array.data());
347
348 for (animrig::StripKeyframeData *keyframe_data : strip_keyframe_data_array) {
349 write_strip_keyframe_data(writer, *keyframe_data);
350 }
351}
352
354{
355 BLO_write_pointer_array(writer, strips.size(), strips.data());
356
357 for (animrig::Strip *strip : strips) {
358 BLO_write_struct(writer, ActionStrip, strip);
359 }
360}
361
363{
364 BLO_write_pointer_array(writer, layers.size(), layers.data());
365
366 for (animrig::Layer *layer : layers) {
367 BLO_write_struct(writer, ActionLayer, layer);
368 write_strips(writer, layer->strips());
369 }
370}
371
373{
374 BLO_write_pointer_array(writer, slots.size(), slots.data());
375 for (animrig::Slot *slot : slots) {
376 /* Make a shallow copy using the C type, so that no new runtime struct is
377 * allocated for the copy. */
378 ActionSlot shallow_copy = *slot;
379 shallow_copy.runtime = nullptr;
380
381 BLO_write_struct_at_address(writer, ActionSlot, slot, &shallow_copy);
382 }
383}
384
401 ListBase &listbase, const Span<bActionGroup *> channel_groups)
402{
403 if (channel_groups.is_empty()) {
404 BLI_listbase_clear(&listbase);
405 return;
406 }
407
408 /* Set the fcurve listbase pointers.
409 *
410 * Note that the fcurves' own prev/next pointers are hooked up by
411 * `action_blend_write_make_legacy_fcurves_listbase()`, so that they function
412 * properly as a list. */
413 for (bActionGroup *group : channel_groups) {
414 Span<FCurve *> fcurves = group->wrap().fcurves();
415 if (fcurves.is_empty()) {
416 group->channels = {nullptr, nullptr};
417 }
418 else {
419 group->channels = {fcurves.first(), fcurves.last()};
420 }
421 }
422
423 /* Determine the prev/next pointers on the elements. */
424 const int last_index = channel_groups.size() - 1;
425 for (int index : channel_groups.index_range()) {
426 channel_groups[index]->prev = (index > 0) ? channel_groups[index - 1] : nullptr;
427 channel_groups[index]->next = (index < last_index) ? channel_groups[index + 1] : nullptr;
428 }
429
430 listbase.first = channel_groups[0];
431 listbase.last = channel_groups[last_index];
432}
433
435{
436 LISTBASE_FOREACH_MUTABLE (bActionGroup *, group, &listbase) {
437 group->prev = nullptr;
438 group->next = nullptr;
439 group->channels = {nullptr, nullptr};
440 }
441
442 BLI_listbase_clear(&listbase);
443}
444
460 const Span<FCurve *> fcurves)
461{
462 if (fcurves.is_empty()) {
463 BLI_listbase_clear(&listbase);
464 return;
465 }
466
467 /* Determine the prev/next pointers on the elements. */
468 const int last_index = fcurves.size() - 1;
469 for (int index : fcurves.index_range()) {
470 fcurves[index]->prev = (index > 0) ? fcurves[index - 1] : nullptr;
471 fcurves[index]->next = (index < last_index) ? fcurves[index + 1] : nullptr;
472 }
473
474 listbase.first = fcurves[0];
475 listbase.last = fcurves[last_index];
476}
477
479{
480 LISTBASE_FOREACH_MUTABLE (FCurve *, fcurve, &listbase) {
481 fcurve->prev = nullptr;
482 fcurve->next = nullptr;
483 }
484
485 BLI_listbase_clear(&listbase);
486}
487
488static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
489{
490 animrig::Action &action = reinterpret_cast<bAction *>(id)->wrap();
491
492 /* Create legacy data for Layered Actions: the F-Curves from the first Slot,
493 * bottom layer, first Keyframe strip. */
494 const bool do_write_forward_compat = !BLO_write_is_undo(writer) && action.slot_array_num > 0 &&
495 action.is_action_layered();
496 if (do_write_forward_compat) {
499 "Layered Action should not have legacy data");
501 "Layered Action should not have legacy data");
502
503 const animrig::Slot &first_slot = *action.slot(0);
504
505 /* The forward-compat animation data we write is for IDs of the type that
506 * the first slot is intended for. Therefore, the Action should have that
507 * `idroot` when loaded in old versions of Blender.
508 *
509 * Note that if there is no slot, this code will never run and therefore the
510 * action will be written with `idroot = 0`. Despite that, old
511 * pre-slotted-action files are still guaranteed to round-trip losslessly,
512 * because old actions (even when empty) are versioned to have one slot with
513 * `idtype` set to whatever the old action's `idroot` was. In other words,
514 * zero-slot actions can only be created via non-legacy features, and
515 * therefore represent animation data that wasn't purely from old files
516 * anyway. */
517 action.idroot = first_slot.idtype;
518
519 /* Note: channel group forward-compat data requires that fcurve
520 * forward-compat legacy data is also written, and vice-versa. Both have
521 * pointers to each other that won't resolve properly when loaded in older
522 * Blender versions if only one is written. */
523 animrig::Channelbag *bag = channelbag_for_action_slot(action, first_slot.handle);
524 if (bag) {
527 }
528 }
529
530 BLO_write_id_struct(writer, bAction, id_address, &action.id);
531 BKE_id_blend_write(writer, &action.id);
532
533 /* Write layered Action data. */
535 write_layers(writer, action.layers());
536 write_slots(writer, action.slots());
537
538 if (do_write_forward_compat) {
539 /* Set the idroot back to 'unspecified', as it always should be for layered
540 * Actions. */
541 action.idroot = 0;
542
543 /* The pointers to the first/last FCurve in the `action.curves` have already
544 * been written as part of the Action struct data, so they can be cleared
545 * here, such that the code writing legacy fcurves below does nothing (as
546 * expected). And to leave the Action in a consistent state (it shouldn't
547 * have F-Curves in both legacy and layered storage).
548 *
549 * Note that the FCurves themselves have been written as part of the layered
550 * animation writing code called above. Writing them again as part of the
551 * handling of the legacy `action.fcurves` ListBase would corrupt the
552 * blend-file by generating two `BHead` `DATA` blocks with the same old
553 * address for the same ID.
554 */
557 }
558
559 /* Write legacy F-Curves & Groups. */
561 LISTBASE_FOREACH (bActionGroup *, grp, &action.groups) {
562 BLO_write_struct(writer, bActionGroup, grp);
563 }
564
566
567 BKE_previewimg_blend_write(writer, action.preview);
568}
569
570static void read_channelbag(BlendDataReader *reader, animrig::Channelbag &channelbag)
571{
573 reader, channelbag.group_array_num, reinterpret_cast<void **>(&channelbag.group_array));
574 for (int i = 0; i < channelbag.group_array_num; i++) {
575 BLO_read_struct(reader, bActionGroup, &channelbag.group_array[i]);
576 channelbag.group_array[i]->channelbag = &channelbag;
577
578 /* Clear the legacy channels #ListBase, since it will have been set for some
579 * groups for forward compatibility.
580 * See #action_blend_write_make_legacy_channel_groups_listbase. */
581 channelbag.group_array[i]->channels = {nullptr, nullptr};
582 }
583
585 reader, channelbag.fcurve_array_num, reinterpret_cast<void **>(&channelbag.fcurve_array));
586 for (int i = 0; i < channelbag.fcurve_array_num; i++) {
587 BLO_read_struct(reader, FCurve, &channelbag.fcurve_array[i]);
588 FCurve *fcurve = channelbag.fcurve_array[i];
589
590 /* Clear the prev/next pointers set by the forward compatibility code in
591 * action_blend_write(). */
592 fcurve->prev = nullptr;
593 fcurve->next = nullptr;
594
595 BKE_fcurve_blend_read_data(reader, fcurve);
596 }
597}
598
600 animrig::StripKeyframeData &strip_keyframe_data)
601{
603 strip_keyframe_data.channelbag_array_num,
604 reinterpret_cast<void **>(&strip_keyframe_data.channelbag_array));
605
606 for (int i = 0; i < strip_keyframe_data.channelbag_array_num; i++) {
607 BLO_read_struct(reader, ActionChannelbag, &strip_keyframe_data.channelbag_array[i]);
608 ActionChannelbag *channelbag = strip_keyframe_data.channelbag_array[i];
609 read_channelbag(reader, channelbag->wrap());
610 }
611}
612
614{
617 reinterpret_cast<void **>(&action.strip_keyframe_data_array));
618
619 for (int i = 0; i < action.strip_keyframe_data_array_num; i++) {
621 ActionStripKeyframeData *keyframe_data = action.strip_keyframe_data_array[i];
622 read_strip_keyframe_data(reader, keyframe_data->wrap());
623 }
624}
625
626static void read_layers(BlendDataReader *reader, animrig::Action &action)
627{
629 reader, action.layer_array_num, reinterpret_cast<void **>(&action.layer_array));
630
631 for (int layer_idx = 0; layer_idx < action.layer_array_num; layer_idx++) {
632 BLO_read_struct(reader, ActionLayer, &action.layer_array[layer_idx]);
633 ActionLayer *layer = action.layer_array[layer_idx];
634
636 reader, layer->strip_array_num, reinterpret_cast<void **>(&layer->strip_array));
637 for (int strip_idx = 0; strip_idx < layer->strip_array_num; strip_idx++) {
638 BLO_read_struct(reader, ActionStrip, &layer->strip_array[strip_idx]);
639
640 /* This if statement and the code in it is only for a transitional period
641 * while we land #126559 and for a while after, to prevent crashes for
642 * people that were already playing with slotted actions and have some
643 * blend files written with them. This code can be removed after a while.
644 * At the very least, if you're reading this and slotted actions are
645 * already in an official release of Blender then this code is no longer
646 * relevant and can be deleted. */
647 if (layer->strip_array[strip_idx] == nullptr) {
648 layer->strip_array[strip_idx] = &animrig::Strip::create(action,
649 animrig::Strip::Type::Keyframe);
650 }
651 }
652 }
653}
654
655static void read_slots(BlendDataReader *reader, animrig::Action &action)
656{
658 reader, action.slot_array_num, reinterpret_cast<void **>(&action.slot_array));
659
660 for (int i = 0; i < action.slot_array_num; i++) {
661 BLO_read_struct(reader, ActionSlot, &action.slot_array[i]);
662
663 /* NOTE: this is endianness-sensitive. */
664 /* In case of required endian switching, this code would have to undo the generic endian
665 * switching, as the ID type values are not numerically the same between little and big endian
666 * machines. Due to the way they are defined, they are always in the same byte order,
667 * regardless of hardware/platform endianness. */
668
669 action.slot_array[i]->wrap().blend_read_post();
670 }
671}
672
674{
675 animrig::Action &action = reinterpret_cast<bAction *>(id)->wrap();
676
677 /* NOTE: this is endianness-sensitive. */
678 /* In case of required endianness switching, this code would need to undo the generic endian
679 * switching (careful, only the two least significant bytes of the int32 must be swapped back
680 * here, since this value is actually an int16). */
681
682 read_strip_keyframe_data_array(reader, action);
683 read_layers(reader, action);
684 read_slots(reader, action);
685
687 /* Clear the forward-compatible storage (see action_blend_write_data()). */
688 BLI_listbase_clear(&action.curves);
689 BLI_listbase_clear(&action.groups);
690
691 /* Layered actions should always have `idroot == 0`, but when writing an
692 * action to a blend file `idroot` is typically set otherwise for forward
693 * compatibility reasons (see `action_blend_write()`). So we set it to zero
694 * here to put it back as it should be. */
695 action.idroot = 0;
696 }
697 else {
698 /* Read legacy data. */
699 BLO_read_struct_list(reader, FCurve, &action.curves);
700 BLO_read_struct_list(reader, bActionGroup, &action.groups);
701
703
704 LISTBASE_FOREACH (bActionGroup *, agrp, &action.groups) {
705 BLO_read_struct(reader, FCurve, &agrp->channels.first);
706 BLO_read_struct(reader, FCurve, &agrp->channels.last);
707 }
708 }
709
710 BKE_time_markers_blend_read(reader, action.markers);
711
712 /* End of reading legacy data. */
713
714 BLO_read_struct(reader, PreviewImage, &action.preview);
715 BKE_previewimg_blend_read(reader, action.preview);
716}
717
719{
720 using namespace blender;
721 const bool is_single_frame = action && action->wrap().has_single_frame();
722 return bke::idprop::create("is_single_frame", int(is_single_frame)).release();
723}
724
725static void action_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_data)
726{
727 bAction *action = (bAction *)asset_ptr;
728 BLI_assert(GS(action->id.name) == ID_AC);
729
730 IDProperty *action_type = action_asset_type_property(action);
731 BKE_asset_metadata_idprop_ensure(asset_data, action_type);
732}
733
735 /*pre_save_fn*/ action_asset_metadata_ensure,
736 /*on_mark_asset_fn*/ action_asset_metadata_ensure,
737 /*on_clear_asset_fn*/ nullptr,
738};
739
740} // namespace blender::bke
741
743 /*id_code*/ bAction::id_type,
744 /*id_filter*/ FILTER_ID_AC,
745
746 /* This value will be set dynamically in `BKE_idtype_init()` to only include
747 * animatable ID types (see `animrig::Slot::users()`). */
748 /*dependencies_id_types*/ FILTER_ID_ALL,
749
750 /*main_listbase_index*/ INDEX_ID_AC,
751 /*struct_size*/ sizeof(bAction),
752 /*name*/ "Action",
753 /*name_plural*/ "actions",
754 /*translation_context*/ BLT_I18NCONTEXT_ID_ACTION,
755 /*flags*/ IDTYPE_FLAGS_NO_ANIMDATA,
756 /*asset_type_info*/ &blender::bke::AssetType_AC,
757
758 /*init_data*/ blender::bke::action_init_data,
759 /*copy_data*/ blender::bke::action_copy_data,
760 /*free_data*/ blender::bke::action_free_data,
761 /*make_local*/ nullptr,
762 /*foreach_id*/ blender::bke::action_foreach_id,
763 /*foreach_cache*/ nullptr,
764 /*foreach_path*/ nullptr,
765 /*foreach_working_space_color*/ nullptr,
766 /*owner_pointer_get*/ nullptr,
767
768 /*blend_write*/ blender::bke::action_blend_write,
769 /*blend_read_data*/ blender::bke::action_blend_read_data,
770 /*blend_read_after_liblink*/ nullptr,
771
772 /*blend_read_undo_preserve*/ nullptr,
773
774 /*lib_override_apply_post*/ nullptr,
775};
776
777/* ***************** Library data level operations on action ************** */
778
779bAction *BKE_action_add(Main *bmain, const char name[])
780{
781 bAction *act;
782
783 act = BKE_id_new<bAction>(bmain, name);
784
785 return act;
786}
787
788/* .................................. */
789
790/* *************** Action Groups *************** */
791
793{
794 /* TODO: move this logic to the animrig::Channelbag struct and unify with code
795 * that uses direct access to the flags. */
797 if (agrp->flag & AGRP_ACTIVE) {
798 return agrp;
799 }
800 }
801 return nullptr;
802}
803
805{
806 /* TODO: move this logic to the animrig::Channelbag struct and unify with code
807 * that uses direct access to the flags. */
809 if ((grp == agrp) && (select)) {
810 grp->flag |= AGRP_ACTIVE;
811 }
812 else {
813 grp->flag &= ~AGRP_ACTIVE;
814 }
815 }
816}
817
819{
820 /* Only do color copying if using a custom color (i.e. not default color). */
821 if (grp->customCol) {
822 if (grp->customCol > 0) {
823 /* copy theme colors on-to group's custom color in case user tries to edit color */
824 const bTheme *btheme = static_cast<const bTheme *>(U.themes.first);
825 const ThemeWireColor *col_set = &btheme->tarm[(grp->customCol - 1)];
826
827 memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
828 }
829 else {
830 /* if a reference group is provided, use the custom color from there... */
831 if (ref_grp) {
832 /* assumption: reference group has a color set */
833 memcpy(&grp->cs, &ref_grp->cs, sizeof(ThemeWireColor));
834 }
835 /* otherwise, init custom color with a generic/placeholder color set if
836 * no previous theme color was used that we can just keep using
837 */
838 else if (grp->cs.solid[0] == 0) {
839 /* define for setting colors in theme below */
840 rgba_uchar_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255);
841 rgba_uchar_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255);
842 rgba_uchar_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
843 }
844 }
845 }
846}
847
849{
850 BLI_assert_msg(pchan, "cannot 'set action group colors from posebone' without a posebone");
851 if (!pchan->bone) {
852 /* pchan->bone is only set after leaving editmode. */
853 return;
854 }
855
858}
859
861{
862 const blender::animrig::BoneColor &bone_color = color->wrap();
863
864 grp->customCol = int(bone_color.palette_index);
865
866 const ThemeWireColor *effective_color = bone_color.effective_color();
867 if (effective_color) {
868 /* The drawing code assumes that grp->cs always contains the effective
869 * color. This is why the effective color is always written to it, and why
870 * the above action_group_colors_sync() function exists: it needs to update
871 * grp->cs in case the theme changes. */
872 memcpy(&grp->cs, effective_color, sizeof(grp->cs));
873 }
874}
875
877{
878 bActionGroup *agrp;
879
880 /* sanity check: must have action and name */
881 if (ELEM(nullptr, act, name)) {
882 return nullptr;
883 }
884
885 BLI_assert(act->wrap().is_action_legacy());
886
887 /* allocate a new one */
888 agrp = MEM_callocN<bActionGroup>("bActionGroup");
889
890 /* make it selected, with default name */
891 agrp->flag = AGRP_SELECTED;
892 STRNCPY_UTF8(agrp->name, name[0] ? name : DATA_("Group"));
893
894 /* add to action, and validate */
895 BLI_addtail(&act->groups, agrp);
897 &act->groups, agrp, DATA_("Group"), '.', offsetof(bActionGroup, name), sizeof(agrp->name));
898
899 /* return the new group */
900 return agrp;
901}
902
904{
905 /* sanity checks */
906 if (ELEM(nullptr, act, agrp, fcurve)) {
907 return;
908 }
909
910 BLI_assert(act->wrap().is_action_legacy());
911
912 /* if no channels anywhere, just add to two lists at the same time */
913 if (BLI_listbase_is_empty(&act->curves)) {
914 fcurve->next = fcurve->prev = nullptr;
915
916 agrp->channels.first = agrp->channels.last = fcurve;
917 act->curves.first = act->curves.last = fcurve;
918 }
919
920 /* if the group already has channels, the F-Curve can simply be added to the list
921 * (i.e. as the last channel in the group)
922 */
923 else if (agrp->channels.first) {
924 /* if the group's last F-Curve is the action's last F-Curve too,
925 * then set the F-Curve as the last for the action first so that
926 * the lists will be in sync after linking
927 */
928 if (agrp->channels.last == act->curves.last) {
929 act->curves.last = fcurve;
930 }
931
932 /* link in the given F-Curve after the last F-Curve in the group,
933 * which means that it should be able to fit in with the rest of the
934 * list seamlessly
935 */
936 BLI_insertlinkafter(&agrp->channels, agrp->channels.last, fcurve);
937 }
938
939 /* otherwise, need to find the nearest F-Curve in group before/after current to link with */
940 else {
941 bActionGroup *grp;
942
943 /* firstly, link this F-Curve to the group */
944 agrp->channels.first = agrp->channels.last = fcurve;
945
946 /* Step through the groups preceding this one,
947 * finding the F-Curve there to attach this one after. */
948 for (grp = agrp->prev; grp; grp = grp->prev) {
949 /* if this group has F-Curves, we want weave the given one in right after the last channel
950 * there, but via the Action's list not this group's list
951 * - this is so that the F-Curve is in the right place in the Action,
952 * but won't be included in the previous group.
953 */
954 if (grp->channels.last) {
955 /* once we've added, break here since we don't need to search any further... */
956 BLI_insertlinkafter(&act->curves, grp->channels.last, fcurve);
957 break;
958 }
959 }
960
961 /* If grp is nullptr, that means we fell through, and this F-Curve should be added as the new
962 * first since group is (effectively) the first group. Thus, the existing first F-Curve becomes
963 * the second in the chain, etc. */
964 if (grp == nullptr) {
965 BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
966 }
967 }
968
969 /* set the F-Curve's new group */
970 fcurve->grp = agrp;
971}
972
974{
975 /* Sanity check. */
976 if (!act) {
977 return;
978 }
979
980 if (BLI_listbase_is_empty(&act->groups)) {
981 /* NOTE: this also includes layered Actions, as act->groups is the legacy storage for groups.
982 * Layered Actions should never have to deal with 'reconstructing' groups, as arbitrarily
983 * shuffling of the underlying data isn't allowed, and the available methods for modifying
984 * F-Curves/Groups already ensure that the data is valid when they return. */
985 return;
986 }
987
988 BLI_assert(act->wrap().is_action_legacy());
989
990 /* Clear out all group channels. Channels that are actually in use are
991 * reconstructed below; this step is necessary to clear out unused groups. */
992 LISTBASE_FOREACH (bActionGroup *, group, &act->groups) {
993 BLI_listbase_clear(&group->channels);
994 }
995
996 /* Sort the channels into the group lists, destroying the act->curves list. */
997 ListBase ungrouped = {nullptr, nullptr};
998
999 LISTBASE_FOREACH_MUTABLE (FCurve *, fcurve, &act->curves) {
1000 if (fcurve->grp) {
1001 BLI_assert(BLI_findindex(&act->groups, fcurve->grp) >= 0);
1002
1003 BLI_addtail(&fcurve->grp->channels, fcurve);
1004 }
1005 else {
1006 BLI_addtail(&ungrouped, fcurve);
1007 }
1008 }
1009
1010 /* Recombine into the main list. */
1012
1013 LISTBASE_FOREACH (bActionGroup *, group, &act->groups) {
1014 /* Copy the list header to preserve the pointers in the group. */
1015 ListBase tmp = group->channels;
1016 BLI_movelisttolist(&act->curves, &tmp);
1017 }
1018
1019 BLI_movelisttolist(&act->curves, &ungrouped);
1020}
1021
1023{
1024 /* sanity checks */
1025 if (ELEM(nullptr, act, fcu)) {
1026 return;
1027 }
1028
1029 BLI_assert(act->wrap().is_action_legacy());
1030
1031 /* check if any group used this directly */
1032 if (fcu->grp) {
1033 bActionGroup *agrp = fcu->grp;
1034
1035 if (agrp->channels.first == agrp->channels.last) {
1036 if (agrp->channels.first == fcu) {
1038 }
1039 }
1040 else if (agrp->channels.first == fcu) {
1041 if ((fcu->next) && (fcu->next->grp == agrp)) {
1042 agrp->channels.first = fcu->next;
1043 }
1044 else {
1045 agrp->channels.first = nullptr;
1046 }
1047 }
1048 else if (agrp->channels.last == fcu) {
1049 if ((fcu->prev) && (fcu->prev->grp == agrp)) {
1050 agrp->channels.last = fcu->prev;
1051 }
1052 else {
1053 agrp->channels.last = nullptr;
1054 }
1055 }
1056
1057 fcu->grp = nullptr;
1058 }
1059
1060 /* now just remove from list */
1061 BLI_remlink(&act->curves, fcu);
1062}
1063
1065{
1066 /* sanity checks */
1067 if (ELEM(nullptr, act, act->groups.first, name) || (name[0] == 0)) {
1068 return nullptr;
1069 }
1070
1071 BLI_assert(act->wrap().is_action_legacy());
1072
1073 /* do string comparisons */
1074 return static_cast<bActionGroup *>(
1076}
1077
1079{
1081 agrp->flag &= ~AGRP_TEMP;
1082 }
1083}
1084
1085/* *************** Pose channels *************** */
1086
1091
1093{
1094 if (ELEM(nullptr, pose, name) || (name[0] == '\0')) {
1095 return nullptr;
1096 }
1097
1098 if (pose->chanhash) {
1099 return static_cast<bPoseChannel *>(BLI_ghash_lookup(pose->chanhash, (const void *)name));
1100 }
1101
1102 return static_cast<bPoseChannel *>(
1104}
1105
1107{
1108 bPoseChannel *chan;
1109
1110 if (pose == nullptr) {
1111 return nullptr;
1112 }
1113
1114 /* See if this channel exists */
1115 chan = BKE_pose_channel_find_name(pose, name);
1116 if (chan) {
1117 return chan;
1118 }
1119
1120 /* If not, create it and add it */
1121 chan = MEM_callocN<bPoseChannel>("verifyPoseChannel");
1122
1124
1125 STRNCPY_UTF8(chan->name, name);
1126
1127 copy_v3_fl(chan->custom_scale_xyz, 1.0f);
1130 chan->custom_shape_wire_width = 1.0f;
1131
1132 /* init vars to prevent math errors */
1133 unit_qt(chan->quat);
1134 unit_axis_angle(chan->rotAxis, &chan->rotAngle);
1135 chan->scale[0] = chan->scale[1] = chan->scale[2] = 1.0f;
1136
1137 copy_v3_fl(chan->scale_in, 1.0f);
1138 copy_v3_fl(chan->scale_out, 1.0f);
1139
1140 chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
1141 chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
1142 chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f;
1143 chan->ikrotweight = chan->iklinweight = 0.0f;
1144 unit_m4(chan->constinv);
1145
1146 chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */
1147
1148 BLI_addtail(&pose->chanbase, chan);
1149 if (pose->chanhash) {
1150 BLI_ghash_insert(pose->chanhash, chan->name, chan);
1151 }
1152
1153 return chan;
1154}
1155
1156#ifndef NDEBUG
1158{
1159 if (pose->chanhash) {
1160 bPoseChannel *pchan;
1161 for (pchan = static_cast<bPoseChannel *>(pose->chanbase.first); pchan; pchan = pchan->next) {
1162 if (BLI_ghash_lookup(pose->chanhash, pchan->name) != pchan) {
1163 return false;
1164 }
1165 }
1166 }
1167
1168 return true;
1169}
1170
1171#endif
1172
1174{
1175 return pchan->bone && ANIM_bone_in_visible_collection(arm, pchan->bone);
1176}
1177
1178bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_bonecoll)
1179{
1180 bArmature *arm = static_cast<bArmature *>((ob) ? ob->data : nullptr);
1181 if (ELEM(nullptr, ob, ob->pose, arm)) {
1182 return nullptr;
1183 }
1184
1185 /* find active */
1186 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
1187 if ((pchan->bone) && (pchan->bone == arm->act_bone)) {
1188 if (!check_bonecoll || ANIM_bone_in_visible_collection(arm, pchan->bone)) {
1189 return pchan;
1190 }
1191 }
1192 }
1193
1194 return nullptr;
1195}
1196
1201
1203{
1204 bArmature *arm = static_cast<bArmature *>((ob) ? ob->data : nullptr);
1205
1206 if (ELEM(nullptr, ob, ob->pose, arm)) {
1207 return nullptr;
1208 }
1209
1211 if (pchan && blender::animrig::bone_is_selected(arm, pchan)) {
1212 return pchan;
1213 }
1214
1215 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
1216 if (pchan->bone != nullptr) {
1217 if (blender::animrig::bone_is_selected(arm, pchan)) {
1218 return pchan;
1219 }
1220 }
1221 }
1222 return nullptr;
1223}
1224
1226{
1227 char name_flip[MAXBONENAME];
1228
1229 BLI_string_flip_side_name(name_flip, name, false, sizeof(name_flip));
1230
1231 if (!STREQ(name_flip, name)) {
1232 return BKE_pose_channel_find_name(pose, name_flip);
1233 }
1234
1235 return nullptr;
1236}
1237
1239{
1240 if (pose) {
1241 switch (pose->iksolver) {
1242 case IKSOLVER_STANDARD:
1243 return nullptr;
1244 case IKSOLVER_ITASC:
1245 return "bItasc";
1246 }
1247 }
1248 return nullptr;
1249}
1250
1252 const bPose *src,
1253 const int flag,
1254 const bool copy_constraints)
1255{
1256 bPose *outPose;
1257 ListBase listb;
1258
1259 if (!src) {
1260 *dst = nullptr;
1261 return;
1262 }
1263
1264 outPose = MEM_callocN<bPose>("pose");
1265
1266 BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
1267
1268 /* Rebuild ghash here too, so that name lookups below won't be too bad...
1269 * BUT this will have the penalty that the ghash will be built twice
1270 * if BKE_pose_rebuild() gets called after this...
1271 */
1272 if (outPose->chanbase.first != outPose->chanbase.last) {
1273 outPose->chanhash = nullptr;
1275 }
1276
1277 outPose->iksolver = src->iksolver;
1278 outPose->ikdata = nullptr;
1279 outPose->ikparam = MEM_dupallocN(src->ikparam);
1280 outPose->avs = src->avs;
1281
1282 LISTBASE_FOREACH (bPoseChannel *, pchan, &outPose->chanbase) {
1283 if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
1284 id_us_plus((ID *)pchan->custom);
1285 }
1286
1287 if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
1289 }
1290
1291 /* warning, O(n2) here, if done without the hash, but these are rarely used features. */
1292 if (pchan->custom_tx) {
1293 pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
1294 }
1295 if (pchan->bbone_prev) {
1296 pchan->bbone_prev = BKE_pose_channel_find_name(outPose, pchan->bbone_prev->name);
1297 }
1298 if (pchan->bbone_next) {
1299 pchan->bbone_next = BKE_pose_channel_find_name(outPose, pchan->bbone_next->name);
1300 }
1301
1302 if (copy_constraints) {
1303 /* #BKE_constraints_copy nullptr's `listb` */
1304 BKE_constraints_copy_ex(&listb, &pchan->constraints, flag, true);
1305
1306 pchan->constraints = listb;
1307
1308 /* XXX: This is needed for motionpath drawing to work.
1309 * Dunno why it was setting to null before... */
1310 pchan->mpath = animviz_copy_motionpath(pchan->mpath);
1311 }
1312
1313 if (pchan->prop) {
1314 pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
1315 }
1316 if (pchan->system_properties) {
1317 pchan->system_properties = IDP_CopyProperty_ex(pchan->system_properties, flag);
1318 }
1319
1320 pchan->draw_data = nullptr; /* Drawing cache, no need to copy. */
1321
1322 /* Runtime data, no need to copy. */
1324 }
1325
1326 /* for now, duplicate Bone Groups too when doing this */
1327 if (copy_constraints) {
1328 BLI_duplicatelist(&outPose->agroups, &src->agroups);
1329 }
1330
1331 *dst = outPose;
1332}
1333
1334void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constraints)
1335{
1336 BKE_pose_copy_data_ex(dst, src, 0, copy_constraints);
1337}
1338
1340{
1341 if (itasc) {
1342 itasc->iksolver = IKSOLVER_ITASC;
1343 itasc->minstep = 0.01f;
1344 itasc->maxstep = 0.06f;
1345 itasc->numiter = 100;
1346 itasc->numstep = 4;
1347 itasc->precision = 0.005f;
1349 itasc->feedback = 20.0f;
1350 itasc->maxvel = 50.0f;
1351 itasc->solver = ITASC_SOLVER_SDLS;
1352 itasc->dampmax = 0.5;
1353 itasc->dampeps = 0.15;
1354 }
1355}
1357{
1358 bItasc *itasc;
1359 switch (pose->iksolver) {
1360 case IKSOLVER_ITASC:
1361 itasc = MEM_callocN<bItasc>("itasc");
1362 BKE_pose_itasc_init(itasc);
1363 pose->ikparam = itasc;
1364 break;
1365 case IKSOLVER_STANDARD:
1366 default:
1367 pose->ikparam = nullptr;
1368 break;
1369 }
1370}
1371
1372/* only for real IK, not for auto-IK */
1373static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
1374{
1375 /* No need to check if constraint is active (has influence),
1376 * since all constraints with CONSTRAINT_IK_AUTO are active */
1377 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
1378 if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
1379 bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data);
1380 if ((data->rootbone == 0) || (data->rootbone > level)) {
1381 if ((data->flag & CONSTRAINT_IK_AUTO) == 0) {
1382 return true;
1383 }
1384 }
1385 }
1386 }
1387 LISTBASE_FOREACH (Bone *, bone, &pchan->bone->childbase) {
1388 pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
1389 if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) {
1390 return true;
1391 }
1392 }
1393 return false;
1394}
1395
1397{
1398 return pose_channel_in_IK_chain(ob, pchan, 0);
1399}
1400
1401static bool transform_follows_custom_tx(const bArmature *arm, const bPoseChannel *pchan)
1402{
1403 if (arm->flag & ARM_NO_CUSTOM) {
1404 return false;
1405 }
1406
1407 if (!pchan->custom || !pchan->custom_tx) {
1408 return false;
1409 }
1410
1411 return pchan->flag & POSE_TRANSFORM_AT_CUSTOM_TX;
1412}
1413
1415 const bPoseChannel *pose_bone,
1416 float r_pose_orientation[3][3])
1417{
1418 if (!transform_follows_custom_tx(arm, pose_bone)) {
1419 copy_m3_m4(r_pose_orientation, pose_bone->pose_mat);
1420 return;
1421 }
1422
1423 BLI_assert(pose_bone->custom_tx);
1424
1425 const bPoseChannel *custom_tx_bone = pose_bone->custom_tx;
1426 copy_m3_m4(r_pose_orientation, custom_tx_bone->pose_mat);
1427}
1428
1430 const bPoseChannel *pose_bone,
1431 float r_pose_space_pivot[3])
1432{
1433 if (!transform_follows_custom_tx(arm, pose_bone)) {
1434 copy_v3_v3(r_pose_space_pivot, pose_bone->pose_mat[3]);
1435 return;
1436 }
1437
1438 copy_v3_v3(r_pose_space_pivot, pose_bone->custom_tx->pose_mat[3]);
1439}
1440
1442{
1443 if (!pose->chanhash) {
1444 pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
1445 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
1446 BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
1447 }
1448 }
1449}
1450
1452{
1453 if (pose->chanhash) {
1454 BLI_ghash_free(pose->chanhash, nullptr, nullptr);
1455 pose->chanhash = nullptr;
1456 }
1457}
1458
1460{
1461 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
1462 if (pchan->bbone_prev == unlinked_pchan) {
1463 pchan->bbone_prev = nullptr;
1464 }
1465 if (pchan->bbone_next == unlinked_pchan) {
1466 pchan->bbone_next = nullptr;
1467 }
1468 if (pchan->custom_tx == unlinked_pchan) {
1469 pchan->custom_tx = nullptr;
1470 }
1471 }
1472}
1473
1475 bool (*filter_fn)(const char *bone_name, void *user_data),
1476 void *user_data)
1477{
1478 /* Erase any associated pose channel, along with any references to them */
1479 if (ob->pose) {
1480 bPoseChannel *pchan, *pchan_next;
1481
1482 for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchan_next)
1483 {
1484 pchan_next = pchan->next;
1485
1486 if (filter_fn(pchan->name, user_data)) {
1487 /* Bone itself is being removed */
1488 BKE_pose_channel_free(pchan);
1490 if (ob->pose->chanhash) {
1491 BLI_ghash_remove(ob->pose->chanhash, pchan->name, nullptr, nullptr);
1492 }
1493 BLI_freelinkN(&ob->pose->chanbase, pchan);
1494 }
1495 else {
1496 /* Maybe something the bone references is being removed instead? */
1497 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
1498 ListBase targets = {nullptr, nullptr};
1499 if (BKE_constraint_targets_get(con, &targets)) {
1500 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
1501 if (ct->tar == ob) {
1502 if (ct->subtarget[0]) {
1503 if (filter_fn(ct->subtarget, user_data)) {
1504 con->flag |= CONSTRAINT_DISABLE;
1505 ct->subtarget[0] = 0;
1506 }
1507 }
1508 }
1509 }
1510
1511 BKE_constraint_targets_flush(con, &targets, false);
1512 }
1513 }
1514
1515 if (pchan->bbone_prev) {
1516 if (filter_fn(pchan->bbone_prev->name, user_data)) {
1517 pchan->bbone_prev = nullptr;
1518 }
1519 }
1520 if (pchan->bbone_next) {
1521 if (filter_fn(pchan->bbone_next->name, user_data)) {
1522 pchan->bbone_next = nullptr;
1523 }
1524 }
1525
1526 if (pchan->custom_tx) {
1527 if (filter_fn(pchan->custom_tx->name, user_data)) {
1528 pchan->custom_tx = nullptr;
1529 }
1530 }
1531 }
1532 }
1533 }
1534}
1535
1536void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
1537{
1538 if (pchan->custom) {
1539 if (do_id_user) {
1540 id_us_min(&pchan->custom->id);
1541 }
1542 pchan->custom = nullptr;
1543 }
1544
1545 if (pchan->mpath) {
1547 pchan->mpath = nullptr;
1548 }
1549
1550 BKE_constraints_free_ex(&pchan->constraints, do_id_user);
1551
1552 if (pchan->prop) {
1553 IDP_FreeProperty_ex(pchan->prop, do_id_user);
1554 pchan->prop = nullptr;
1555 }
1556 if (pchan->system_properties) {
1557 IDP_FreeProperty_ex(pchan->system_properties, do_id_user);
1558 pchan->system_properties = nullptr;
1559 }
1560
1561 /* Cached data, for new draw manager rendering code. */
1562 MEM_SAFE_FREE(pchan->draw_data);
1563
1564 /* Cached B-Bone shape and other data. */
1566}
1567
1572
1574{
1575 const SessionUID uid = runtime->session_uid;
1576 *runtime = bPoseChannel_Runtime{};
1577 runtime->session_uid = uid;
1578}
1579
1584
1594
1596{
1597 BKE_pose_channel_free_ex(pchan, true);
1598}
1599
1600void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
1601{
1602 if (!BLI_listbase_is_empty(&pose->chanbase)) {
1603 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
1604 BKE_pose_channel_free_ex(pchan, do_id_user);
1605 }
1606
1607 BLI_freelistN(&pose->chanbase);
1608 }
1609
1611
1613}
1614
1616{
1617 BKE_pose_channels_free_ex(pose, true);
1618}
1619
1620void BKE_pose_free_data_ex(bPose *pose, bool do_id_user)
1621{
1622 /* free pose-channels */
1623 BKE_pose_channels_free_ex(pose, do_id_user);
1624
1625 /* free pose-groups */
1626 if (pose->agroups.first) {
1627 BLI_freelistN(&pose->agroups);
1628 }
1629
1630 /* free IK solver state */
1631 BIK_clear_data(pose);
1632
1633 /* free IK solver param */
1634 if (pose->ikparam) {
1635 MEM_freeN(static_cast<bItasc *>(pose->ikparam));
1636 }
1637}
1638
1640{
1641 BKE_pose_free_data_ex(pose, true);
1642}
1643
1644void BKE_pose_free_ex(bPose *pose, bool do_id_user)
1645{
1646 if (pose) {
1647 BKE_pose_free_data_ex(pose, do_id_user);
1648 /* free pose */
1649 MEM_freeN(pose);
1650 }
1651}
1652
1654{
1655 BKE_pose_free_ex(pose, true);
1656}
1657
1659{
1660 /* copy transform locks */
1661 pchan->protectflag = pchan_from->protectflag;
1662
1663 /* copy rotation mode */
1664 pchan->rotmode = pchan_from->rotmode;
1665
1666 /* copy bone group */
1667 pchan->agrp_index = pchan_from->agrp_index;
1668
1669 /* IK (DOF) settings. */
1670 pchan->ikflag = pchan_from->ikflag;
1671 copy_v3_v3(pchan->limitmin, pchan_from->limitmin);
1672 copy_v3_v3(pchan->limitmax, pchan_from->limitmax);
1673 copy_v3_v3(pchan->stiffness, pchan_from->stiffness);
1674 pchan->ikstretch = pchan_from->ikstretch;
1675 pchan->ikrotweight = pchan_from->ikrotweight;
1676 pchan->iklinweight = pchan_from->iklinweight;
1677
1678 /* bbone settings (typically not animated) */
1679 pchan->bbone_next = pchan_from->bbone_next;
1680 pchan->bbone_prev = pchan_from->bbone_prev;
1681
1682 /* constraints */
1683 BKE_constraints_copy(&pchan->constraints, &pchan_from->constraints, true);
1684
1685 /* id-properties */
1686 if (pchan->prop) {
1687 /* Unlikely, but possible that it exists. */
1688 IDP_FreeProperty(pchan->prop);
1689 pchan->prop = nullptr;
1690 }
1691 if (pchan_from->prop) {
1692 pchan->prop = IDP_CopyProperty(pchan_from->prop);
1693 }
1694 if (pchan->system_properties) {
1695 /* Unlikely, but possible that it exists. */
1697 pchan->system_properties = nullptr;
1698 }
1699 if (pchan_from->system_properties) {
1701 }
1702
1703 /* custom shape */
1704 pchan->custom = pchan_from->custom;
1705 if (pchan->custom) {
1706 id_us_plus(&pchan->custom->id);
1707 }
1708 copy_v3_v3(pchan->custom_scale_xyz, pchan_from->custom_scale_xyz);
1712
1713 pchan->color.palette_index = pchan_from->color.palette_index;
1714 copy_v4_v4_uchar(pchan->color.custom.active, pchan_from->color.custom.active);
1715 copy_v4_v4_uchar(pchan->color.custom.select, pchan_from->color.custom.select);
1716 copy_v4_v4_uchar(pchan->color.custom.solid, pchan_from->color.custom.solid);
1717 pchan->color.custom.flag = pchan_from->color.custom.flag;
1718
1719 pchan->drawflag = pchan_from->drawflag;
1720}
1721
1723{
1725
1726 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
1727 pchan->constflag = 0;
1728
1729 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
1730 pchan->constflag |= PCHAN_HAS_CONST;
1731
1732 switch (con->type) {
1735
1736 pchan->constflag |= PCHAN_HAS_IK;
1737
1738 if (data->tar == nullptr || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
1739 {
1740 pchan->constflag |= PCHAN_HAS_NO_TARGET;
1741 }
1742
1743 bPoseChannel *chain_tip = (data->flag & CONSTRAINT_IK_TIP) ? pchan : pchan->parent;
1744
1745 /* negative rootbone = recalc rootbone index. used in do_versions */
1746 if (data->rootbone < 0) {
1747 data->rootbone = 0;
1748
1749 bPoseChannel *parchan = chain_tip;
1750 while (parchan) {
1751 data->rootbone++;
1752 if ((parchan->bone->flag & BONE_CONNECTED) == 0) {
1753 break;
1754 }
1755 parchan = parchan->parent;
1756 }
1757 }
1758
1759 /* Mark the pose bones in the IK chain as influenced by it. */
1760 {
1761 bPoseChannel *chain_bone = chain_tip;
1762 for (short index = 0; chain_bone && (data->rootbone == 0 || index < data->rootbone);
1763 index++)
1764 {
1765 chain_bone->constflag |= PCHAN_INFLUENCED_BY_IK;
1766 chain_bone = chain_bone->parent;
1767 }
1768 }
1769 break;
1770 }
1771
1774
1775 /* if we have a valid target, make sure that this will get updated on frame-change
1776 * (needed for when there is no anim-data for this pose)
1777 */
1778 if ((data->tar) && (data->tar->type == OB_CURVES_LEGACY)) {
1780 }
1781 break;
1782 }
1783
1785 pchan->constflag |= PCHAN_HAS_SPLINEIK;
1786 break;
1787
1788 default:
1789 break;
1790 }
1791 }
1792 }
1793
1795}
1796
1801
1802/* ************************** Bone Groups ************************** */
1803
1805{
1806 bActionGroup *grp;
1807
1808 if (!name) {
1809 name = DATA_("Group");
1810 }
1811
1812 grp = MEM_callocN<bActionGroup>("PoseGroup");
1813 STRNCPY_UTF8(grp->name, name);
1814 BLI_addtail(&pose->agroups, grp);
1815 BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
1816
1817 pose->active_group = BLI_listbase_count(&pose->agroups);
1818
1819 return grp;
1820}
1821
1822void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
1823{
1824 int idx = index;
1825
1826 if (idx < 1) {
1827 idx = BLI_findindex(&pose->agroups, grp) + 1;
1828 }
1829
1830 BLI_assert(idx > 0);
1831
1832 /* adjust group references (the trouble of using indices!):
1833 * - firstly, make sure nothing references it
1834 * - also, make sure that those after this item get corrected
1835 */
1836 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
1837 if (pchan->agrp_index == idx) {
1838 pchan->agrp_index = 0;
1839 }
1840 else if (pchan->agrp_index > idx) {
1841 pchan->agrp_index--;
1842 }
1843 }
1844
1845 /* now, remove it from the pose */
1846 BLI_freelinkN(&pose->agroups, grp);
1847 if (pose->active_group >= idx) {
1848 const bool has_groups = !BLI_listbase_is_empty(&pose->agroups);
1849 pose->active_group--;
1850 if (pose->active_group == 0 && has_groups) {
1851 pose->active_group = 1;
1852 }
1853 else if (pose->active_group < 0 || !has_groups) {
1854 pose->active_group = 0;
1855 }
1856 }
1857}
1858
1859void BKE_pose_remove_group_index(bPose *pose, const int index)
1860{
1861 bActionGroup *grp = nullptr;
1862
1863 /* get group to remove */
1864 grp = static_cast<bActionGroup *>(BLI_findlink(&pose->agroups, index - 1));
1865 if (grp) {
1866 BKE_pose_remove_group(pose, grp, index);
1867 }
1868}
1869
1870/* ************** Pose Management Tools ****************** */
1871
1872void BKE_pose_rest(bPose *pose, bool selected_bones_only)
1873{
1874 if (!pose) {
1875 return;
1876 }
1877
1878 memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
1879 memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
1880
1881 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
1882 if (selected_bones_only && pchan->bone != nullptr && (pchan->flag & POSE_SELECTED) == 0) {
1883 continue;
1884 }
1885 zero_v3(pchan->loc);
1886 zero_v3(pchan->eul);
1887 unit_qt(pchan->quat);
1888 unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
1889 pchan->scale[0] = pchan->scale[1] = pchan->scale[2] = 1.0f;
1890
1891 pchan->roll1 = pchan->roll2 = 0.0f;
1892 pchan->curve_in_x = pchan->curve_in_z = 0.0f;
1893 pchan->curve_out_x = pchan->curve_out_z = 0.0f;
1894 pchan->ease1 = pchan->ease2 = 0.0f;
1895
1896 copy_v3_fl(pchan->scale_in, 1.0f);
1897 copy_v3_fl(pchan->scale_out, 1.0f);
1898
1899 pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SCALE | POSE_BBONE_SHAPE);
1900 }
1901}
1902
1904{
1905 copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
1906 copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
1907
1908 /* used for local constraints */
1909 copy_v3_v3(pchanto->loc, pchanfrom->loc);
1910 copy_qt_qt(pchanto->quat, pchanfrom->quat);
1911 copy_v3_v3(pchanto->eul, pchanfrom->eul);
1912 copy_v3_v3(pchanto->scale, pchanfrom->scale);
1913
1914 copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head);
1915 copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail);
1916
1917 pchanto->roll1 = pchanfrom->roll1;
1918 pchanto->roll2 = pchanfrom->roll2;
1919 pchanto->curve_in_x = pchanfrom->curve_in_x;
1920 pchanto->curve_in_z = pchanfrom->curve_in_z;
1921 pchanto->curve_out_x = pchanfrom->curve_out_x;
1922 pchanto->curve_out_z = pchanfrom->curve_out_z;
1923 pchanto->ease1 = pchanfrom->ease1;
1924 pchanto->ease2 = pchanfrom->ease2;
1925
1926 copy_v3_v3(pchanto->scale_in, pchanfrom->scale_in);
1927 copy_v3_v3(pchanto->scale_out, pchanfrom->scale_out);
1928
1929 pchanto->rotmode = pchanfrom->rotmode;
1930 pchanto->flag = pchanfrom->flag;
1931 pchanto->protectflag = pchanfrom->protectflag;
1932}
1933
1935{
1936 if (to == nullptr || from == nullptr) {
1937 CLOG_ERROR(
1938 &LOG, "Pose copy error, pose to:%p from:%p", (void *)to, (void *)from); /* debug temp */
1939 return false;
1940 }
1941
1942 if (to == from) {
1943 CLOG_ERROR(&LOG, "source and target are the same");
1944 return false;
1945 }
1946
1947 LISTBASE_FOREACH (bPoseChannel *, pchanfrom, &from->chanbase) {
1948 bPoseChannel *pchanto = BKE_pose_channel_find_name(to, pchanfrom->name);
1949 if (pchanto != nullptr) {
1950 BKE_pose_copy_pchan_result(pchanto, pchanfrom);
1951 }
1952 }
1953 return true;
1954}
1955
1956void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
1957{
1958 pose->flag |= POSE_RECALC;
1959 /* Depsgraph components depends on actual pose state,
1960 * if pose was changed depsgraph is to be updated as well.
1961 */
1963}
1964
1966 Object *workob,
1967 bPose *pose,
1968 bAction *act,
1969 const int32_t action_slot_handle,
1970 char groupname[],
1971 const AnimationEvalContext *anim_eval_context)
1972{
1973 using namespace blender::animrig;
1974 BLI_assert(act);
1975
1976 bActionGroup *agrp = nullptr;
1977 if (groupname && groupname[0]) {
1978 /* Find the named channel group. */
1979 Action &action = act->wrap();
1980 if (action.is_action_layered()) {
1981 Channelbag *cbag = channelbag_for_action_slot(action, action_slot_handle);
1982 agrp = cbag ? cbag->channel_group_find(groupname) : nullptr;
1983 }
1984 else {
1985 agrp = BKE_action_group_find_name(act, groupname);
1986 }
1987 }
1988
1989 /* clear workob */
1990 blender::bke::ObjectRuntime workob_runtime;
1992 workob->runtime = &workob_runtime;
1993
1994 /* init workob */
1995 copy_m4_m4(workob->runtime->object_to_world.ptr(), ob->object_to_world().ptr());
1996 copy_m4_m4(workob->parentinv, ob->parentinv);
1997 copy_m4_m4(workob->constinv, ob->constinv);
1998 workob->parent = ob->parent;
1999
2000 workob->rotmode = ob->rotmode;
2001
2002 workob->trackflag = ob->trackflag;
2003 workob->upflag = ob->upflag;
2004
2005 workob->partype = ob->partype;
2006 workob->par1 = ob->par1;
2007 workob->par2 = ob->par2;
2008 workob->par3 = ob->par3;
2009
2010 workob->constraints.first = ob->constraints.first;
2011 workob->constraints.last = ob->constraints.last;
2012
2013 /* Need to set pose too, since this is used for both types of Action Constraint. */
2014 workob->pose = pose;
2015 if (pose) {
2016 /* This function is most likely to be used with a temporary pose with a single bone in there.
2017 * For such cases it makes no sense to create hash since it'll only waste CPU ticks on memory
2018 * allocation and also will make lookup slower.
2019 */
2020 if (pose->chanbase.first != pose->chanbase.last) {
2022 }
2025 }
2026 }
2027
2028 STRNCPY_UTF8(workob->parsubstr, ob->parsubstr);
2029
2030 /* we don't use real object name, otherwise RNA screws with the real thing */
2031 STRNCPY_UTF8(workob->id.name, "OB<ConstrWorkOb>");
2032
2033 /* If we're given a group to use, it's likely to be more efficient
2034 * (though a bit more dangerous). */
2035 if (agrp) {
2036 /* specifically evaluate this group only */
2037
2038 /* get RNA-pointer for the workob's ID */
2039 PointerRNA id_ptr = RNA_id_pointer_create(&workob->id);
2040
2041 /* execute action for this group only */
2042 animsys_evaluate_action_group(&id_ptr, act, agrp, anim_eval_context);
2043 }
2044 else {
2045 AnimData adt = {nullptr};
2046
2047 /* init animdata, and attach to workob */
2048 workob->adt = &adt;
2049
2050 adt.action = act;
2051 adt.slot_handle = action_slot_handle;
2053
2054 /* execute effects of Action on to workob (or its PoseChannels) */
2055 BKE_animsys_evaluate_animdata(&workob->id, &adt, anim_eval_context, ADT_RECALC_ANIM, false);
2056
2057 /* Ensure stack memory set here isn't accessed later, relates to !118847. */
2058 workob->adt = nullptr;
2059 }
2060 /* Ensure stack memory set here isn't accessed later, see !118847. */
2061 workob->runtime = nullptr;
2062}
2063
2065{
2066 if (pose == nullptr) {
2067 return;
2068 }
2069
2070 GSet *used_uids = BLI_gset_new(
2072
2073 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
2074 const SessionUID *session_uid = &pchan->runtime.session_uid;
2075 if (!BLI_session_uid_is_generated(session_uid)) {
2076 printf("Pose channel %s does not have UID generated.\n", pchan->name);
2077 continue;
2078 }
2079
2080 if (BLI_gset_lookup(used_uids, session_uid) != nullptr) {
2081 printf("Pose channel %s has duplicate UID generated.\n", pchan->name);
2082 continue;
2083 }
2084
2085 BLI_gset_insert(used_uids, (void *)session_uid);
2086 }
2087
2088 BLI_gset_free(used_uids, nullptr);
2089}
2090
2092{
2093#ifndef __GNUC__
2094 BLI_assert(pose != nullptr);
2095#endif
2096
2097 /* Write channels */
2098 LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
2099 /* Write ID Properties -- and copy this comment EXACTLY for easy finding
2100 * of library blocks that implement this. */
2101 if (chan->prop) {
2102 IDP_BlendWrite(writer, chan->prop);
2103 }
2104 if (chan->system_properties) {
2105 IDP_BlendWrite(writer, chan->system_properties);
2106 }
2107
2108 BKE_constraint_blend_write(writer, &chan->constraints);
2109
2110 animviz_motionpath_blend_write(writer, chan->mpath);
2111
2112 BLO_write_struct(writer, bPoseChannel, chan);
2113 }
2114
2115 /* Write groups */
2116 LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
2117 BLO_write_struct(writer, bActionGroup, grp);
2118 }
2119
2120 /* write IK param */
2121 if (pose->ikparam) {
2122 const char *structname = BKE_pose_ikparam_get_name(pose);
2123 if (structname) {
2124 BLO_write_struct_by_name(writer, structname, pose->ikparam);
2125 }
2126 }
2127
2128 /* Write this pose */
2129 BLO_write_struct(writer, bPose, pose);
2130}
2131
2132void BKE_pose_blend_read_data(BlendDataReader *reader, ID *id_owner, bPose *pose)
2133{
2134 if (!pose) {
2135 return;
2136 }
2137
2139 BLO_read_struct_list(reader, bActionGroup, &pose->agroups);
2140
2141 pose->chanhash = nullptr;
2142 pose->chan_array = nullptr;
2143
2144 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
2145 BKE_pose_channel_runtime_reset(&pchan->runtime);
2147
2148 pchan->bone = nullptr;
2149 BLO_read_struct(reader, bPoseChannel, &pchan->parent);
2150 BLO_read_struct(reader, bPoseChannel, &pchan->child);
2151 BLO_read_struct(reader, bPoseChannel, &pchan->custom_tx);
2152
2153 BLO_read_struct(reader, bPoseChannel, &pchan->bbone_prev);
2154 BLO_read_struct(reader, bPoseChannel, &pchan->bbone_next);
2155
2156 BKE_constraint_blend_read_data(reader, id_owner, &pchan->constraints);
2157
2158 BLO_read_struct(reader, IDProperty, &pchan->prop);
2159 IDP_BlendDataRead(reader, &pchan->prop);
2160 BLO_read_struct(reader, IDProperty, &pchan->system_properties);
2161 IDP_BlendDataRead(reader, &pchan->system_properties);
2162
2163 BLO_read_struct(reader, bMotionPath, &pchan->mpath);
2164 if (pchan->mpath) {
2165 animviz_motionpath_blend_read_data(reader, pchan->mpath);
2166 }
2167
2168 BLI_listbase_clear(&pchan->iktree);
2169 BLI_listbase_clear(&pchan->siktree);
2170
2171 /* in case this value changes in future, clamp else we get undefined behavior */
2172 CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
2173
2174 pchan->draw_data = nullptr;
2175 }
2176 pose->ikdata = nullptr;
2177 if (pose->ikparam != nullptr) {
2178 const char *structname = BKE_pose_ikparam_get_name(pose);
2179 if (structname) {
2180 pose->ikparam = BLO_read_struct_by_name_array(reader, structname, 1, pose->ikparam);
2181 }
2182 else {
2183 pose->ikparam = nullptr;
2184 }
2185 }
2186}
2187
2189{
2190 bArmature *arm = static_cast<bArmature *>(ob->data);
2191
2192 if (!pose || !arm) {
2193 return;
2194 }
2195
2196 /* Always rebuild to match library changes, except on Undo. */
2197 bool rebuild = false;
2198
2199 if (!BLO_read_lib_is_undo(reader)) {
2200 if (ob->id.lib != arm->id.lib) {
2201 rebuild = true;
2202 }
2203 }
2204
2205 LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
2206 pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
2207
2208 if (UNLIKELY(pchan->bone == nullptr)) {
2209 rebuild = true;
2210 }
2211
2212 /* At some point in history, bones could have an armature object as custom shape, which caused
2213 * all kinds of wonderful issues. This is now avoided in RNA, but through the magic of linking
2214 * and editing the library file, the situation can still occur. Better to just reset the
2215 * pointer in those cases. */
2216 if (pchan->custom && pchan->custom->type == OB_ARMATURE) {
2217 pchan->custom = nullptr;
2218 }
2219 }
2220
2221 if (rebuild) {
2222 Main *bmain = BLO_read_lib_get_main(reader);
2225 BKE_pose_tag_recalc(bmain, pose);
2226 }
2227}
2228
2230{
2231 if (!act) {
2232 return;
2233 }
2234
2235 BLI_assert(act->wrap().is_action_legacy());
2236
2237 while (act->curves.first) {
2238 FCurve *fcu = static_cast<FCurve *>(act->curves.first);
2240 BKE_fcurve_free(fcu);
2241 }
2243}
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
C++ part of the BoneColor DNA struct.
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
void BIK_clear_data(struct bPose *pose)
Blender kernel action and pose functionality.
bool BKE_animdata_action_ensure_idroot(const ID *owner, bAction *action)
Definition anim_data.cc:159
void animviz_free_motionpath(struct bMotionPath *mpath)
void animviz_motionpath_blend_write(struct BlendWriter *writer, struct bMotionPath *mpath)
void animviz_motionpath_blend_read_data(struct BlendDataReader *reader, struct bMotionPath *mpath)
struct bMotionPath * animviz_copy_motionpath(const struct bMotionPath *mpath_src)
void BKE_time_markers_blend_read(BlendDataReader *reader, ListBase &markers)
Definition anim_sys.cc:4317
@ ADT_RECALC_ANIM
void BKE_copy_time_markers(ListBase &markers_dst, const ListBase &markers_src, int flag)
Definition anim_sys.cc:4326
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act, struct bActionGroup *agrp, const struct AnimationEvalContext *anim_eval_context)
void BKE_time_markers_blend_write(BlendWriter *writer, ListBase &markers)
Definition anim_sys.cc:4306
Bone * BKE_armature_find_bone_name(bArmature *arm, const char *name)
void BKE_asset_metadata_idprop_ensure(AssetMetaData *asset_data, IDProperty *prop)
Definition asset.cc:168
void BKE_constraints_free_ex(struct ListBase *list, bool do_id_user)
void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
void BKE_constraint_blend_write(struct BlendWriter *writer, struct ListBase *conlist)
int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
void BKE_constraints_copy(struct ListBase *dst, const struct ListBase *src, bool do_extern)
void BKE_constraint_blend_read_data(struct BlendDataReader *reader, struct ID *id_owner, struct ListBase *lb)
void BKE_constraints_copy_ex(struct ListBase *dst, const struct ListBase *src, int flag, bool do_extern)
support for deformation groups and hooks.
FCurve * BKE_fcurve_copy(const FCurve *fcu)
void BKE_fcurve_blend_write_data(BlendWriter *writer, FCurve *fcu)
void BKE_fcurve_blend_write_listbase(BlendWriter *writer, ListBase *fcurves)
void BKE_fcurve_blend_read_data_listbase(BlendDataReader *reader, ListBase *fcurves)
void BKE_fcurves_free(ListBase *list)
void BKE_fcurve_free(FCurve *fcu)
void BKE_fcurve_blend_read_data(BlendDataReader *reader, FCurve *fcu)
#define IDP_BlendDataRead(reader, prop)
void IDP_FreeProperty(IDProperty *prop)
Definition idprop.cc:1251
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:845
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:863
void IDP_BlendWrite(BlendWriter *writer, const IDProperty *prop)
Definition idprop.cc:1461
void IDP_FreeProperty_ex(IDProperty *prop, bool do_id_user)
Definition idprop.cc:1245
IDTypeInfo IDType_ID_AC
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition BKE_idtype.hh:49
void id_us_plus(ID *id)
Definition lib_id.cc:358
void * BKE_id_new(Main *bmain, short type, const char *name)
Definition lib_id.cc:1514
@ LIB_ID_COPY_NO_PREVIEW
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_MAIN
void id_us_min(ID *id)
Definition lib_id.cc:366
void BKE_id_blend_write(BlendWriter *writer, ID *id)
Definition lib_id.cc:2631
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
LibraryForeachIDCallbackFlag
@ IDWALK_CB_LOOPBACK
@ IDWALK_CB_NEVER_SELF
@ IDWALK_CB_NOP
Main * BKE_lib_query_foreachid_process_main_get(const LibraryForeachIDData *data)
Definition lib_query.cc:134
#define BKE_LIB_FOREACHID_PROCESS_ID(data_, id_, cb_flag_)
LibraryForeachIDFlag BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
Definition lib_query.cc:129
LibraryForeachIDFlag
@ IDWALK_READONLY
General operations, lookup, etc. for blender objects.
void BKE_object_workob_clear(Object *workob)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
void BKE_previewimg_free(PreviewImage **prv)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
struct GSet GSet
Definition BLI_ghash.h:337
void * BLI_gset_lookup(const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_gset_insert(GSet *gs, void *key)
Definition BLI_ghash.cc:959
GSet * BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:944
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:787
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:731
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition BLI_ghash.cc:707
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:860
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
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
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:608
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:270
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
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
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:131
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:524
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:371
MINLINE void rgba_uchar_args_set(unsigned char col[4], unsigned char r, unsigned char g, unsigned char b, unsigned char a)
#define M_PI
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void unit_m4(float m[4][4])
void unit_qt(float q[4])
void unit_axis_angle(float axis[3], float *angle)
void copy_qt_qt(float q[4], const float a[4])
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
bool BLI_session_uid_is_generated(const SessionUID *uid)
uint BLI_session_uid_ghash_hash(const void *uid_v)
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v)
SessionUID BLI_session_uid_generate(void)
#define STRNCPY_UTF8(dst, src)
size_t BLI_string_flip_side_name(char *name_dst, const char *name_src, bool strip_number, size_t name_dst_maxncpy) ATTR_NONNULL(1
void BLI_uniquename(const struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
#define CLAMP(a, b, c)
#define UNLIKELY(x)
#define ELEM(...)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define STREQ(a, b)
Main * BLO_read_lib_get_main(BlendLibReader *reader)
Definition readfile.cc:5988
void BLO_write_struct_by_name(BlendWriter *writer, const char *struct_name, const void *data_ptr)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void * BLO_read_struct_by_name_array(BlendDataReader *reader, const char *struct_name, int64_t items_num, const void *old_address)
Definition readfile.cc:5719
bool BLO_read_lib_is_undo(BlendLibReader *reader)
Definition readfile.cc:5983
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
void BLO_write_pointer_array(BlendWriter *writer, int64_t num, const void *data_ptr)
void BLO_read_pointer_array(BlendDataReader *reader, int64_t array_size, void **ptr_p)
Definition readfile.cc:5880
bool BLO_write_is_undo(BlendWriter *writer)
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
#define BLT_I18NCONTEXT_ID_ACTION
#define DATA_(msgid)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
#define FILTER_ID_ALL
Definition DNA_ID.h:1239
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition DNA_ID.h:1176
#define FILTER_ID_AC
Definition DNA_ID.h:1197
@ INDEX_ID_AC
Definition DNA_ID.h:1284
@ ID_AC
@ ITASC_SOLVER_SDLS
@ IKSOLVER_STANDARD
@ IKSOLVER_ITASC
@ AGRP_TEMP
@ AGRP_ACTIVE
@ AGRP_SELECTED
@ ROT_MODE_MAX
@ ROT_MODE_MIN
@ ITASC_AUTO_STEP
@ ITASC_INITIAL_REITERATION
@ PCHAN_INFLUENCED_BY_IK
@ PCHAN_HAS_CONST
@ PCHAN_HAS_NO_TARGET
@ PCHAN_HAS_IK
@ PCHAN_HAS_SPLINEIK
@ POSE_SCALE
@ POSE_BBONE_SHAPE
@ POSE_SELECTED
@ POSE_ROT
@ POSE_TRANSFORM_AT_CUSTOM_TX
@ POSE_LOC
@ POSE_CONSTRAINTS_NEED_UPDATE_FLAGS
@ POSE_RECALC
@ POSE_CONSTRAINTS_TIMEDEPEND
#define MAXBONENAME
@ BONE_CONNECTED
@ ARM_NO_CUSTOM
@ CONSTRAINT_DISABLE
@ CONSTRAINT_IK_AUTO
@ CONSTRAINT_IK_TIP
@ CONSTRAINT_TYPE_SPLINEIK
@ CONSTRAINT_TYPE_KINEMATIC
@ CONSTRAINT_TYPE_FOLLOWPATH
#define DNA_struct_default_get(struct_name)
Object is a sort of wrapper for general info.
@ OB_ARMATURE
@ OB_CURVES_LEGACY
@ OB_LOCK_ROT4D
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
#define U
void BKE_pose_channels_remove(Object *ob, bool(*filter_fn)(const char *bone_name, void *user_data), void *user_data)
void BKE_pose_channels_free(bPose *pose)
void action_group_colors_set_from_posebone(bActionGroup *grp, const bPoseChannel *pchan)
bPoseChannel * BKE_pose_channel_active_if_bonecoll_visible(Object *ob)
void BKE_pose_channel_transform_orientation(const bArmature *arm, const bPoseChannel *pose_bone, float r_pose_orientation[3][3])
bool BKE_pose_channels_is_valid(const bPose *pose)
void BKE_pose_channel_runtime_reset(bPoseChannel_Runtime *runtime)
void BKE_pose_free_data(bPose *pose)
static bool transform_follows_custom_tx(const bArmature *arm, const bPoseChannel *pchan)
void BKE_pose_blend_read_after_liblink(BlendLibReader *reader, Object *ob, bPose *pose)
void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
void BKE_pose_remove_group_index(bPose *pose, const int index)
bool BKE_pose_copy_result(bPose *to, bPose *from)
void action_group_colors_set(bActionGroup *grp, const BoneColor *color)
void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
bActionGroup * get_active_actiongroup(bAction *act)
void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
void BKE_pose_channel_runtime_free(bPoseChannel_Runtime *runtime)
static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
void BKE_pose_tag_update_constraint_flags(bPose *pose)
void action_groups_clear_tempflags(bAction *act)
void BKE_pose_ikparam_init(bPose *pose)
static void pose_channels_remove_internal_links(Object *ob, bPoseChannel *unlinked_pchan)
bool BKE_pose_is_bonecoll_visible(const bArmature *arm, const bPoseChannel *pchan)
void BKE_pose_free_data_ex(bPose *pose, bool do_id_user)
void BKE_pose_itasc_init(bItasc *itasc)
void BKE_pose_copy_pchan_result(bPoseChannel *pchanto, const bPoseChannel *pchanfrom)
bPoseChannel * BKE_pose_channel_get_mirrored(const bPose *pose, const char *name)
void BKE_pose_channel_free(bPoseChannel *pchan)
bPoseChannel * BKE_pose_channel_active(Object *ob, const bool check_bonecoll)
void BKE_pose_channels_hash_ensure(bPose *pose)
bActionGroup * BKE_pose_add_group(bPose *pose, const char *name)
void BKE_pose_free_ex(bPose *pose, bool do_id_user)
void BKE_action_groups_reconstruct(bAction *act)
void BKE_pose_channel_session_uid_generate(bPoseChannel *pchan)
bPoseChannel * BKE_pose_channel_ensure(bPose *pose, const char *name)
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const bool copy_constraints)
void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, const int32_t action_slot_handle, char groupname[], const AnimationEvalContext *anim_eval_context)
bPoseChannel * BKE_pose_channel_active_or_first_selected(Object *ob)
void BKE_action_fcurves_clear(bAction *act)
void BKE_pose_blend_write(BlendWriter *writer, bPose *pose)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
void BKE_pose_blend_read_data(BlendDataReader *reader, ID *id_owner, bPose *pose)
void BKE_pose_free(bPose *pose)
void action_groups_remove_channel(bAction *act, FCurve *fcu)
void BKE_pose_channel_transform_location(const bArmature *arm, const bPoseChannel *pose_bone, float r_pose_space_pivot[3])
bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
void BKE_pose_channel_free_bbone_cache(bPoseChannel_Runtime *runtime)
void BKE_pose_channel_runtime_reset_on_copy(bPoseChannel_Runtime *runtime)
void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
bAction * BKE_action_add(Main *bmain, const char name[])
void BKE_pose_update_constraint_flags(bPose *pose)
const char * BKE_pose_ikparam_get_name(bPose *pose)
bActionGroup * action_groups_add_new(bAction *act, const char name[])
void BKE_pose_channels_hash_free(bPose *pose)
void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
bActionGroup * BKE_action_group_find_name(bAction *act, const char name[])
void BKE_pose_check_uids_unique_and_report(const bPose *pose)
void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constraints)
void BKE_pose_rest(bPose *pose, bool selected_bones_only)
BMesh const char void * data
constexpr const T * data() const
Definition BLI_span.hh:215
constexpr const T & first() const
Definition BLI_span.hh:315
constexpr int64_t size() const
Definition BLI_span.hh:252
constexpr const T & last(const int64_t n=0) const
Definition BLI_span.hh:325
constexpr IndexRange index_range() const
Definition BLI_span.hh:401
constexpr bool is_empty() const
Definition BLI_span.hh:260
const Layer * layer(int64_t index) const
const Slot * slot(int64_t index) const
blender::Span< const Layer * > layers() const
blender::Span< const Slot * > slots() const
Span< const StripKeyframeData * > strip_keyframe_data() const
const ThemeWireColor * effective_color() const
Definition bonecolor.cc:32
const bActionGroup * channel_group_find(StringRef name) const
blender::Span< const FCurve * > fcurves() const
blender::Span< const bActionGroup * > channel_groups() const
Layer * duplicate_with_shallow_strip_copies(StringRefNull allocation_name) const
static void users_invalidate(Main &bmain)
blender::Span< const Channelbag * > channelbags() const
#define offsetof(t, d)
#define GS(x)
#define printf(...)
#define select(A, B, C)
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
#define LOG(level)
Definition log.h:97
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_dupallocN(const void *vmemh)
Definition mallocn.cc:143
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
Vector< bActionGroup * > channel_groups_all(bAction *action)
bool action_is_layered(const bAction &dna_action)
Definition versioning.cc:38
void assert_baklava_phase_1_invariants(const Action &action)
const animrig::Channelbag * channelbag_for_action_slot(const Action &action, slot_handle_t slot_handle)
const BoneColor & ANIM_bonecolor_posebone_get(const bPoseChannel *pose_bone)
Definition bonecolor.cc:90
bool bone_is_selected(const bArmature *armature, const Bone *bone)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRef prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
static void write_strips(BlendWriter *writer, Span< animrig::Strip * > strips)
static void action_blend_read_data(BlendDataReader *reader, ID *id)
static void action_init_data(ID *action_id)
static void read_layers(BlendDataReader *reader, animrig::Action &action)
static void write_layers(BlendWriter *writer, Span< animrig::Layer * > layers)
static void action_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int flag)
static void read_slots(BlendDataReader *reader, animrig::Action &action)
static void read_strip_keyframe_data_array(BlendDataReader *reader, animrig::Action &action)
static void action_blend_write_make_legacy_fcurves_listbase(ListBase &listbase, const Span< FCurve * > fcurves)
static void read_strip_keyframe_data(BlendDataReader *reader, animrig::StripKeyframeData &strip_keyframe_data)
static void write_slots(BlendWriter *writer, Span< animrig::Slot * > slots)
static void action_blend_write_clear_legacy_channel_groups_listbase(ListBase &listbase)
static IDProperty * action_asset_type_property(const bAction *action)
static void write_strip_keyframe_data(BlendWriter *writer, animrig::StripKeyframeData &strip_keyframe_data)
static void action_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_data)
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static void write_strip_keyframe_data_array(BlendWriter *writer, Span< animrig::StripKeyframeData * > strip_keyframe_data_array)
static void action_blend_write_make_legacy_channel_groups_listbase(ListBase &listbase, const Span< bActionGroup * > channel_groups)
static void action_free_data(ID *id)
static void read_channelbag(BlendDataReader *reader, animrig::Channelbag &channelbag)
static void write_channelbag(BlendWriter *writer, animrig::Channelbag &channelbag)
static void action_blend_write_clear_legacy_fcurves_listbase(ListBase &listbase)
static void action_foreach_id(ID *id, LibraryForeachIDData *data)
static AssetTypeInfo AssetType_AC
float wrap(float value, float max, float min)
Definition node_math.h:103
const char * name
PointerRNA RNA_id_pointer_create(ID *id)
struct bActionGroup ** group_array
struct FCurve ** fcurve_array
struct ActionStrip ** strip_array
ActionSlotRuntimeHandle * runtime
struct ActionChannelbag ** channelbag_array
bAction * action
int32_t slot_handle
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
ThemeWireColor custom
ListBase childbase
struct FCurve * next
bActionGroup * grp
struct FCurve * prev
Definition DNA_ID.h:414
struct Library * lib
Definition DNA_ID.h:420
char name[258]
Definition DNA_ID.h:432
void * last
void * first
bool is_action_slot_to_id_map_dirty
Definition BKE_main.hh:253
ListBase constraints
struct bPose * pose
ObjectRuntimeHandle * runtime
float constinv[4][4]
float parentinv[4][4]
struct AnimData * adt
struct Object * parent
short trackflag
char parsubstr[64]
unsigned char select[4]
unsigned char solid[4]
unsigned char active[4]
ThemeWireColor cs
struct bActionGroup * prev
struct bActionGroup * next
struct ActionChannelbag * channelbag
struct ActionSlot ** slot_array
ListBase curves
struct ActionStripKeyframeData ** strip_keyframe_data_array
int32_t last_slot_handle
struct ActionLayer ** layer_array
int strip_keyframe_data_array_num
int layer_active_index
ListBase groups
PreviewImage * preview
ListBase markers
float precision
struct Mat4 * bbone_deform_mats
struct bPoseChannel_BBoneSegmentBoundary * bbone_segment_boundaries
struct DualQuat * bbone_dual_quats
struct Mat4 * bbone_pose_mats
struct Mat4 * bbone_rest_mats
IDProperty * prop
float custom_scale_xyz[3]
bPoseChannelDrawData * draw_data
float custom_rotation_euler[3]
struct Bone * bone
struct bPoseChannel * parent
struct bPoseChannel * custom_tx
bMotionPath * mpath
float chan_mat[4][4]
struct bPoseChannel * bbone_next
struct Object * custom
struct bPoseChannel * next
float custom_translation[3]
float constinv[4][4]
float custom_shape_wire_width
IDProperty * system_properties
struct bPoseChannel_Runtime runtime
struct bPoseChannel * bbone_prev
float pose_mat[4][4]
struct bPoseChannel * child
ListBase chanbase
void * ikdata
void * ikparam
struct GHash * chanhash
ListBase agroups
bAnimVizSettings avs
float stride_offset[3]
bPoseChannel ** chan_array
float cyclic_offset[3]
ThemeWireColor tarm[20]
i
Definition text_draw.cc:230
uint8_t flag
Definition wm_window.cc:145