diff options
Diffstat (limited to 'source/blender/blenkernel/intern/ipo.c')
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 145 |
1 files changed, 82 insertions, 63 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5c0c0fbf0c1..41639a619b3 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -59,8 +59,9 @@ #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_animsys.h" #include "BKE_action.h" @@ -102,7 +103,7 @@ void free_ipo (Ipo *ipo) /* Mapping Table for bitflag <-> RNA path */ typedef struct AdrBit2Path { int bit; - char *path; + const char *path; int array_index; } AdrBit2Path; @@ -111,27 +112,26 @@ typedef struct AdrBit2Path { /* Object layers */ static AdrBit2Path ob_layer_bits[]= { - {(1<<0), "layer", 0}, - {(1<<1), "layer", 1}, - {(1<<2), "layer", 2}, - {(1<<3), "layer", 3}, - {(1<<4), "layer", 4}, - {(1<<5), "layer", 5}, - {(1<<6), "layer", 6}, - {(1<<7), "layer", 7}, - {(1<<8), "layer", 8}, - {(1<<9), "layer", 9}, - {(1<<10), "layer", 10}, - {(1<<11), "layer", 11}, - {(1<<12), "layer", 12}, - {(1<<13), "layer", 13}, - {(1<<14), "layer", 14}, - {(1<<15), "layer", 15}, - {(1<<16), "layer", 16}, - {(1<<17), "layer", 17}, - {(1<<18), "layer", 18}, - {(1<<19), "layer", 19}, - {(1<<20), "layer", 20} + {(1<<0), "layers", 0}, + {(1<<1), "layers", 1}, + {(1<<2), "layers", 2}, + {(1<<3), "layers", 3}, + {(1<<4), "layers", 4}, + {(1<<5), "layers", 5}, + {(1<<6), "layers", 6}, + {(1<<7), "layers", 7}, + {(1<<8), "layers", 8}, + {(1<<9), "layers", 9}, + {(1<<10), "layers", 10}, + {(1<<11), "layers", 11}, + {(1<<12), "layers", 12}, + {(1<<13), "layers", 13}, + {(1<<14), "layers", 14}, + {(1<<15), "layers", 15}, + {(1<<16), "layers", 16}, + {(1<<17), "layers", 17}, + {(1<<18), "layers", 18}, + {(1<<19), "layers", 19} }; /* Material mode */ @@ -172,7 +172,7 @@ static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *t /* ADRCODE to RNA-Path Conversion Code - Standard */ /* Object types */ -static char *ob_adrcodes_to_paths (int adrcode, int *array_index) +static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -253,7 +253,7 @@ static char *ob_adrcodes_to_paths (int adrcode, int *array_index) /* PoseChannel types * NOTE: pchan name comes from 'actname' added earlier... */ -static char *pchan_adrcodes_to_paths (int adrcode, int *array_index) +static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -297,7 +297,7 @@ static char *pchan_adrcodes_to_paths (int adrcode, int *array_index) } /* Constraint types */ -static char *constraint_adrcodes_to_paths (int adrcode, int *array_index) +static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -315,9 +315,9 @@ static char *constraint_adrcodes_to_paths (int adrcode, int *array_index) /* ShapeKey types * NOTE: as we don't have access to the keyblock where the data comes from (for now), - * we'll just use numerical indicies for now... + * we'll just use numerical indices for now... */ -static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index) +static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { static char buf[128]; @@ -331,9 +331,9 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index) } /* MTex (Texture Slot) types */ -static char *mtex_adrcodes_to_paths (int adrcode, int *array_index) +static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { - char *base=NULL, *prop=NULL; + const char *base=NULL, *prop=NULL; static char buf[128]; /* base part of path */ @@ -401,7 +401,7 @@ static char *mtex_adrcodes_to_paths (int adrcode, int *array_index) } /* Texture types */ -static char *texture_adrcodes_to_paths (int adrcode, int *array_index) +static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -481,7 +481,7 @@ static char *texture_adrcodes_to_paths (int adrcode, int *array_index) } /* Material Types */ -static char *material_adrcodes_to_paths (int adrcode, int *array_index) +static const char *material_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -565,7 +565,7 @@ static char *material_adrcodes_to_paths (int adrcode, int *array_index) } /* Camera Types */ -static char *camera_adrcodes_to_paths (int adrcode, int *array_index) +static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -605,7 +605,7 @@ static char *camera_adrcodes_to_paths (int adrcode, int *array_index) } /* Lamp Types */ -static char *lamp_adrcodes_to_paths (int adrcode, int *array_index) +static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -647,7 +647,7 @@ static char *lamp_adrcodes_to_paths (int adrcode, int *array_index) } /* Sound Types */ -static char *sound_adrcodes_to_paths (int adrcode, int *array_index) +static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -670,7 +670,7 @@ static char *sound_adrcodes_to_paths (int adrcode, int *array_index) } /* World Types */ -static char *world_adrcodes_to_paths (int adrcode, int *array_index) +static const char *world_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -709,6 +709,11 @@ static char *world_adrcodes_to_paths (int adrcode, int *array_index) *array_index= 1; return "stars.color"; case WO_STAR_B: *array_index= 2; return "stars.color"; */ + case WO_STAR_R: + case WO_STAR_G: + case WO_STAR_B: + printf("WARNING: WO_STAR_R/G/B deprecated\n"); + return NULL; case WO_STARDIST: return "stars.min_distance"; @@ -723,7 +728,7 @@ static char *world_adrcodes_to_paths (int adrcode, int *array_index) } /* Particle Types */ -static char *particle_adrcodes_to_paths (int adrcode, int *array_index) +static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -798,10 +803,11 @@ static char *particle_adrcodes_to_paths (int adrcode, int *array_index) * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index) +static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) { DynStr *path= BLI_dynstr_new(); - char *propname=NULL, *rpath=NULL; + const char *propname=NULL; + char *rpath=NULL; char buf[512]; int dummy_index= 0; @@ -913,8 +919,17 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { - /* Pose-Channel */ - sprintf(buf, "pose.bones[\"%s\"]", actname); + if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { + /* Actionified "Object" IPO's... no extra path stuff needed */ + } + else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) { + /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ + strcpy(buf, "data.shape_keys"); + } + else { + /* Pose-Channel */ + sprintf(buf, "pose.bones[\"%s\"]", actname); + } } else if (constname && constname[0]) { /* Constraint in Object */ @@ -922,8 +937,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else if (seq) { /* Sequence names in Scene */ - sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", - seq->name+2); + sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2); } else strcpy(buf, ""); /* empty string */ @@ -1017,13 +1031,13 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) - BLI_strncpy(dtar->pchan_name, idriver->name, 32); + BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); /* second bone target (name was stored in same var as the first one) */ dtar= &dvar->targets[1]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) // xxx... for safety - BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, 32); + BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); } else { /* only a single variable, of type 'transform channel' */ @@ -1034,7 +1048,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) - BLI_strncpy(dtar->pchan_name, idriver->name, 32); + BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ } @@ -1123,7 +1137,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * { AdrBit2Path *abp; FCurve *fcu; - int i=0, totbits; + int totbits; /* allocate memory for a new F-Curve */ fcu= MEM_callocN(sizeof(FCurve), "FCurve"); @@ -1188,6 +1202,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * 3) filter the keyframes for the flag of interest */ for (b=0; b < totbits; b++, abp++) { + unsigned int i=0; + /* make a copy of existing base-data if not the last curve */ if (b < (totbits-1)) fcurve= copy_fcurve(fcu); @@ -1195,7 +1211,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcurve= fcu; /* set path */ - fcurve->rna_path= BLI_strdupn(abp->path, strlen(abp->path)); + fcurve->rna_path= BLI_strdup(abp->path); fcurve->array_index= abp->array_index; /* convert keyframes @@ -1211,7 +1227,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcurve->bezt, src=icu->bezt; i < fcurve->totvert; i++, dst++, src++) { + for (dst=fcurve->bezt, src=icu->bezt, i=0; i < fcurve->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ *dst= *src; @@ -1239,6 +1255,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } else { + unsigned int i=0; + /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ @@ -1259,7 +1277,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcu->bezt, src=icu->bezt; i < fcu->totvert; i++, dst++, src++) { + for (dst=fcu->bezt, src=icu->bezt, i=0; i < fcu->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ *dst= *src; @@ -1316,20 +1334,17 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } - /* correct values for sequencer curves, - that were not locked to frame */ - - if (seq && - (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { + /* correct values for sequencer curves, that were not locked to frame */ + if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { double mul= (seq->enddisp-seq->startdisp)/100.0f; double offset= seq->startdisp; dst->vec[0][0] *= mul; dst->vec[0][0] += offset; - + dst->vec[1][0] *= mul; dst->vec[1][0] += offset; - + dst->vec[2][0] *= mul; dst->vec[2][0] += offset; } @@ -1476,7 +1491,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq) +static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { AnimData *adt= BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1507,19 +1522,23 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (G.f & G_DEBUG) printf("\thas anim \n"); /* try to get action */ if (adt->action == NULL) { - adt->action= add_empty_action("ConvData_Action"); // XXX we need a better name for this - if (G.f & G_DEBUG) printf("\t\tadded new action \n"); + char nameBuf[MAX_ID_NAME]; + + BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2); + + adt->action= add_empty_action(nameBuf); + if (G.f & G_DEBUG) printf("\t\tadded new action - '%s' \n", nameBuf); } /* add F-Curves to action */ - addlisttolist(&adt->action->curves, &anim); + BLI_movelisttolist(&adt->action->curves, &anim); } /* deal with drivers */ if (drivers.first) { if (G.f & G_DEBUG) printf("\thas drivers \n"); /* add drivers to end of driver stack */ - addlisttolist(&adt->drivers, &drivers); + BLI_movelisttolist(&adt->drivers, &drivers); } } @@ -1864,7 +1883,7 @@ void do_versions_ipos_to_animato(Main *main) to different DNA variables later (semi-hack (tm) ) */ - switch(seq->type) { + switch (seq->type) { case SEQ_IMAGE: case SEQ_META: case SEQ_SCENE: |