From 4263c13c392fadea67f7b4884fb6af50585a6c69 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 13 Apr 2009 11:15:43 +0000 Subject: Animato Bugfixes: * Copying objects with animation data now works correctly. Previously, actions were not getting copied correctly, leading to loss of data in some cases. * Action and Graph editors now display the name of the Action concerned (for 'Action' folder channels), making it easier to tell which AnimData blocks are sharing the same actions * Added some code to make relative KeyingSets (converted from absolute ones) work better. --- source/blender/blenkernel/intern/action.c | 30 ++++++++++++++++++++--- source/blender/blenkernel/intern/anim_sys.c | 6 ++++- source/blender/blenkernel/intern/fcurve.c | 2 ++ source/blender/editors/armature/poselib.c | 3 +-- source/blender/editors/space_action/action_draw.c | 2 +- source/blender/editors/space_graph/graph_draw.c | 2 +- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 9ed469c9028..7221650ac44 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -169,17 +169,39 @@ void free_action (bAction *act) bAction *copy_action (bAction *src) { bAction *dst = NULL; - //bActionGroup *dgrp, *sgrp; // XXX not used yet + bActionGroup *dgrp, *sgrp; + FCurve *dfcu, *sfcu; if (src == NULL) return NULL; dst= copy_libblock(src); - BLI_duplicatelist(&dst->groups, &src->groups); // XXX not used yet + /* duplicate the lists of groups and markers */ + BLI_duplicatelist(&dst->groups, &src->groups); BLI_duplicatelist(&dst->markers, &src->markers); - /* copy f-curves */ - copy_fcurves(&dst->curves, &src->curves); + /* copy F-Curves, fixing up the links as we go */ + dst->curves.first= dst->curves.last= NULL; + + for (sfcu= src->curves.first; sfcu; sfcu= sfcu->next) { + /* duplicate F-Curve */ + dfcu= copy_fcurve(sfcu); + BLI_addtail(&dst->curves, dfcu); + + /* fix group links (kindof bad list-in-list search, but this is the most reliable way) */ + for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && sgrp; dgrp=dgrp->next, sgrp=sgrp->next) { + if (sfcu->grp == sgrp) { + dfcu->grp= dgrp; + + if (dgrp->channels.first == sfcu) + dgrp->channels.first= dfcu; + if (dgrp->channels.last == sfcu) + dgrp->channels.last= dfcu; + + break; + } + } + } dst->id.flag |= LIB_FAKEUSER; // XXX this is nasty for new users... maybe we don't want this anymore dst->id.us++; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index f1340215967..ebced7837ae 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -279,6 +279,10 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name strcpy(ksp->group, ""); } + /* store additional info for relative paths (just in case user makes the set relative) */ + if (id) + ksp->idtype= GS(id->name); + /* just copy path info */ // XXX no checks are performed for templates yet // should array index be checked too? @@ -859,7 +863,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) // TODO... /* objects */ - EVAL_ANIM_IDS(main->object.first, 0); + EVAL_ANIM_IDS(main->object.first, ADT_RECALC_ANIM); /* worlds */ EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index acdaec63c3b..3e1b6f29403 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -98,7 +98,9 @@ FCurve *copy_fcurve (FCurve *fcu) /* make a copy */ fcu_d= MEM_dupallocN(fcu); + fcu_d->next= fcu_d->prev= NULL; + fcu_d->grp= NULL; /* copy curve data */ fcu_d->bezt= MEM_dupallocN(fcu_d->bezt); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 8e6f118118a..f27bec81d7a 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -193,8 +193,7 @@ bAction *poselib_init_new (Object *ob) /* init object's poselib action (unlink old one if there) */ if (ob->poselib) ob->poselib->id.us--; - // XXX old anim stuff - // ob->poselib= add_empty_action("PoseLib"); + ob->poselib= add_empty_action("PoseLib"); return ob->poselib; } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 669320e72bf..4eb26303b13 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -499,7 +499,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) expand= ICON_TRIA_RIGHT; sel = SEL_ACTC(act); - strcpy(name, "Action"); + strcpy(name, act->id.name+2); } break; case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 97c9995eab6..e8c84b1d74d 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1007,7 +1007,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) expand= ICON_TRIA_RIGHT; sel = SEL_ACTC(act); - strcpy(name, "Action"); + strcpy(name, act->id.name+2); } break; case ANIMTYPE_FILLDRIVERS: /* drivers widget */ -- cgit v1.2.3