115
116
/* Mapping Tables to use bits <-> RNA paths */
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}
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},
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) \
157
*tot= sizeof(items)/sizeof(AdrBit2Path); \
158
*tot = sizeof(items) / sizeof(AdrBit2Path); \
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)
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 */
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)
181
182
/* set array index like this in-case nothing sets it correctly */
184
185
/* result depends on adrcode */
185
186
switch (adrcode) {
187
*array_index= 0; return "location";
188
*array_index = 0; return "location";
189
*array_index= 1; return "location";
190
*array_index = 1; return "location";
191
*array_index= 2; return "location";
192
*array_index = 2; return "location";
193
*array_index= 0; return "delta_location";
194
*array_index = 0; return "delta_location";
195
*array_index= 1; return "delta_location";
196
*array_index = 1; return "delta_location";
197
*array_index= 2; return "delta_location";
198
*array_index = 2; return "delta_location";
200
*array_index= 0; return "rotation_euler";
201
*array_index = 0; return "rotation_euler";
202
*array_index= 1; return "rotation_euler";
203
*array_index = 1; return "rotation_euler";
204
*array_index= 2; return "rotation_euler";
205
*array_index = 2; return "rotation_euler";
206
*array_index= 0; return "delta_rotation_euler";
207
*array_index = 0; return "delta_rotation_euler";
208
*array_index= 1; return "delta_rotation_euler";
209
*array_index = 1; return "delta_rotation_euler";
210
*array_index= 2; return "delta_rotation_euler";
211
*array_index = 2; return "delta_rotation_euler";
213
*array_index= 0; return "scale";
214
*array_index = 0; return "scale";
215
*array_index= 1; return "scale";
216
*array_index = 1; return "scale";
217
*array_index= 2; return "scale";
218
*array_index = 2; return "scale";
219
*array_index= 0; return "delta_scale";
220
*array_index = 0; return "delta_scale";
221
*array_index= 1; return "delta_scale";
222
*array_index = 1; return "delta_scale";
223
*array_index= 2; return "delta_scale";
224
*array_index = 2; return "delta_scale";
225
*array_index= 0; return "color";
226
*array_index = 0; return "color";
227
*array_index= 1; return "color";
228
*array_index = 1; return "color";
229
*array_index= 2; return "color";
230
*array_index = 2; return "color";
231
*array_index= 3; return "color";
232
*array_index = 3; return "color";
234
if (ob->pd) poin= &(ob->pd->f_strength);
235
if (ob->pd) poin = &(ob->pd->f_strength);
236
237
case OB_PD_FFALL:
237
if (ob->pd) poin= &(ob->pd->f_power);
238
if (ob->pd) poin = &(ob->pd->f_power);
239
240
case OB_PD_SDAMP:
240
if (ob->pd) poin= &(ob->pd->pdef_damp);
241
if (ob->pd) poin = &(ob->pd->pdef_damp);
242
243
case OB_PD_RDAMP:
243
if (ob->pd) poin= &(ob->pd->pdef_rdamp);
244
if (ob->pd) poin = &(ob->pd->pdef_rdamp);
246
if (ob->pd) poin= &(ob->pd->pdef_perm);
247
if (ob->pd) poin = &(ob->pd->pdef_perm);
248
249
case OB_PD_FMAXD:
249
if (ob->pd) poin= &(ob->pd->maxdist);
250
if (ob->pd) poin = &(ob->pd->maxdist);
257
258
/* PoseChannel types
258
259
* NOTE: pchan name comes from 'actname' added earlier...
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)
262
263
/* set array index like this in-case nothing sets it correctly */
265
266
/* result depends on adrcode */
266
267
switch (adrcode) {
268
*array_index= 0; return "rotation_quaternion";
269
*array_index = 0; return "rotation_quaternion";
270
*array_index= 1; return "rotation_quaternion";
271
*array_index = 1; return "rotation_quaternion";
272
*array_index= 2; return "rotation_quaternion";
273
*array_index = 2; return "rotation_quaternion";
274
*array_index= 3; return "rotation_quaternion";
275
*array_index = 3; return "rotation_quaternion";
277
*array_index= 0; return "rotation_euler";
278
*array_index = 0; return "rotation_euler";
279
*array_index= 1; return "rotation_euler";
280
*array_index = 1; return "rotation_euler";
281
*array_index= 2; return "rotation_euler";
282
*array_index = 2; return "rotation_euler";
284
*array_index= 0; return "location";
285
*array_index = 0; return "location";
286
*array_index= 1; return "location";
287
*array_index = 1; return "location";
288
*array_index= 2; return "location";
289
*array_index = 2; return "location";
291
*array_index= 0; return "scale";
292
*array_index = 0; return "scale";
293
*array_index= 1; return "scale";
294
*array_index = 1; return "scale";
295
*array_index= 2; return "scale";
296
*array_index = 2; return "scale";
298
299
/* for debugging only */
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))
343
const char *base=NULL, *prop=NULL;
344
const char *base = NULL, *prop = NULL;
344
345
static char buf[128];
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]";
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!
371
poin= &(mtex->ofs[0]); break;
372
poin = &(mtex->ofs[0]); break;
373
poin= &(mtex->ofs[1]); break;
374
poin = &(mtex->ofs[1]); break;
375
poin= &(mtex->ofs[2]); break;
376
poin = &(mtex->ofs[2]); break;
377
poin= &(mtex->size[0]); break;
378
poin = &(mtex->size[0]); break;
379
poin= &(mtex->size[1]); break;
380
poin = &(mtex->size[1]); break;
381
poin= &(mtex->size[2]); break;
382
poin = &(mtex->size[2]); break;
383
poin= &(mtex->r); break;
384
poin = &(mtex->r); break;
385
poin= &(mtex->g); break;
386
poin = &(mtex->g); break;
387
poin= &(mtex->b); break;
388
poin = &(mtex->b); break;
389
poin= &(mtex->def_var); break;
390
poin = &(mtex->def_var); break;
391
poin= &(mtex->colfac); break;
392
poin = &(mtex->colfac); break;
393
poin= &(mtex->norfac); break;
394
poin = &(mtex->norfac); break;
395
poin= &(mtex->varfac); break;
396
poin = &(mtex->varfac); break;
398
prop= "warp_factor"; break;
399
prop = "warp_factor"; break;
401
402
/* only build and return path if there's a property */
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)
493
494
/* set array index like this in-case nothing sets it correctly */
496
497
/* result depends on adrcode */
497
498
switch (adrcode) {
499
*array_index= 0; return "diffuse_color";
500
*array_index = 0; return "diffuse_color";
501
*array_index= 1; return "diffuse_color";
502
*array_index = 1; return "diffuse_color";
503
*array_index= 2; return "diffuse_color";
504
*array_index = 2; return "diffuse_color";
506
*array_index= 0; return "specular_color";
507
*array_index = 0; return "specular_color";
508
*array_index= 1; return "specular_color";
509
*array_index = 1; return "specular_color";
510
*array_index= 2; return "specular_color";
511
*array_index = 2; return "specular_color";
513
*array_index= 0; return "mirror_color";
514
*array_index = 0; return "mirror_color";
515
*array_index= 1; return "mirror_color";
516
*array_index = 1; return "mirror_color";
517
*array_index= 2; return "mirror_color";
518
*array_index = 2; return "mirror_color";
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)
684
685
/* set array index like this in-case nothing sets it correctly */
687
688
/* result depends on adrcode */
688
689
switch (adrcode) {
690
*array_index= 0; return "horizon_color";
691
*array_index = 0; return "horizon_color";
692
*array_index= 1; return "horizon_color";
693
*array_index = 1; return "horizon_color";
694
*array_index= 2; return "horizon_color";
695
*array_index = 2; return "horizon_color";
696
*array_index= 0; return "zenith_color";
697
*array_index = 0; return "zenith_color";
698
*array_index= 1; return "zenith_color";
699
*array_index = 1; return "zenith_color";
700
*array_index= 2; return "zenith_color";
701
*array_index = 2; return "zenith_color";
703
704
return "exposure";
773
774
* as the similar object forces */
775
776
case PART_PD_FSTR:
776
if (part->pd) poin= &(part->pd->f_strength);
777
if (part->pd) poin = &(part->pd->f_strength);
778
779
case PART_PD_FFALL:
779
if (part->pd) poin= &(part->pd->f_power);
780
if (part->pd) poin = &(part->pd->f_power);
781
782
case PART_PD_FMAXD:
782
if (part->pd) poin= &(part->pd->maxdist);
783
if (part->pd) poin = &(part->pd->maxdist);
784
785
case PART_PD2_FSTR:
785
if (part->pd2) poin= &(part->pd2->f_strength);
786
if (part->pd2) poin = &(part->pd2->f_strength);
787
788
case PART_PD2_FFALL:
788
if (part->pd2) poin= &(part->pd2->f_power);
789
if (part->pd2) poin = &(part->pd2->f_power);
790
791
case PART_PD2_FMAXD:
791
if (part->pd2) poin= &(part->pd2->maxdist);
792
if (part->pd2) poin = &(part->pd2->maxdist);
807
808
* - array_index - index in property's array (if applicable) to use
808
809
* - return - the allocated path...
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)
812
DynStr *path= BLI_dynstr_new();
813
const char *propname=NULL;
813
DynStr *path = BLI_dynstr_new();
814
const char *propname = NULL;
818
819
/* hack: if constname is set, we can only be dealing with an Constraint curve */
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);
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);
832
833
case ID_KE: /* shapekeys */
833
propname= shapekey_adrcodes_to_paths(adrcode, &dummy_index);
834
propname = shapekey_adrcodes_to_paths(adrcode, &dummy_index);
836
837
case ID_CO: /* constraint */
837
propname= constraint_adrcodes_to_paths(adrcode, &dummy_index);
838
propname = constraint_adrcodes_to_paths(adrcode, &dummy_index);
840
841
case ID_TE: /* texture */
841
propname= texture_adrcodes_to_paths(adrcode, &dummy_index);
842
propname = texture_adrcodes_to_paths(adrcode, &dummy_index);
844
845
case ID_MA: /* material */
845
propname= material_adrcodes_to_paths(adrcode, &dummy_index);
846
propname = material_adrcodes_to_paths(adrcode, &dummy_index);
848
849
case ID_CA: /* camera */
849
propname= camera_adrcodes_to_paths(adrcode, &dummy_index);
850
propname = camera_adrcodes_to_paths(adrcode, &dummy_index);
852
853
case ID_LA: /* lamp */
853
propname= lamp_adrcodes_to_paths(adrcode, &dummy_index);
854
propname = lamp_adrcodes_to_paths(adrcode, &dummy_index);
856
857
case ID_SO: /* sound */
857
propname= sound_adrcodes_to_paths(adrcode, &dummy_index);
858
propname = sound_adrcodes_to_paths(adrcode, &dummy_index);
860
861
case ID_WO: /* world */
861
propname= world_adrcodes_to_paths(adrcode, &dummy_index);
862
propname = world_adrcodes_to_paths(adrcode, &dummy_index);
864
865
case ID_PA: /* particle */
865
propname= particle_adrcodes_to_paths(adrcode, &dummy_index);
866
propname = particle_adrcodes_to_paths(adrcode, &dummy_index);
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!
872
propname= "eval_time";
873
propname = "eval_time";
875
/* XXX problematic blocktypes */
876
/* XXX problematic blocktypes */
876
877
case ID_SEQ: /* sequencer strip */
878
879
switch (adrcode) {
880
propname= "effect_fader";
883
propname= "speed_fader";
885
case SEQ_FAC_OPACITY:
886
propname= "blend_opacity";
881
propname = "effect_fader";
884
propname = "speed_fader";
886
case SEQ_FAC_OPACITY:
887
propname = "blend_opacity";
889
890
// poin= &(seq->facf0); // XXX this doesn't seem to be included anywhere in sequencer RNA...
925
926
BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
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 */
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");
977
978
/* Conversion Utilities */
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)
982
983
switch (adrcode) {
984
985
return DTAR_TRANSCHAN_LOCX;
986
987
return DTAR_TRANSCHAN_LOCY;
988
989
return DTAR_TRANSCHAN_LOCZ;
991
992
return DTAR_TRANSCHAN_ROTX;
993
994
return DTAR_TRANSCHAN_ROTY;
995
996
return DTAR_TRANSCHAN_ROTZ;
998
999
return DTAR_TRANSCHAN_SCALEX;
1000
1001
return DTAR_TRANSCHAN_SCALEX;
1027
1028
DriverTarget *dtar = NULL;
1029
1030
/* this should be ok for all types here... */
1030
cdriver->type= DRIVER_TYPE_AVERAGE;
1031
cdriver->type = DRIVER_TYPE_AVERAGE;
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);
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));
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));
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);
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 */
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);
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);
1093
1094
* and extract the resultant lists...
1095
1096
bAction tmp_act;
1096
bActionGroup *agrp= NULL;
1097
bActionGroup *agrp = NULL;
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 */
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");
1113
1114
agrp->flag = AGRP_SELECTED;
1114
1115
if (muteipo) agrp->flag |= AGRP_MUTED;
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
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)
1149
1150
AdrBit2Path *abp;
1153
1154
/* allocate memory for a new F-Curve */
1154
fcu= MEM_callocN(sizeof(FCurve), "FCurve");
1155
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
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);
1160
1161
/* copy flags */
1161
1162
if (icu->flag & IPO_VISIBLE) fcu->flag |= FCURVE_VISIBLE;
1180
1181
/* Add a new FModifier (Cyclic) instead of setting extend value
1181
1182
* as that's the new equivalent of that option.
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;
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;
1190
data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC;
1191
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
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;
1203
1204
if (G.debug & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits);
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);
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
1214
for (b=0; b < totbits; b++, abp++) {
1215
for (b = 0; b < totbits; b++, abp++) {
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);
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;
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)
1231
fcurve->totvert= icu->totvert;
1232
fcurve->totvert = icu->totvert;
1233
1234
if (icu->bezt) {
1234
1235
BezTriple *dst, *src;
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");
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 */
1244
1245
/* interpolation can only be constant... */
1245
dst->ipo= BEZT_IPO_CONST;
1246
dst->ipo = BEZT_IPO_CONST;
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;
1250
1251
/* auto-handles - per curve to per handle */
1251
1252
if (icu->flag & IPO_AUTO_HORIZ) {
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)
1287
fcu->totvert= icu->totvert;
1288
fcu->totvert = icu->totvert;
1289
1290
if (icu->bezt) {
1290
1291
BezTriple *dst, *src;
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");
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 */
1300
1301
/* now copy interpolation from curve (if not already set) */
1301
1302
if (icu->ipo != IPO_MIXED)
1303
dst->ipo = icu->ipo;
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;
1307
1308
/* auto-handles - per curve to per handle */
1308
1309
if (icu->flag & IPO_AUTO_HORIZ) {
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
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];
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;
1353
1354
dst->vec[0][0] *= fac;
1354
1355
dst->vec[1][0] *= fac;
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.
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)
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!
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)
1463
1464
bActionChannel *achan, *achann;
1464
1465
bConstraintChannel *conchan, *conchann;
1473
1474
BLI_freelistN(&act->groups);
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;
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--;
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;
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--;
1497
conchan->ipo = NULL;
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...
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)
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};
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));
1535
1536
/* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers),
1588
1589
/* ------------------------- */
1591
// - NLA group duplicators info
1592
// - NLA curve/stride modifiers...
1592
* - NLA group duplicators info
1593
* - NLA curve/stride modifiers... */
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)
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;
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
for (as = strips->first; as; as = asn) {
1606
1607
/* this old strip is only worth something if it had an action... */
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
1617
strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
1618
strip->act= as->act;
1621
strip->start= as->start;
1622
strip->end= as->end;
1623
strip->actstart= as->actstart;
1624
strip->actend= as->actend;
1627
strip->repeat= as->repeat;
1628
strip->scale= as->scale;
1629
if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
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;
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;
1641
if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED;
1642
if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE;
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;
1618
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
1619
strip->act = as->act;
1622
strip->start = as->start;
1623
strip->end = as->end;
1624
strip->actstart = as->actstart;
1625
strip->actend = as->actend;
1628
strip->repeat = as->repeat;
1629
strip->scale = as->scale;
1630
if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
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;
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;
1642
if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED;
1643
if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE;
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;
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...
1654
nlt= add_nlatrack(adt, NULL);
1655
nlt = add_nlatrack(adt, NULL);
1655
1656
BKE_nlatrack_add_strip(nlt, strip);
1701
1702
/* ----------- Animation Attached to Data -------------- */
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;
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);
1712
1713
/* check if object has any animation data */
1713
1714
if (ob->nlastrips.first) {
1753
1754
ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
1754
1755
ob->ipo->id.us--;
1759
/* If we have any empty action actuators, assume they were
1760
* converted IPO Actuators using the object IPO */
1762
bActionActuator *aa;
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;
1823
1841
/* object's action will always be object-rooted */
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;
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;
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);
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
1849
1867
adt->action->idroot = key->ipo->blocktype;
1851
1869
key->ipo->id.us--;
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;
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);
1862
1880
/* we're only interested in the IPO */
1864
1882
/* Add AnimData block */
1865
AnimData *adt= BKE_id_add_animdata(id);
1883
AnimData *adt = BKE_id_add_animdata(id);
1867
1885
/* Convert Material data... */
1868
1886
ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL);
1871
1889
adt->action->idroot = ma->ipo->blocktype;
1873
1891
ma->ipo->id.us--;
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;
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);
1884
1902
/* we're only interested in the IPO */
1886
1904
/* Add AnimData block */
1887
AnimData *adt= BKE_id_add_animdata(id);
1905
AnimData *adt = BKE_id_add_animdata(id);
1889
1907
/* Convert World data... */
1890
1908
ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL);
1893
1911
adt->action->idroot = wo->ipo->blocktype;
1895
1913
wo->ipo->id.us--;
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) {
1907
AnimData *adt= BKE_id_add_animdata(id);
1909
SEQ_BEGIN(ed, seq) {
1925
AnimData *adt = BKE_id_add_animdata(id);
1910
1929
IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
1911
1930
short adrcode = SEQ_FAC1;
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);
1916
1935
if (ELEM(NULL, seq->ipo, icu)) {
1917
1936
seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
1954
for (id= main->tex.first; id; id= id->next) {
1973
for (id = main->tex.first; id; id = id->next) {
1974
Tex *te = (Tex *)id;
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);
1959
1978
/* we're only interested in the IPO */
1961
1980
/* Add AnimData block */
1962
AnimData *adt= BKE_id_add_animdata(id);
1981
AnimData *adt = BKE_id_add_animdata(id);
1964
1983
/* Convert Texture data... */
1965
1984
ipo_to_animdata(id, te->ipo, NULL, NULL, NULL);
1968
1987
adt->action->idroot = te->ipo->blocktype;
1970
1989
te->ipo->id.us--;
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;
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);
1981
2000
/* we're only interested in the IPO */
1983
2002
/* Add AnimData block */
1984
AnimData *adt= BKE_id_add_animdata(id);
2003
AnimData *adt = BKE_id_add_animdata(id);
1986
2005
/* Convert Camera data... */
1987
2006
ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL);
1990
2009
adt->action->idroot = ca->ipo->blocktype;
1992
2011
ca->ipo->id.us--;
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;
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);
2003
2022
/* we're only interested in the IPO */
2005
2024
/* Add AnimData block */
2006
AnimData *adt= BKE_id_add_animdata(id);
2025
AnimData *adt = BKE_id_add_animdata(id);
2008
2027
/* Convert Lamp data... */
2009
2028
ipo_to_animdata(id, la->ipo, NULL, NULL, NULL);
2012
2031
adt->action->idroot = la->ipo->blocktype;
2014
2033
la->ipo->id.us--;
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;
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);
2025
2044
/* we're only interested in the IPO */
2027
2046
/* Add AnimData block */
2028
AnimData *adt= BKE_id_add_animdata(id);
2047
AnimData *adt = BKE_id_add_animdata(id);
2030
2049
/* Convert Curve data... */
2031
2050
ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL);
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;
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);
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;
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;
2082
2101
/* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */
2084
2103
ipo->id.flag &= ~LIB_FAKEUSER;