Blender V4.3
ipo.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/* NOTE:
10 *
11 * This file is no longer used to provide tools for the deprecated IPO system. Instead, it
12 * is only used to house the conversion code to the new system.
13 *
14 * -- Joshua Leung, Jan 2009
15 */
16
17#include <cmath>
18#include <cstddef>
19#include <cstdio>
20#include <cstring>
21
22/* since we have versioning code here */
23#define DNA_DEPRECATED_ALLOW
24
25#include "DNA_anim_types.h"
26#include "DNA_camera_types.h"
28#include "DNA_ipo_types.h"
29#include "DNA_key_types.h"
30#include "DNA_light_types.h"
31#include "DNA_material_types.h"
32#include "DNA_nla_types.h"
33#include "DNA_object_types.h"
34#include "DNA_scene_types.h"
35#include "DNA_sequence_types.h"
36#include "DNA_world_types.h"
37
38#include "BLI_blenlib.h"
39#include "BLI_dynstr.h"
40#include "BLI_endian_switch.h"
41#include "BLI_string_utils.hh"
42#include "BLI_utildefines.h"
43
44#include "BLT_translation.hh"
45
46#include "BKE_action.hh"
47#include "BKE_anim_data.hh"
48#include "BKE_fcurve.hh"
49#include "BKE_fcurve_driver.h"
50#include "BKE_global.hh"
51#include "BKE_idtype.hh"
52#include "BKE_ipo.h"
53#include "BKE_key.hh"
54#include "BKE_lib_id.hh"
55#include "BKE_lib_query.hh"
56#include "BKE_main.hh"
57#include "BKE_nla.hh"
58
59#include "ANIM_action.hh"
60
61#include "CLG_log.h"
62
63#include "MEM_guardedalloc.h"
64
65#include "SEQ_iterator.hh"
66
67#include "BLO_read_write.hh"
68
69#ifdef WIN32
70# include "BLI_math_base.h" /* M_PI */
71#endif
72
73static CLG_LogRef LOG = {"bke.ipo"};
74
75using namespace blender;
76
77static void ipo_free_data(ID *id)
78{
79 Ipo *ipo = (Ipo *)id;
80
81 IpoCurve *icu, *icn;
82 int n = 0;
83
84 for (icu = static_cast<IpoCurve *>(ipo->curve.first); icu; icu = icn) {
85 icn = icu->next;
86 n++;
87
88 if (icu->bezt) {
89 MEM_freeN(icu->bezt);
90 }
91 if (icu->bp) {
92 MEM_freeN(icu->bp);
93 }
94 if (icu->driver) {
95 MEM_freeN(icu->driver);
96 }
97
98 BLI_freelinkN(&ipo->curve, icu);
99 }
100
101 if (G.debug & G_DEBUG) {
102 printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name + 2);
103 }
104}
105
107{
108 Ipo *ipo = reinterpret_cast<Ipo *>(id);
110
112 LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
113 if (icu->driver) {
114 BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, icu->driver->ob, IDWALK_CB_NOP);
115 }
116 }
117 }
118}
119
120static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
121{
122 Ipo *ipo = (Ipo *)id;
123
124 BLO_read_struct_list(reader, IpoCurve, &(ipo->curve));
125
126 LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
127 BLO_read_struct_array(reader, BezTriple, icu->totvert, &icu->bezt);
128 BLO_read_struct_array(reader, BPoint, icu->totvert, &icu->bp);
129 BLO_read_struct(reader, IpoDriver, &icu->driver);
130
131 /* Undo generic endian switching. */
133 BLI_endian_switch_int16(&icu->blocktype);
134 if (icu->driver != nullptr) {
135
136 /* Undo generic endian switching. */
138 BLI_endian_switch_int16(&icu->blocktype);
139 if (icu->driver != nullptr) {
140 BLI_endian_switch_int16(&icu->driver->blocktype);
141 }
142 }
143 }
144
145 /* Undo generic endian switching. */
148 if (icu->driver != nullptr) {
149 BLI_endian_switch_int16(&icu->driver->blocktype);
150 }
151 }
152 }
153 }
154
155 /* Undo generic endian switching. */
158 }
159}
160
162 /*id_code*/ ID_IP,
163 /*id_filter*/ FILTER_ID_IP,
164 /*dependencies_id_types*/ 0,
165 /*main_listbase_index*/ INDEX_ID_IP,
166 /*struct_size*/ sizeof(Ipo),
167 /*name*/ "Ipo",
168 /*name_plural*/ N_("ipos"),
169 /*translation_context*/ "",
171 /*asset_type_info*/ nullptr,
172
173 /*init_data*/ nullptr,
174 /*copy_data*/ nullptr,
175 /*free_data*/ ipo_free_data,
176 /*make_local*/ nullptr,
177 /*foreach_id*/ ipo_foreach_id,
178 /*foreach_cache*/ nullptr,
179 /*foreach_path*/ nullptr,
180 /*owner_pointer_get*/ nullptr,
181
182 /*blend_write*/ nullptr,
183 /*blend_read_data*/ ipo_blend_read_data,
184 /*blend_read_after_liblink*/ nullptr,
185
186 /*blend_read_undo_preserve*/ nullptr,
187
188 /*lib_override_apply_post*/ nullptr,
189};
190
191/* *************************************************** */
192/* Old-Data Freeing Tools */
193
194/* *************************************************** */
195/* ADRCODE to RNA-Path Conversion Code - Special (Bitflags) */
196
197/* Mapping Table for bitflag <-> RNA path */
199 int bit;
200 const char *path;
202};
203
204/* ----------------- */
205/* Mapping Tables to use bits <-> RNA paths */
206
207/* Object layers */
209 {(1 << 0), "layers", 0}, {(1 << 1), "layers", 1}, {(1 << 2), "layers", 2},
210 {(1 << 3), "layers", 3}, {(1 << 4), "layers", 4}, {(1 << 5), "layers", 5},
211 {(1 << 6), "layers", 6}, {(1 << 7), "layers", 7}, {(1 << 8), "layers", 8},
212 {(1 << 9), "layers", 9}, {(1 << 10), "layers", 10}, {(1 << 11), "layers", 11},
213 {(1 << 12), "layers", 12}, {(1 << 13), "layers", 13}, {(1 << 14), "layers", 14},
214 {(1 << 15), "layers", 15}, {(1 << 16), "layers", 16}, {(1 << 17), "layers", 17},
215 {(1 << 18), "layers", 18}, {(1 << 19), "layers", 19},
216};
217
218/* ----------------- */
219
220/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
221#define RET_ABP(items) \
222 { \
223 *tot = ARRAY_SIZE(items); \
224 return items; \
225 } \
226 (void)0
227
228/* This function checks if a `blocktype+adrcode` combination, returning a mapping table. */
229static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *tot)
230{
231 /* Object layers */
232 if ((blocktype == ID_OB) && (adrcode == OB_LAY)) {
234 }
235 /* XXX TODO: add other types... */
236
237 /* Normal curve */
238 return nullptr;
239}
240#undef RET_ABP
241
242/* *************************************************** */
243/* ADRCODE to RNA-Path Conversion Code - Standard */
244
245/* Object types */
246static const char *ob_adrcodes_to_paths(int adrcode, int *r_array_index)
247{
248 /* Set array index like this in-case nothing sets it correctly. */
249 *r_array_index = 0;
250
251 /* result depends on adrcode */
252 switch (adrcode) {
253 case OB_LOC_X:
254 *r_array_index = 0;
255 return "location";
256 case OB_LOC_Y:
257 *r_array_index = 1;
258 return "location";
259 case OB_LOC_Z:
260 *r_array_index = 2;
261 return "location";
262 case OB_DLOC_X:
263 *r_array_index = 0;
264 return "delta_location";
265 case OB_DLOC_Y:
266 *r_array_index = 1;
267 return "delta_location";
268 case OB_DLOC_Z:
269 *r_array_index = 2;
270 return "delta_location";
271
272 case OB_ROT_X:
273 *r_array_index = 0;
274 return "rotation_euler";
275 case OB_ROT_Y:
276 *r_array_index = 1;
277 return "rotation_euler";
278 case OB_ROT_Z:
279 *r_array_index = 2;
280 return "rotation_euler";
281 case OB_DROT_X:
282 *r_array_index = 0;
283 return "delta_rotation_euler";
284 case OB_DROT_Y:
285 *r_array_index = 1;
286 return "delta_rotation_euler";
287 case OB_DROT_Z:
288 *r_array_index = 2;
289 return "delta_rotation_euler";
290
291 case OB_SIZE_X:
292 *r_array_index = 0;
293 return "scale";
294 case OB_SIZE_Y:
295 *r_array_index = 1;
296 return "scale";
297 case OB_SIZE_Z:
298 *r_array_index = 2;
299 return "scale";
300 case OB_DSIZE_X:
301 *r_array_index = 0;
302 return "delta_scale";
303 case OB_DSIZE_Y:
304 *r_array_index = 1;
305 return "delta_scale";
306 case OB_DSIZE_Z:
307 *r_array_index = 2;
308 return "delta_scale";
309 case OB_COL_R:
310 *r_array_index = 0;
311 return "color";
312 case OB_COL_G:
313 *r_array_index = 1;
314 return "color";
315 case OB_COL_B:
316 *r_array_index = 2;
317 return "color";
318 case OB_COL_A:
319 *r_array_index = 3;
320 return "color";
321#if 0
322 case OB_PD_FSTR:
323 if (ob->pd) {
324 poin = &(ob->pd->f_strength);
325 }
326 break;
327 case OB_PD_FFALL:
328 if (ob->pd) {
329 poin = &(ob->pd->f_power);
330 }
331 break;
332 case OB_PD_SDAMP:
333 if (ob->pd) {
334 poin = &(ob->pd->pdef_damp);
335 }
336 break;
337 case OB_PD_RDAMP:
338 if (ob->pd) {
339 poin = &(ob->pd->pdef_rdamp);
340 }
341 break;
342 case OB_PD_PERM:
343 if (ob->pd) {
344 poin = &(ob->pd->pdef_perm);
345 }
346 break;
347 case OB_PD_FMAXD:
348 if (ob->pd) {
349 poin = &(ob->pd->maxdist);
350 }
351 break;
352#endif
353 }
354
355 return nullptr;
356}
357
358/* PoseChannel types
359 * NOTE: pchan name comes from 'actname' added earlier...
360 */
361static const char *pchan_adrcodes_to_paths(int adrcode, int *r_array_index)
362{
363 /* Set array index like this in-case nothing sets it correctly. */
364 *r_array_index = 0;
365
366 /* result depends on adrcode */
367 switch (adrcode) {
368 case AC_QUAT_W:
369 *r_array_index = 0;
370 return "rotation_quaternion";
371 case AC_QUAT_X:
372 *r_array_index = 1;
373 return "rotation_quaternion";
374 case AC_QUAT_Y:
375 *r_array_index = 2;
376 return "rotation_quaternion";
377 case AC_QUAT_Z:
378 *r_array_index = 3;
379 return "rotation_quaternion";
380
381 case AC_EUL_X:
382 *r_array_index = 0;
383 return "rotation_euler";
384 case AC_EUL_Y:
385 *r_array_index = 1;
386 return "rotation_euler";
387 case AC_EUL_Z:
388 *r_array_index = 2;
389 return "rotation_euler";
390
391 case AC_LOC_X:
392 *r_array_index = 0;
393 return "location";
394 case AC_LOC_Y:
395 *r_array_index = 1;
396 return "location";
397 case AC_LOC_Z:
398 *r_array_index = 2;
399 return "location";
400
401 case AC_SIZE_X:
402 *r_array_index = 0;
403 return "scale";
404 case AC_SIZE_Y:
405 *r_array_index = 1;
406 return "scale";
407 case AC_SIZE_Z:
408 *r_array_index = 2;
409 return "scale";
410 }
411
412 /* for debugging only */
413 CLOG_ERROR(&LOG, "unmatched PoseChannel setting (code %d)", adrcode);
414 return nullptr;
415}
416
417/* Constraint types */
418static const char *constraint_adrcodes_to_paths(int adrcode, int *r_array_index)
419{
420 /* Set array index like this in-case nothing sets it correctly. */
421 *r_array_index = 0;
422
423 /* result depends on adrcode */
424 switch (adrcode) {
425 case CO_ENFORCE:
426 return "influence";
427 case CO_HEADTAIL:
428 /* XXX this needs to be wrapped in RNA.. probably then this path will be invalid. */
429 return "data.head_tail";
430 }
431
432 return nullptr;
433}
434
435/* ShapeKey types
436 * NOTE: as we don't have access to the keyblock where the data comes from (for now),
437 * we'll just use numerical indices for now...
438 */
439static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int * /*r_array_index*/)
440{
441 static char buf[128];
442
443 /* block will be attached to ID_KE block... */
444 if (adrcode == 0) {
445 /* adrcode=0 was the misnamed "speed" curve (now "evaluation time") */
446 STRNCPY(buf, "eval_time");
447 }
448 else {
449 /* Find the name of the ShapeKey (i.e. KeyBlock) to look for */
450 Key *key = (Key *)id;
451 KeyBlock *kb = BKE_keyblock_find_by_index(key, adrcode);
452
453 /* setting that we alter is the "value" (i.e. keyblock.curval) */
454 if (kb) {
455 /* Use the keyblock name, escaped, so that path lookups for this will work */
456 char kb_name_esc[sizeof(kb->name) * 2];
457 BLI_str_escape(kb_name_esc, kb->name, sizeof(kb_name_esc));
458 SNPRINTF(buf, "key_blocks[\"%s\"].value", kb_name_esc);
459 }
460 else {
461 /* Fallback - Use the adrcode as index directly, so that this can be manually fixed */
462 SNPRINTF(buf, "key_blocks[%d].value", adrcode);
463 }
464 }
465 return buf;
466}
467
468/* MTex (Texture Slot) types */
469static const char *mtex_adrcodes_to_paths(int adrcode, int * /*r_array_index*/)
470{
471 const char *base = nullptr, *prop = nullptr;
472 static char buf[128];
473
474 /* base part of path */
475 if (adrcode & MA_MAP1) {
476 base = "textures[0]";
477 }
478 else if (adrcode & MA_MAP2) {
479 base = "textures[1]";
480 }
481 else if (adrcode & MA_MAP3) {
482 base = "textures[2]";
483 }
484 else if (adrcode & MA_MAP4) {
485 base = "textures[3]";
486 }
487 else if (adrcode & MA_MAP5) {
488 base = "textures[4]";
489 }
490 else if (adrcode & MA_MAP6) {
491 base = "textures[5]";
492 }
493 else if (adrcode & MA_MAP7) {
494 base = "textures[6]";
495 }
496 else if (adrcode & MA_MAP8) {
497 base = "textures[7]";
498 }
499 else if (adrcode & MA_MAP9) {
500 base = "textures[8]";
501 }
502 else if (adrcode & MA_MAP10) {
503 base = "textures[9]";
504 }
505 else if (adrcode & MA_MAP11) {
506 base = "textures[10]";
507 }
508 else if (adrcode & MA_MAP12) {
509 base = "textures[11]";
510 }
511 else if (adrcode & MA_MAP13) {
512 base = "textures[12]";
513 }
514 else if (adrcode & MA_MAP14) {
515 base = "textures[13]";
516 }
517 else if (adrcode & MA_MAP15) {
518 base = "textures[14]";
519 }
520 else if (adrcode & MA_MAP16) {
521 base = "textures[15]";
522 }
523 else if (adrcode & MA_MAP17) {
524 base = "textures[16]";
525 }
526 else if (adrcode & MA_MAP18) {
527 base = "textures[17]";
528 }
529
530 /* property identifier for path */
531 adrcode = (adrcode & (MA_MAP1 - 1));
532 switch (adrcode) {
533#if 0 /* XXX these are not wrapped in RNA yet! */
534 case MAP_OFS_X:
535 poin = &(mtex->ofs[0]);
536 break;
537 case MAP_OFS_Y:
538 poin = &(mtex->ofs[1]);
539 break;
540 case MAP_OFS_Z:
541 poin = &(mtex->ofs[2]);
542 break;
543 case MAP_SIZE_X:
544 poin = &(mtex->size[0]);
545 break;
546 case MAP_SIZE_Y:
547 poin = &(mtex->size[1]);
548 break;
549 case MAP_SIZE_Z:
550 poin = &(mtex->size[2]);
551 break;
552 case MAP_R:
553 poin = &(mtex->r);
554 break;
555 case MAP_G:
556 poin = &(mtex->g);
557 break;
558 case MAP_B:
559 poin = &(mtex->b);
560 break;
561 case MAP_DVAR:
562 poin = &(mtex->def_var);
563 break;
564 case MAP_COLF:
565 poin = &(mtex->colfac);
566 break;
567 case MAP_NORF:
568 poin = &(mtex->norfac);
569 break;
570 case MAP_VARF:
571 poin = &(mtex->varfac);
572 break;
573#endif
574 case MAP_DISP:
575 prop = "warp_factor";
576 break;
577 }
578
579 /* only build and return path if there's a property */
580 if (prop) {
581 SNPRINTF(buf, "%s.%s", base, prop);
582 return buf;
583 }
584
585 return nullptr;
586}
587
588/* Texture types */
589static const char *texture_adrcodes_to_paths(int adrcode, int *r_array_index)
590{
591 /* Set array index like this in-case nothing sets it correctly. */
592 *r_array_index = 0;
593
594 /* result depends on adrcode */
595 switch (adrcode) {
596 case TE_NSIZE:
597 return "noise_size";
598 case TE_TURB:
599 return "turbulence";
600
601 case TE_NDEPTH: /* XXX texture RNA undefined */
602 // poin= &(tex->noisedepth); *type= IPO_SHORT; break;
603 break;
604 case TE_NTYPE: /* XXX texture RNA undefined */
605 // poin= &(tex->noisetype); *type= IPO_SHORT; break;
606 break;
607
608 case TE_N_BAS1:
609 return "noise_basis";
610 case TE_N_BAS2:
611 return "noise_basis"; /* XXX this is not yet defined in RNA... */
612
613 /* voronoi */
614 case TE_VNW1:
615 *r_array_index = 0;
616 return "feature_weights";
617 case TE_VNW2:
618 *r_array_index = 1;
619 return "feature_weights";
620 case TE_VNW3:
621 *r_array_index = 2;
622 return "feature_weights";
623 case TE_VNW4:
624 *r_array_index = 3;
625 return "feature_weights";
626 case TE_VNMEXP:
627 return "minkovsky_exponent";
628 case TE_VN_DISTM:
629 return "distance_metric";
630 case TE_VN_COLT:
631 return "color_type";
632
633 /* distorted noise / voronoi */
634 case TE_ISCA:
635 return "noise_intensity";
636
637 /* distorted noise */
638 case TE_DISTA:
639 return "distortion_amount";
640
641 /* musgrave */
642 case TE_MG_TYP: /* XXX texture RNA undefined */
643 // poin= &(tex->stype); *type= IPO_SHORT; break;
644 break;
645 case TE_MGH:
646 return "highest_dimension";
647 case TE_MG_LAC:
648 return "lacunarity";
649 case TE_MG_OCT:
650 return "octaves";
651 case TE_MG_OFF:
652 return "offset";
653 case TE_MG_GAIN:
654 return "gain";
655
656 case TE_COL_R:
657 *r_array_index = 0;
658 return "rgb_factor";
659 case TE_COL_G:
660 *r_array_index = 1;
661 return "rgb_factor";
662 case TE_COL_B:
663 *r_array_index = 2;
664 return "rgb_factor";
665
666 case TE_BRIGHT:
667 return "brightness";
668 case TE_CONTRA:
669 return "contrast";
670 }
671
672 return nullptr;
673}
674
675/* Material Types */
676static const char *material_adrcodes_to_paths(int adrcode, int *r_array_index)
677{
678 /* Set array index like this in-case nothing sets it correctly. */
679 *r_array_index = 0;
680
681 /* result depends on adrcode */
682 switch (adrcode) {
683 case MA_COL_R:
684 *r_array_index = 0;
685 return "diffuse_color";
686 case MA_COL_G:
687 *r_array_index = 1;
688 return "diffuse_color";
689 case MA_COL_B:
690 *r_array_index = 2;
691 return "diffuse_color";
692
693 case MA_SPEC_R:
694 *r_array_index = 0;
695 return "specular_color";
696 case MA_SPEC_G:
697 *r_array_index = 1;
698 return "specular_color";
699 case MA_SPEC_B:
700 *r_array_index = 2;
701 return "specular_color";
702
703 case MA_MIR_R:
704 *r_array_index = 0;
705 return "mirror_color";
706 case MA_MIR_G:
707 *r_array_index = 1;
708 return "mirror_color";
709 case MA_MIR_B:
710 *r_array_index = 2;
711 return "mirror_color";
712
713 case MA_ALPHA:
714 return "alpha";
715
716 case MA_REF:
717 return "diffuse_intensity";
718
719 case MA_EMIT:
720 return "emit";
721
722 case MA_AMB:
723 return "ambient";
724
725 case MA_SPEC:
726 return "specular_intensity";
727
728 case MA_HARD:
729 return "specular_hardness";
730
731 case MA_SPTR:
732 return "specular_opacity";
733
734 case MA_IOR:
735 return "ior";
736
737 case MA_HASIZE:
738 return "halo.size";
739
740 case MA_TRANSLU:
741 return "translucency";
742
743 case MA_RAYM:
744 return "raytrace_mirror.reflect";
745
746 case MA_FRESMIR:
747 return "raytrace_mirror.fresnel";
748
749 case MA_FRESMIRI:
750 return "raytrace_mirror.fresnel_factor";
751
752 case MA_FRESTRA:
753 return "raytrace_transparency.fresnel";
754
755 case MA_FRESTRAI:
756 return "raytrace_transparency.fresnel_factor";
757
758 case MA_ADD:
759 return "halo.add";
760
761 default: /* for now, we assume that the others were MTex channels */
762 return mtex_adrcodes_to_paths(adrcode, r_array_index);
763 }
764
765 return nullptr;
766}
767
768/* Camera Types */
769static const char *camera_adrcodes_to_paths(int adrcode, int *r_array_index)
770{
771 /* Set array index like this in-case nothing sets it correctly. */
772 *r_array_index = 0;
773
774 /* result depends on adrcode */
775 switch (adrcode) {
776 case CAM_LENS:
777#if 0 /* XXX this cannot be resolved easily... \
778 * perhaps we assume camera is perspective (works for most cases... */
779 if (ca->type == CAM_ORTHO) {
780 return "ortho_scale";
781 }
782 else {
783 return "lens";
784 }
785#else /* XXX lazy hack for now... */
786 return "lens";
787#endif /* XXX this cannot be resolved easily */
788
789 case CAM_STA:
790 return "clip_start";
791 case CAM_END:
792 return "clip_end";
793
794#if 0 /* XXX these are not defined in RNA */
795 case CAM_YF_APERT:
796 poin = &(ca->YF_aperture);
797 break;
798 case CAM_YF_FDIST:
799 poin = &(ca->dof_distance);
800 break;
801#endif /* XXX these are not defined in RNA */
802
803 case CAM_SHIFT_X:
804 return "shift_x";
805 case CAM_SHIFT_Y:
806 return "shift_y";
807 }
808
809 /* unrecognized adrcode, or not-yet-handled ones! */
810 return nullptr;
811}
812
813/* Light Types */
814static const char *light_adrcodes_to_paths(int adrcode, int *r_array_index)
815{
816 /* Set array index like this in-case nothing sets it correctly. */
817 *r_array_index = 0;
818
819 /* result depends on adrcode */
820 switch (adrcode) {
821 case LA_ENERGY:
822 return "energy";
823
824 case LA_COL_R:
825 *r_array_index = 0;
826 return "color";
827 case LA_COL_G:
828 *r_array_index = 1;
829 return "color";
830 case LA_COL_B:
831 *r_array_index = 2;
832 return "color";
833
834 case LA_DIST:
835 return "distance";
836
837 case LA_SPOTSI:
838 return "spot_size";
839 case LA_SPOTBL:
840 return "spot_blend";
841
842 case LA_QUAD1:
843 return "linear_attenuation";
844 case LA_QUAD2:
845 return "quadratic_attenuation";
846
847 case LA_HALOINT:
848 return "halo_intensity";
849
850 default: /* for now, we assume that the others were MTex channels */
851 return mtex_adrcodes_to_paths(adrcode, r_array_index);
852 }
853
854 /* unrecognized adrcode, or not-yet-handled ones! */
855 return nullptr;
856}
857
858/* Sound Types */
859static const char *sound_adrcodes_to_paths(int adrcode, int *r_array_index)
860{
861 /* Set array index like this in-case nothing sets it correctly. */
862 *r_array_index = 0;
863
864 /* result depends on adrcode */
865 switch (adrcode) {
866 case SND_VOLUME:
867 return "volume";
868 case SND_PITCH:
869 return "pitch";
870/* XXX Joshua -- I had wrapped panning in rna,
871 * but someone commented out, calling it "unused" */
872#if 0
873 case SND_PANNING:
874 return "panning";
875#endif
876 case SND_ATTEN:
877 return "attenuation";
878 }
879
880 /* unrecognized adrcode, or not-yet-handled ones! */
881 return nullptr;
882}
883
884/* World Types */
885static const char *world_adrcodes_to_paths(int adrcode, int *r_array_index)
886{
887 /* Set array index like this in-case nothing sets it correctly. */
888 *r_array_index = 0;
889
890 /* result depends on adrcode */
891 switch (adrcode) {
892 case WO_HOR_R:
893 *r_array_index = 0;
894 return "horizon_color";
895 case WO_HOR_G:
896 *r_array_index = 1;
897 return "horizon_color";
898 case WO_HOR_B:
899 *r_array_index = 2;
900 return "horizon_color";
901 case WO_ZEN_R:
902 *r_array_index = 0;
903 return "zenith_color";
904 case WO_ZEN_G:
905 *r_array_index = 1;
906 return "zenith_color";
907 case WO_ZEN_B:
908 *r_array_index = 2;
909 return "zenith_color";
910
911 case WO_EXPOS:
912 return "exposure";
913
914 case WO_MISI:
915 return "mist.intensity";
916 case WO_MISTDI:
917 return "mist.depth";
918 case WO_MISTSTA:
919 return "mist.start";
920 case WO_MISTHI:
921 return "mist.height";
922
923 default: /* for now, we assume that the others were MTex channels */
924 return mtex_adrcodes_to_paths(adrcode, r_array_index);
925 }
926
927 return nullptr;
928}
929
930/* Particle Types */
931static const char *particle_adrcodes_to_paths(int adrcode, int *r_array_index)
932{
933 /* Set array index like this in-case nothing sets it correctly. */
934 *r_array_index = 0;
935
936 /* result depends on adrcode */
937 switch (adrcode) {
938 case PART_CLUMP:
939 return "settings.clump_factor";
940 case PART_AVE:
941 return "settings.angular_velocity_factor";
942 case PART_SIZE:
943 return "settings.particle_size";
944 case PART_DRAG:
945 return "settings.drag_factor";
946 case PART_BROWN:
947 return "settings.brownian_factor";
948 case PART_DAMP:
949 return "settings.damp_factor";
950 case PART_LENGTH:
951 return "settings.length";
952 case PART_GRAV_X:
953 *r_array_index = 0;
954 return "settings.acceleration";
955 case PART_GRAV_Y:
956 *r_array_index = 1;
957 return "settings.acceleration";
958 case PART_GRAV_Z:
959 *r_array_index = 2;
960 return "settings.acceleration";
961 case PART_KINK_AMP:
962 return "settings.kink_amplitude";
963 case PART_KINK_FREQ:
964 return "settings.kink_frequency";
965 case PART_KINK_SHAPE:
966 return "settings.kink_shape";
967 case PART_BB_TILT:
968 return "settings.billboard_tilt";
969
970/* PartDeflect needs to be sorted out properly in rna_object_force;
971 * If anyone else works on this, but is unfamiliar, these particular
972 * settings reference the particles of the system themselves
973 * being used as forces -- it will use the same rna structure
974 * as the similar object forces */
975#if 0
976 case PART_PD_FSTR:
977 if (part->pd) {
978 poin = &(part->pd->f_strength);
979 }
980 break;
981 case PART_PD_FFALL:
982 if (part->pd) {
983 poin = &(part->pd->f_power);
984 }
985 break;
986 case PART_PD_FMAXD:
987 if (part->pd) {
988 poin = &(part->pd->maxdist);
989 }
990 break;
991 case PART_PD2_FSTR:
992 if (part->pd2) {
993 poin = &(part->pd2->f_strength);
994 }
995 break;
996 case PART_PD2_FFALL:
997 if (part->pd2) {
998 poin = &(part->pd2->f_power);
999 }
1000 break;
1001 case PART_PD2_FMAXD:
1002 if (part->pd2) {
1003 poin = &(part->pd2->maxdist);
1004 }
1005 break;
1006#endif
1007 }
1008
1009 return nullptr;
1010}
1011
1012/* ------- */
1013
1014/* Allocate memory for RNA-path for some property given a blocktype, adrcode,
1015 * and 'root' parts of path.
1016 *
1017 * Input:
1018 * - id - the data-block that the curve's IPO block
1019 * is attached to and/or which the new paths will start from
1020 * - blocktype, adrcode - determines setting to get
1021 * - actname, constname, seq - used to build path
1022 * Output:
1023 * - r_array_index - index in property's array (if applicable) to use
1024 * - return - the allocated path...
1025 */
1026static char *get_rna_access(ID *id,
1027 int blocktype,
1028 int adrcode,
1029 const char actname[],
1030 const char constname[],
1031 Sequence *seq,
1032 int *r_array_index)
1033{
1034 DynStr *path = BLI_dynstr_new();
1035 const char *propname = nullptr;
1036 char *rpath = nullptr;
1037 char buf[512];
1038 int dummy_index = 0;
1039
1040 /* hack: if constname is set, we can only be dealing with an Constraint curve */
1041 if (constname) {
1042 blocktype = ID_CO;
1043 }
1044
1045 /* get property name based on blocktype */
1046 switch (blocktype) {
1047 case ID_OB: /* object */
1048 propname = ob_adrcodes_to_paths(adrcode, &dummy_index);
1049 break;
1050
1051 case ID_PO: /* pose channel */
1052 propname = pchan_adrcodes_to_paths(adrcode, &dummy_index);
1053 break;
1054
1055 case ID_KE: /* shapekeys */
1056 propname = shapekey_adrcodes_to_paths(id, adrcode, &dummy_index);
1057 break;
1058
1059 case ID_CO: /* constraint */
1060 propname = constraint_adrcodes_to_paths(adrcode, &dummy_index);
1061 break;
1062
1063 case ID_TE: /* texture */
1064 propname = texture_adrcodes_to_paths(adrcode, &dummy_index);
1065 break;
1066
1067 case ID_MA: /* material */
1068 propname = material_adrcodes_to_paths(adrcode, &dummy_index);
1069 break;
1070
1071 case ID_CA: /* camera */
1072 propname = camera_adrcodes_to_paths(adrcode, &dummy_index);
1073 break;
1074
1075 case ID_LA: /* light */
1076 propname = light_adrcodes_to_paths(adrcode, &dummy_index);
1077 break;
1078
1079 case ID_SO: /* sound */
1080 propname = sound_adrcodes_to_paths(adrcode, &dummy_index);
1081 break;
1082
1083 case ID_WO: /* world */
1084 propname = world_adrcodes_to_paths(adrcode, &dummy_index);
1085 break;
1086
1087 case ID_PA: /* particle */
1088 propname = particle_adrcodes_to_paths(adrcode, &dummy_index);
1089 break;
1090
1091 case ID_CU_LEGACY: /* curve */
1092 /* this used to be a 'dummy' curve which got evaluated on the fly...
1093 * now we've got real var for this!
1094 */
1095 propname = "eval_time";
1096 break;
1097
1098 /* XXX problematic block-types. */
1099 case ID_SEQ: /* sequencer strip */
1100 /* SEQ_FAC1: */
1101 switch (adrcode) {
1102 case SEQ_FAC1:
1103 propname = "effect_fader";
1104 break;
1105 case SEQ_FAC_SPEED:
1106 propname = "speed_fader";
1107 break;
1108 case SEQ_FAC_OPACITY:
1109 propname = "blend_alpha";
1110 break;
1111 }
1112 /* XXX this doesn't seem to be included anywhere in sequencer RNA... */
1113 // poin= &(seq->facf0);
1114 break;
1115
1116 /* special hacks */
1117 case -1:
1118 /* special case for rotdiff drivers... we don't need a property for this... */
1119 break;
1120
1121 /* TODO: add other block-types. */
1122 default:
1123 CLOG_WARN(&LOG, "No path for blocktype %d, adrcode %d yet", blocktype, adrcode);
1124 break;
1125 }
1126
1127 /* check if any property found
1128 * - blocktype < 0 is special case for a specific type of driver,
1129 * where we don't need a property name...
1130 */
1131 if ((propname == nullptr) && (blocktype > 0)) {
1132 /* nothing was found, so exit */
1133 if (r_array_index) {
1134 *r_array_index = 0;
1135 }
1136
1137 BLI_dynstr_free(path);
1138
1139 return nullptr;
1140 }
1141
1142 if (r_array_index) {
1143 *r_array_index = dummy_index;
1144 }
1145
1146 /* 'buf' _must_ be initialized in this block */
1147 /* append preceding bits to path */
1148 /* NOTE: strings are not escaped and they should be! */
1149 if ((actname && actname[0]) && (constname && constname[0])) {
1150 /* Constraint in Pose-Channel */
1151 char actname_esc[sizeof(bActionChannel::name) * 2];
1152 char constname_esc[sizeof(bConstraint::name) * 2];
1153 BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
1154 BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
1155 SNPRINTF(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
1156 }
1157 else if (actname && actname[0]) {
1158 if ((blocktype == ID_OB) && STREQ(actname, "Object")) {
1159 /* Actionified "Object" IPO's... no extra path stuff needed */
1160 buf[0] = '\0'; /* empty string */
1161 }
1162 else if ((blocktype == ID_KE) && STREQ(actname, "Shape")) {
1163 /* Actionified "Shape" IPO's -
1164 * these are forced onto object level via the action container there... */
1165 STRNCPY(buf, "data.shape_keys");
1166 }
1167 else {
1168 /* Pose-Channel */
1169 char actname_esc[sizeof(bActionChannel::name) * 2];
1170 BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
1171 SNPRINTF(buf, "pose.bones[\"%s\"]", actname_esc);
1172 }
1173 }
1174 else if (constname && constname[0]) {
1175 /* Constraint in Object */
1176 char constname_esc[sizeof(bConstraint::name) * 2];
1177 BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
1178 SNPRINTF(buf, "constraints[\"%s\"]", constname_esc);
1179 }
1180 else if (seq) {
1181 /* Sequence names in Scene */
1182 char seq_name_esc[(sizeof(seq->name) - 2) * 2];
1183 BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc));
1184 SNPRINTF(buf, "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
1185 }
1186 else {
1187 buf[0] = '\0'; /* empty string */
1188 }
1189
1190 BLI_dynstr_append(path, buf);
1191
1192 /* need to add dot before property if there was anything preceding this */
1193 if (buf[0]) {
1194 BLI_dynstr_append(path, ".");
1195 }
1196
1197 /* now write name of property */
1198 BLI_dynstr_append(path, propname);
1199
1200 /* if there was no array index pointer provided, add it to the path */
1201 if (r_array_index == nullptr) {
1202 SNPRINTF(buf, "[\"%d\"]", dummy_index);
1203 BLI_dynstr_append(path, buf);
1204 }
1205
1206 /* convert to normal MEM_malloc'd string */
1207 rpath = BLI_dynstr_get_cstring(path);
1208 BLI_dynstr_free(path);
1209
1210 /* return path... */
1211 return rpath;
1212}
1213
1214/* *************************************************** */
1215/* Conversion Utilities */
1216
1217/* Convert adrcodes to driver target transform channel types */
1218static short adrcode_to_dtar_transchan(short adrcode)
1219{
1220 switch (adrcode) {
1221 case OB_LOC_X:
1222 return DTAR_TRANSCHAN_LOCX;
1223 case OB_LOC_Y:
1224 return DTAR_TRANSCHAN_LOCY;
1225 case OB_LOC_Z:
1226 return DTAR_TRANSCHAN_LOCZ;
1227
1228 case OB_ROT_X:
1229 return DTAR_TRANSCHAN_ROTX;
1230 case OB_ROT_Y:
1231 return DTAR_TRANSCHAN_ROTY;
1232 case OB_ROT_Z:
1233 return DTAR_TRANSCHAN_ROTZ;
1234
1235 case OB_SIZE_X:
1236 return DTAR_TRANSCHAN_SCALEX;
1237 case OB_SIZE_Y:
1238 return DTAR_TRANSCHAN_SCALEX;
1239 case OB_SIZE_Z:
1240 return DTAR_TRANSCHAN_SCALEX;
1241
1242 default:
1243 return 0;
1244 }
1245}
1246
1247/* Convert IpoDriver to ChannelDriver - will free the old data (i.e. the old driver) */
1249{
1250 ChannelDriver *cdriver;
1251
1252 /* allocate memory for new driver */
1253 cdriver = static_cast<ChannelDriver *>(MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"));
1254
1255 /* if 'pydriver', just copy data across */
1256 if (idriver->type == IPO_DRIVER_TYPE_PYTHON) {
1257 /* PyDriver only requires the expression to be copied */
1258 /* FIXME: expression will be useless due to API changes, but at least not totally lost */
1259 cdriver->type = DRIVER_TYPE_PYTHON;
1260 if (idriver->name[0]) {
1261 STRNCPY(cdriver->expression, idriver->name);
1262 }
1263 }
1264 else {
1265 DriverVar *dvar = nullptr;
1266 DriverTarget *dtar = nullptr;
1267
1268 /* this should be ok for all types here... */
1269 cdriver->type = DRIVER_TYPE_AVERAGE;
1270
1271 /* what to store depends on the 'blocktype' - object or posechannel */
1272 if (idriver->blocktype == ID_AR) { /* PoseChannel */
1273 if (idriver->adrcode == OB_ROT_DIFF) {
1274 /* Rotational Difference requires a special type of variable */
1275 dvar = driver_add_new_variable(cdriver);
1277
1278 /* first bone target */
1279 dtar = &dvar->targets[0];
1280 dtar->id = (ID *)idriver->ob;
1281 dtar->idtype = ID_OB;
1282 if (idriver->name[0]) {
1283 STRNCPY(dtar->pchan_name, idriver->name);
1284 }
1285
1286 /* second bone target (name was stored in same var as the first one) */
1287 dtar = &dvar->targets[1];
1288 dtar->id = (ID *)idriver->ob;
1289 dtar->idtype = ID_OB;
1290 if (idriver->name[0]) { /* XXX: for safety. */
1291 STRNCPY(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS);
1292 }
1293 }
1294 else {
1295 /* only a single variable, of type 'transform channel' */
1296 dvar = driver_add_new_variable(cdriver);
1298
1299 /* only requires a single target */
1300 dtar = &dvar->targets[0];
1301 dtar->id = (ID *)idriver->ob;
1302 dtar->idtype = ID_OB;
1303 if (idriver->name[0]) {
1304 STRNCPY(dtar->pchan_name, idriver->name);
1305 }
1307 dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
1308 }
1309 }
1310 else { /* Object */
1311 /* only a single variable, of type 'transform channel' */
1312 dvar = driver_add_new_variable(cdriver);
1314
1315 /* only requires single target */
1316 dtar = &dvar->targets[0];
1317 dtar->id = (ID *)idriver->ob;
1318 dtar->idtype = ID_OB;
1320 }
1321 }
1322
1323 /* return the new one */
1324 return cdriver;
1325}
1326
1327/* Add F-Curve to the correct list
1328 * - grpname is needed to be used as group name where relevant, and is usually derived from actname
1329 */
1331 ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo)
1332{
1333 /* If we're adding to an action, we will have groups to write to... */
1334 if (groups && grpname) {
1335 /* wrap the pointers given into a dummy action that we pass to the API func
1336 * and extract the resultant lists...
1337 */
1338 bAction tmp_act;
1339 bActionGroup *agrp = nullptr;
1340
1341 /* init the temp action */
1342 memset(&tmp_act, 0, sizeof(bAction)); /* XXX: Only enable this line if we get errors. */
1343 tmp_act.groups.first = groups->first;
1344 tmp_act.groups.last = groups->last;
1345 tmp_act.curves.first = list->first;
1346 tmp_act.curves.last = list->last;
1347 /* XXX: The other vars don't need to be filled in. */
1348
1349 /* get the group to use */
1350 agrp = BKE_action_group_find_name(&tmp_act, grpname);
1351 /* no matching group, so add one */
1352 if (agrp == nullptr) {
1353 /* Add a new group, and make it active */
1354 agrp = static_cast<bActionGroup *>(MEM_callocN(sizeof(bActionGroup), "bActionGroup"));
1355
1356 agrp->flag = AGRP_SELECTED;
1357 if (muteipo) {
1358 agrp->flag |= AGRP_MUTED;
1359 }
1360
1361 STRNCPY(agrp->name, grpname);
1362
1363 BLI_addtail(&tmp_act.groups, agrp);
1364 BLI_uniquename(&tmp_act.groups,
1365 agrp,
1366 DATA_("Group"),
1367 '.',
1368 offsetof(bActionGroup, name),
1369 sizeof(agrp->name));
1370 }
1371
1372 /* add F-Curve to group */
1373 /* WARNING: this func should only need to look at the stuff we initialized,
1374 * if not, things may crash. */
1375 action_groups_add_channel(&tmp_act, agrp, fcu);
1376
1377 if (agrp->flag & AGRP_MUTED) { /* flush down */
1378 fcu->flag |= FCURVE_MUTED;
1379 }
1380
1381 /* set the output lists based on the ones in the temp action */
1382 groups->first = tmp_act.groups.first;
1383 groups->last = tmp_act.groups.last;
1384 list->first = tmp_act.curves.first;
1385 list->last = tmp_act.curves.last;
1386 }
1387 else {
1388 /* simply add the F-Curve to the end of the given list */
1389 BLI_addtail(list, fcu);
1390 }
1391}
1392
1402static void icu_to_fcurves(ID *id,
1403 ListBase *groups,
1404 ListBase *list,
1405 IpoCurve *icu,
1406 char *actname,
1407 char *constname,
1408 Sequence *seq,
1409 int muteipo)
1410{
1411 AdrBit2Path *abp;
1412 FCurve *fcu;
1413 int totbits;
1414
1415 /* allocate memory for a new F-Curve */
1416 fcu = BKE_fcurve_create();
1417
1418 /* convert driver */
1419 if (icu->driver) {
1420 fcu->driver = idriver_to_cdriver(icu->driver);
1421 }
1422
1423 /* copy flags */
1424 if (icu->flag & IPO_VISIBLE) {
1425 fcu->flag |= FCURVE_VISIBLE;
1426 }
1427 if (icu->flag & IPO_SELECT) {
1428 fcu->flag |= FCURVE_SELECTED;
1429 }
1430 if (icu->flag & IPO_ACTIVE) {
1431 fcu->flag |= FCURVE_ACTIVE;
1432 }
1433 if (icu->flag & IPO_MUTE) {
1434 fcu->flag |= FCURVE_MUTED;
1435 }
1436 if (icu->flag & IPO_PROTECT) {
1437 fcu->flag |= FCURVE_PROTECTED;
1438 }
1439
1440 /* set extrapolation */
1441 switch (icu->extrap) {
1442 case IPO_HORIZ: /* constant extrapolation */
1443 case IPO_DIR: /* linear extrapolation */
1444 {
1445 /* just copy, as the new defines match the old ones... */
1446 fcu->extend = icu->extrap;
1447 break;
1448 }
1449 case IPO_CYCL: /* cyclic extrapolation */
1450 case IPO_CYCLX: /* cyclic extrapolation + offset */
1451 {
1452 /* Add a new FModifier (Cyclic) instead of setting extend value
1453 * as that's the new equivalent of that option.
1454 */
1456 FMod_Cycles *data = (FMod_Cycles *)fcm->data;
1457
1458 /* if 'offset' one is in use, set appropriate settings */
1459 if (icu->extrap == IPO_CYCLX) {
1460 data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET;
1461 }
1462 else {
1463 data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
1464 }
1465 break;
1466 }
1467 }
1468
1469 /* -------- */
1470
1471 /* get adrcode <-> bitflags mapping to handle nasty bitflag curves? */
1472 abp = adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits);
1473 if (abp && totbits) {
1474 FCurve *fcurve;
1475 int b;
1476
1477 if (G.debug & G_DEBUG) {
1478 printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits);
1479 }
1480
1481 /* add the 'only int values' flag */
1483
1484 /* for each bit we have to remap + check for:
1485 * 1) we need to make copy the existing F-Curve data (fcu -> fcurve),
1486 * except for the last one which will use the original
1487 * 2) copy the relevant path info across
1488 * 3) filter the keyframes for the flag of interest
1489 */
1490 for (b = 0; b < totbits; b++, abp++) {
1491 uint i = 0;
1492
1493 /* make a copy of existing base-data if not the last curve */
1494 if (b < (totbits - 1)) {
1495 fcurve = BKE_fcurve_copy(fcu);
1496 }
1497 else {
1498 fcurve = fcu;
1499 }
1500
1501 /* set path */
1502 fcurve->rna_path = BLI_strdup(abp->path);
1503 fcurve->array_index = abp->array_index;
1504
1505 /* Convert keyframes:
1506 * - Beztriples and bpoints are mutually exclusive,
1507 * so we won't have both at the same time.
1508 * - Beztriples are more likely to be encountered as they are keyframes
1509 * (the other type wasn't used yet).
1510 */
1511 fcurve->totvert = icu->totvert;
1512
1513 if (icu->bezt) {
1514 BezTriple *dst, *src;
1515
1516 /* allocate new array for keyframes/beztriples */
1517 fcurve->bezt = static_cast<BezTriple *>(
1518 MEM_callocN(sizeof(BezTriple) * fcurve->totvert, "BezTriples"));
1519
1520 /* loop through copying all BezTriples individually, as we need to modify a few things */
1521 for (dst = fcurve->bezt, src = icu->bezt, i = 0; i < fcurve->totvert; i++, dst++, src++) {
1522 /* firstly, copy BezTriple data */
1523 *dst = *src;
1524
1525 /* interpolation can only be constant... */
1526 dst->ipo = BEZT_IPO_CONST;
1527
1528 /* 'hide' flag is now used for keytype - only 'keyframes' existed before */
1530
1531 /* auto-handles - per curve to per handle */
1532 if (icu->flag & IPO_AUTO_HORIZ) {
1533 if (dst->h1 == HD_AUTO) {
1534 dst->h1 = HD_AUTO_ANIM;
1535 }
1536 if (dst->h2 == HD_AUTO) {
1537 dst->h2 = HD_AUTO_ANIM;
1538 }
1539 }
1540
1541 /* correct values, by checking if the flag of interest is set */
1542 if (int(dst->vec[1][1]) & (abp->bit)) {
1543 dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f;
1544 }
1545 else {
1546 dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 0.0f;
1547 }
1548 }
1549 }
1550 else if (icu->bp) {
1551 /* TODO: need to convert from BPoint type to the more compact FPoint type...
1552 * but not priority, since no data used this. */
1553 // BPoint *bp;
1554 // FPoint *fpt;
1555 }
1556
1557 /* add new F-Curve to list */
1558 fcurve_add_to_list(groups, list, fcurve, actname, muteipo);
1559 }
1560 }
1561 else {
1562 uint i = 0;
1563
1564 /* get rna-path
1565 * - we will need to set the 'disabled' flag if no path is able to be made (for now)
1566 */
1567 fcu->rna_path = get_rna_access(
1568 id, icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index);
1569 if (fcu->rna_path == nullptr) {
1570 fcu->flag |= FCURVE_DISABLED;
1571 }
1572
1573 /* Convert keyframes:
1574 * - Beztriples and bpoints are mutually exclusive, so we won't have both at the same time.
1575 * - Beztriples are more likely to be encountered as they are keyframes
1576 * (the other type wasn't used yet).
1577 */
1578 fcu->totvert = icu->totvert;
1579
1580 if (icu->bezt) {
1581 BezTriple *dst, *src;
1582
1583 /* allocate new array for keyframes/beztriples */
1584 fcu->bezt = static_cast<BezTriple *>(
1585 MEM_callocN(sizeof(BezTriple) * fcu->totvert, "BezTriples"));
1586
1587 /* loop through copying all BezTriples individually, as we need to modify a few things */
1588 for (dst = fcu->bezt, src = icu->bezt, i = 0; i < fcu->totvert; i++, dst++, src++) {
1589 /* firstly, copy BezTriple data */
1590 *dst = *src;
1591
1592 /* now copy interpolation from curve (if not already set) */
1593 if (icu->ipo != IPO_MIXED) {
1594 dst->ipo = icu->ipo;
1595 }
1596
1597 /* 'hide' flag is now used for keytype - only 'keyframes' existed before */
1599
1600 /* auto-handles - per curve to per handle */
1601 if (icu->flag & IPO_AUTO_HORIZ) {
1602 if (dst->h1 == HD_AUTO) {
1603 dst->h1 = HD_AUTO_ANIM;
1604 }
1605 if (dst->h2 == HD_AUTO) {
1606 dst->h2 = HD_AUTO_ANIM;
1607 }
1608 }
1609
1610 /* correct values for euler rotation curves
1611 * - they were degrees/10
1612 * - we need radians for RNA to do the right thing
1613 */
1614 if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
1615 ((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)))
1616 {
1617 const float fac = float(M_PI) / 18.0f; /* `10.0f * M_PI/180.0f`. */
1618
1619 dst->vec[0][1] *= fac;
1620 dst->vec[1][1] *= fac;
1621 dst->vec[2][1] *= fac;
1622 }
1623
1624 /* correct values for path speed curves
1625 * - their values were 0-1
1626 * - we now need as 'frames'
1627 */
1628 if ((id) && (icu->blocktype == GS(id->name)) && (GS(id->name) == ID_CU_LEGACY) &&
1629 (fcu->rna_path && STREQ(fcu->rna_path, "eval_time")))
1630 {
1631 const Curve *cu = (const Curve *)id;
1632
1633 dst->vec[0][1] *= cu->pathlen;
1634 dst->vec[1][1] *= cu->pathlen;
1635 dst->vec[2][1] *= cu->pathlen;
1636 }
1637
1638 /* correct times for rotation drivers
1639 * - need to go from degrees to radians...
1640 * - there's only really 1 target to worry about
1641 * - were also degrees/10
1642 */
1643 if (fcu->driver && fcu->driver->variables.first) {
1644 const DriverVar *dvar = static_cast<const DriverVar *>(fcu->driver->variables.first);
1645 const DriverTarget *dtar = &dvar->targets[0];
1646
1648 {
1649 const float fac = float(M_PI) / 18.0f;
1650
1651 dst->vec[0][0] *= fac;
1652 dst->vec[1][0] *= fac;
1653 dst->vec[2][0] *= fac;
1654 }
1655 }
1656
1657 /* correct values for sequencer curves, that were not locked to frame */
1658 if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
1659 const float mul = (seq->enddisp - seq->startdisp) / 100.0f;
1660 const float offset = seq->startdisp;
1661
1662 dst->vec[0][0] *= mul;
1663 dst->vec[0][0] += offset;
1664
1665 dst->vec[1][0] *= mul;
1666 dst->vec[1][0] += offset;
1667
1668 dst->vec[2][0] *= mul;
1669 dst->vec[2][0] += offset;
1670 }
1671 }
1672 }
1673 else if (icu->bp) {
1674 /* TODO: need to convert from BPoint type to the more compact FPoint type...
1675 * but not priority, since no data used this */
1676 // BPoint *bp;
1677 // FPoint *fpt;
1678 }
1679
1680 /* add new F-Curve to list */
1681 fcurve_add_to_list(groups, list, fcu, actname, muteipo);
1682 }
1683}
1684
1685/* ------------------------- */
1686
1687/* Convert IPO-block (i.e. all its IpoCurves) to the new system.
1688 * This does not assume that any ID or AnimData uses it, but does assume that
1689 * it is given two lists, which it will perform driver/animation-data separation.
1690 */
1691static void ipo_to_animato(ID *id,
1692 Ipo *ipo,
1693 char actname[],
1694 char constname[],
1695 Sequence *seq,
1696 ListBase *animgroups,
1697 ListBase *anim,
1698 ListBase *drivers)
1699{
1700 IpoCurve *icu;
1701
1702 /* sanity check */
1703 if (ELEM(nullptr, ipo, anim, drivers)) {
1704 return;
1705 }
1706
1707 if (G.debug & G_DEBUG) {
1708 printf("ipo_to_animato\n");
1709 }
1710
1711 /* validate actname and constname
1712 * - clear actname if it was one of the generic <builtin> ones (i.e. 'Object', or 'Shapes')
1713 * - actname can then be used to assign F-Curves in Action to Action Groups
1714 * (i.e. thus keeping the benefits that used to be provided by Action Channels for grouping
1715 * F-Curves for bones). This may be added later... for now let's just dump without them...
1716 */
1717 if (actname) {
1718 if ((ipo->blocktype == ID_OB) && STREQ(actname, "Object")) {
1719 actname = nullptr;
1720 }
1721 else if ((ipo->blocktype == ID_OB) && STREQ(actname, "Shape")) {
1722 actname = nullptr;
1723 }
1724 }
1725
1726 /* loop over IPO-Curves, freeing as we progress */
1727 LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
1728 /* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves),
1729 * we figure out the best place to put the channel,
1730 * then tell the curve-converter to just dump there. */
1731 if (icu->driver) {
1732 /* Blender 2.4x allowed empty drivers,
1733 * but we don't now, since they cause more trouble than they're worth. */
1734 if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) {
1735 icu_to_fcurves(id, nullptr, drivers, icu, actname, constname, seq, ipo->muteipo);
1736 }
1737 else {
1738 MEM_freeN(icu->driver);
1739 icu->driver = nullptr;
1740 }
1741 }
1742 else {
1743 icu_to_fcurves(id, animgroups, anim, icu, actname, constname, seq, ipo->muteipo);
1744 }
1745 }
1746
1747 /* if this IPO block doesn't have any users after this one, free... */
1748 id_us_min(&ipo->id);
1749 if (ID_REAL_USERS(ipo) <= 0) {
1750 IpoCurve *icn;
1751
1752 for (icu = static_cast<IpoCurve *>(ipo->curve.first); icu; icu = icn) {
1753 icn = icu->next;
1754
1755 /* free driver */
1756 if (icu->driver) {
1757 MEM_freeN(icu->driver);
1758 }
1759
1760 /* free old data of curve now that it's no longer needed for converting any more curves */
1761 if (icu->bezt) {
1762 MEM_freeN(icu->bezt);
1763 }
1764 if (icu->bp) {
1765 MEM_freeN(icu->bezt);
1766 }
1767
1768 /* free this IPO-Curve */
1769 BLI_freelinkN(&ipo->curve, icu);
1770 }
1771 }
1772}
1773
1774/* Convert Action-block to new system, separating animation and drivers
1775 * New curves may not be converted directly into the given Action (i.e. for Actions linked
1776 * to Objects, where ob->ipo and ob->action need to be combined).
1777 * NOTE: we need to be careful here, as same data-structs are used for new system too!
1778 */
1780 ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
1781{
1782 bActionChannel *achan, *achann;
1783 bConstraintChannel *conchan, *conchann;
1784
1786 act->wrap().is_action_legacy(),
1787 "Conversion from pre-2.5 animation data should happen before conversion to layered Actions");
1788
1789 /* only continue if there are Action Channels (indicating unconverted data) */
1790 if (BLI_listbase_is_empty(&act->chanbase)) {
1791 return;
1792 }
1793
1794 /* get rid of all Action Groups */
1795 /* XXX this is risky if there's some old + some new data in the Action... */
1796 if (act->groups.first) {
1797 BLI_freelistN(&act->groups);
1798 }
1799
1800 /* loop through Action-Channels, converting data, freeing as we go */
1801 for (achan = static_cast<bActionChannel *>(act->chanbase.first); achan; achan = achann) {
1802 /* get pointer to next Action Channel */
1803 achann = achan->next;
1804
1805 /* convert Action Channel's IPO data */
1806 if (achan->ipo) {
1807 ipo_to_animato(id, achan->ipo, achan->name, nullptr, nullptr, groups, curves, drivers);
1808 id_us_min(&achan->ipo->id);
1809 achan->ipo = nullptr;
1810 }
1811
1812 /* convert constraint channel IPO-data */
1813 for (conchan = static_cast<bConstraintChannel *>(achan->constraintChannels.first); conchan;
1814 conchan = conchann)
1815 {
1816 /* get pointer to next Constraint Channel */
1817 conchann = conchan->next;
1818
1819 /* convert Constraint Channel's IPO data */
1820 if (conchan->ipo) {
1822 id, conchan->ipo, achan->name, conchan->name, nullptr, groups, curves, drivers);
1823 id_us_min(&conchan->ipo->id);
1824 conchan->ipo = nullptr;
1825 }
1826
1827 /* free Constraint Channel */
1828 BLI_freelinkN(&achan->constraintChannels, conchan);
1829 }
1830
1831 /* free Action Channel */
1832 BLI_freelinkN(&act->chanbase, achan);
1833 }
1834}
1835
1836/* ------------------------- */
1837
1838/* Convert IPO-block (i.e. all its IpoCurves) for some ID to the new system
1839 * This assumes that AnimData has been added already. Separation of drivers
1840 * from animation data is accomplished here too...
1841 */
1843 Main *bmain, ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq)
1844{
1845 AnimData *adt = BKE_animdata_from_id(id);
1846 ListBase anim = {nullptr, nullptr};
1847 ListBase drivers = {nullptr, nullptr};
1848
1849 /* sanity check */
1850 if (ELEM(nullptr, id, ipo)) {
1851 return;
1852 }
1853 if (adt == nullptr) {
1854 CLOG_ERROR(&LOG, "adt invalid");
1855 return;
1856 }
1857
1858 if (G.debug & G_DEBUG) {
1859 printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d\n",
1860 id->name + 2,
1861 ipo->id.name + 2,
1862 (actname) ? actname : "<None>",
1863 (constname) ? constname : "<None>",
1864 (seq) ? (seq->name + 2) : "<None>",
1865 BLI_listbase_count(&ipo->curve));
1866 }
1867
1868 /* Convert curves to animato system
1869 * (separated into separate lists of F-Curves for animation and drivers),
1870 * and the try to put these lists in the right places, but do not free the lists here. */
1871 /* XXX there shouldn't be any need for the groups, so don't supply pointer for that now... */
1872 ipo_to_animato(id, ipo, actname, constname, seq, nullptr, &anim, &drivers);
1873
1874 /* deal with animation first */
1875 if (anim.first) {
1876 if (G.debug & G_DEBUG) {
1877 printf("\thas anim\n");
1878 }
1879 /* try to get action */
1880 if (adt->action == nullptr) {
1881 char nameBuf[MAX_ID_NAME];
1882
1883 SNPRINTF(nameBuf, "CDA:%s", ipo->id.name + 2);
1884
1885 bAction *action = BKE_action_add(bmain, nameBuf);
1886 id_us_min(&action->id);
1887 const bool assign_ok = animrig::assign_action(action, {*id, *adt});
1888 BLI_assert_msg(assign_ok, "Expecting the assignment of a new Action to always work");
1889 UNUSED_VARS_NDEBUG(assign_ok);
1890
1891 if (G.debug & G_DEBUG) {
1892 printf("\t\tadded new action - '%s'\n", nameBuf);
1893 }
1894 }
1895
1896 /* add F-Curves to action */
1897 BLI_movelisttolist(&adt->action->curves, &anim);
1898 }
1899
1900 /* deal with drivers */
1901 if (drivers.first) {
1902 if (G.debug & G_DEBUG) {
1903 printf("\thas drivers\n");
1904 }
1905 /* add drivers to end of driver stack */
1906 BLI_movelisttolist(&adt->drivers, &drivers);
1907 }
1908}
1909
1910/* Convert Action-block to new system
1911 * NOTE: we need to be careful here, as same data-structs are used for new system too!
1912 */
1913static void action_to_animdata(ID *id, bAction *act)
1914{
1915 AnimData *adt = BKE_animdata_from_id(id);
1916
1917 /* only continue if there are Action Channels (indicating unconverted data) */
1918 if (ELEM(nullptr, adt, act->chanbase.first)) {
1919 return;
1920 }
1921
1922 /* check if we need to set this Action as the AnimData's action */
1923 if (adt->action == nullptr) {
1924 /* set this Action as AnimData's Action */
1925 if (G.debug & G_DEBUG) {
1926 printf("act_to_adt - set adt action to act\n");
1927 }
1928 const bool assign_ok = animrig::assign_action(act, {*id, *adt});
1929 BLI_assert_msg(assign_ok, "Expecting the assignment of a just-converted Action to work");
1930 UNUSED_VARS_NDEBUG(assign_ok);
1931 }
1932
1933 /* convert Action data */
1934 action_to_animato(id, act, &adt->action->groups, &adt->action->curves, &adt->drivers);
1935}
1936
1937/* ------------------------- */
1938
1939/* TODO:
1940 * - NLA group duplicators info
1941 * - NLA curve/stride modifiers... */
1942
1943/* Convert NLA-Strip to new system */
1944static void nlastrips_to_animdata(ID *id, ListBase *strips)
1945{
1946 AnimData *adt = BKE_animdata_from_id(id);
1947 NlaTrack *nlt = nullptr;
1948 NlaStrip *strip;
1949 bActionStrip *as, *asn;
1950
1951 /* for each one of the original strips, convert to a new strip and free the old... */
1952 for (as = static_cast<bActionStrip *>(strips->first); as; as = asn) {
1953 asn = as->next;
1954
1955 /* this old strip is only worth something if it had an action... */
1956 if (as->act) {
1957 /* convert Action data (if not yet converted), storing the results in the same Action */
1958 action_to_animato(id, as->act, &as->act->groups, &as->act->curves, &adt->drivers);
1959
1960 /* Create a new-style NLA-strip which references this Action,
1961 * then copy over relevant settings. */
1962 {
1963 /* init a new strip, and assign the action to it
1964 * - no need to muck around with the user-counts, since this is just
1965 * passing over the ref to the new owner, not creating an additional ref
1966 */
1967 strip = static_cast<NlaStrip *>(MEM_callocN(sizeof(NlaStrip), "NlaStrip"));
1968 strip->act = as->act;
1969
1970 /* endpoints */
1971 strip->start = as->start;
1972 strip->end = as->end;
1973 strip->actstart = as->actstart;
1974 strip->actend = as->actend;
1975
1976 /* action reuse */
1977 strip->repeat = as->repeat;
1978 strip->scale = as->scale;
1979 if (as->flag & ACTSTRIP_LOCK_ACTION) {
1981 }
1982
1983 /* blending */
1984 strip->blendin = as->blendin;
1985 strip->blendout = as->blendout;
1986 strip->blendmode = (as->mode == ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD :
1988 if (as->flag & ACTSTRIP_AUTO_BLENDS) {
1990 }
1991
1992 /* assorted setting flags */
1993 if (as->flag & ACTSTRIP_SELECT) {
1994 strip->flag |= NLASTRIP_FLAG_SELECT;
1995 }
1996 if (as->flag & ACTSTRIP_ACTIVE) {
1997 strip->flag |= NLASTRIP_FLAG_ACTIVE;
1998 }
1999
2000 if (as->flag & ACTSTRIP_MUTE) {
2001 strip->flag |= NLASTRIP_FLAG_MUTED;
2002 }
2003 if (as->flag & ACTSTRIP_REVERSE) {
2004 strip->flag |= NLASTRIP_FLAG_REVERSE;
2005 }
2006
2007 /* by default, we now always extrapolate, while in the past this was optional */
2008 if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0) {
2010 }
2011 }
2012
2013 /* Try to add this strip to the current NLA-Track
2014 * (i.e. the 'last' one on the stack at the moment). */
2015 if (BKE_nlatrack_add_strip(nlt, strip, false) == 0) {
2016 /* trying to add to the current failed (no space),
2017 * so add a new track to the stack, and add to that...
2018 */
2019 nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, false);
2021 BKE_nlatrack_add_strip(nlt, strip, false);
2022 }
2023
2024 /* ensure that strip has a name */
2025 BKE_nlastrip_validate_name(adt, strip);
2026 }
2027
2028 /* modifiers */
2029 /* FIXME: for now, we just free them... */
2030 if (as->modifiers.first) {
2031 BLI_freelistN(&as->modifiers);
2032 }
2033
2034 /* free the old strip */
2035 BLI_freelinkN(strips, as);
2036 }
2037}
2038
2044
2045static bool seq_convert_callback(Sequence *seq, void *userdata)
2046{
2047 IpoCurve *icu = static_cast<IpoCurve *>((seq->ipo) ? seq->ipo->curve.first : nullptr);
2048 short adrcode = SEQ_FAC1;
2049
2050 if (G.debug & G_DEBUG) {
2051 printf("\tconverting sequence strip %s\n", seq->name + 2);
2052 }
2053
2054 if (ELEM(nullptr, seq->ipo, icu)) {
2056 return true;
2057 }
2058
2059 /* Patch `adrcode`, so that we can map to different DNA variables later (semi-hack (tm)). */
2060 switch (seq->type) {
2061 case SEQ_TYPE_IMAGE:
2062 case SEQ_TYPE_META:
2063 case SEQ_TYPE_SCENE:
2064 case SEQ_TYPE_MOVIE:
2065 case SEQ_TYPE_COLOR:
2066 adrcode = SEQ_FAC_OPACITY;
2067 break;
2068 case SEQ_TYPE_SPEED:
2069 adrcode = SEQ_FAC_SPEED;
2070 break;
2071 }
2072 icu->adrcode = adrcode;
2073
2074 Seq_callback_data *cd = (Seq_callback_data *)userdata;
2075
2076 /* convert IPO */
2077 ipo_to_animdata(cd->bmain, (ID *)cd->scene, seq->ipo, nullptr, nullptr, seq);
2078
2079 if (cd->adt->action) {
2080 cd->adt->action->idroot = ID_SCE; /* scene-rooted */
2081 }
2082
2083 id_us_min(&seq->ipo->id);
2084 seq->ipo = nullptr;
2085 return true;
2086}
2087
2088/* *************************************************** */
2089/* External API - Only Called from do_versions() */
2090
2092{
2093 ListBase drivers = {nullptr, nullptr};
2094 ID *id;
2095
2096 if (bmain == nullptr) {
2097 CLOG_ERROR(&LOG, "Argh! Main is nullptr");
2098 return;
2099 }
2100
2101 /* only convert if version is right */
2102 if (bmain->versionfile >= 250) {
2103 CLOG_WARN(&LOG, "Animation data too new to convert (Version %d)", bmain->versionfile);
2104 return;
2105 }
2106 if (G.debug & G_DEBUG) {
2107 printf("INFO: Converting to Animato...\n");
2108 }
2109
2110 /* ----------- Animation Attached to Data -------------- */
2111
2112 /* objects */
2113 for (id = static_cast<ID *>(bmain->objects.first); id; id = static_cast<ID *>(id->next)) {
2114 Object *ob = (Object *)id;
2115 bConstraintChannel *conchan, *conchann;
2116
2117 if (G.debug & G_DEBUG) {
2118 printf("\tconverting ob %s\n", id->name + 2);
2119 }
2120
2121 /* check if object has any animation data */
2122 if (ob->nlastrips.first) {
2123 /* Add AnimData block */
2125
2126 /* IPO first to take into any non-NLA'd Object Animation */
2127 if (ob->ipo) {
2128 ipo_to_animdata(bmain, id, ob->ipo, nullptr, nullptr, nullptr);
2129 /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */
2130 ob->ipo = nullptr;
2131 }
2132
2133 /* Action is skipped since it'll be used by some strip in the NLA anyway,
2134 * causing errors with evaluation in the new evaluation pipeline
2135 */
2136 if (ob->action) {
2137 id_us_min(&ob->action->id);
2138 ob->action = nullptr;
2139 }
2140
2141 /* finally NLA */
2142 nlastrips_to_animdata(id, &ob->nlastrips);
2143 }
2144 else if ((ob->ipo) || (ob->action)) {
2146
2147 /* Action first - so that Action name get conserved */
2148 if (ob->action) {
2149 action_to_animdata(id, ob->action);
2150
2151 id_us_min(&ob->action->id);
2152 ob->action = nullptr;
2153 }
2154
2155 /* IPO second... */
2156 if (ob->ipo) {
2157 ipo_to_animdata(bmain, id, ob->ipo, nullptr, nullptr, nullptr);
2158 /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */
2159 ob->ipo = nullptr;
2160 }
2161 }
2162
2163 /* check PoseChannels for constraints with local data */
2164 if (ob->pose) {
2165 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
2166 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
2167 /* if constraint has its own IPO, convert add these to Object
2168 * (NOTE: they're most likely to be drivers too)
2169 */
2170 if (con->ipo) {
2171 /* Verify if there's AnimData block */
2173
2174 /* although this was the constraint's local IPO, we still need to provide pchan + con
2175 * so that drivers can be added properly...
2176 */
2177 ipo_to_animdata(bmain, id, con->ipo, pchan->name, con->name, nullptr);
2178 id_us_min(&con->ipo->id);
2179 con->ipo = nullptr;
2180 }
2181 }
2182 }
2183 }
2184
2185 /* check constraints for local IPO's */
2187 /* if constraint has its own IPO, convert add these to Object
2188 * (NOTE: they're most likely to be drivers too)
2189 */
2190 if (con->ipo) {
2191 /* Verify if there's AnimData block, just in case */
2193
2194 /* although this was the constraint's local IPO, we still need to provide con
2195 * so that drivers can be added properly...
2196 */
2197 ipo_to_animdata(bmain, id, con->ipo, nullptr, con->name, nullptr);
2198 id_us_min(&con->ipo->id);
2199 con->ipo = nullptr;
2200 }
2201
2202 /* check for Action Constraint */
2203 /* XXX do we really want to do this here? */
2204 }
2205
2206 /* check constraint channels - we need to remove them anyway... */
2207 if (ob->constraintChannels.first) {
2208 for (conchan = static_cast<bConstraintChannel *>(ob->constraintChannels.first); conchan;
2209 conchan = conchann)
2210 {
2211 /* get pointer to next Constraint Channel */
2212 conchann = conchan->next;
2213
2214 /* convert Constraint Channel's IPO data */
2215 if (conchan->ipo) {
2216 /* Verify if there's AnimData block */
2218
2219 ipo_to_animdata(bmain, id, conchan->ipo, nullptr, conchan->name, nullptr);
2220 id_us_min(&conchan->ipo->id);
2221 conchan->ipo = nullptr;
2222 }
2223
2224 /* free Constraint Channel */
2225 BLI_freelinkN(&ob->constraintChannels, conchan);
2226 }
2227 }
2228
2229 /* object's action will always be object-rooted */
2230 {
2231 AnimData *adt = BKE_animdata_from_id(id);
2232 if (adt && adt->action) {
2233 adt->action->idroot = ID_OB;
2234 }
2235 }
2236 }
2237
2238 /* shapekeys */
2239 for (id = static_cast<ID *>(bmain->shapekeys.first); id; id = static_cast<ID *>(id->next)) {
2240 Key *key = (Key *)id;
2241
2242 if (G.debug & G_DEBUG) {
2243 printf("\tconverting key %s\n", id->name + 2);
2244 }
2245
2246 /* we're only interested in the IPO
2247 * NOTE: for later, it might be good to port these over to Object instead, as many of these
2248 * are likely to be drivers, but it's hard to trace that from here, so move this to Ob loop?
2249 */
2250 if (key->ipo) {
2251 /* Add AnimData block */
2253
2254 /* Convert Shape-key data... */
2255 ipo_to_animdata(bmain, id, key->ipo, nullptr, nullptr, nullptr);
2256
2257 if (adt->action) {
2258 adt->action->idroot = key->ipo->blocktype;
2259 }
2260
2261 id_us_min(&key->ipo->id);
2262 key->ipo = nullptr;
2263 }
2264 }
2265
2266 /* materials */
2267 for (id = static_cast<ID *>(bmain->materials.first); id; id = static_cast<ID *>(id->next)) {
2268 Material *ma = (Material *)id;
2269
2270 if (G.debug & G_DEBUG) {
2271 printf("\tconverting material %s\n", id->name + 2);
2272 }
2273
2274 /* we're only interested in the IPO */
2275 if (ma->ipo) {
2276 /* Add AnimData block */
2278
2279 /* Convert Material data... */
2280 ipo_to_animdata(bmain, id, ma->ipo, nullptr, nullptr, nullptr);
2281
2282 if (adt->action) {
2283 adt->action->idroot = ma->ipo->blocktype;
2284 }
2285
2286 id_us_min(&ma->ipo->id);
2287 ma->ipo = nullptr;
2288 }
2289 }
2290
2291 /* worlds */
2292 for (id = static_cast<ID *>(bmain->worlds.first); id; id = static_cast<ID *>(id->next)) {
2293 World *wo = (World *)id;
2294
2295 if (G.debug & G_DEBUG) {
2296 printf("\tconverting world %s\n", id->name + 2);
2297 }
2298
2299 /* we're only interested in the IPO */
2300 if (wo->ipo) {
2301 /* Add AnimData block */
2303
2304 /* Convert World data... */
2305 ipo_to_animdata(bmain, id, wo->ipo, nullptr, nullptr, nullptr);
2306
2307 if (adt->action) {
2308 adt->action->idroot = wo->ipo->blocktype;
2309 }
2310
2311 id_us_min(&wo->ipo->id);
2312 wo->ipo = nullptr;
2313 }
2314 }
2315
2316 /* sequence strips */
2317 for (id = static_cast<ID *>(bmain->scenes.first); id; id = static_cast<ID *>(id->next)) {
2318 Scene *scene = (Scene *)id;
2319 Editing *ed = scene->ed;
2320 if (ed && ed->seqbasep) {
2321 Seq_callback_data cb_data = {bmain, scene, BKE_animdata_ensure_id(id)};
2323 }
2324 }
2325
2326 /* textures */
2327 for (id = static_cast<ID *>(bmain->textures.first); id; id = static_cast<ID *>(id->next)) {
2328 Tex *te = (Tex *)id;
2329
2330 if (G.debug & G_DEBUG) {
2331 printf("\tconverting texture %s\n", id->name + 2);
2332 }
2333
2334 /* we're only interested in the IPO */
2335 if (te->ipo) {
2336 /* Add AnimData block */
2338
2339 /* Convert Texture data... */
2340 ipo_to_animdata(bmain, id, te->ipo, nullptr, nullptr, nullptr);
2341
2342 if (adt->action) {
2343 adt->action->idroot = te->ipo->blocktype;
2344 }
2345
2346 id_us_min(&te->ipo->id);
2347 te->ipo = nullptr;
2348 }
2349 }
2350
2351 /* cameras */
2352 for (id = static_cast<ID *>(bmain->cameras.first); id; id = static_cast<ID *>(id->next)) {
2353 Camera *ca = (Camera *)id;
2354
2355 if (G.debug & G_DEBUG) {
2356 printf("\tconverting camera %s\n", id->name + 2);
2357 }
2358
2359 /* we're only interested in the IPO */
2360 if (ca->ipo) {
2361 /* Add AnimData block */
2363
2364 /* Convert Camera data... */
2365 ipo_to_animdata(bmain, id, ca->ipo, nullptr, nullptr, nullptr);
2366
2367 if (adt->action) {
2368 adt->action->idroot = ca->ipo->blocktype;
2369 }
2370
2371 id_us_min(&ca->ipo->id);
2372 ca->ipo = nullptr;
2373 }
2374 }
2375
2376 /* lights */
2377 for (id = static_cast<ID *>(bmain->lights.first); id; id = static_cast<ID *>(id->next)) {
2378 Light *la = (Light *)id;
2379
2380 if (G.debug & G_DEBUG) {
2381 printf("\tconverting light %s\n", id->name + 2);
2382 }
2383
2384 /* we're only interested in the IPO */
2385 if (la->ipo) {
2386 /* Add AnimData block */
2388
2389 /* Convert Light data... */
2390 ipo_to_animdata(bmain, id, la->ipo, nullptr, nullptr, nullptr);
2391
2392 if (adt->action) {
2393 adt->action->idroot = la->ipo->blocktype;
2394 }
2395
2396 id_us_min(&la->ipo->id);
2397 la->ipo = nullptr;
2398 }
2399 }
2400
2401 /* curves */
2402 for (id = static_cast<ID *>(bmain->curves.first); id; id = static_cast<ID *>(id->next)) {
2403 Curve *cu = (Curve *)id;
2404
2405 if (G.debug & G_DEBUG) {
2406 printf("\tconverting curve %s\n", id->name + 2);
2407 }
2408
2409 /* we're only interested in the IPO */
2410 if (cu->ipo) {
2411 /* Add AnimData block */
2413
2414 /* Convert Curve data... */
2415 ipo_to_animdata(bmain, id, cu->ipo, nullptr, nullptr, nullptr);
2416
2417 if (adt->action) {
2418 adt->action->idroot = cu->ipo->blocktype;
2419 }
2420
2421 id_us_min(&cu->ipo->id);
2422 cu->ipo = nullptr;
2423 }
2424 }
2425
2426 /* --------- Unconverted Animation Data ------------------ */
2427 /* For Animation data which may not be directly connected (i.e. not linked) to any other
2428 * data, we need to perform a separate pass to make sure that they are converted to standalone
2429 * Actions which may then be able to be reused. This does mean that we will be going over data
2430 * that's already been converted, but there are no problems with that.
2431 *
2432 * The most common case for this will be Action Constraints, or IPO's with Fake-Users.
2433 * We collect all drivers that were found into a temporary collection, and free them in one go,
2434 * as they're impossible to resolve.
2435 */
2436
2437 /* actions */
2438 for (id = static_cast<ID *>(bmain->actions.first); id; id = static_cast<ID *>(id->next)) {
2439 bAction *act = (bAction *)id;
2440
2441 if (G.debug & G_DEBUG) {
2442 printf("\tconverting action %s\n", id->name + 2);
2443 }
2444
2445 /* if old action, it will be object-only... */
2446 if (act->chanbase.first) {
2447 act->idroot = ID_OB;
2448 }
2449
2450 /* be careful! some of the actions we encounter will be converted ones... */
2451 action_to_animato(nullptr, act, &act->groups, &act->curves, &drivers);
2452 }
2453
2454 /* ipo's */
2455 for (id = static_cast<ID *>(bmain->ipo.first); id; id = static_cast<ID *>(id->next)) {
2456 Ipo *ipo = (Ipo *)id;
2457
2458 if (G.debug & G_DEBUG) {
2459 printf("\tconverting ipo %s\n", id->name + 2);
2460 }
2461
2462 /* most likely this IPO has already been processed, so check if any curves left to convert */
2463 if (ipo->curve.first) {
2464 bAction *new_act;
2465
2466 /* add a new action for this, and convert all data into that action */
2467 new_act = BKE_action_add(bmain, id->name + 2);
2468 ipo_to_animato(nullptr, ipo, nullptr, nullptr, nullptr, nullptr, &new_act->curves, &drivers);
2469 new_act->idroot = ipo->blocktype;
2470 }
2471
2472 /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */
2473 ipo->id.us = 0;
2474 ipo->id.flag &= ~ID_FLAG_FAKEUSER;
2475 }
2476
2477 /* free unused drivers from actions + ipos */
2478 BKE_fcurves_free(&drivers);
2479
2480 if (G.debug & G_DEBUG) {
2481 printf("INFO: Animato convert done\n");
2482 }
2483}
Functions and classes to work with Actions.
Blender kernel action and pose functionality.
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
bAction * BKE_action_add(Main *bmain, const char name[])
bActionGroup * BKE_action_group_find_name(bAction *act, const char name[])
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:103
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:89
FCurve * BKE_fcurve_copy(const FCurve *fcu)
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
FCurve * BKE_fcurve_create(void)
void BKE_fcurves_free(ListBase *list)
struct DriverVar * driver_add_new_variable(struct ChannelDriver *driver)
void driver_change_variable_type(struct DriverVar *dvar, int type)
@ G_DEBUG
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition BKE_idtype.hh:41
@ IDTYPE_FLAGS_NO_COPY
Definition BKE_idtype.hh:30
@ IDTYPE_FLAGS_NO_LIBLINKING
Definition BKE_idtype.hh:32
KeyBlock * BKE_keyblock_find_by_index(Key *key, int index)
Definition key.cc:1923
void id_us_min(ID *id)
Definition lib_id.cc:359
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
@ IDWALK_CB_NOP
int BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
Definition lib_query.cc:120
@ IDWALK_DO_DEPRECATED_POINTERS
bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip, bool is_liboverride)
void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt)
NlaTrack * BKE_nlatrack_new_tail(ListBase *nla_tracks, const bool is_liboverride)
void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition BLI_dynstr.c:149
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_dynstr.c:37
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
Definition BLI_dynstr.c:174
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition BLI_dynstr.c:62
BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_NONNULL(1)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:269
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
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define M_PI
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.c:40
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t 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
unsigned int uint
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define STREQ(a, b)
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
Definition readfile.cc:4903
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define DATA_(msgid)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:182
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:181
#define MAX_ID_NAME
Definition DNA_ID.h:377
@ INDEX_ID_IP
Definition DNA_ID.h:1251
#define ID_REAL_USERS(id)
Definition DNA_ID.h:637
#define FILTER_ID_IP
Definition DNA_ID.h:1204
@ ID_CA
@ ID_AR
@ ID_TE
@ ID_LA
@ ID_KE
@ ID_SO
@ ID_SCE
@ ID_WO
@ ID_MA
@ ID_CU_LEGACY
@ ID_IP
@ ID_OB
@ ID_PA
#define ID_CO
#define ID_SEQ
#define ID_PO
@ AGRP_SELECTED
@ AGRP_MUTED
@ NLASTRIP_FLAG_ACTIVE
@ NLASTRIP_FLAG_AUTO_BLENDS
@ NLASTRIP_FLAG_REVERSE
@ NLASTRIP_FLAG_MUTED
@ NLASTRIP_FLAG_SELECT
@ NLASTRIP_FLAG_SYNC_LENGTH
@ DTAR_TRANSCHAN_ROTZ
@ DTAR_TRANSCHAN_SCALEX
@ DTAR_TRANSCHAN_LOCX
@ DTAR_TRANSCHAN_LOCY
@ DTAR_TRANSCHAN_ROTX
@ DTAR_TRANSCHAN_LOCZ
@ DTAR_TRANSCHAN_ROTY
@ FCM_EXTRAPOLATE_CYCLIC
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
@ DRIVER_TYPE_AVERAGE
@ DRIVER_TYPE_PYTHON
@ DVAR_TYPE_TRANSFORM_CHAN
@ DVAR_TYPE_ROT_DIFF
@ FMODIFIER_TYPE_CYCLES
@ NLASTRIP_EXTEND_NOTHING
@ DTAR_FLAG_LOCALSPACE
@ NLASTRIP_MODE_REPLACE
@ NLASTRIP_MODE_ADD
@ FCURVE_DISABLED
@ FCURVE_MUTED
@ FCURVE_INT_VALUES
@ FCURVE_ACTIVE
@ FCURVE_SELECTED
@ FCURVE_DISCRETE_VALUES
@ FCURVE_PROTECTED
@ FCURVE_VISIBLE
@ CAM_ORTHO
@ HD_AUTO_ANIM
@ HD_AUTO
@ BEZT_IPO_CONST
@ BEZT_KEYTYPE_KEYFRAME
#define TE_MG_GAIN
#define MAP_SIZE_Z
#define SEQ_FAC_SPEED
#define CAM_SHIFT_X
#define MAP_OFS_Y
#define SND_ATTEN
#define AC_EUL_Z
#define WO_ZEN_G
#define MAP_SIZE_X
#define TE_NTYPE
#define PART_DAMP
#define OB_COL_R
#define TE_VNW2
#define IPO_MIXED
#define MA_HASIZE
#define MA_MAP17
#define OB_DROT_Z
#define AC_QUAT_Z
#define OB_COL_A
#define OB_DSIZE_Z
#define MA_COL_G
#define MA_SPEC
#define PART_PD_FSTR
#define TE_VN_COLT
#define OB_LOC_X
#define TE_NSIZE
#define TE_DISTA
#define AC_LOC_Z
#define TE_VNW1
#define OB_ROT_Y
#define OB_LAY
#define CO_HEADTAIL
#define MA_IOR
#define MA_FRESTRA
#define WO_MISTHI
#define MA_MAP10
#define TE_VN_DISTM
#define OB_PD_FSTR
#define MAP_OFS_Z
#define OB_SIZE_Z
#define MA_MAP2
#define PART_AVE
#define WO_MISTDI
#define PART_PD_FMAXD
#define SEQ_FAC_OPACITY
#define MA_MAP15
#define MAP_NORF
#define MAP_R
#define MA_MAP11
#define AC_QUAT_W
#define PART_PD_FFALL
#define OB_DSIZE_Y
#define PART_CLUMP
#define MA_MIR_G
#define MA_ADD
#define OB_LOC_Y
#define MAP_COLF
#define OB_PD_PERM
#define MA_SPEC_B
#define LA_ENERGY
#define AC_SIZE_Y
#define SND_PITCH
#define TE_N_BAS1
#define MAP_SIZE_Y
#define MA_MAP7
#define MA_HARD
#define IPO_DIR
#define WO_ZEN_R
#define WO_EXPOS
#define LA_QUAD2
#define PART_PD2_FFALL
#define CAM_SHIFT_Y
#define OB_ROT_Z
#define OB_DLOC_Y
#define AC_QUAT_Y
#define LA_COL_B
#define AC_SIZE_Z
#define OB_DSIZE_X
#define LA_HALOINT
#define MA_MAP4
#define IPO_MUTE
#define TE_VNMEXP
#define MA_AMB
#define LA_SPOTSI
#define OB_PD_FMAXD
#define LA_COL_G
#define PART_KINK_FREQ
#define PART_PD2_FMAXD
#define WO_HOR_G
#define TE_VNW3
#define AC_LOC_Y
#define MA_MAP5
#define IPO_VISIBLE
#define PART_KINK_SHAPE
#define AC_LOC_X
#define OB_ROT_DIFF
#define IPO_DRIVER_TYPE_PYTHON
#define CAM_LENS
#define CAM_STA
#define MAP_OFS_X
#define PART_LENGTH
#define LA_DIST
#define AC_QUAT_X
#define SND_VOLUME
#define MA_SPTR
#define MA_MAP13
#define TE_NDEPTH
#define OB_LOC_Z
#define MA_MAP1
#define PART_SIZE
#define MAP_DISP
#define MAP_DVAR
#define CAM_END
#define IPO_AUTO_HORIZ
#define TE_MG_OFF
#define AC_EUL_Y
#define DRIVER_NAME_OFFS
#define OB_COL_B
#define AC_EUL_X
#define MAP_B
#define IPO_CYCL
#define MA_MAP16
#define WO_MISI
#define MA_MAP9
#define OB_SIZE_X
#define SND_PANNING
#define OB_COL_G
#define TE_BRIGHT
#define MA_SPEC_R
#define MA_FRESTRAI
#define MA_TRANSLU
#define WO_ZEN_B
#define MA_MAP3
#define MA_MAP18
#define MA_FRESMIRI
#define IPO_PROTECT
#define MA_RAYM
#define LA_QUAD1
#define TE_N_BAS2
#define MA_ALPHA
#define TE_MG_TYP
#define TE_VNW4
#define OB_ROT_X
#define IPO_SELECT
#define TE_COL_G
#define MA_MAP6
#define TE_COL_R
#define OB_PD_FFALL
#define PART_GRAV_X
#define PART_KINK_AMP
#define TE_ISCA
#define SEQ_FAC1
#define LA_SPOTBL
#define PART_BROWN
#define MA_COL_B
#define AC_SIZE_X
#define MAP_VARF
#define WO_HOR_B
#define MA_COL_R
#define MA_MAP12
#define IPO_HORIZ
#define TE_TURB
#define PART_BB_TILT
#define MAP_G
#define PART_GRAV_Y
#define WO_MISTSTA
#define OB_DLOC_Z
#define OB_DROT_Y
#define MA_FRESMIR
#define OB_SIZE_Y
#define TE_MGH
#define PART_PD2_FSTR
#define CAM_YF_FDIST
#define OB_PD_SDAMP
#define TE_MG_LAC
#define MA_MIR_R
#define MA_MAP8
#define MA_MIR_B
#define IPO_ACTIVE
struct Ipo Ipo
#define PART_GRAV_Z
#define LA_COL_R
#define CO_ENFORCE
#define TE_CONTRA
#define MA_EMIT
#define OB_PD_RDAMP
#define MA_MAP14
#define TE_COL_B
#define TE_MG_OCT
#define IPO_CYCLX
#define MA_SPEC_G
#define CAM_YF_APERT
#define PART_DRAG
#define MA_REF
#define WO_HOR_R
#define OB_DROT_X
#define OB_DLOC_X
@ ACTSTRIPMODE_ADD
@ ACTSTRIP_ACTIVE
@ ACTSTRIP_MUTE
@ ACTSTRIP_SELECT
@ ACTSTRIP_REVERSE
@ ACTSTRIP_LOCK_ACTION
@ ACTSTRIP_HOLDLASTFRAME
@ ACTSTRIP_AUTO_BLENDS
Object is a sort of wrapper for general info.
@ SEQ_TYPE_META
@ SEQ_TYPE_SCENE
@ SEQ_TYPE_IMAGE
@ SEQ_TYPE_SPEED
@ SEQ_TYPE_COLOR
@ SEQ_TYPE_MOVIE
@ SEQ_IPO_FRAME_LOCKED
@ SEQ_USE_EFFECT_DEFAULT_FADE
Read Guarded memory(de)allocation.
static void mul(btAlignedObjectArray< T > &items, const Q &value)
local_group_size(16, 16) .push_constant(Type b
#define printf
#define offsetof(t, d)
draw_view in_light_buf[] float
static const char * texture_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:589
static char * shapekey_adrcodes_to_paths(ID *id, int adrcode, int *)
Definition ipo.cc:439
static const char * material_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:676
static AdrBit2Path ob_layer_bits[]
Definition ipo.cc:208
static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
Definition ipo.cc:120
static bool seq_convert_callback(Sequence *seq, void *userdata)
Definition ipo.cc:2045
static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
Definition ipo.cc:1779
static void ipo_foreach_id(ID *id, LibraryForeachIDData *data)
Definition ipo.cc:106
static void nlastrips_to_animdata(ID *id, ListBase *strips)
Definition ipo.cc:1944
static const char * world_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:885
static const char * camera_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:769
static void action_to_animdata(ID *id, bAction *act)
Definition ipo.cc:1913
IDTypeInfo IDType_ID_IP
Definition ipo.cc:161
static const char * ob_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:246
static const char * pchan_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:361
static void ipo_to_animato(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers)
Definition ipo.cc:1691
void do_versions_ipos_to_animato(Main *bmain)
Definition ipo.cc:2091
static const char * sound_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:859
static void ipo_to_animdata(Main *bmain, ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq)
Definition ipo.cc:1842
static const char * light_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:814
static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence *seq, int muteipo)
Definition ipo.cc:1402
static AdrBit2Path * adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *tot)
Definition ipo.cc:229
static const char * constraint_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:418
#define RET_ABP(items)
Definition ipo.cc:221
static CLG_LogRef LOG
Definition ipo.cc:73
static short adrcode_to_dtar_transchan(short adrcode)
Definition ipo.cc:1218
static char * get_rna_access(ID *id, int blocktype, int adrcode, const char actname[], const char constname[], Sequence *seq, int *r_array_index)
Definition ipo.cc:1026
static const char * particle_adrcodes_to_paths(int adrcode, int *r_array_index)
Definition ipo.cc:931
static void fcurve_add_to_list(ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo)
Definition ipo.cc:1330
static const char * mtex_adrcodes_to_paths(int adrcode, int *)
Definition ipo.cc:469
static void ipo_free_data(ID *id)
Definition ipo.cc:77
static ChannelDriver * idriver_to_cdriver(IpoDriver *idriver)
Definition ipo.cc:1248
#define GS(x)
Definition iris.cc:202
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data)
Definition iterator.cc:43
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
#define G(x, y, z)
bool assign_action(bAction *action, ID &animated_id)
int array_index
Definition ipo.cc:201
int bit
Definition ipo.cc:199
const char * path
Definition ipo.cc:200
bAction * action
ListBase drivers
ListBase nla_tracks
float vec[3][3]
char expression[256]
char pchan_name[64]
DriverTarget targets[8]
ListBase seqbase
ListBase * seqbasep
char * rna_path
ChannelDriver * driver
BezTriple * bezt
short extend
int array_index
unsigned int totvert
ListBase modifiers
Definition DNA_ID.h:413
int us
Definition DNA_ID.h:435
short flag
Definition DNA_ID.h:430
char name[66]
Definition DNA_ID.h:425
struct BezTriple * bezt
IpoDriver * driver
short totvert
short blocktype
struct BPoint * bp
short extrap
short adrcode
struct IpoCurve * next
char name[128]
short blocktype
struct Object * ob
short adrcode
short muteipo
ListBase curve
short blocktype
char name[64]
void * last
void * first
ListBase scenes
Definition BKE_main.hh:210
ListBase textures
Definition BKE_main.hh:217
ListBase actions
Definition BKE_main.hh:233
ListBase ipo
Definition BKE_main.hh:222
ListBase lights
Definition BKE_main.hh:220
ListBase materials
Definition BKE_main.hh:216
ListBase shapekeys
Definition BKE_main.hh:223
ListBase cameras
Definition BKE_main.hh:221
ListBase curves
Definition BKE_main.hh:214
ListBase worlds
Definition BKE_main.hh:224
short versionfile
Definition BKE_main.hh:137
ListBase objects
Definition BKE_main.hh:212
short blendmode
short extendmode
bAction * act
ListBase constraints
struct bPose * pose
Scene * scene
Definition ipo.cc:2041
AnimData * adt
Definition ipo.cc:2042
struct bActionChannel * next
ListBase constraintChannels
struct bActionStrip * next
ListBase curves
ListBase groups
struct bConstraintChannel * next
ListBase chanbase
#define N_(msgid)
uint8_t flag
Definition wm_window.cc:138