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