Revision: 18282
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18282
Author: aligorith
Date: 2009-01-03 07:01:11 +0100 (Sat, 03 Jan 2009)
Log Message:
-----------
2.5 - Action Editor: IPO Curve Protect works now
* Added the relevant filtering necessary for this to work, into the
animation-channel filtering code.
* Updated most of the keyframe-editing tools to respect this
* Renamed keyframe-editing API loopers (added ANIM_ prefix) for consistency
* Added function for mapping keyframes to/from NLA-mapping for Ipo-Curves in
addition to the one for IPO blocks. As a result, renamed the latter for
consistency.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
Modified:
branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
2009-01-03 05:41:58 UTC (rev 18281)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
2009-01-03 06:01:11 UTC (rev 18282)
@@ -51,6 +51,7 @@
#include "BKE_utildefines.h"
#include "ED_anim_api.h"
+#include "ED_keyframes_edit.h"
#include "ED_util.h"
#include "WM_api.h"
@@ -180,7 +181,7 @@
}
/* *************************************************** */
-/* KEYFRAME DRAWING UTILITIES */
+/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */
/* Obtain the Object providing NLA-scaling for the given channel (if
applicable) */
Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
@@ -255,38 +256,81 @@
}
}
+/* ------------------- */
+
+/* helper function for ANIM_nla_mapping_apply_ipocurve() -> "restore", i.e.
mapping points back to IPO-time */
+static short bezt_nlamapping_restore(BeztEditData *bed, BezTriple *bezt)
+{
+ /* object providing scaling is stored in 'data', only_keys option is
stored in i1 */
+ Object *ob= (Object *)bed->data;
+ short only_keys= (short)bed->i1;
+
+ /* adjust BezTriple handles only if allowed to */
+ if (only_keys == 0) {
+ bezt->vec[0][0]= get_action_frame(ob, bezt->vec[0][0]);
+ bezt->vec[2][0]= get_action_frame(ob, bezt->vec[2][0]);
+ }
+ bezt->vec[1][0]= get_action_frame(ob, bezt->vec[1][0]);
+}
+
+/* helper function for ANIM_nla_mapping_apply_ipocurve() -> "apply", i.e.
mapping points to NLA-mapped global time */
+static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt)
+{
+ /* object providing scaling is stored in 'data', only_keys option is
stored in i1 */
+ Object *ob= (Object *)bed->data;
+ short only_keys= (short)bed->i1;
+
+ /* adjust BezTriple handles only if allowed to */
+ if (only_keys == 0) {
+ bezt->vec[0][0]= get_action_frame_inv(ob, bezt->vec[0][0]);
+ bezt->vec[2][0]= get_action_frame_inv(ob, bezt->vec[2][0]);
+ }
+ bezt->vec[1][0]= get_action_frame_inv(ob, bezt->vec[1][0]);
+}
+
+
+
+/* Apply/Unapply NLA mapping to all keyframes in the nominated IPO-Curve
+ * - restore = whether to map points back to ipo-time
+ * - only_keys = whether to only adjust the location of the center point
of beztriples
+ */
+void ANIM_nla_mapping_apply_ipocurve(Object *ob, IpoCurve *icu, short restore,
short only_keys)
+{
+ BeztEditData bed;
+ BeztEditFunc map_cb;
+
+ /* init edit data
+ * - ob is stored in 'data'
+ * - only_keys is stored in 'i1'
+ */
+ memset(&bed, 0, sizeof(BeztEditData));
+ bed.data= (void *)ob;
+ bed.i1= (int)only_keys;
+
+ /* get editing callback */
+ if (restore)
+ map_cb= bezt_nlamapping_restore;
+ else
+ map_cb= bezt_nlamapping_apply;
+
+ /* apply to IPO curve */
+ ANIM_icu_keys_bezier_loop(&bed, icu, NULL, map_cb, NULL);
+}
+
/* Apply/Unapply NLA mapping to all keyframes in the nominated IPO block
* - restore = whether to map points back to ipo-time
* - only_keys = whether to only adjust the location of the center point
of beztriples
*/
// was called actstrip_map_ipo_keys()
-void ANIM_nla_mapping_apply(Object *ob, Ipo *ipo, short restore, short
only_keys)
+void ANIM_nla_mapping_apply_ipo(Object *ob, Ipo *ipo, short restore, short
only_keys)
{
IpoCurve *icu;
- BezTriple *bezt;
- int a;
- if (ipo==NULL) return;
+ if (ipo == NULL) return;
/* loop through all ipo curves, adjusting the times of the selected
keys */
for (icu= ipo->curve.first; icu; icu= icu->next) {
- for (a=0, bezt=icu->bezt; a<icu->totvert; a++, bezt++) {
- /* are the times being adjusted for editing, or has
editing finished */
- if (restore) {
- if (only_keys == 0) {
- bezt->vec[0][0]= get_action_frame(ob,
bezt->vec[0][0]);
- bezt->vec[2][0]= get_action_frame(ob,
bezt->vec[2][0]);
- }
- bezt->vec[1][0]= get_action_frame(ob,
bezt->vec[1][0]);
- }
- else {
- if (only_keys == 0) {
- bezt->vec[0][0]=
get_action_frame_inv(ob, bezt->vec[0][0]);
- bezt->vec[2][0]=
get_action_frame_inv(ob, bezt->vec[2][0]);
- }
- bezt->vec[1][0]= get_action_frame_inv(ob,
bezt->vec[1][0]);
- }
- }
+ ANIM_nla_mapping_apply_ipocurve(ob, icu, restore, only_keys);
}
}
Modified:
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
2009-01-03 05:41:58 UTC (rev 18281)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
2009-01-03 06:01:11 UTC (rev 18282)
@@ -465,6 +465,7 @@
IpoCurve *icu= (IpoCurve *)data;
ale->flag= icu->flag;
+
ale->key_data= icu;
ale->datatype= ALE_ICU;
}
@@ -486,6 +487,7 @@
case ANIMTYPE_IPO:
{
ale->flag= 0;
+
ale->key_data= data;
ale->datatype= ALE_IPO;
}
@@ -510,6 +512,36 @@
/* ----------------------------------------- */
+// FIXME: use this...
+static int animdata_filter_ipocurves (ListBase *anim_data, Ipo *ipo, int
filter_mode, void *owner, short ownertype, ID *owner_id)
+{
+ bAnimListElem *ale = NULL;
+ IpoCurve *icu;
+ int items = 0;
+
+ /* loop over ipo curves - assume that the caller of this has already
checked that these should be included */
+ for (icu= ipo->curve.first; icu; icu= icu->next) {
+ /* only work with this channel and its subchannels if it is
editable */
+ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_ICU(icu)) {
+ /* only include this curve if selected or we are
including all IPO-curves */
+ if (!(filter_mode & ANIMFILTER_SEL) || (filter_mode &
ANIMFILTER_ONLYICU) || (SEL_ICU(icu))) {
+ /* owner/ownertype will be either object or
action-channel, depending if it was dopesheet or part of an action */
+ ale= make_new_animlistelem(icu, ANIMTYPE_ICU,
owner, ownertype);
+
+ if (ale) {
+ /* ID will only be Object if data to
write to directly belongs there, otherwise, another pointer will be used */
+ ale->id= owner_id;
+ BLI_addtail(anim_data, ale);
+ items++;
+ }
+ }
+ }
+ }
+
+ /* return the number of items added to the list */
+ return items;
+}
+
static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel
*achan, int filter_mode, void *owner, short ownertype)
{
bAnimListElem *ale = NULL;
@@ -563,15 +595,7 @@
/* 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);
- items++;
- }
- }
+ items +=
animdata_filter_ipocurves(anim_data, achan->ipo, filter_mode, achan,
ANIMTYPE_ACHAN, (owned)?(owner):(NULL));
}
}
@@ -755,14 +779,7 @@
}
}
else {
- for (icu= key->ipo->curve.first; icu;
icu=icu->next) {
- ale= make_new_animlistelem(icu,
ANIMTYPE_ICU, key, ANIMTYPE_SHAPEKEY);
- if (ale) {
- if (owned) ale->id= owner;
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
+ items += animdata_filter_ipocurves(anim_data,
key->ipo, filter_mode, key, ANIMTYPE_SHAPEKEY, (owned)?(owner):(NULL));
}
}
}
@@ -877,21 +894,10 @@
if ( (FILTER_MAT_OBJD(ma) || (filter_mode &
ANIMFILTER_ONLYICU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
- /* loop through ipo-curve channels, adding them
*/
- for (icu= ma->ipo->curve.first; icu;
icu=icu->next) {
- /* only if selected (if checking for
selection) */
- if ( !(filter_mode & ANIMFILTER_SEL) ||
(SEL_ICU(icu)) ) {
- ale= make_new_animlistelem(icu,
ANIMTYPE_ICU, base, ANIMTYPE_OBJECT);
- if (ale) {
- /* make owner the
material not object, so that indent is not just object level */
- ale->id= (ID *)ma;
- BLI_addtail(anim_data,
ale);
- items++;
- }
- }
- }
+ items += animdata_filter_ipocurves(anim_data,
ma->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ma);
}
}
+
}
/* return the number of items added to the list */
@@ -903,7 +909,6 @@
bAnimListElem *ale=NULL;
Object *ob= base->object;
Camera *ca= (Camera *)ob->data;
- IpoCurve *icu;
int items = 0;
/* include camera-expand widget? */
@@ -919,19 +924,7 @@
if ( (FILTER_CAM_OBJD(ca) || (filter_mode & ANIMFILTER_ONLYICU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
- /* loop through ipo-curve channels, adding them */
- for (icu= ca->ipo->curve.first; icu; icu=icu->next) {
- /* only if selected (if checking for selection) */
- if ( !(filter_mode & ANIMFILTER_SEL) || (SEL_ICU(icu))
) {
- ale= make_new_animlistelem(icu, ANIMTYPE_ICU,
base, ANIMTYPE_OBJECT);
- if (ale) {
- /* make owner the material not object,
so that indent is not just object level */
- ale->id= (ID *)ca;
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
- }
+ items += animdata_filter_ipocurves(anim_data, ca->ipo,
filter_mode, base, ANIMTYPE_OBJECT, (ID *)ca);
}
/* return the number of items added to the list */
@@ -943,7 +936,6 @@
bAnimListElem *ale=NULL;
Object *ob= base->object;
Lamp *la= (Lamp *)ob->data;
- IpoCurve *icu;
int items = 0;
/* include lamp-expand widget? */
@@ -959,19 +951,7 @@
if ( (FILTER_LAM_OBJD(la) || (filter_mode & ANIMFILTER_ONLYICU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
- /* loop through ipo-curve channels, adding them */
- for (icu= la->ipo->curve.first; icu; icu=icu->next) {
- /* only if selected (if checking for selection) */
- if ( !(filter_mode & ANIMFILTER_SEL) || (SEL_ICU(icu))
) {
- ale= make_new_animlistelem(icu, ANIMTYPE_ICU,
base, ANIMTYPE_OBJECT);
- if (ale) {
- /* make owner the material not object,
so that indent is not just object level */
- ale->id= (ID *)la;
- BLI_addtail(anim_data, ale);
- items++;
- }
- }
- }
+ items += animdata_filter_ipocurves(anim_data, la->ipo,
filter_mode, base, ANIMTYPE_OBJECT, (ID *)la);
}
/* return the number of items added to the list */
@@ -983,7 +963,6 @@
bAnimListElem *ale=NULL;
Object *ob= base->object;
Curve *cu= (Curve *)ob->data;
- IpoCurve *icu;
int items = 0;
/* include curve-expand widget? */
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs