~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/ipo.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
/* NOTE:
34
34
 *
35
 
 * This file is no longer used to provide tools for the depreceated IPO system. Instead, it
 
35
 * This file is no longer used to provide tools for the deprecated IPO system. Instead, it
36
36
 * is only used to house the conversion code to the new system.
37
37
 *
38
38
 * -- Joshua Leung, Jan 2009
46
46
/* since we have versioning code here */
47
47
#define DNA_DEPRECATED_ALLOW
48
48
 
 
49
#include "DNA_actuator_types.h"
49
50
#include "DNA_anim_types.h"
50
51
#include "DNA_constraint_types.h"
51
52
#include "DNA_camera_types.h"
81
82
 
82
83
/* Free data from old IPO-Blocks (those which haven't been converted), but not IPO block itself */
83
84
// XXX this shouldn't be necessary anymore, but may occur while not all data is converted yet
84
 
void free_ipo (Ipo *ipo)
 
85
void BKE_ipo_free(Ipo *ipo)
85
86
{
86
87
        IpoCurve *icu, *icn;
87
 
        int n= 0;
 
88
        int n = 0;
88
89
        
89
 
        for (icu= ipo->curve.first; icu; icu= icn) {
90
 
                icn= icu->next;
 
90
        for (icu = ipo->curve.first; icu; icu = icn) {
 
91
                icn = icu->next;
91
92
                n++;
92
93
                
93
94
                if (icu->bezt) MEM_freeN(icu->bezt);
98
99
        }
99
100
        
100
101
        if (G.debug & G_DEBUG)
101
 
                printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name+2);
 
102
                printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name + 2);
102
103
}
103
104
 
104
105
/* *************************************************** */
115
116
/* Mapping Tables to use bits <-> RNA paths */
116
117
 
117
118
/* Object layers */
118
 
static AdrBit2Path ob_layer_bits[]= {
119
 
        {(1<<0), "layers", 0},
120
 
        {(1<<1), "layers", 1},
121
 
        {(1<<2), "layers", 2},
122
 
        {(1<<3), "layers", 3},
123
 
        {(1<<4), "layers", 4},
124
 
        {(1<<5), "layers", 5},
125
 
        {(1<<6), "layers", 6},
126
 
        {(1<<7), "layers", 7},
127
 
        {(1<<8), "layers", 8},
128
 
        {(1<<9), "layers", 9},
129
 
        {(1<<10), "layers", 10},
130
 
        {(1<<11), "layers", 11},
131
 
        {(1<<12), "layers", 12},
132
 
        {(1<<13), "layers", 13},
133
 
        {(1<<14), "layers", 14},
134
 
        {(1<<15), "layers", 15},
135
 
        {(1<<16), "layers", 16},
136
 
        {(1<<17), "layers", 17},
137
 
        {(1<<18), "layers", 18},
138
 
        {(1<<19), "layers", 19}
 
119
static AdrBit2Path ob_layer_bits[] = {
 
120
        {(1 << 0), "layers", 0},
 
121
        {(1 << 1), "layers", 1},
 
122
        {(1 << 2), "layers", 2},
 
123
        {(1 << 3), "layers", 3},
 
124
        {(1 << 4), "layers", 4},
 
125
        {(1 << 5), "layers", 5},
 
126
        {(1 << 6), "layers", 6},
 
127
        {(1 << 7), "layers", 7},
 
128
        {(1 << 8), "layers", 8},
 
129
        {(1 << 9), "layers", 9},
 
130
        {(1 << 10), "layers", 10},
 
131
        {(1 << 11), "layers", 11},
 
132
        {(1 << 12), "layers", 12},
 
133
        {(1 << 13), "layers", 13},
 
134
        {(1 << 14), "layers", 14},
 
135
        {(1 << 15), "layers", 15},
 
136
        {(1 << 16), "layers", 16},
 
137
        {(1 << 17), "layers", 17},
 
138
        {(1 << 18), "layers", 18},
 
139
        {(1 << 19), "layers", 19}
139
140
};
140
141
 
141
142
/* Material mode */
142
 
static AdrBit2Path ma_mode_bits[]= {
 
143
static AdrBit2Path ma_mode_bits[] = {
143
144
//      {MA_TRACEBLE, "traceable", 0},
144
 
//      {MA_SHADOW, "shadow", 0},
 
145
//  {MA_SHADOW, "shadow", 0},
145
146
//      {MA_SHLESS, "shadeless", 0},
146
 
//      ...
 
147
//  ...
147
148
        {MA_RAYTRANSP, "transparency", 0},
148
149
        {MA_RAYMIRROR, "raytrace_mirror.enabled", 0},
149
150
//      {MA_HALO, "type", MA_TYPE_HALO}
154
155
/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
155
156
#define RET_ABP(items) \
156
157
        { \
157
 
                *tot= sizeof(items)/sizeof(AdrBit2Path); \
 
158
                *tot = sizeof(items) / sizeof(AdrBit2Path); \
158
159
                return items; \
159
160
        }
160
161
 
161
162
/* This function checks if a Blocktype+Adrcode combo, returning a mapping table */
162
 
static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot)
 
163
static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *tot)
163
164
{
164
165
        /* Object layers */
165
 
        if ((blocktype == ID_OB) && (adrcode == OB_LAY)) 
 
166
        if ((blocktype == ID_OB) && (adrcode == OB_LAY))
166
167
                RET_ABP(ob_layer_bits)
167
168
        else if ((blocktype == ID_MA) && (adrcode == MA_MODE))
168
169
                RET_ABP(ma_mode_bits)
176
177
/* ADRCODE to RNA-Path Conversion Code  - Standard */
177
178
 
178
179
/* Object types */
179
 
static const char *ob_adrcodes_to_paths (int adrcode, int *array_index)
 
180
static const char *ob_adrcodes_to_paths(int adrcode, int *array_index)
180
181
{
181
182
        /* set array index like this in-case nothing sets it correctly  */
182
 
        *array_index= 0;
 
183
        *array_index = 0;
183
184
        
184
185
        /* result depends on adrcode */
185
186
        switch (adrcode) {
186
187
                case OB_LOC_X:
187
 
                        *array_index= 0; return "location";
 
188
                        *array_index = 0; return "location";
188
189
                case OB_LOC_Y:
189
 
                        *array_index= 1; return "location";
 
190
                        *array_index = 1; return "location";
190
191
                case OB_LOC_Z:
191
 
                        *array_index= 2; return "location";
 
192
                        *array_index = 2; return "location";
192
193
                case OB_DLOC_X:
193
 
                        *array_index= 0; return "delta_location";
 
194
                        *array_index = 0; return "delta_location";
194
195
                case OB_DLOC_Y:
195
 
                        *array_index= 1; return "delta_location";
 
196
                        *array_index = 1; return "delta_location";
196
197
                case OB_DLOC_Z:
197
 
                        *array_index= 2; return "delta_location";
 
198
                        *array_index = 2; return "delta_location";
198
199
                
199
200
                case OB_ROT_X:
200
 
                        *array_index= 0; return "rotation_euler";
 
201
                        *array_index = 0; return "rotation_euler";
201
202
                case OB_ROT_Y:
202
 
                        *array_index= 1; return "rotation_euler";
 
203
                        *array_index = 1; return "rotation_euler";
203
204
                case OB_ROT_Z:
204
 
                        *array_index= 2; return "rotation_euler";
 
205
                        *array_index = 2; return "rotation_euler";
205
206
                case OB_DROT_X:
206
 
                        *array_index= 0; return "delta_rotation_euler";
 
207
                        *array_index = 0; return "delta_rotation_euler";
207
208
                case OB_DROT_Y:
208
 
                        *array_index= 1; return "delta_rotation_euler";
 
209
                        *array_index = 1; return "delta_rotation_euler";
209
210
                case OB_DROT_Z:
210
 
                        *array_index= 2; return "delta_rotation_euler";
 
211
                        *array_index = 2; return "delta_rotation_euler";
211
212
                        
212
213
                case OB_SIZE_X:
213
 
                        *array_index= 0; return "scale";
 
214
                        *array_index = 0; return "scale";
214
215
                case OB_SIZE_Y:
215
 
                        *array_index= 1; return "scale";
 
216
                        *array_index = 1; return "scale";
216
217
                case OB_SIZE_Z:
217
 
                        *array_index= 2; return "scale";
 
218
                        *array_index = 2; return "scale";
218
219
                case OB_DSIZE_X:
219
 
                        *array_index= 0; return "delta_scale";
 
220
                        *array_index = 0; return "delta_scale";
220
221
                case OB_DSIZE_Y:
221
 
                        *array_index= 1; return "delta_scale";
 
222
                        *array_index = 1; return "delta_scale";
222
223
                case OB_DSIZE_Z:
223
 
                        *array_index= 2; return "delta_scale";
 
224
                        *array_index = 2; return "delta_scale";
224
225
                case OB_COL_R:
225
 
                        *array_index= 0; return "color";
 
226
                        *array_index = 0; return "color";
226
227
                case OB_COL_G:
227
 
                        *array_index= 1; return "color";
 
228
                        *array_index = 1; return "color";
228
229
                case OB_COL_B:
229
 
                        *array_index= 2; return "color";
 
230
                        *array_index = 2; return "color";
230
231
                case OB_COL_A:
231
 
                        *array_index= 3; return "color";
 
232
                        *array_index = 3; return "color";
232
233
#if 0
233
234
                case OB_PD_FSTR:
234
 
                        if (ob->pd) poin= &(ob->pd->f_strength);
 
235
                        if (ob->pd) poin = &(ob->pd->f_strength);
235
236
                        break;
236
237
                case OB_PD_FFALL:
237
 
                        if (ob->pd) poin= &(ob->pd->f_power);
 
238
                        if (ob->pd) poin = &(ob->pd->f_power);
238
239
                        break;
239
240
                case OB_PD_SDAMP:
240
 
                        if (ob->pd) poin= &(ob->pd->pdef_damp);
 
241
                        if (ob->pd) poin = &(ob->pd->pdef_damp);
241
242
                        break;
242
243
                case OB_PD_RDAMP:
243
 
                        if (ob->pd) poin= &(ob->pd->pdef_rdamp);
 
244
                        if (ob->pd) poin = &(ob->pd->pdef_rdamp);
244
245
                        break;
245
246
                case OB_PD_PERM:
246
 
                        if (ob->pd) poin= &(ob->pd->pdef_perm);
 
247
                        if (ob->pd) poin = &(ob->pd->pdef_perm);
247
248
                        break;
248
249
                case OB_PD_FMAXD:
249
 
                        if (ob->pd) poin= &(ob->pd->maxdist);
 
250
                        if (ob->pd) poin = &(ob->pd->maxdist);
250
251
                        break;
251
252
#endif
252
253
        }
257
258
/* PoseChannel types 
258
259
 * NOTE: pchan name comes from 'actname' added earlier... 
259
260
 */
260
 
static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index)
 
261
static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index)
261
262
{
262
263
        /* set array index like this in-case nothing sets it correctly  */
263
 
        *array_index= 0;
 
264
        *array_index = 0;
264
265
        
265
266
        /* result depends on adrcode */
266
267
        switch (adrcode) {
267
268
                case AC_QUAT_W:
268
 
                        *array_index= 0; return "rotation_quaternion";
 
269
                        *array_index = 0; return "rotation_quaternion";
269
270
                case AC_QUAT_X:
270
 
                        *array_index= 1; return "rotation_quaternion";
 
271
                        *array_index = 1; return "rotation_quaternion";
271
272
                case AC_QUAT_Y:
272
 
                        *array_index= 2; return "rotation_quaternion";
 
273
                        *array_index = 2; return "rotation_quaternion";
273
274
                case AC_QUAT_Z:
274
 
                        *array_index= 3; return "rotation_quaternion";
 
275
                        *array_index = 3; return "rotation_quaternion";
275
276
                        
276
277
                case AC_EUL_X:
277
 
                        *array_index= 0; return "rotation_euler";
 
278
                        *array_index = 0; return "rotation_euler";
278
279
                case AC_EUL_Y:
279
 
                        *array_index= 1; return "rotation_euler";
 
280
                        *array_index = 1; return "rotation_euler";
280
281
                case AC_EUL_Z:
281
 
                        *array_index= 2; return "rotation_euler";
 
282
                        *array_index = 2; return "rotation_euler";
282
283
                
283
284
                case AC_LOC_X:
284
 
                        *array_index= 0; return "location";
 
285
                        *array_index = 0; return "location";
285
286
                case AC_LOC_Y:
286
 
                        *array_index= 1; return "location";
 
287
                        *array_index = 1; return "location";
287
288
                case AC_LOC_Z:
288
 
                        *array_index= 2; return "location";
 
289
                        *array_index = 2; return "location";
289
290
                
290
291
                case AC_SIZE_X:
291
 
                        *array_index= 0; return "scale";
 
292
                        *array_index = 0; return "scale";
292
293
                case AC_SIZE_Y:
293
 
                        *array_index= 1; return "scale";
 
294
                        *array_index = 1; return "scale";
294
295
                case AC_SIZE_Z:
295
 
                        *array_index= 2; return "scale";
 
296
                        *array_index = 2; return "scale";
296
297
        }
297
298
        
298
299
        /* for debugging only */
301
302
}
302
303
 
303
304
/* Constraint types */
304
 
static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index)
 
305
static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index)
305
306
{
306
307
        /* set array index like this in-case nothing sets it correctly  */
307
 
        *array_index= 0;
 
308
        *array_index = 0;
308
309
        
309
310
        /* result depends on adrcode */
310
311
        switch (adrcode) {
311
312
                case CO_ENFORCE:
312
313
                        return "influence";
313
 
                case CO_HEADTAIL:       // XXX this needs to be wrapped in RNA.. probably then this path will be invalid
 
314
                case CO_HEADTAIL:   // XXX this needs to be wrapped in RNA.. probably then this path will be invalid
314
315
                        return "data.head_tail";
315
316
        }
316
317
        
321
322
 * NOTE: as we don't have access to the keyblock where the data comes from (for now), 
322
323
 *       we'll just use numerical indices for now...
323
324
 */
324
 
static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index))
 
325
static char *shapekey_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
325
326
{
326
327
        static char buf[128];
327
328
        
338
339
}
339
340
 
340
341
/* MTex (Texture Slot) types */
341
 
static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index))
 
342
static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
342
343
{
343
 
        const char *base=NULL, *prop=NULL;
 
344
        const char *base = NULL, *prop = NULL;
344
345
        static char buf[128];
345
346
        
346
347
        /* base part of path */
347
 
        if (adrcode & MA_MAP1) base= "textures[0]";
348
 
        else if (adrcode & MA_MAP2) base= "textures[1]";
349
 
        else if (adrcode & MA_MAP3) base= "textures[2]";
350
 
        else if (adrcode & MA_MAP4) base= "textures[3]";
351
 
        else if (adrcode & MA_MAP5) base= "textures[4]";
352
 
        else if (adrcode & MA_MAP6) base= "textures[5]";
353
 
        else if (adrcode & MA_MAP7) base= "textures[6]";
354
 
        else if (adrcode & MA_MAP8) base= "textures[7]";
355
 
        else if (adrcode & MA_MAP9) base= "textures[8]";
356
 
        else if (adrcode & MA_MAP10) base= "textures[9]";
357
 
        else if (adrcode & MA_MAP11) base= "textures[10]";
358
 
        else if (adrcode & MA_MAP12) base= "textures[11]";
359
 
        else if (adrcode & MA_MAP13) base= "textures[12]";
360
 
        else if (adrcode & MA_MAP14) base= "textures[13]";
361
 
        else if (adrcode & MA_MAP15) base= "textures[14]";
362
 
        else if (adrcode & MA_MAP16) base= "textures[15]";
363
 
        else if (adrcode & MA_MAP17) base= "textures[16]";
364
 
        else if (adrcode & MA_MAP18) base= "textures[17]";
 
348
        if (adrcode & MA_MAP1) base = "textures[0]";
 
349
        else if (adrcode & MA_MAP2) base = "textures[1]";
 
350
        else if (adrcode & MA_MAP3) base = "textures[2]";
 
351
        else if (adrcode & MA_MAP4) base = "textures[3]";
 
352
        else if (adrcode & MA_MAP5) base = "textures[4]";
 
353
        else if (adrcode & MA_MAP6) base = "textures[5]";
 
354
        else if (adrcode & MA_MAP7) base = "textures[6]";
 
355
        else if (adrcode & MA_MAP8) base = "textures[7]";
 
356
        else if (adrcode & MA_MAP9) base = "textures[8]";
 
357
        else if (adrcode & MA_MAP10) base = "textures[9]";
 
358
        else if (adrcode & MA_MAP11) base = "textures[10]";
 
359
        else if (adrcode & MA_MAP12) base = "textures[11]";
 
360
        else if (adrcode & MA_MAP13) base = "textures[12]";
 
361
        else if (adrcode & MA_MAP14) base = "textures[13]";
 
362
        else if (adrcode & MA_MAP15) base = "textures[14]";
 
363
        else if (adrcode & MA_MAP16) base = "textures[15]";
 
364
        else if (adrcode & MA_MAP17) base = "textures[16]";
 
365
        else if (adrcode & MA_MAP18) base = "textures[17]";
365
366
                
366
367
        /* property identifier for path */
367
 
        adrcode= (adrcode & (MA_MAP1-1));
 
368
        adrcode = (adrcode & (MA_MAP1 - 1));
368
369
        switch (adrcode) {
369
370
#if 0 // XXX these are not wrapped in RNA yet!
370
371
                case MAP_OFS_X:
371
 
                        poin= &(mtex->ofs[0]); break;
 
372
                        poin = &(mtex->ofs[0]); break;
372
373
                case MAP_OFS_Y:
373
 
                        poin= &(mtex->ofs[1]); break;
 
374
                        poin = &(mtex->ofs[1]); break;
374
375
                case MAP_OFS_Z:
375
 
                        poin= &(mtex->ofs[2]); break;
 
376
                        poin = &(mtex->ofs[2]); break;
376
377
                case MAP_SIZE_X:
377
 
                        poin= &(mtex->size[0]); break;
 
378
                        poin = &(mtex->size[0]); break;
378
379
                case MAP_SIZE_Y:
379
 
                        poin= &(mtex->size[1]); break;
 
380
                        poin = &(mtex->size[1]); break;
380
381
                case MAP_SIZE_Z:
381
 
                        poin= &(mtex->size[2]); break;
 
382
                        poin = &(mtex->size[2]); break;
382
383
                case MAP_R:
383
 
                        poin= &(mtex->r); break;
 
384
                        poin = &(mtex->r); break;
384
385
                case MAP_G:
385
 
                        poin= &(mtex->g); break;
 
386
                        poin = &(mtex->g); break;
386
387
                case MAP_B:
387
 
                        poin= &(mtex->b); break;
 
388
                        poin = &(mtex->b); break;
388
389
                case MAP_DVAR:
389
 
                        poin= &(mtex->def_var); break;
 
390
                        poin = &(mtex->def_var); break;
390
391
                case MAP_COLF:
391
 
                        poin= &(mtex->colfac); break;
 
392
                        poin = &(mtex->colfac); break;
392
393
                case MAP_NORF:
393
 
                        poin= &(mtex->norfac); break;
 
394
                        poin = &(mtex->norfac); break;
394
395
                case MAP_VARF:
395
 
                        poin= &(mtex->varfac); break;
 
396
                        poin = &(mtex->varfac); break;
396
397
#endif
397
398
                case MAP_DISP:
398
 
                        prop= "warp_factor"; break;
 
399
                        prop = "warp_factor"; break;
399
400
        }
400
401
        
401
402
        /* only build and return path if there's a property */
408
409
}
409
410
 
410
411
/* Texture types */
411
 
static const char *texture_adrcodes_to_paths (int adrcode, int *array_index)
 
412
static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
412
413
{
413
414
        /* set array index like this in-case nothing sets it correctly  */
414
 
        *array_index= 0;
 
415
        *array_index = 0;
415
416
        
416
417
        /* result depends on adrcode */
417
418
        switch (adrcode) {
420
421
                case TE_TURB:
421
422
                        return "turbulence";
422
423
                        
423
 
                case TE_NDEPTH: // XXX texture RNA undefined
 
424
                case TE_NDEPTH: // XXX texture RNA undefined
424
425
                        //poin= &(tex->noisedepth); *type= IPO_SHORT; break;
425
426
                        break;
426
427
                case TE_NTYPE: // XXX texture RNA undefined
432
433
                case TE_N_BAS2:
433
434
                        return "noise_basis"; // XXX this is not yet defined in RNA...
434
435
                
435
 
                        /* voronoi */
 
436
                /* voronoi */
436
437
                case TE_VNW1:
437
 
                        *array_index= 0; return "feature_weights";
 
438
                        *array_index = 0; return "feature_weights";
438
439
                case TE_VNW2:
439
 
                        *array_index= 1; return "feature_weights";
 
440
                        *array_index = 1; return "feature_weights";
440
441
                case TE_VNW3:
441
 
                        *array_index= 2; return "feature_weights";
 
442
                        *array_index = 2; return "feature_weights";
442
443
                case TE_VNW4:
443
 
                        *array_index= 3; return "feature_weights";
 
444
                        *array_index = 3; return "feature_weights";
444
445
                case TE_VNMEXP:
445
446
                        return "minkovsky_exponent";
446
447
                case TE_VN_DISTM:
448
449
                case TE_VN_COLT:
449
450
                        return "color_type";
450
451
                
451
 
                        /* distorted noise / voronoi */
 
452
                /* distorted noise / voronoi */
452
453
                case TE_ISCA:
453
454
                        return "noise_intensity";
454
455
                        
455
 
                        /* distorted noise */
 
456
                /* distorted noise */
456
457
                case TE_DISTA:
457
458
                        return "distortion_amount";
458
459
                
459
 
                        /* musgrave */
 
460
                /* musgrave */
460
461
                case TE_MG_TYP: // XXX texture RNA undefined
461
 
                //      poin= &(tex->stype); *type= IPO_SHORT; break;
 
462
                        //      poin= &(tex->stype); *type= IPO_SHORT; break;
462
463
                        break;
463
464
                case TE_MGH:
464
465
                        return "highest_dimension";
472
473
                        return "gain";
473
474
                        
474
475
                case TE_COL_R:
475
 
                        *array_index= 0; return "rgb_factor";
 
476
                        *array_index = 0; return "rgb_factor";
476
477
                case TE_COL_G:
477
 
                        *array_index= 1; return "rgb_factor";
 
478
                        *array_index = 1; return "rgb_factor";
478
479
                case TE_COL_B:
479
 
                        *array_index= 2; return "rgb_factor";
 
480
                        *array_index = 2; return "rgb_factor";
480
481
                        
481
482
                case TE_BRIGHT:
482
483
                        return "brightness";
488
489
}
489
490
 
490
491
/* Material Types */
491
 
static const char *material_adrcodes_to_paths (int adrcode, int *array_index)
 
492
static const char *material_adrcodes_to_paths(int adrcode, int *array_index)
492
493
{
493
494
        /* set array index like this in-case nothing sets it correctly  */
494
 
        *array_index= 0;
 
495
        *array_index = 0;
495
496
        
496
497
        /* result depends on adrcode */
497
498
        switch (adrcode) {
498
499
                case MA_COL_R:
499
 
                        *array_index= 0; return "diffuse_color";
 
500
                        *array_index = 0; return "diffuse_color";
500
501
                case MA_COL_G:
501
 
                        *array_index= 1; return "diffuse_color";
 
502
                        *array_index = 1; return "diffuse_color";
502
503
                case MA_COL_B:
503
 
                        *array_index= 2; return "diffuse_color";
 
504
                        *array_index = 2; return "diffuse_color";
504
505
                        
505
506
                case MA_SPEC_R:
506
 
                        *array_index= 0; return "specular_color";
 
507
                        *array_index = 0; return "specular_color";
507
508
                case MA_SPEC_G:
508
 
                        *array_index= 1; return "specular_color";
 
509
                        *array_index = 1; return "specular_color";
509
510
                case MA_SPEC_B:
510
 
                        *array_index= 2; return "specular_color";
 
511
                        *array_index = 2; return "specular_color";
511
512
                        
512
513
                case MA_MIR_R:
513
 
                        *array_index= 0; return "mirror_color";
 
514
                        *array_index = 0; return "mirror_color";
514
515
                case MA_MIR_G:
515
 
                        *array_index= 1; return "mirror_color";
 
516
                        *array_index = 1; return "mirror_color";
516
517
                case MA_MIR_B:
517
 
                        *array_index= 2; return "mirror_color";
 
518
                        *array_index = 2; return "mirror_color";
518
519
                        
519
520
                case MA_ALPHA:
520
521
                        return "alpha";
568
569
                        return mtex_adrcodes_to_paths(adrcode, array_index);
569
570
        }
570
571
        
571
 
        return NULL;    
 
572
        return NULL;
572
573
}
573
574
 
574
575
/* Camera Types */
575
 
static const char *camera_adrcodes_to_paths (int adrcode, int *array_index)
 
576
static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
576
577
{
577
578
        /* set array index like this in-case nothing sets it correctly  */
578
 
        *array_index= 0;
 
579
        *array_index = 0;
579
580
        
580
581
        /* result depends on adrcode */
581
582
        switch (adrcode) {
596
597
                        
597
598
#if 0 // XXX these are not defined in RNA
598
599
                case CAM_YF_APERT:
599
 
                        poin= &(ca->YF_aperture); break;
 
600
                        poin = &(ca->YF_aperture); break;
600
601
                case CAM_YF_FDIST:
601
 
                        poin= &(ca->YF_dofdist); break;
 
602
                        poin = &(ca->YF_dofdist); break;
602
603
#endif // XXX these are not defined in RNA
603
604
                        
604
605
                case CAM_SHIFT_X:
612
613
}
613
614
 
614
615
/* Lamp Types */
615
 
static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index)
 
616
static const char *lamp_adrcodes_to_paths(int adrcode, int *array_index)
616
617
{
617
618
        /* set array index like this in-case nothing sets it correctly  */
618
 
        *array_index= 0;
 
619
        *array_index = 0;
619
620
        
620
621
        /* result depends on adrcode */
621
622
        switch (adrcode) {
623
624
                        return "energy";
624
625
                        
625
626
                case LA_COL_R:
626
 
                        *array_index= 0;  return "color";
 
627
                        *array_index = 0;  return "color";
627
628
                case LA_COL_G:
628
 
                        *array_index= 1;  return "color";
 
629
                        *array_index = 1;  return "color";
629
630
                case LA_COL_B:
630
 
                        *array_index= 2;  return "color";
 
631
                        *array_index = 2;  return "color";
631
632
                        
632
633
                case LA_DIST:
633
634
                        return "distance";
654
655
}
655
656
 
656
657
/* Sound Types */
657
 
static const char *sound_adrcodes_to_paths (int adrcode, int *array_index)
 
658
static const char *sound_adrcodes_to_paths(int adrcode, int *array_index)
658
659
{
659
660
        /* set array index like this in-case nothing sets it correctly  */
660
 
        *array_index= 0;
 
661
        *array_index = 0;
661
662
        
662
663
        /* result depends on adrcode */
663
664
        switch (adrcode) {
665
666
                        return "volume";
666
667
                case SND_PITCH:
667
668
                        return "pitch";
668
 
        /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */
 
669
                        /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */
669
670
#if 0
670
671
                case SND_PANNING:
671
672
                        return "panning";
679
680
}
680
681
 
681
682
/* World Types */
682
 
static const char *world_adrcodes_to_paths (int adrcode, int *array_index)
 
683
static const char *world_adrcodes_to_paths(int adrcode, int *array_index)
683
684
{
684
685
        /* set array index like this in-case nothing sets it correctly  */
685
 
        *array_index= 0;
 
686
        *array_index = 0;
686
687
        
687
688
        /* result depends on adrcode */
688
689
        switch (adrcode) {
689
690
                case WO_HOR_R:
690
 
                        *array_index= 0; return "horizon_color";
 
691
                        *array_index = 0; return "horizon_color";
691
692
                case WO_HOR_G:
692
 
                        *array_index= 1; return "horizon_color";
 
693
                        *array_index = 1; return "horizon_color";
693
694
                case WO_HOR_B:
694
 
                        *array_index= 2; return "horizon_color";
 
695
                        *array_index = 2; return "horizon_color";
695
696
                case WO_ZEN_R:
696
 
                        *array_index= 0; return "zenith_color";
 
697
                        *array_index = 0; return "zenith_color";
697
698
                case WO_ZEN_G:
698
 
                        *array_index= 1; return "zenith_color";
 
699
                        *array_index = 1; return "zenith_color";
699
700
                case WO_ZEN_B:
700
 
                        *array_index= 2; return "zenith_color";
 
701
                        *array_index = 2; return "zenith_color";
701
702
                
702
703
                case WO_EXPOS:
703
704
                        return "exposure";
724
725
                
725
726
                default: /* for now, we assume that the others were MTex channels */
726
727
                        return mtex_adrcodes_to_paths(adrcode, array_index);
727
 
                }
 
728
        }
728
729
                
729
 
        return NULL;    
 
730
        return NULL;
730
731
}
731
732
 
732
733
/* Particle Types */
733
 
static const char *particle_adrcodes_to_paths (int adrcode, int *array_index)
 
734
static const char *particle_adrcodes_to_paths(int adrcode, int *array_index)
734
735
{
735
736
        /* set array index like this in-case nothing sets it correctly  */
736
 
        *array_index= 0;
 
737
        *array_index = 0;
737
738
        
738
739
        /* result depends on adrcode */
739
740
        switch (adrcode) {
752
753
                case PART_LENGTH:
753
754
                        return "settings.length";
754
755
                case PART_GRAV_X:
755
 
                        *array_index= 0; return "settings.acceleration";
 
756
                        *array_index = 0; return "settings.acceleration";
756
757
                case PART_GRAV_Y:
757
 
                        *array_index= 1; return "settings.acceleration";
 
758
                        *array_index = 1; return "settings.acceleration";
758
759
                case PART_GRAV_Z:
759
 
                        *array_index= 2; return "settings.acceleration";
 
760
                        *array_index = 2; return "settings.acceleration";
760
761
                case PART_KINK_AMP:
761
762
                        return "settings.kink_amplitude";
762
763
                case PART_KINK_FREQ:
773
774
                 * as the similar object forces */
774
775
#if 0
775
776
                case PART_PD_FSTR:
776
 
                        if (part->pd) poin= &(part->pd->f_strength);
 
777
                        if (part->pd) poin = &(part->pd->f_strength);
777
778
                        break;
778
779
                case PART_PD_FFALL:
779
 
                        if (part->pd) poin= &(part->pd->f_power);
 
780
                        if (part->pd) poin = &(part->pd->f_power);
780
781
                        break;
781
782
                case PART_PD_FMAXD:
782
 
                        if (part->pd) poin= &(part->pd->maxdist);
 
783
                        if (part->pd) poin = &(part->pd->maxdist);
783
784
                        break;
784
785
                case PART_PD2_FSTR:
785
 
                        if (part->pd2) poin= &(part->pd2->f_strength);
 
786
                        if (part->pd2) poin = &(part->pd2->f_strength);
786
787
                        break;
787
788
                case PART_PD2_FFALL:
788
 
                        if (part->pd2) poin= &(part->pd2->f_power);
 
789
                        if (part->pd2) poin = &(part->pd2->f_power);
789
790
                        break;
790
791
                case PART_PD2_FMAXD:
791
 
                        if (part->pd2) poin= &(part->pd2->maxdist);
 
792
                        if (part->pd2) poin = &(part->pd2->maxdist);
792
793
                        break;
793
794
#endif
794
795
 
807
808
 *              - array_index                   - index in property's array (if applicable) to use
808
809
 *              - return                                - the allocated path...
809
810
 */
810
 
static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index)
 
811
static char *get_rna_access(int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index)
811
812
{
812
 
        DynStr *path= BLI_dynstr_new();
813
 
        const char *propname=NULL;
814
 
        char *rpath=NULL;
 
813
        DynStr *path = BLI_dynstr_new();
 
814
        const char *propname = NULL;
 
815
        char *rpath = NULL;
815
816
        char buf[512];
816
 
        int dummy_index= 0;
 
817
        int dummy_index = 0;
817
818
        
818
819
        /* hack: if constname is set, we can only be dealing with an Constraint curve */
819
820
        if (constname)
820
 
                blocktype= ID_CO;
 
821
                blocktype = ID_CO;
821
822
        
822
823
        /* get property name based on blocktype */
823
824
        switch (blocktype) {
824
825
                case ID_OB: /* object */
825
 
                        propname= ob_adrcodes_to_paths(adrcode, &dummy_index);
 
826
                        propname = ob_adrcodes_to_paths(adrcode, &dummy_index);
826
827
                        break;
827
828
                
828
829
                case ID_PO: /* pose channel */
829
 
                        propname= pchan_adrcodes_to_paths(adrcode, &dummy_index);
 
830
                        propname = pchan_adrcodes_to_paths(adrcode, &dummy_index);
830
831
                        break;
831
832
                        
832
833
                case ID_KE: /* shapekeys */
833
 
                        propname= shapekey_adrcodes_to_paths(adrcode, &dummy_index);
 
834
                        propname = shapekey_adrcodes_to_paths(adrcode, &dummy_index);
834
835
                        break;
835
836
                        
836
837
                case ID_CO: /* constraint */
837
 
                        propname= constraint_adrcodes_to_paths(adrcode, &dummy_index);  
 
838
                        propname = constraint_adrcodes_to_paths(adrcode, &dummy_index);
838
839
                        break;
839
840
                        
840
841
                case ID_TE: /* texture */
841
 
                        propname= texture_adrcodes_to_paths(adrcode, &dummy_index);
 
842
                        propname = texture_adrcodes_to_paths(adrcode, &dummy_index);
842
843
                        break;
843
844
                        
844
845
                case ID_MA: /* material */
845
 
                        propname= material_adrcodes_to_paths(adrcode, &dummy_index);
 
846
                        propname = material_adrcodes_to_paths(adrcode, &dummy_index);
846
847
                        break;
847
848
                        
848
849
                case ID_CA: /* camera */
849
 
                        propname= camera_adrcodes_to_paths(adrcode, &dummy_index);
 
850
                        propname = camera_adrcodes_to_paths(adrcode, &dummy_index);
850
851
                        break;
851
852
                        
852
853
                case ID_LA: /* lamp */
853
 
                        propname= lamp_adrcodes_to_paths(adrcode, &dummy_index);
 
854
                        propname = lamp_adrcodes_to_paths(adrcode, &dummy_index);
854
855
                        break;
855
856
                
856
857
                case ID_SO: /* sound */
857
 
                        propname= sound_adrcodes_to_paths(adrcode, &dummy_index);
 
858
                        propname = sound_adrcodes_to_paths(adrcode, &dummy_index);
858
859
                        break;
859
860
                
860
861
                case ID_WO: /* world */
861
 
                        propname= world_adrcodes_to_paths(adrcode, &dummy_index);
 
862
                        propname = world_adrcodes_to_paths(adrcode, &dummy_index);
862
863
                        break;
863
864
                
864
865
                case ID_PA: /* particle */
865
 
                        propname= particle_adrcodes_to_paths(adrcode, &dummy_index);
 
866
                        propname = particle_adrcodes_to_paths(adrcode, &dummy_index);
866
867
                        break;
867
868
                        
868
869
                case ID_CU: /* curve */
869
870
                        /* this used to be a 'dummy' curve which got evaluated on the fly... 
870
871
                         * now we've got real var for this!
871
872
                         */
872
 
                        propname= "eval_time";
 
873
                        propname = "eval_time";
873
874
                        break;
874
875
                
875
 
                /* XXX problematic blocktypes */                
 
876
                /* XXX problematic blocktypes */
876
877
                case ID_SEQ: /* sequencer strip */
877
878
                        //SEQ_FAC1:
878
879
                        switch (adrcode) {
879
 
                        case SEQ_FAC1:
880
 
                                propname= "effect_fader";
881
 
                                break;
882
 
                        case SEQ_FAC_SPEED:
883
 
                                propname= "speed_fader";
884
 
                                break;
885
 
                        case SEQ_FAC_OPACITY:
886
 
                                propname= "blend_opacity";
887
 
                                break;
 
880
                                case SEQ_FAC1:
 
881
                                        propname = "effect_fader";
 
882
                                        break;
 
883
                                case SEQ_FAC_SPEED:
 
884
                                        propname = "speed_fader";
 
885
                                        break;
 
886
                                case SEQ_FAC_OPACITY:
 
887
                                        propname = "blend_opacity";
 
888
                                        break;
888
889
                        }
889
890
                        //      poin= &(seq->facf0); // XXX this doesn't seem to be included anywhere in sequencer RNA...
890
891
                        break;
894
895
                        /* special case for rotdiff drivers... we don't need a property for this... */
895
896
                        break;
896
897
                        
897
 
                // TODO... add other blocktypes...
 
898
                /* TODO... add other blocktypes... */
898
899
                default:
899
900
                        printf("IPO2ANIMATO WARNING: No path for blocktype %d, adrcode %d yet\n", blocktype, adrcode);
900
901
                        break;
906
907
        if ((propname == NULL) && (blocktype > 0)) {
907
908
                /* nothing was found, so exit */
908
909
                if (array_index) 
909
 
                        *array_index= 0;
 
910
                        *array_index = 0;
910
911
                        
911
912
                BLI_dynstr_free(path);
912
913
                
914
915
        }
915
916
        else {
916
917
                if (array_index)
917
 
                        *array_index= dummy_index;
 
918
                        *array_index = dummy_index;
918
919
        }
919
920
 
920
921
        /* 'buf' _must_ be initialized in this block */
925
926
                BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
926
927
        }
927
928
        else if (actname && actname[0]) {
928
 
                if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) {
 
929
                if ((blocktype == ID_OB) && strcmp(actname, "Object") == 0) {
929
930
                        /* Actionified "Object" IPO's... no extra path stuff needed */
930
 
                        buf[0]= '\0'; /* empty string */
 
931
                        buf[0] = '\0'; /* empty string */
931
932
                }
932
 
                else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) {
 
933
                else if ((blocktype == ID_KE) && strcmp(actname, "Shape") == 0) {
933
934
                        /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */
934
935
                        strcpy(buf, "data.shape_keys");
935
936
                }
944
945
        }
945
946
        else if (seq) {
946
947
                /* Sequence names in Scene */
947
 
                BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name+2);
 
948
                BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name + 2);
948
949
        }
949
950
        else {
950
 
                buf[0]= '\0'; /* empty string */
 
951
                buf[0] = '\0'; /* empty string */
951
952
        }
952
953
 
953
954
        BLI_dynstr_append(path, buf);
966
967
        }
967
968
        
968
969
        /* convert to normal MEM_malloc'd string */
969
 
        rpath= BLI_dynstr_get_cstring(path);
 
970
        rpath = BLI_dynstr_get_cstring(path);
970
971
        BLI_dynstr_free(path);
971
972
        
972
973
        /* return path... */
977
978
/* Conversion Utilities */
978
979
 
979
980
/* Convert adrcodes to driver target transform channel types */
980
 
static short adrcode_to_dtar_transchan (short adrcode)
 
981
static short adrcode_to_dtar_transchan(short adrcode)
981
982
{
982
983
        switch (adrcode) {
983
 
                case OB_LOC_X:  
 
984
                case OB_LOC_X:
984
985
                        return DTAR_TRANSCHAN_LOCX;
985
986
                case OB_LOC_Y:
986
987
                        return DTAR_TRANSCHAN_LOCY;
987
988
                case OB_LOC_Z:
988
989
                        return DTAR_TRANSCHAN_LOCZ;
989
990
                
990
 
                case OB_ROT_X:  
 
991
                case OB_ROT_X:
991
992
                        return DTAR_TRANSCHAN_ROTX;
992
993
                case OB_ROT_Y:
993
994
                        return DTAR_TRANSCHAN_ROTY;
994
995
                case OB_ROT_Z:
995
996
                        return DTAR_TRANSCHAN_ROTZ;
996
997
                
997
 
                case OB_SIZE_X: 
 
998
                case OB_SIZE_X:
998
999
                        return DTAR_TRANSCHAN_SCALEX;
999
1000
                case OB_SIZE_Y:
1000
1001
                        return DTAR_TRANSCHAN_SCALEX;
1007
1008
}
1008
1009
 
1009
1010
/* Convert IpoDriver to ChannelDriver - will free the old data (i.e. the old driver) */
1010
 
static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
 
1011
static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
1011
1012
{
1012
1013
        ChannelDriver *cdriver;
1013
1014
        
1014
1015
        /* allocate memory for new driver */
1015
 
        cdriver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
 
1016
        cdriver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
1016
1017
        
1017
1018
        /* if 'pydriver', just copy data across */
1018
1019
        if (idriver->type == IPO_DRIVER_TYPE_PYTHON) {
1027
1028
                DriverTarget *dtar = NULL;
1028
1029
                
1029
1030
                /* this should be ok for all types here... */
1030
 
                cdriver->type= DRIVER_TYPE_AVERAGE;
 
1031
                cdriver->type = DRIVER_TYPE_AVERAGE;
1031
1032
                
1032
1033
                /* what to store depends on the 'blocktype' - object or posechannel */
1033
1034
                if (idriver->blocktype == ID_AR) { /* PoseChannel */
1034
1035
                        if (idriver->adrcode == OB_ROT_DIFF) {
1035
1036
                                /* Rotational Difference requires a special type of variable */
1036
 
                                dvar= driver_add_new_variable(cdriver);
 
1037
                                dvar = driver_add_new_variable(cdriver);
1037
1038
                                driver_change_variable_type(dvar, DVAR_TYPE_ROT_DIFF);
1038
1039
                                
1039
 
                                        /* first bone target */
1040
 
                                dtar= &dvar->targets[0];
1041
 
                                dtar->id= (ID *)idriver->ob;
1042
 
                                dtar->idtype= ID_OB;
 
1040
                                /* first bone target */
 
1041
                                dtar = &dvar->targets[0];
 
1042
                                dtar->id = (ID *)idriver->ob;
 
1043
                                dtar->idtype = ID_OB;
1043
1044
                                if (idriver->name[0])
1044
1045
                                        BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
1045
1046
                                
1046
 
                                        /* second bone target (name was stored in same var as the first one) */
1047
 
                                dtar= &dvar->targets[1];
1048
 
                                dtar->id= (ID *)idriver->ob;
1049
 
                                dtar->idtype= ID_OB;
 
1047
                                /* second bone target (name was stored in same var as the first one) */
 
1048
                                dtar = &dvar->targets[1];
 
1049
                                dtar->id = (ID *)idriver->ob;
 
1050
                                dtar->idtype = ID_OB;
1050
1051
                                if (idriver->name[0]) // xxx... for safety
1051
 
                                        BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
 
1052
                                        BLI_strncpy(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
1052
1053
                        }
1053
1054
                        else {
1054
1055
                                /* only a single variable, of type 'transform channel' */
1055
 
                                dvar= driver_add_new_variable(cdriver);
 
1056
                                dvar = driver_add_new_variable(cdriver);
1056
1057
                                driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN);
1057
1058
                                
1058
1059
                                /* only requires a single target */
1059
 
                                dtar= &dvar->targets[0];
1060
 
                                dtar->id= (ID *)idriver->ob;
1061
 
                                dtar->idtype= ID_OB;
 
1060
                                dtar = &dvar->targets[0];
 
1061
                                dtar->id = (ID *)idriver->ob;
 
1062
                                dtar->idtype = ID_OB;
1062
1063
                                if (idriver->name[0])
1063
1064
                                        BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
1064
 
                                dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode);
 
1065
                                dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
1065
1066
                                dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
1066
1067
                        }
1067
1068
                }
1068
1069
                else { /* Object */
1069
 
                        /* only a single variable, of type 'transform channel' */
1070
 
                        dvar= driver_add_new_variable(cdriver);
 
1070
                           /* only a single variable, of type 'transform channel' */
 
1071
                        dvar = driver_add_new_variable(cdriver);
1071
1072
                        driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN);
1072
1073
                        
1073
 
                                /* only requires single target */
1074
 
                        dtar= &dvar->targets[0];
1075
 
                        dtar->id= (ID *)idriver->ob;
1076
 
                        dtar->idtype= ID_OB;
1077
 
                        dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode);
 
1074
                        /* only requires single target */
 
1075
                        dtar = &dvar->targets[0];
 
1076
                        dtar->id = (ID *)idriver->ob;
 
1077
                        dtar->idtype = ID_OB;
 
1078
                        dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
1078
1079
                }
1079
1080
        }
1080
1081
        
1085
1086
/* Add F-Curve to the correct list 
1086
1087
 *      - grpname is needed to be used as group name where relevant, and is usually derived from actname
1087
1088
 */
1088
 
static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo)
 
1089
static void fcurve_add_to_list(ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo)
1089
1090
{
1090
1091
        /* If we're adding to an action, we will have groups to write to... */
1091
1092
        if (groups && grpname) {
1093
1094
                 * and extract the resultant lists...
1094
1095
                 */
1095
1096
                bAction tmp_act;
1096
 
                bActionGroup *agrp= NULL;
 
1097
                bActionGroup *agrp = NULL;
1097
1098
                
1098
1099
                /* init the temp action */
1099
1100
                memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors
1100
 
                tmp_act.groups.first= groups->first;
1101
 
                tmp_act.groups.last= groups->last;
1102
 
                tmp_act.curves.first= list->first;
1103
 
                tmp_act.curves.last= list->last;
 
1101
                tmp_act.groups.first = groups->first;
 
1102
                tmp_act.groups.last = groups->last;
 
1103
                tmp_act.curves.first = list->first;
 
1104
                tmp_act.curves.last = list->last;
1104
1105
                /* ... xxx, the other vars don't need to be filled in */
1105
1106
                
1106
1107
                /* get the group to use */
1107
 
                agrp= action_groups_find_named(&tmp_act, grpname);
 
1108
                agrp = BKE_action_group_find_name(&tmp_act, grpname);
1108
1109
                /* no matching group, so add one */
1109
1110
                if (agrp == NULL) {
1110
1111
                        /* Add a new group, and make it active */
1111
 
                        agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
 
1112
                        agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
1112
1113
 
1113
1114
                        agrp->flag = AGRP_SELECTED;
1114
1115
                        if (muteipo) agrp->flag |= AGRP_MUTED;
1127
1128
                        fcu->flag |= FCURVE_MUTED;
1128
1129
                
1129
1130
                /* set the output lists based on the ones in the temp action */
1130
 
                groups->first= tmp_act.groups.first;
1131
 
                groups->last= tmp_act.groups.last;
1132
 
                list->first= tmp_act.curves.first;
1133
 
                list->last= tmp_act.curves.last;
 
1131
                groups->first = tmp_act.groups.first;
 
1132
                groups->last = tmp_act.groups.last;
 
1133
                list->first = tmp_act.curves.first;
 
1134
                list->last = tmp_act.curves.last;
1134
1135
        }
1135
1136
        else {
1136
1137
                /* simply add the F-Curve to the end of the given list */
1144
1145
 *      constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to
1145
1146
 *      seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to
1146
1147
 */
1147
 
static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence * seq, int muteipo)
 
1148
static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence *seq, int muteipo)
1148
1149
{
1149
1150
        AdrBit2Path *abp;
1150
1151
        FCurve *fcu;
1151
1152
        int totbits;
1152
1153
        
1153
1154
        /* allocate memory for a new F-Curve */
1154
 
        fcu= MEM_callocN(sizeof(FCurve), "FCurve");
 
1155
        fcu = MEM_callocN(sizeof(FCurve), "FCurve");
1155
1156
        
1156
1157
        /* convert driver */
1157
1158
        if (icu->driver)
1158
 
                fcu->driver= idriver_to_cdriver(icu->driver);
 
1159
                fcu->driver = idriver_to_cdriver(icu->driver);
1159
1160
        
1160
1161
        /* copy flags */
1161
1162
        if (icu->flag & IPO_VISIBLE) fcu->flag |= FCURVE_VISIBLE;
1170
1171
                case IPO_DIR: /* linear extrapolation */
1171
1172
                {
1172
1173
                        /* just copy, as the new defines match the old ones... */
1173
 
                        fcu->extend= icu->extrap;
 
1174
                        fcu->extend = icu->extrap;
1174
1175
                }
1175
 
                        break;
 
1176
                break;
1176
1177
                        
1177
1178
                case IPO_CYCL: /* cyclic extrapolation */
1178
1179
                case IPO_CYCLX: /* cyclic extrapolation + offset */
1180
1181
                        /* Add a new FModifier (Cyclic) instead of setting extend value 
1181
1182
                         * as that's the new equivalent of that option.
1182
1183
                         */
1183
 
                        FModifier *fcm= add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
1184
 
                        FMod_Cycles *data= (FMod_Cycles *)fcm->data;
 
1184
                        FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
 
1185
                        FMod_Cycles *data = (FMod_Cycles *)fcm->data;
1185
1186
                        
1186
1187
                        /* if 'offset' one is in use, set appropriate settings */
1187
1188
                        if (icu->extrap == IPO_CYCLX)
1188
 
                                data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC_OFFSET;
 
1189
                                data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET;
1189
1190
                        else
1190
 
                                data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC;
 
1191
                                data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
1191
1192
                }
1192
 
                        break;
 
1193
                break;
1193
1194
        }
1194
1195
        
1195
1196
        /* -------- */
1196
1197
        
1197
1198
        /* get adrcode <-> bitflags mapping to handle nasty bitflag curves? */
1198
 
        abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits);
 
1199
        abp = adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits);
1199
1200
        if (abp && totbits) {
1200
1201
                FCurve *fcurve;
1201
1202
                int b;
1203
1204
                if (G.debug & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits);
1204
1205
                
1205
1206
                /* add the 'only int values' flag */
1206
 
                fcu->flag |= (FCURVE_INT_VALUES|FCURVE_DISCRETE_VALUES);                
 
1207
                fcu->flag |= (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES);
1207
1208
                
1208
1209
                /* for each bit we have to remap + check for:
1209
1210
                 * 1) we need to make copy the existing F-Curve data (fcu -> fcurve),
1210
 
                 *        except for the last one which will use the original 
 
1211
                 *    except for the last one which will use the original
1211
1212
                 * 2) copy the relevant path info across
1212
1213
                 * 3) filter the keyframes for the flag of interest
1213
1214
                 */
1214
 
                for (b=0; b < totbits; b++, abp++) {
1215
 
                        unsigned int i=0;
 
1215
                for (b = 0; b < totbits; b++, abp++) {
 
1216
                        unsigned int i = 0;
1216
1217
                        
1217
1218
                        /* make a copy of existing base-data if not the last curve */
1218
 
                        if (b < (totbits-1))
1219
 
                                fcurve= copy_fcurve(fcu);
 
1219
                        if (b < (totbits - 1))
 
1220
                                fcurve = copy_fcurve(fcu);
1220
1221
                        else
1221
 
                                fcurve= fcu;
 
1222
                                fcurve = fcu;
1222
1223
                                
1223
1224
                        /* set path */
1224
 
                        fcurve->rna_path= BLI_strdup(abp->path);
1225
 
                        fcurve->array_index= abp->array_index;
 
1225
                        fcurve->rna_path = BLI_strdup(abp->path);
 
1226
                        fcurve->array_index = abp->array_index;
1226
1227
                        
1227
1228
                        /* convert keyframes 
1228
1229
                         *      - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
1229
1230
                         *      - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
1230
1231
                         */
1231
 
                        fcurve->totvert= icu->totvert;
 
1232
                        fcurve->totvert = icu->totvert;
1232
1233
                        
1233
1234
                        if (icu->bezt) {
1234
1235
                                BezTriple *dst, *src;
1235
1236
                                
1236
1237
                                /* allocate new array for keyframes/beztriples */
1237
 
                                fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples");
 
1238
                                fcurve->bezt = MEM_callocN(sizeof(BezTriple) * fcurve->totvert, "BezTriples");
1238
1239
                                
1239
1240
                                /* loop through copying all BezTriples individually, as we need to modify a few things */
1240
 
                                for (dst=fcurve->bezt, src=icu->bezt, i=0; i < fcurve->totvert; i++, dst++, src++) {
 
1241
                                for (dst = fcurve->bezt, src = icu->bezt, i = 0; i < fcurve->totvert; i++, dst++, src++) {
1241
1242
                                        /* firstly, copy BezTriple data */
1242
 
                                        *dst= *src;
 
1243
                                        *dst = *src;
1243
1244
                                        
1244
1245
                                        /* interpolation can only be constant... */
1245
 
                                        dst->ipo= BEZT_IPO_CONST;
 
1246
                                        dst->ipo = BEZT_IPO_CONST;
1246
1247
                                        
1247
1248
                                        /* 'hide' flag is now used for keytype - only 'keyframes' existed before */
1248
 
                                        dst->hide= BEZT_KEYTYPE_KEYFRAME;
 
1249
                                        dst->hide = BEZT_KEYTYPE_KEYFRAME;
1249
1250
                                        
1250
1251
                                        /* auto-handles - per curve to per handle */
1251
1252
                                        if (icu->flag & IPO_AUTO_HORIZ) {
1255
1256
                                        
1256
1257
                                        /* correct values, by checking if the flag of interest is set */
1257
1258
                                        if ( ((int)(dst->vec[1][1])) & (abp->bit) )
1258
 
                                                dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f;
 
1259
                                                dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f;
1259
1260
                                        else
1260
 
                                                dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 0.0f;
 
1261
                                                dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 0.0f;
1261
1262
                                }
1262
1263
                        }
1263
1264
                        else if (icu->bp) {
1271
1272
                }
1272
1273
        }
1273
1274
        else {
1274
 
                unsigned int i=0;
 
1275
                unsigned int i = 0;
1275
1276
                
1276
1277
                /* get rna-path
1277
1278
                 *      - we will need to set the 'disabled' flag if no path is able to be made (for now)
1278
1279
                 */
1279
 
                fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index);
 
1280
                fcu->rna_path = get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index);
1280
1281
                if (fcu->rna_path == NULL)
1281
1282
                        fcu->flag |= FCURVE_DISABLED;
1282
1283
                
1284
1285
                 *      - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
1285
1286
                 *      - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
1286
1287
                 */
1287
 
                fcu->totvert= icu->totvert;
 
1288
                fcu->totvert = icu->totvert;
1288
1289
                
1289
1290
                if (icu->bezt) {
1290
1291
                        BezTriple *dst, *src;
1291
1292
                        
1292
1293
                        /* allocate new array for keyframes/beztriples */
1293
 
                        fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples");
 
1294
                        fcu->bezt = MEM_callocN(sizeof(BezTriple) * fcu->totvert, "BezTriples");
1294
1295
                        
1295
1296
                        /* loop through copying all BezTriples individually, as we need to modify a few things */
1296
 
                        for (dst=fcu->bezt, src=icu->bezt, i=0; i < fcu->totvert; i++, dst++, src++) {
 
1297
                        for (dst = fcu->bezt, src = icu->bezt, i = 0; i < fcu->totvert; i++, dst++, src++) {
1297
1298
                                /* firstly, copy BezTriple data */
1298
 
                                *dst= *src;
 
1299
                                *dst = *src;
1299
1300
                                
1300
1301
                                /* now copy interpolation from curve (if not already set) */
1301
1302
                                if (icu->ipo != IPO_MIXED)
1302
 
                                        dst->ipo= icu->ipo;
 
1303
                                        dst->ipo = icu->ipo;
1303
1304
                                        
1304
1305
                                /* 'hide' flag is now used for keytype - only 'keyframes' existed before */
1305
 
                                dst->hide= BEZT_KEYTYPE_KEYFRAME;
 
1306
                                dst->hide = BEZT_KEYTYPE_KEYFRAME;
1306
1307
                                
1307
1308
                                /* auto-handles - per curve to per handle */
1308
1309
                                if (icu->flag & IPO_AUTO_HORIZ) {
1315
1316
                                 *      - we need radians for RNA to do the right thing
1316
1317
                                 */
1317
1318
                                if ( ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
1318
 
                                         ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) )
 
1319
                                     ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) )
1319
1320
                                {
1320
 
                                        const float fac= (float)M_PI / 18.0f; //10.0f * M_PI/180.0f;
 
1321
                                        const float fac = (float)M_PI / 18.0f; //10.0f * M_PI/180.0f;
1321
1322
                                        
1322
1323
                                        dst->vec[0][1] *= fac;
1323
1324
                                        dst->vec[1][1] *= fac;
1329
1330
                                 *      - we now need as 'frames'
1330
1331
                                 */
1331
1332
                                if ( (id) && (icu->blocktype == GS(id->name)) && 
1332
 
                                         (fcu->rna_path && strcmp(fcu->rna_path, "eval_time")==0) )
 
1333
                                     (fcu->rna_path && strcmp(fcu->rna_path, "eval_time") == 0) )
1333
1334
                                {
1334
1335
                                        Curve *cu = (Curve *)id;
1335
1336
                                        
1340
1341
                                
1341
1342
                                /* correct times for rotation drivers 
1342
1343
                                 *      - need to go from degrees to radians...
1343
 
                                 *      - there's only really 1 target to worry about 
 
1344
                                 *  - there's only really 1 target to worry about
1344
1345
                                 *  - were also degrees/10
1345
1346
                                 */
1346
1347
                                if (fcu->driver && fcu->driver->variables.first) {
1347
 
                                        DriverVar *dvar= fcu->driver->variables.first;
1348
 
                                        DriverTarget *dtar= &dvar->targets[0];
 
1348
                                        DriverVar *dvar = fcu->driver->variables.first;
 
1349
                                        DriverTarget *dtar = &dvar->targets[0];
1349
1350
                                        
1350
1351
                                        if (ELEM3(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ)) {
1351
 
                                                const float fac= (float)M_PI / 18.0f;
 
1352
                                                const float fac = (float)M_PI / 18.0f;
1352
1353
                                                
1353
1354
                                                dst->vec[0][0] *= fac;
1354
1355
                                                dst->vec[1][0] *= fac;
1358
1359
                                
1359
1360
                                /* correct values for sequencer curves, that were not locked to frame */
1360
1361
                                if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
1361
 
                                        double mul= (seq->enddisp-seq->startdisp)/100.0f;
1362
 
                                        double offset= seq->startdisp;
 
1362
                                        const float mul = (seq->enddisp - seq->startdisp) / 100.0f;
 
1363
                                        const float offset = seq->startdisp;
1363
1364
                                        
1364
1365
                                        dst->vec[0][0] *= mul;
1365
1366
                                        dst->vec[0][0] += offset;
1389
1390
 * This does not assume that any ID or AnimData uses it, but does assume that
1390
1391
 * it is given two lists, which it will perform driver/animation-data separation.
1391
1392
 */
1392
 
static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers)
 
1393
static void ipo_to_animato(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers)
1393
1394
{
1394
1395
        IpoCurve *icu;
1395
1396
        
1407
1408
         */
1408
1409
        if (actname) {
1409
1410
                if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Object") == 0))
1410
 
                        actname= NULL;
 
1411
                        actname = NULL;
1411
1412
                else if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Shape") == 0))
1412
 
                        actname= NULL;
 
1413
                        actname = NULL;
1413
1414
        }
1414
1415
        
1415
1416
        /* loop over IPO-Curves, freeing as we progress */
1416
 
        for (icu= ipo->curve.first; icu; icu= icu->next) {
 
1417
        for (icu = ipo->curve.first; icu; icu = icu->next) {
1417
1418
                /* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves), 
1418
1419
                 * we figure out the best place to put the channel, then tell the curve-converter to just dump there
1419
1420
                 */
1424
1425
                        }
1425
1426
                        else {
1426
1427
                                MEM_freeN(icu->driver);
1427
 
                                icu->driver= NULL;
 
1428
                                icu->driver = NULL;
1428
1429
                        }
1429
1430
                }
1430
1431
                else
1436
1437
        if (ID_REAL_USERS(ipo) <= 0) {
1437
1438
                IpoCurve *icn;
1438
1439
                
1439
 
                for (icu= ipo->curve.first; icu; icu= icn) {
1440
 
                        icn= icu->next;
 
1440
                for (icu = ipo->curve.first; icu; icu = icn) {
 
1441
                        icn = icu->next;
1441
1442
                        
1442
1443
                        /* free driver */
1443
1444
                        if (icu->driver)
1458
1459
 * to Objects, where ob->ipo and ob->action need to be combined).
1459
1460
 * NOTE: we need to be careful here, as same data-structs are used for new system too!
1460
1461
 */
1461
 
static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
 
1462
static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
1462
1463
{
1463
1464
        bActionChannel *achan, *achann;
1464
1465
        bConstraintChannel *conchan, *conchann;
1473
1474
                BLI_freelistN(&act->groups);
1474
1475
        
1475
1476
        /* loop through Action-Channels, converting data, freeing as we go */
1476
 
        for (achan= act->chanbase.first; achan; achan= achann) {
 
1477
        for (achan = act->chanbase.first; achan; achan = achann) {
1477
1478
                /* get pointer to next Action Channel */
1478
 
                achann= achan->next;
 
1479
                achann = achan->next;
1479
1480
                
1480
1481
                /* convert Action Channel's IPO data */
1481
1482
                if (achan->ipo) {
1482
1483
                        ipo_to_animato(id, achan->ipo, achan->name, NULL, NULL, groups, curves, drivers);
1483
1484
                        achan->ipo->id.us--;
1484
 
                        achan->ipo= NULL;
 
1485
                        achan->ipo = NULL;
1485
1486
                }
1486
1487
                
1487
1488
                /* convert constraint channel IPO-data */
1488
 
                for (conchan= achan->constraintChannels.first; conchan; conchan= conchann) {
 
1489
                for (conchan = achan->constraintChannels.first; conchan; conchan = conchann) {
1489
1490
                        /* get pointer to next Constraint Channel */
1490
 
                        conchann= conchan->next;
 
1491
                        conchann = conchan->next;
1491
1492
                        
1492
1493
                        /* convert Constraint Channel's IPO data */
1493
1494
                        if (conchan->ipo) {
1494
1495
                                ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, NULL, groups, curves, drivers);
1495
1496
                                conchan->ipo->id.us--;
1496
 
                                conchan->ipo= NULL;
 
1497
                                conchan->ipo = NULL;
1497
1498
                        }
1498
1499
                        
1499
1500
                        /* free Constraint Channel */
1512
1513
 * This assumes that AnimData has been added already. Separation of drivers
1513
1514
 * from animation data is accomplished here too...
1514
1515
 */
1515
 
static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq)
 
1516
static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq)
1516
1517
{
1517
 
        AnimData *adt= BKE_animdata_from_id(id);
 
1518
        AnimData *adt = BKE_animdata_from_id(id);
1518
1519
        ListBase anim = {NULL, NULL};
1519
1520
        ListBase drivers = {NULL, NULL};
1520
1521
        
1528
1529
        
1529
1530
        if (G.debug & G_DEBUG) {
1530
1531
                printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s  curves:%d\n",
1531
 
                       id->name+2, ipo->id.name+2, (actname)?actname:"<None>", (constname)?constname:"<None>", (seq)?(seq->name+2):"<None>",
1532
 
                        BLI_countlist(&ipo->curve));
 
1532
                       id->name + 2, ipo->id.name + 2, (actname) ? actname : "<None>", (constname) ? constname : "<None>", (seq) ? (seq->name + 2) : "<None>",
 
1533
                       BLI_countlist(&ipo->curve));
1533
1534
        }
1534
1535
        
1535
1536
        /* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers),
1545
1546
                if (adt->action == NULL) {
1546
1547
                        char nameBuf[MAX_ID_NAME];
1547
1548
                        
1548
 
                        BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2);
 
1549
                        BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
1549
1550
                        
1550
 
                        adt->action= add_empty_action(nameBuf);
 
1551
                        adt->action = add_empty_action(G.main, nameBuf);
1551
1552
                        if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf);
1552
1553
                }
1553
1554
                
1566
1567
/* Convert Action-block to new system
1567
1568
 * NOTE: we need to be careful here, as same data-structs are used for new system too!
1568
1569
 */
1569
 
static void action_to_animdata (ID *id, bAction *act)
 
1570
static void action_to_animdata(ID *id, bAction *act)
1570
1571
{
1571
 
        AnimData *adt= BKE_animdata_from_id(id);
 
1572
        AnimData *adt = BKE_animdata_from_id(id);
1572
1573
        
1573
1574
        /* only continue if there are Action Channels (indicating unconverted data) */
1574
1575
        if (ELEM(NULL, adt, act->chanbase.first))
1578
1579
        if (adt->action == NULL) {
1579
1580
                /* set this Action as AnimData's Action */
1580
1581
                if (G.debug & G_DEBUG) printf("act_to_adt - set adt action to act\n");
1581
 
                adt->action= act;
 
1582
                adt->action = act;
1582
1583
        }
1583
1584
        
1584
1585
        /* convert Action data */
1587
1588
 
1588
1589
/* ------------------------- */
1589
1590
 
1590
 
// TODO:
1591
 
//      - NLA group duplicators info
1592
 
//      - NLA curve/stride modifiers...
 
1591
/* TODO:
 
1592
 * - NLA group duplicators info
 
1593
 * - NLA curve/stride modifiers... */
1593
1594
 
1594
1595
/* Convert NLA-Strip to new system */
1595
 
static void nlastrips_to_animdata (ID *id, ListBase *strips)
 
1596
static void nlastrips_to_animdata(ID *id, ListBase *strips)
1596
1597
{
1597
 
        AnimData *adt= BKE_animdata_from_id(id);
 
1598
        AnimData *adt = BKE_animdata_from_id(id);
1598
1599
        NlaTrack *nlt = NULL;
1599
1600
        NlaStrip *strip;
1600
1601
        bActionStrip *as, *asn;
1601
1602
        
1602
1603
        /* for each one of the original strips, convert to a new strip and free the old... */
1603
 
        for (as= strips->first; as; as= asn) {
1604
 
                asn= as->next;
 
1604
        for (as = strips->first; as; as = asn) {
 
1605
                asn = as->next;
1605
1606
                
1606
1607
                /* this old strip is only worth something if it had an action... */
1607
1608
                if (as->act) {
1614
1615
                                 *      - no need to muck around with the user-counts, since this is just 
1615
1616
                                 *        passing over the ref to the new owner, not creating an additional ref
1616
1617
                                 */
1617
 
                                strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
1618
 
                                strip->act= as->act;
1619
 
                                
1620
 
                                        /* endpoints */
1621
 
                                strip->start= as->start;
1622
 
                                strip->end= as->end;
1623
 
                                strip->actstart= as->actstart;
1624
 
                                strip->actend= as->actend;
1625
 
                                
1626
 
                                        /* action reuse */
1627
 
                                strip->repeat= as->repeat;
1628
 
                                strip->scale= as->scale;
1629
 
                                if (as->flag & ACTSTRIP_LOCK_ACTION)    strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
1630
 
                                
1631
 
                                        /* blending */
1632
 
                                strip->blendin= as->blendin;
1633
 
                                strip->blendout= as->blendout;
1634
 
                                strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE;
1635
 
                                if (as->flag & ACTSTRIP_AUTO_BLENDS)    strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
1636
 
                                        
1637
 
                                        /* assorted setting flags */
1638
 
                                if (as->flag & ACTSTRIP_SELECT)                 strip->flag |= NLASTRIP_FLAG_SELECT;
1639
 
                                if (as->flag & ACTSTRIP_ACTIVE)                 strip->flag |= NLASTRIP_FLAG_ACTIVE;
1640
 
                                
1641
 
                                if (as->flag & ACTSTRIP_MUTE)                   strip->flag |= NLASTRIP_FLAG_MUTED;
1642
 
                                if (as->flag & ACTSTRIP_REVERSE)                strip->flag |= NLASTRIP_FLAG_REVERSE;
1643
 
                                
1644
 
                                        /* by default, we now always extrapolate, while in the past this was optional */
1645
 
                                if ((as->flag & ACTSTRIP_HOLDLASTFRAME)==0) 
1646
 
                                        strip->extendmode= NLASTRIP_EXTEND_NOTHING;
1647
 
                        }       
 
1618
                                strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
 
1619
                                strip->act = as->act;
 
1620
                                
 
1621
                                /* endpoints */
 
1622
                                strip->start = as->start;
 
1623
                                strip->end = as->end;
 
1624
                                strip->actstart = as->actstart;
 
1625
                                strip->actend = as->actend;
 
1626
 
 
1627
                                /* action reuse */
 
1628
                                strip->repeat = as->repeat;
 
1629
                                strip->scale = as->scale;
 
1630
                                if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
 
1631
 
 
1632
                                /* blending */
 
1633
                                strip->blendin = as->blendin;
 
1634
                                strip->blendout = as->blendout;
 
1635
                                strip->blendmode = (as->mode == ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE;
 
1636
                                if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
 
1637
 
 
1638
                                /* assorted setting flags */
 
1639
                                if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT;
 
1640
                                if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE;
 
1641
 
 
1642
                                if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED;
 
1643
                                if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE;
 
1644
 
 
1645
                                /* by default, we now always extrapolate, while in the past this was optional */
 
1646
                                if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0)
 
1647
                                        strip->extendmode = NLASTRIP_EXTEND_NOTHING;
 
1648
                        }
1648
1649
                        
1649
1650
                        /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
1650
1651
                        if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
1651
1652
                                /* trying to add to the current failed (no space), 
1652
1653
                                 * so add a new track to the stack, and add to that...
1653
1654
                                 */
1654
 
                                nlt= add_nlatrack(adt, NULL);
 
1655
                                nlt = add_nlatrack(adt, NULL);
1655
1656
                                BKE_nlatrack_add_strip(nlt, strip);
1656
1657
                        }
1657
1658
                }
1701
1702
        /* ----------- Animation Attached to Data -------------- */
1702
1703
        
1703
1704
        /* objects */
1704
 
        for (id= main->object.first; id; id= id->next) {
1705
 
                Object *ob= (Object *)id;
 
1705
        for (id = main->object.first; id; id = id->next) {
 
1706
                Object *ob = (Object *)id;
1706
1707
                bPoseChannel *pchan;
1707
1708
                bConstraint *con;
1708
1709
                bConstraintChannel *conchan, *conchann;
1709
1710
                
1710
 
                if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name+2);
 
1711
                if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name + 2);
1711
1712
                
1712
1713
                /* check if object has any animation data */
1713
1714
                if (ob->nlastrips.first) {
1719
1720
                                ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
1720
1721
                                
1721
1722
                                ob->ipo->id.us--;
1722
 
                                ob->ipo= NULL;
 
1723
                                ob->ipo = NULL;
1723
1724
                        }
1724
1725
                        
1725
1726
                        /* Action is skipped since it'll be used by some strip in the NLA anyway, 
1727
1728
                         */
1728
1729
                        if (ob->action) {
1729
1730
                                ob->action->id.us--;
1730
 
                                ob->action= NULL;
 
1731
                                ob->action = NULL;
1731
1732
                        }
1732
1733
                        
1733
1734
                        /* finally NLA */
1735
1736
                }
1736
1737
                else if ((ob->ipo) || (ob->action)) {
1737
1738
                        /* Add AnimData block */
1738
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
1739
                        AnimData *adt = BKE_id_add_animdata(id);
1739
1740
                        
1740
1741
                        /* Action first - so that Action name get conserved */
1741
1742
                        if (ob->action) {
1744
1745
                                /* only decrease usercount if this Action isn't now being used by AnimData */
1745
1746
                                if (ob->action != adt->action) {
1746
1747
                                        ob->action->id.us--;
1747
 
                                        ob->action= NULL;
 
1748
                                        ob->action = NULL;
1748
1749
                                }
1749
1750
                        }
1750
1751
                        
1752
1753
                        if (ob->ipo) {
1753
1754
                                ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
1754
1755
                                ob->ipo->id.us--;
1755
 
                                ob->ipo= NULL;
 
1756
                                ob->ipo = NULL;
 
1757
 
 
1758
                                {
 
1759
                                        /* If we have any empty action actuators, assume they were
 
1760
                                         * converted IPO Actuators using the object IPO */
 
1761
                                        bActuator *act;
 
1762
                                        bActionActuator *aa;
 
1763
 
 
1764
                                        for (act = ob->actuators.first; act; act = act->next) {
 
1765
                                                /* Any actuators set to ACT_IPO at this point are actually Action Actuators that
 
1766
                                                 * need this converted IPO to finish converting the actuator. */
 
1767
                                                if (act->type == ACT_IPO) {
 
1768
                                                        aa = (bActionActuator *)act->data;
 
1769
                                                        aa->act = ob->adt->action;
 
1770
                                                        act->type = ACT_ACTION;
 
1771
                                                }
 
1772
                                        }
 
1773
                                }
1756
1774
                        }
1757
1775
                }
1758
1776
                
1761
1779
                        /* Verify if there's AnimData block */
1762
1780
                        BKE_id_add_animdata(id);
1763
1781
                        
1764
 
                        for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
1765
 
                                for (con= pchan->constraints.first; con; con= con->next) {
 
1782
                        for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 
1783
                                for (con = pchan->constraints.first; con; con = con->next) {
1766
1784
                                        /* if constraint has own IPO, convert add these to Object 
1767
1785
                                         * (NOTE: they're most likely to be drivers too) 
1768
1786
                                         */
1772
1790
                                                 */
1773
1791
                                                ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL);
1774
1792
                                                con->ipo->id.us--;
1775
 
                                                con->ipo= NULL;
 
1793
                                                con->ipo = NULL;
1776
1794
                                        }
1777
1795
                                }
1778
1796
                        }
1779
1797
                }
1780
1798
                
1781
1799
                /* check constraints for local IPO's */
1782
 
                for (con= ob->constraints.first; con; con= con->next) {
 
1800
                for (con = ob->constraints.first; con; con = con->next) {
1783
1801
                        /* if constraint has own IPO, convert add these to Object 
1784
1802
                         * (NOTE: they're most likely to be drivers too) 
1785
1803
                         */
1792
1810
                                 */
1793
1811
                                ipo_to_animdata(id, con->ipo, NULL, con->name, NULL);
1794
1812
                                con->ipo->id.us--;
1795
 
                                con->ipo= NULL;
 
1813
                                con->ipo = NULL;
1796
1814
                        }
1797
1815
                         
1798
1816
                        /* check for Action Constraint */
1804
1822
                        /* Verify if there's AnimData block */
1805
1823
                        BKE_id_add_animdata(id);
1806
1824
                        
1807
 
                        for (conchan= ob->constraintChannels.first; conchan; conchan= conchann) {
 
1825
                        for (conchan = ob->constraintChannels.first; conchan; conchan = conchann) {
1808
1826
                                /* get pointer to next Constraint Channel */
1809
 
                                conchann= conchan->next;
 
1827
                                conchann = conchan->next;
1810
1828
                                
1811
1829
                                /* convert Constraint Channel's IPO data */
1812
1830
                                if (conchan->ipo) {
1813
1831
                                        ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL);
1814
1832
                                        conchan->ipo->id.us--;
1815
 
                                        conchan->ipo= NULL;
 
1833
                                        conchan->ipo = NULL;
1816
1834
                                }
1817
1835
                                
1818
1836
                                /* free Constraint Channel */
1822
1840
                
1823
1841
                /* object's action will always be object-rooted */
1824
1842
                {
1825
 
                        AnimData *adt= BKE_animdata_from_id(id);
 
1843
                        AnimData *adt = BKE_animdata_from_id(id);
1826
1844
                        if (adt && adt->action)
1827
1845
                                adt->action->idroot = ID_OB;
1828
1846
                }
1829
1847
        }
1830
1848
        
1831
1849
        /* shapekeys */
1832
 
        for (id= main->key.first; id; id= id->next) {
1833
 
                Key *key= (Key *)id;
 
1850
        for (id = main->key.first; id; id = id->next) {
 
1851
                Key *key = (Key *)id;
1834
1852
                
1835
 
                if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name+2);
 
1853
                if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name + 2);
1836
1854
                
1837
1855
                /* we're only interested in the IPO 
1838
1856
                 * NOTE: for later, it might be good to port these over to Object instead, as many of these
1840
1858
                 */
1841
1859
                if (key->ipo) {
1842
1860
                        /* Add AnimData block */
1843
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
1861
                        AnimData *adt = BKE_id_add_animdata(id);
1844
1862
                        
1845
1863
                        /* Convert Shapekey data... */
1846
1864
                        ipo_to_animdata(id, key->ipo, NULL, NULL, NULL);
1849
1867
                                adt->action->idroot = key->ipo->blocktype;
1850
1868
                        
1851
1869
                        key->ipo->id.us--;
1852
 
                        key->ipo= NULL;
 
1870
                        key->ipo = NULL;
1853
1871
                }
1854
1872
        }
1855
1873
        
1856
1874
        /* materials */
1857
 
        for (id= main->mat.first; id; id= id->next) {
1858
 
                Material *ma= (Material *)id;
 
1875
        for (id = main->mat.first; id; id = id->next) {
 
1876
                Material *ma = (Material *)id;
1859
1877
                
1860
 
                if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name+2);
 
1878
                if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name + 2);
1861
1879
                
1862
1880
                /* we're only interested in the IPO */
1863
1881
                if (ma->ipo) {
1864
1882
                        /* Add AnimData block */
1865
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
1883
                        AnimData *adt = BKE_id_add_animdata(id);
1866
1884
                        
1867
1885
                        /* Convert Material data... */
1868
1886
                        ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL);
1871
1889
                                adt->action->idroot = ma->ipo->blocktype;
1872
1890
                        
1873
1891
                        ma->ipo->id.us--;
1874
 
                        ma->ipo= NULL;
 
1892
                        ma->ipo = NULL;
1875
1893
                }
1876
1894
        }
1877
1895
        
1878
1896
        /* worlds */
1879
 
        for (id= main->world.first; id; id= id->next) {
1880
 
                World *wo= (World *)id;
 
1897
        for (id = main->world.first; id; id = id->next) {
 
1898
                World *wo = (World *)id;
1881
1899
                
1882
 
                if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name+2);
 
1900
                if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name + 2);
1883
1901
                
1884
1902
                /* we're only interested in the IPO */
1885
1903
                if (wo->ipo) {
1886
1904
                        /* Add AnimData block */
1887
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
1905
                        AnimData *adt = BKE_id_add_animdata(id);
1888
1906
                        
1889
1907
                        /* Convert World data... */
1890
1908
                        ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL);
1893
1911
                                adt->action->idroot = wo->ipo->blocktype;
1894
1912
                        
1895
1913
                        wo->ipo->id.us--;
1896
 
                        wo->ipo= NULL;
 
1914
                        wo->ipo = NULL;
1897
1915
                }
1898
1916
        }
1899
1917
        
1900
1918
        /* sequence strips */
1901
 
        for (id= main->scene.first; id; id= id->next) {
 
1919
        for (id = main->scene.first; id; id = id->next) {
1902
1920
                Scene *scene = (Scene *)id;
1903
 
                Editing * ed = scene->ed;
 
1921
                Editing *ed = scene->ed;
1904
1922
                if (ed && ed->seqbasep) {
1905
 
                        Sequence * seq;
1906
 
                        
1907
 
                        AnimData *adt= BKE_id_add_animdata(id);
1908
 
                        
1909
 
                        SEQ_BEGIN(ed, seq) {
 
1923
                        Sequence *seq;
 
1924
                        
 
1925
                        AnimData *adt = BKE_id_add_animdata(id);
 
1926
                        
 
1927
                        SEQ_BEGIN(ed, seq)
 
1928
                        {
1910
1929
                                IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
1911
1930
                                short adrcode = SEQ_FAC1;
1912
1931
                                
1913
1932
                                if (G.debug & G_DEBUG)
1914
 
                                        printf("\tconverting sequence strip %s\n", seq->name+2);
 
1933
                                        printf("\tconverting sequence strip %s\n", seq->name + 2);
1915
1934
                                
1916
1935
                                if (ELEM(NULL, seq->ipo, icu)) {
1917
1936
                                        seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
1923
1942
                                 * (semi-hack (tm) )
1924
1943
                                 */
1925
1944
                                switch (seq->type) {
1926
 
                                        case SEQ_IMAGE:
1927
 
                                        case SEQ_META:
1928
 
                                        case SEQ_SCENE:
1929
 
                                        case SEQ_MOVIE:
1930
 
                                        case SEQ_COLOR:
 
1945
                                        case SEQ_TYPE_IMAGE:
 
1946
                                        case SEQ_TYPE_META:
 
1947
                                        case SEQ_TYPE_SCENE:
 
1948
                                        case SEQ_TYPE_MOVIE:
 
1949
                                        case SEQ_TYPE_COLOR:
1931
1950
                                                adrcode = SEQ_FAC_OPACITY;
1932
1951
                                                break;
1933
 
                                        case SEQ_SPEED:
 
1952
                                        case SEQ_TYPE_SPEED:
1934
1953
                                                adrcode = SEQ_FAC_SPEED;
1935
1954
                                                break;
1936
1955
                                }
1940
1959
                                ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq);
1941
1960
                                
1942
1961
                                if (adt->action)
1943
 
                                        adt->action->idroot = ID_SCE; /* scene-rooted */
 
1962
                                        adt->action->idroot = ID_SCE;  /* scene-rooted */
1944
1963
                                
1945
1964
                                seq->ipo->id.us--;
1946
1965
                                seq->ipo = NULL;
1951
1970
 
1952
1971
 
1953
1972
        /* textures */
1954
 
        for (id= main->tex.first; id; id= id->next) {
1955
 
                Tex *te= (Tex *)id;
 
1973
        for (id = main->tex.first; id; id = id->next) {
 
1974
                Tex *te = (Tex *)id;
1956
1975
                
1957
 
                if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name+2);
 
1976
                if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name + 2);
1958
1977
                
1959
1978
                /* we're only interested in the IPO */
1960
1979
                if (te->ipo) {
1961
1980
                        /* Add AnimData block */
1962
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
1981
                        AnimData *adt = BKE_id_add_animdata(id);
1963
1982
                        
1964
1983
                        /* Convert Texture data... */
1965
1984
                        ipo_to_animdata(id, te->ipo, NULL, NULL, NULL);
1968
1987
                                adt->action->idroot = te->ipo->blocktype;
1969
1988
                        
1970
1989
                        te->ipo->id.us--;
1971
 
                        te->ipo= NULL;
 
1990
                        te->ipo = NULL;
1972
1991
                }
1973
1992
        }
1974
1993
        
1975
1994
        /* cameras */
1976
 
        for (id= main->camera.first; id; id= id->next) {
1977
 
                Camera *ca= (Camera *)id;
 
1995
        for (id = main->camera.first; id; id = id->next) {
 
1996
                Camera *ca = (Camera *)id;
1978
1997
                
1979
 
                if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name+2);
 
1998
                if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name + 2);
1980
1999
                
1981
2000
                /* we're only interested in the IPO */
1982
2001
                if (ca->ipo) {
1983
2002
                        /* Add AnimData block */
1984
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
2003
                        AnimData *adt = BKE_id_add_animdata(id);
1985
2004
                        
1986
2005
                        /* Convert Camera data... */
1987
2006
                        ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL);
1990
2009
                                adt->action->idroot = ca->ipo->blocktype;
1991
2010
                        
1992
2011
                        ca->ipo->id.us--;
1993
 
                        ca->ipo= NULL;
 
2012
                        ca->ipo = NULL;
1994
2013
                }
1995
2014
        }
1996
2015
        
1997
2016
        /* lamps */
1998
 
        for (id= main->lamp.first; id; id= id->next) {
1999
 
                Lamp *la= (Lamp *)id;
 
2017
        for (id = main->lamp.first; id; id = id->next) {
 
2018
                Lamp *la = (Lamp *)id;
2000
2019
                
2001
 
                if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name+2);
 
2020
                if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2);
2002
2021
                
2003
2022
                /* we're only interested in the IPO */
2004
2023
                if (la->ipo) {
2005
2024
                        /* Add AnimData block */
2006
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
2025
                        AnimData *adt = BKE_id_add_animdata(id);
2007
2026
                        
2008
2027
                        /* Convert Lamp data... */
2009
2028
                        ipo_to_animdata(id, la->ipo, NULL, NULL, NULL);
2012
2031
                                adt->action->idroot = la->ipo->blocktype;
2013
2032
                        
2014
2033
                        la->ipo->id.us--;
2015
 
                        la->ipo= NULL;
 
2034
                        la->ipo = NULL;
2016
2035
                }
2017
2036
        }
2018
2037
        
2019
2038
        /* curves */
2020
 
        for (id= main->curve.first; id; id= id->next) {
2021
 
                Curve *cu= (Curve *)id;
 
2039
        for (id = main->curve.first; id; id = id->next) {
 
2040
                Curve *cu = (Curve *)id;
2022
2041
                
2023
 
                if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name+2);
 
2042
                if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name + 2);
2024
2043
                
2025
2044
                /* we're only interested in the IPO */
2026
2045
                if (cu->ipo) {
2027
2046
                        /* Add AnimData block */
2028
 
                        AnimData *adt= BKE_id_add_animdata(id);
 
2047
                        AnimData *adt = BKE_id_add_animdata(id);
2029
2048
                        
2030
2049
                        /* Convert Curve data... */
2031
2050
                        ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL);
2034
2053
                                adt->action->idroot = cu->ipo->blocktype;
2035
2054
                        
2036
2055
                        cu->ipo->id.us--;
2037
 
                        cu->ipo= NULL;
 
2056
                        cu->ipo = NULL;
2038
2057
                }
2039
2058
        }
2040
2059
        
2050
2069
         */
2051
2070
        
2052
2071
        /* actions */
2053
 
        for (id= main->action.first; id; id= id->next) {
2054
 
                bAction *act= (bAction *)id;
 
2072
        for (id = main->action.first; id; id = id->next) {
 
2073
                bAction *act = (bAction *)id;
2055
2074
                
2056
 
                if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name+2);
 
2075
                if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name + 2);
2057
2076
                
2058
2077
                /* if old action, it will be object-only... */
2059
2078
                if (act->chanbase.first)
2064
2083
        }
2065
2084
        
2066
2085
        /* ipo's */
2067
 
        for (id= main->ipo.first; id; id= id->next) {
2068
 
                Ipo *ipo= (Ipo *)id;
 
2086
        for (id = main->ipo.first; id; id = id->next) {
 
2087
                Ipo *ipo = (Ipo *)id;
2069
2088
                
2070
 
                if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name+2);
 
2089
                if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name + 2);
2071
2090
                
2072
2091
                /* most likely this IPO has already been processed, so check if any curves left to convert */
2073
2092
                if (ipo->curve.first) {
2074
2093
                        bAction *new_act;
2075
2094
                        
2076
2095
                        /* add a new action for this, and convert all data into that action */
2077
 
                        new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name...
 
2096
                        new_act = add_empty_action(main, id->name + 2);
2078
2097
                        ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers);
2079
2098
                        new_act->idroot = ipo->blocktype;
2080
2099
                }
2081
2100
                
2082
2101
                /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */
2083
 
                ipo->id.us= 0;
 
2102
                ipo->id.us = 0;
2084
2103
                ipo->id.flag &= ~LIB_FAKEUSER;
2085
2104
        }
2086
2105