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