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