[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13166] branches/animsys-aligorith/source/ blender: == AnimSys Branch - More Keyframing API work ==
Joshua Leung
aligorith at gmail.com
Tue Jan 8 10:21:03 CET 2008
Revision: 13166
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13166
Author: aligorith
Date: 2008-01-08 10:21:02 +0100 (Tue, 08 Jan 2008)
Log Message:
-----------
== AnimSys Branch - More Keyframing API work ==
Made a function which is specially used to add a keyframe to a provided IPO-curve, instead of having to insert one in the default one.
Modified Paths:
--------------
branches/animsys-aligorith/source/blender/include/BIF_keyframing.h
branches/animsys-aligorith/source/blender/src/keyframing.c
Modified: branches/animsys-aligorith/source/blender/include/BIF_keyframing.h
===================================================================
--- branches/animsys-aligorith/source/blender/include/BIF_keyframing.h 2008-01-08 05:57:27 UTC (rev 13165)
+++ branches/animsys-aligorith/source/blender/include/BIF_keyframing.h 2008-01-08 09:21:02 UTC (rev 13166)
@@ -35,11 +35,18 @@
struct bAnimData;
struct bKeyableType;
+struct IpoCurve;
/* Anim-Data validation calls. Used by insert_key */
struct bAnimData *validate_animdata(void *data, short blocktype);
struct IpoCurve *validate_animdata_data(struct bAnimData *adt, struct bKeyableType *kt);
+/* Main Keyframing API call:
+ * Use this when validation of necessary animation data isn't necessary as it
+ * already exists. It will insert a keyframe using the current value being keyframed.
+ */
+void insert_key_icu(struct bAnimData *adt, void *data, struct IpoCurve *icu, short flag);
+
/* Main Keyframing API call:
* Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place.
Modified: branches/animsys-aligorith/source/blender/src/keyframing.c
===================================================================
--- branches/animsys-aligorith/source/blender/src/keyframing.c 2008-01-08 05:57:27 UTC (rev 13165)
+++ branches/animsys-aligorith/source/blender/src/keyframing.c 2008-01-08 09:21:02 UTC (rev 13166)
@@ -172,7 +172,7 @@
break;
case IPOB_POSE:
{
- Ob *ob= (Object *)data;
+ Object *ob= (Object *)data;
GETSET_ANIMDATA(ob->pose_animdata, "PoseAnimData")
}
break;
@@ -181,6 +181,12 @@
// hrm...
}
break;
+ case IPOB_FLUID:
+ {
+ Object *ob= (Object *)data;
+ GETSET_ANIMDATA(ob->fluid_animdata, "FluidAnimData");
+ }
+ break;
}
}
@@ -535,25 +541,23 @@
/* ------------------------- Insert Key API ------------------------- */
-// TODO: figure out what to do when user is keyframing to nla-strip on top of other strips...
-
/* Main Keyframing API call:
- * Use this to create any necessary animation data, and then insert a keyframe
- * using the current value being keyframed, in the relevant place.
+ * Use this when validation of necessary animation data isn't necessary as it
+ * already exists. It will insert a keyframe using the current value being keyframed.
*
* The flag argument is used for special settings that alter the behaviour of
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
* and extra keyframe filtering.
*/
-void insert_key (bAnimData *adt, bKeyableType *kt, void *data, short flag)
-{
- IpoCurve *icu= validate_animdata_data(adt, kt, (flag & INSERTKEY_DRIVER));
- bActionStrip *strip= adt_get_active_strip(adt);
- float cfra = frame_to_float(CFRA);
- float curval= 0.0f;
-
+void insert_key_icu (bAnimData *adt, void *data, IpoCurve *icu, short flag)
+{
/* only continue if we have an ipo-curve to add keyframe to */
if (icu) {
+ bActionStrip *strip= adt_get_active_strip(adt);
+ bKeyableType *kt= &icu->kt;
+ float cfra = frame_to_float(CFRA);
+ float curval= 0.0f;
+
/* apply scaling of time - special cases */
if (1==0 /* TODO: need macro to test if nla-scale time */) {
cfra= get_action_frame(adt, cfra);
@@ -619,6 +623,22 @@
insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST));
}
}
+}
+
+/* Main Keyframing API call:
+ * Use this to create any necessary animation data, and then insert a keyframe
+ * using the current value being keyframed, in the relevant place.
+ *
+ * The flag argument is used for special settings that alter the behaviour of
+ * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
+ * and extra keyframe filtering.
+ */
+void insert_key (bAnimData *adt, bKeyableType *kt, void *data, short flag)
+{
+ IpoCurve *icu= validate_animdata_data(adt, kt, (flag & INSERTKEY_DRIVER));
+
+ /* insert keyframe to the ipo-curve obtained */
+ insert_key_icu(adt, data, icu, flag);
}
/* ------------------- 'Common'-InsertKey / Menus API ------------------- */
@@ -649,27 +669,26 @@
if ((ob) && (ob->pose) && (ob->flag & OB_POSEMODE)) {
/* PoseMode */
bArmature *arm= ob->data;
- bPoseChannel *pchan= NULL;
-
+ bPoseChannel *pchan;
+
/* make sure we have at least one selected pose-channel */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if ( (pchan->bone) && (arm->layer & pchan->bone->layer) &&
(pchan->bone->flag & BONE_SELECTED) )
- break;
+ {
+ /* make sure we have animdata (only really needs to be done for first time...) */
+ validate_animdata(ob, IPOB_POSE);
+
+ /* allocate memory for temporary bCommonKeySource struct (on stack is risky) */
+ cks= MEM_callocN(sizeof(bCommonKeySource), "bCommonKeySource");
+
+ cks->adt= ob->pose_animdata;
+ cks->data= pchan;
+ cks->active= 1;
+
+ BLI_addtail(animsrcs, cks);
+ }
}
- if (pchan == NULL) return;
-
- /* make sure we have animdata */
- validate_animdata(ob, IPOB_POSE);
-
- /* allocate memory for temporary bCommonKeySource struct (on stack is risky) */
- cks= MEM_callocN(sizeof(bCommonKeySource), "bCommonKeySource");
-
- cks->adt= ob->pose_animdata;
- cks->data= ob;
- cks->active= 1;
-
- BLI_addtail(animsrcs, cks);
}
else {
/* ObjectMode */
@@ -837,6 +856,7 @@
}
/* check for invalid/lack-of data */
+ // TODO: maybe if no keyingset, just list all keyable types?
if (animsrcs.first==NULL) {
error("No data available for keyframing");
return;
More information about the Bf-blender-cvs
mailing list