diff options
author | Joshua Leung <aligorith@gmail.com> | 2012-06-01 17:54:44 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2012-06-01 17:54:44 +0400 |
commit | 1ced3560099b66d70399b4a5cfbb343b36562979 (patch) | |
tree | d2927d8f403e2cb7a0526f40068d4e8873db5c48 /source/blender/editors | |
parent | 719b3e26e768f03990be95e07f588b84deef9caa (diff) |
Action Group Colors for Bones (Part 2)
Colors used by Bone Groups are now copied/assigned to Action Groups too when
they're created now. This completes the work started in r.46960 to restore this
functionality from 2.48.
Currently, there is no control over when/whether these colors are copied over
(although it is possible to disable the display of these colors for relevant
animation editors if desired). Originally I was going to make this a more
generic Keying Sets feature, though that turned out to be a bit too complex to
manage.
Other notes:
* Split out the code for copying colors to a common library function
Diffstat (limited to 'source/blender/editors')
5 files changed, 30 insertions, 12 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 08672a22666..386313b1d3c 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3060,7 +3060,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* find or create new F-Curve */ // XXX is the group name for this ok? bAction *act = verify_adt_action((ID *)key, 1); - FCurve *fcu = verify_fcurve(act, NULL, rna_path, 0, 1); + FCurve *fcu = verify_fcurve(act, NULL, &ptr, rna_path, 0, 1); /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 05c87e98f9b..ac37b6c4141 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -671,7 +671,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float BezTriple *bezt; int i; - /* First de-select existing FCuvre */ + /* First de-select existing FCurve's keyframes */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { bezt->f2 &= ~SELECT; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2a68d32557a..b8601419d51 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -150,9 +150,10 @@ bAction *verify_adt_action(ID *id, short add) /* Get (or add relevant data to be able to do so) F-Curve from the Active Action, * for the given Animation Data block. This assumes that all the destinations are valid. */ -FCurve *verify_fcurve(bAction *act, const char group[], const char rna_path[], const int array_index, short add) +FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, + const char rna_path[], const int array_index, short add) { - bActionGroup *grp; + bActionGroup *agrp; FCurve *fcu; /* sanity checks */ @@ -183,14 +184,30 @@ FCurve *verify_fcurve(bAction *act, const char group[], const char rna_path[], c /* if a group name has been provided, try to add or find a group, then add F-Curve to it */ if (group) { /* try to find group */ - grp = BKE_action_group_find_name(act, group); + agrp = BKE_action_group_find_name(act, group); /* no matching groups, so add one */ - if (grp == NULL) - grp = action_groups_add_new(act, group); + if (agrp == NULL) { + agrp = action_groups_add_new(act, group); + + /* sync bone group colors if applicable */ + if (ptr && (ptr->type == &RNA_PoseBone)) { + Object *ob = (Object *)ptr->id.data; + bPoseChannel *pchan = (bPoseChannel *)ptr->data; + bPose *pose = ob->pose; + bActionGroup *grp; + + /* find bone group (if present), and use the color from that */ + grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); + if (grp) { + agrp->customCol = grp->customCol; + action_group_colors_sync(agrp); + } + } + } /* add F-Curve to group */ - action_groups_add_channel(act, grp, fcu); + action_groups_add_channel(act, agrp, fcu); } else { /* just add F-Curve to end of Action's list */ @@ -939,7 +956,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet * but still try to get the F-Curve if it exists... */ - fcu = verify_fcurve(act, group, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0); + fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0); /* we may not have a F-Curve when we're replacing only... */ if (fcu) { @@ -1027,7 +1044,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { - FCurve *fcu = verify_fcurve(act, group, rna_path, array_index, 0); + FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0); short found = -1; int i; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index be5ad5b0c70..95fad17274e 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -75,7 +75,8 @@ struct bAction *verify_adt_action(struct ID *id, short add); /* Get (or add relevant data to be able to do so) F-Curve from the given Action. * This assumes that all the destinations are valid. */ -struct FCurve *verify_fcurve(struct bAction *act, const char group[], const char rna_path[], const int array_index, short add); +struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr, + const char rna_path[], const int array_index, short add); /* -------- */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 34fb2ca6c32..85b9d78c657 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -542,7 +542,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object if (partype == PAR_FOLLOW) { /* get or create F-Curve */ bAction *act = verify_adt_action(&cu->id, 1); - FCurve *fcu = verify_fcurve(act, NULL, "eval_time", 0, 1); + FCurve *fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1); /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) |