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