[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17979] branches/blender2.5/blender/source /blender/editors: 2.5 - Animation Editors - Filtering API
Joshua Leung
aligorith at gmail.com
Sun Dec 21 05:11:25 CET 2008
Revision: 17979
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17979
Author: aligorith
Date: 2008-12-21 05:11:19 +0100 (Sun, 21 Dec 2008)
Log Message:
-----------
2.5 - Animation Editors - Filtering API
Brought back the Filtering API for Animation Editors. This is the 'backbone' of the current Action/Dopesheet Editor code, so it is essential to have this working.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
branches/blender2.5/blender/source/blender/editors/animation/anim_keyframing.c
branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c 2008-12-21 03:43:01 UTC (rev 17978)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c 2008-12-21 04:11:19 UTC (rev 17979)
@@ -26,16 +26,21 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/* This file defines the system for filtering data into a form suitable for
- * use by the Animation Editors, thus acting as a means by which the Animation
- * Editors maintain a level of abstraction from the data they actually manipulate.
- * Thus, they only need to check on the type of the data they're manipulating, and
- * NOT worry about various layers of context/hierarchy checks.
+/* This file contains a system used to provide a layer of abstraction between sources
+ * of animation data and tools in Animation Editors. The method used here involves
+ * generating a list of edit structures which enable tools to naively perform the actions
+ * they require without all the boiler-plate associated with loops within loops and checking
+ * for cases to ignore.
*
* While this is primarily used for the Action/Dopesheet Editor (and its accessory modes),
* the IPO Editor also uses this for it's channel list and for determining which curves
* are being edited.
*
+ * Note: much of the original system this was based on was built before the creation of the RNA
+ * system. In future, it would be interesting to replace some parts of this code with RNA queries,
+ * however, RNA does not eliminate some of the boiler-plate reduction benefits presented by this
+ * system, so if any such work does occur, it should only be used for the internals used here...
+ *
* -- Joshua Leung, Dec 2008
*/
@@ -45,11 +50,15 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
#include "DNA_action_types.h"
+#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
#include "DNA_ipo_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_key_types.h"
+#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
@@ -63,6 +72,9 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_key.h"
+#include "BKE_object.h"
+#include "BKE_material.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -97,7 +109,7 @@
if (ob == NULL)
return NULL;
- /* pinning is not available in 'ShapeKey' mode... */
+ /* XXX pinning is not available in 'ShapeKey' mode... */
//if (saction->pin) return NULL;
/* shapekey data is stored with geometry data */
@@ -215,7 +227,959 @@
/* ----------- 'Private' Stuff --------------- */
+/* this function allocates memory for a new bAnimListElem struct for the
+ * provided animation channel-data.
+ */
+bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, short ownertype)
+{
+ bAnimListElem *ale= NULL;
+
+ /* only allocate memory if there is data to convert */
+ if (data) {
+ /* allocate and set generic data */
+ ale= MEM_callocN(sizeof(bAnimListElem), "bAnimListElem");
+
+ ale->data= data;
+ ale->type= datatype;
+ ale->owner= owner;
+ ale->ownertype= ownertype;
+
+ if ((owner) && (ownertype == ANIMTYPE_ACHAN)) {
+ bActionChannel *ochan= (bActionChannel *)owner;
+ ale->grp= ochan->grp;
+ }
+ else
+ ale->grp= NULL;
+
+ /* do specifics */
+ switch (datatype) {
+ case ANIMTYPE_OBJECT:
+ {
+ Base *base= (Base *)data;
+ Object *ob= base->object;
+
+ ale->flag= ob->flag;
+
+ ale->key_data= ob;
+ ale->datatype= ALE_OB;
+ }
+ break;
+ case ANIMTYPE_FILLACTD:
+ {
+ bAction *act= (bAction *)data;
+
+ ale->flag= act->flag;
+
+ ale->key_data= act;
+ ale->datatype= ALE_ACT;
+ }
+ break;
+ case ANIMTYPE_FILLIPOD:
+ {
+ Object *ob= (Object *)data;
+
+ ale->flag= FILTER_IPO_OBJC(ob);
+
+ ale->key_data= ob->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+ case ANIMTYPE_FILLCOND:
+ {
+ Object *ob= (Object *)data;
+
+ ale->flag= FILTER_CON_OBJC(ob);
+
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ break;
+ case ANIMTYPE_FILLMATD:
+ {
+ Object *ob= (Object *)data;
+
+ ale->flag= FILTER_MAT_OBJC(ob);
+
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ break;
+
+ case ANIMTYPE_DSMAT:
+ {
+ Material *ma= (Material *)data;
+
+ ale->flag= FILTER_MAT_OBJD(ma);
+
+ ale->key_data= ma->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+ case ANIMTYPE_DSLAM:
+ {
+ Lamp *la= (Lamp *)data;
+
+ ale->flag= FILTER_LAM_OBJD(la);
+
+ ale->key_data= la->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+ case ANIMTYPE_DSCAM:
+ {
+ Camera *ca= (Camera *)data;
+
+ ale->flag= FILTER_CAM_OBJD(ca);
+
+ ale->key_data= ca->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+ case ANIMTYPE_DSCUR:
+ {
+ Curve *cu= (Curve *)data;
+
+ ale->flag= FILTER_CUR_OBJD(cu);
+
+ ale->key_data= cu->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+ case ANIMTYPE_DSSKEY:
+ {
+ Key *key= (Key *)data;
+
+ ale->flag= FILTER_SKE_OBJD(key);
+
+ ale->key_data= key->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+
+ case ANIMTYPE_GROUP:
+ {
+ bActionGroup *agrp= (bActionGroup *)data;
+
+ ale->flag= agrp->flag;
+
+ ale->key_data= NULL;
+ ale->datatype= ALE_GROUP;
+ }
+ break;
+ case ANIMTYPE_ACHAN:
+ {
+ bActionChannel *achan= (bActionChannel *)data;
+
+ ale->flag= achan->flag;
+
+ if (achan->ipo) {
+ ale->key_data= achan->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ else {
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ }
+ break;
+ case ANIMTYPE_CONCHAN:
+ case ANIMTYPE_CONCHAN2:
+ {
+ bConstraintChannel *conchan= (bConstraintChannel *)data;
+
+ ale->flag= conchan->flag;
+
+ if (datatype == ANIMTYPE_CONCHAN2) {
+ /* CONCHAN2 is a hack so that constraint-channels keyframes can be edited */
+ if (conchan->ipo) {
+ ale->key_data= conchan->ipo;
+ ale->datatype= ALE_IPO;
+ }
+ else {
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ }
+ else {
+ if ((conchan->ipo) && (conchan->ipo->curve.first)) {
+ /* we assume that constraint ipo blocks only have 1 curve:
+ * INFLUENCE, so we pretend that a constraint channel is
+ * really just a Ipo-Curve channel instead.
+ */
+ ale->key_data= conchan->ipo->curve.first;
+ ale->datatype= ALE_ICU;
+ }
+ else {
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ }
+ }
+ break;
+ case ANIMTYPE_ICU:
+ {
+ IpoCurve *icu= (IpoCurve *)data;
+
+ ale->flag= icu->flag;
+ ale->key_data= icu;
+ ale->datatype= ALE_ICU;
+ }
+ break;
+ case ANIMTYPE_FILLIPO:
+ case ANIMTYPE_FILLCON:
+ {
+ bActionChannel *achan= (bActionChannel *)data;
+
+ if (datatype == ANIMTYPE_FILLIPO)
+ ale->flag= FILTER_IPO_ACHAN(achan);
+ else
+ ale->flag= FILTER_CON_ACHAN(achan);
+
+ ale->key_data= NULL;
+ ale->datatype= ALE_NONE;
+ }
+ break;
+ case ANIMTYPE_IPO:
+ {
+ ale->flag= 0;
+ ale->key_data= data;
+ ale->datatype= ALE_IPO;
+ }
+ break;
+
+ case ANIMTYPE_GPLAYER:
+ {
+ bGPDlayer *gpl= (bGPDlayer *)data;
+
+ ale->flag= gpl->flag;
+
+ ale->key_data= NULL;
+ ale->datatype= ALE_GPFRAME;
+ }
+ break;
+ }
+ }
+
+ /* return created datatype */
+ return ale;
+}
+
+/* ----------------------------------------- */
+static void animdata_filter_animionchannel (ListBase *anim_data, bActionChannel *achan, int filter_mode, void *owner, short ownertype)
+{
+ bAnimListElem *ale = NULL;
+ bConstraintChannel *conchan;
+ IpoCurve *icu;
+ short owned= (owner && ownertype)? 1 : 0;
+
+ /* only work with this channel and its subchannels if it is visible */
+ if (!(filter_mode & ANIMFILTER_VISIBLE) || VISIBLE_ACHAN(achan)) {
+ /* only work with this channel and its subchannels if it is editable */
+ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_ACHAN(achan)) {
+ /* check if this achan should only be included if it is selected */
+ if (!(filter_mode & ANIMFILTER_SEL) || SEL_ACHAN(achan)) {
+ /* are we only interested in the ipo-curves? */
+ if ((filter_mode & ANIMFILTER_ONLYICU)==0) {
+ ale= make_new_animlistelem(achan, ANIMTYPE_ACHAN, achan, ANIMTYPE_ACHAN);
+
+ if (ale) {
+ if (owned) ale->id= owner;
+ BLI_addtail(anim_data, ale);
+ }
+ }
+ }
+ else {
+ /* for insert key... this check could be improved */
+ return;
+ }
+
+ /* check if expanded - if not, continue on to next animion channel */
+ if (EXPANDED_ACHAN(achan) == 0 && (filter_mode & ANIMFILTER_ONLYICU)==0) {
+ /* only exit if we don't need to include constraint channels for group-channel keyframes */
+ if ( !(filter_mode & ANIMFILTER_IPOKEYS) || (achan->grp == NULL) || (EXPANDED_AGRP(achan->grp)==0) )
+ return;
+ }
+
+ /* ipo channels */
+ if ((achan->ipo) && (filter_mode & ANIMFILTER_IPOKEYS)==0) {
+ /* include ipo-expand widget? */
+ if ((filter_mode & ANIMFILTER_CHANNELS) && (filter_mode & ANIMFILTER_ONLYICU)==0) {
+ ale= make_new_animlistelem(achan, ANIMTYPE_FILLIPO, achan, ANIMTYPE_ACHAN);
+
+ if (ale) {
+ if (owned) ale->id= owner;
+ BLI_addtail(anim_data, ale);
+ }
+ }
+
+ /* add ipo-curve channels? */
+ if (FILTER_IPO_ACHAN(achan) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ /* loop through ipo-curve channels, adding them */
+ for (icu= achan->ipo->curve.first; icu; icu=icu->next) {
+ ale= make_new_animlistelem(icu, ANIMTYPE_ICU, achan, ANIMTYPE_ACHAN);
+
+ if (ale) {
+ if (owned) ale->id= owner;
+ BLI_addtail(anim_data, ale);
+ }
+ }
+ }
+ }
+
+ /* constraint channels */
+ if (achan->constraintChannels.first) {
+ /* include constraint-expand widget? */
+ if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYICU)
+ && !(filter_mode & ANIMFILTER_IPOKEYS) )
+ {
+ ale= make_new_animlistelem(achan, ANIMTYPE_FILLCON, achan, ANIMTYPE_ACHAN);
+
+ if (ale) {
+ if (owned) ale->id= owner;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list