[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23780] trunk/blender/source/blender: Animation Editors: 'Only Selected' filtering option now works on Pose Channels too
Joshua Leung
aligorith at gmail.com
Mon Oct 12 13:27:34 CEST 2009
Revision: 23780
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23780
Author: aligorith
Date: 2009-10-12 13:27:34 +0200 (Mon, 12 Oct 2009)
Log Message:
-----------
Animation Editors: 'Only Selected' filtering option now works on Pose Channels too
* Only F-Curves and Drivers that affect selected bones will be visible when this happens.
* Moved the function to grab text within a pair of "" following some prefix to blenlib.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_string.h
trunk/blender/source/blender/blenlib/intern/string.c
trunk/blender/source/blender/editors/animation/anim_deps.c
trunk/blender/source/blender/editors/animation/anim_filter.c
trunk/blender/source/blender/editors/animation/anim_ipo_utils.c
Modified: trunk/blender/source/blender/blenlib/BLI_string.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_string.h 2009-10-12 09:53:28 UTC (rev 23779)
+++ trunk/blender/source/blender/blenlib/BLI_string.h 2009-10-12 11:27:34 UTC (rev 23780)
@@ -68,6 +68,17 @@
*/
char *BLI_strncpy(char *dst, const char *src, int maxncpy);
+ /* Makes a copy of the text within the "" that appear after some text 'blahblah'
+ * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
+ *
+ * - str: is the entire string to chop
+ * - prefix: is the part of the string to leave out
+ *
+ * Assume that the strings returned must be freed afterwards, and that the inputs will contain
+ * data we want...
+ */
+char *BLI_getQuotedStr(const char *str, const char *prefix);
+
/**
* Returns a copy of the cstring @a str into a newly mallocN'd
* string with all instances of oldText replaced with newText,
Modified: trunk/blender/source/blender/blenlib/intern/string.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string.c 2009-10-12 09:53:28 UTC (rev 23779)
+++ trunk/blender/source/blender/blenlib/intern/string.c 2009-10-12 11:27:34 UTC (rev 23780)
@@ -100,6 +100,30 @@
return n;
}
+/* Makes a copy of the text within the "" that appear after some text 'blahblah'
+ * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
+ *
+ * - str: is the entire string to chop
+ * - prefix: is the part of the string to leave out
+ *
+ * Assume that the strings returned must be freed afterwards, and that the inputs will contain
+ * data we want...
+ */
+char *BLI_getQuotedStr (const char *str, const char *prefix)
+{
+ int prefixLen = strlen(prefix);
+ char *startMatch, *endMatch;
+
+ /* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
+ startMatch= strstr(str, prefix) + prefixLen + 1;
+
+ /* get the end point (i.e. where the next occurance of " is after the starting point) */
+ endMatch= strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok...
+
+ /* return the slice indicated */
+ return BLI_strdupn(startMatch, (int)(endMatch-startMatch));
+}
+
/* Replaces all occurances of oldText with newText in str, returning a new string that doesn't
* contain the 'replaced' occurances.
*/
Modified: trunk/blender/source/blender/editors/animation/anim_deps.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_deps.c 2009-10-12 09:53:28 UTC (rev 23779)
+++ trunk/blender/source/blender/editors/animation/anim_deps.c 2009-10-12 11:27:34 UTC (rev 23780)
@@ -78,10 +78,7 @@
* 3) Grouping (only for pose to action for now)
*/
-/* XXX OBSOLETE CODE WARNING:
- * With the Animato system, the code below is somewhat obsolete now...
- */
-
+
/* Notifier from Action/Dopesheet (this may be extended to include other things such as Python...)
* Channels in action changed, so update pose channels/groups to reflect changes.
*
@@ -90,12 +87,14 @@
*/
void ANIM_action_to_pose_sync (Object *ob)
{
- bAction *act= (bAction *)ob->action;
- bActionChannel *achan;
+#if 0
+ AnimData *adt= ob->adt;
+ bAction *act= adt->act;
+ FCurve *fcu;
bPoseChannel *pchan;
/* error checking */
- if ((ob == NULL) || (ob->type != OB_ARMATURE) || ELEM(NULL, act, ob->pose))
+ if (ELEM3(NULL, ob, ob->adt, ob->pose) || (ob->type != OB_ARMATURE))
return;
/* 1b) loop through all Action-Channels (there should be fewer channels to search through here in general) */
@@ -120,6 +119,7 @@
}
// TODO: add grouping changes too? For now, these tools aren't exposed to users in animation editors yet...
+#endif
}
/* Notifier from 3D-View/Outliner (this is likely to include other sources too...)
Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c 2009-10-12 09:53:28 UTC (rev 23779)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c 2009-10-12 11:27:34 UTC (rev 23780)
@@ -77,6 +77,7 @@
#include "BLI_blenlib.h"
#include "BKE_animsys.h"
+#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_key.h"
@@ -676,7 +677,7 @@
/* ----------------------------------------- */
-static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionGroup *grp, void *owner, short ownertype, int filter_mode, ID *owner_id)
+static int animdata_filter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, void *owner, short ownertype, int filter_mode, ID *owner_id)
{
bAnimListElem *ale = NULL;
FCurve *fcu;
@@ -686,6 +687,35 @@
* NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too...
*/
for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) {
+ /* special exception for Pose-Channel Based F-Curves:
+ * - the 'Only Selected' data filter should be applied to Pose-Channel data too, but those are
+ * represented as F-Curves. The way the filter for objects worked was to be the first check
+ * after 'normal' visibility, so this is done first here too...
+ * - we currently use an 'approximate' method for getting these F-Curves that doesn't require
+ * carefully checking the entire path
+ * - this will also affect things like Drivers, and also works for Bone Constraints
+ */
+ if ( ((ads) && (ads->filterflag & ADS_FILTER_ONLYSEL)) &&
+ ((owner_id) && (GS(owner_id->name) == ID_OB)) )
+ {
+ Object *ob= (Object *)owner_id;
+
+ /* only consider if F-Curve involves pose_channels */
+ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose_channels")) {
+ bPoseChannel *pchan;
+ char *bone_name;
+
+ /* get bone-name, and check if this bone is selected */
+ bone_name= BLI_getQuotedStr(fcu->rna_path, "pose_channels[");
+ pchan= get_pose_channel(ob->pose, bone_name);
+ if (bone_name) MEM_freeN(bone_name);
+
+ /* can only add this F-Curve if it is selected */
+ if ((pchan) && (pchan->bone) && (pchan->bone->flag & BONE_SELECTED)==0)
+ continue;
+ }
+ }
+
/* only include if visible (Graph Editor check, not channels check) */
if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
/* only work with this channel and its subchannels if it is editable */
@@ -710,7 +740,7 @@
return items;
}
-static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter_mode, void *owner, short ownertype, ID *owner_id)
+static int animdata_filter_action (ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, void *owner, short ownertype, ID *owner_id)
{
bAnimListElem *ale=NULL;
bActionGroup *agrp;
@@ -718,16 +748,21 @@
int items = 0;
/* loop over groups */
- // XXX in future, we need to be prepared for nestled groups...
+ // TODO: in future, should we expect to need nested groups?
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
+ ListBase tmp_channels = {NULL, NULL};
+ short grp_channel=0;
+ int tmp_items = 0;
+
+
/* add this group as a channel first */
if ((filter_mode & ANIMFILTER_CHANNELS) || !(filter_mode & ANIMFILTER_CURVESONLY)) {
/* check if filtering by selection */
if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) {
ale= make_new_animlistelem(agrp, ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE, owner_id);
if (ale) {
- BLI_addtail(anim_data, ale);
- items++;
+ BLI_addtail(&tmp_channels, ale);
+ grp_channel=1;
}
}
}
@@ -758,28 +793,30 @@
{
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
// XXX the 'owner' info here needs review...
- items += animdata_filter_fcurves(anim_data, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
-
- /* remove group from filtered list if last element is group
- * (i.e. only if group had channels, which were all hidden)
- */
- // XXX this is really hacky... it should be fixed in a much more elegant way!
- if ( (ale) && (anim_data->last == ale) &&
- (ale->data == agrp) && (agrp->channels.first) )
- {
- BLI_freelinkN(anim_data, ale);
- items--;
- }
+ tmp_items += animdata_filter_fcurves(&tmp_channels, ads, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
}
}
}
}
+
+ /* check group had any F-Curves visible */
+ // TODO: this needs more work to truly work so that closed group with no visible channels, and visible group with visible channels are differentiated between
+ if (/*tmp_items*/1) {
+ /* add the temp channels to the list of filtered channels */
+ addlisttolist(anim_data, &tmp_channels);
+
+ /* increase the counts as appropriate */
+ items += tmp_items + grp_channel;
+ }
+ else {
+ BLI_freelistN(&tmp_channels);
+ }
}
/* loop over un-grouped F-Curves (only if we're not only considering those channels in the animive group) */
if (!(filter_mode & ANIMFILTER_ACTGROUPED)) {
// XXX the 'owner' info here needs review...
- items += animdata_filter_fcurves(anim_data, (lastchan)?(lastchan->next):(act->curves.first), NULL, owner, ownertype, filter_mode, owner_id);
+ items += animdata_filter_fcurves(anim_data, ads, (lastchan)?(lastchan->next):(act->curves.first), NULL, owner, ownertype, filter_mode, owner_id);
}
/* return the number of items added to the list */
@@ -794,7 +831,7 @@
* - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation
* order, i.e. first to last. Otherwise, some tools may get screwed up.
*/
-static int animdata_filter_nla (ListBase *anim_data, AnimData *adt, int filter_mode, void *owner, short ownertype, ID *owner_id)
+static int animdata_filter_nla (ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, void *owner, short ownertype, ID *owner_id)
{
bAnimListElem *ale;
NlaTrack *nlt;
@@ -996,9 +1033,9 @@
if (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_CURVESONLY)) {
ANIMDATA_FILTER_CASES(ma,
{ /* AnimData blocks - do nothing... */ },
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list