Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-01-17 06:12:50 +0300
committerJoshua Leung <aligorith@gmail.com>2009-01-17 06:12:50 +0300
commit44e5b7788bcbe55400bf0d91eed0752ed865b644 (patch)
tree7b69e89ff7f93127d5691f528c5dc9bb85835ee1 /source
parent9bcdb4b758d96d1fe5345858f6c61a90f7c57eac (diff)
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future. Highlights of the new system: * Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action. - F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves. - The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc. * F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated. * Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place) * F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place) * NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still) There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details: http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html So, what currently works: * I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code. * Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock. * Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc. Notes: * Drivers haven't been hooked up yet * Only objects and data directly linked to objects can be animated. * Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change). * Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor) * I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review. In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_action.h64
-rw-r--r--source/blender/blenkernel/BKE_animsys.h34
-rw-r--r--source/blender/blenkernel/BKE_constraint.h10
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h100
-rw-r--r--source/blender/blenkernel/BKE_ipo.h4
-rw-r--r--source/blender/blenkernel/intern/action.c510
-rw-r--r--source/blender/blenkernel/intern/anim.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c549
-rw-r--r--source/blender/blenkernel/intern/armature.c3
-rw-r--r--source/blender/blenkernel/intern/constraint.c157
-rw-r--r--source/blender/blenkernel/intern/curve.c8
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c29
-rw-r--r--source/blender/blenkernel/intern/fcurve.c1492
-rw-r--r--source/blender/blenkernel/intern/ipo.c5
-rw-r--r--source/blender/blenkernel/intern/key.c74
-rw-r--r--source/blender/blenkernel/intern/lattice.c7
-rw-r--r--source/blender/blenkernel/intern/library.c6
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/object.c112
-rw-r--r--source/blender/blenkernel/intern/particle.c17
-rw-r--r--source/blender/blenkernel/intern/particle_system.c36
-rw-r--r--source/blender/blenkernel/intern/pointcache.c3
-rw-r--r--source/blender/blenkernel/intern/scene.c46
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c16
-rw-r--r--source/blender/blenkernel/intern/sequence.c22
-rw-r--r--source/blender/blenkernel/intern/texture.c11
-rw-r--r--source/blender/blenkernel/intern/world.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c8
-rw-r--r--source/blender/editors/animation/anim_filter.c48
-rw-r--r--source/blender/editors/animation/anim_ops.c5
-rw-r--r--source/blender/editors/animation/keyframes_edit.c65
-rw-r--r--source/blender/editors/animation/keyframes_general.c64
-rw-r--r--source/blender/editors/animation/keyframing.c1056
-rw-r--r--source/blender/editors/armature/editarmature.c45
-rw-r--r--source/blender/editors/armature/poselib.c15
-rw-r--r--source/blender/editors/armature/poseobject.c8
-rw-r--r--source/blender/editors/curve/editcurve.c7
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c6
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h7
-rw-r--r--source/blender/editors/include/ED_keyframing.h24
-rw-r--r--source/blender/editors/object/editconstraint.c86
-rw-r--r--source/blender/editors/object/editkey.c23
-rw-r--r--source/blender/editors/object/object_edit.c80
-rw-r--r--source/blender/editors/object/object_ops.c4
-rw-r--r--source/blender/editors/space_action/action_edit.c57
-rw-r--r--source/blender/editors/space_action/action_ops.c1
-rw-r--r--source/blender/editors/space_action/action_select.c9
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c38
-rw-r--r--source/blender/editors/space_view3d/drawobject.c46
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/transform/transform_conversions.c102
-rw-r--r--source/blender/editors/transform/transform_generics.c6
-rw-r--r--source/blender/makesdna/DNA_anim_types.h587
-rw-r--r--source/blender/makesdna/DNA_camera_types.h7
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h11
-rw-r--r--source/blender/makesdna/DNA_key_types.h4
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h6
-rw-r--r--source/blender/makesdna/DNA_material_types.h6
-rw-r--r--source/blender/makesdna/DNA_object_types.h20
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
-rw-r--r--source/blender/makesdna/DNA_texture_types.h4
-rw-r--r--source/blender/makesdna/DNA_world_types.h4
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
-rw-r--r--source/blender/render/intern/source/convertblender.c12
-rw-r--r--source/blender/render/intern/source/initrender.c2
-rw-r--r--source/blender/render/intern/source/texture.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c5
68 files changed, 4077 insertions, 1737 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 11e2b828436..444a97364ab 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -26,6 +26,7 @@
* All rights reserved.
*
* Contributor(s): Full recode, Ton Roosendaal, Crete 2005
+ * Full recode, Joshua Leung, 2009
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -36,11 +37,10 @@
#include "DNA_listBase.h"
/**
- * The following structures are defined in DNA_action_types.h
+ * The following structures are defined in DNA_action_types.h, and DNA_anim_types.h
*/
-struct bAction;
-struct bActionChannel;
+struct nAction;
struct bPose;
struct bPoseChannel;
struct Object;
@@ -52,7 +52,23 @@ struct ID;
extern "C" {
#endif
-struct bAction *add_empty_action(const char name[]);
+struct nAction *add_empty_action(const char name[]);
+
+ /**
+ * Allocate a new bAction on the heap and copy
+ * the contents of src into it. If src is NULL NULL is returned.
+ */
+
+struct nAction *copy_action(struct nAction *src);
+
+/**
+ * Deallocate the action's channels including constraint channels.
+ * does not free the action structure.
+ */
+void free_action(struct nAction *act);
+
+// XXX is this needed?
+void make_local_action(struct nAction *act);
/**
* Removes and deallocates all channels from a pose.
@@ -72,18 +88,6 @@ void free_pose(struct bPose *pose);
void copy_pose(struct bPose **dst, struct bPose *src,
int copyconstraints);
-/**
- * Deallocate the action's channels including constraint channels.
- * does not free the action structure.
- */
-void free_action(struct bAction * id);
-
-void make_local_action(struct bAction *act);
-
-/* only for armatures, doing pose actions only too */
-void do_all_pose_actions(struct Scene *scene, struct Object *);
-/* only for objects, doing only 1 channel */
-void do_all_object_actions(struct Scene *scene, struct Object *);
/**
@@ -114,13 +118,6 @@ void update_pose_constraint_flags(struct bPose *pose);
void framechange_poses_clear_unkeyed(void);
/**
- * Allocate a new bAction on the heap and copy
- * the contents of src into it. If src is NULL NULL is returned.
- */
-
-struct bAction *copy_action(struct bAction *src);
-
-/**
* Some kind of bounding box operation on the action.
*/
void calc_action_range(const struct bAction *act, float *start, float *end, int incl_hidden);
@@ -135,22 +132,6 @@ void extract_pose_from_action(struct bPose *pose, struct bAction *act, float cti
*/
void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bAction *act, float cframe);
-/**
- * Iterate through the action channels of the action
- * and return the channel with the given name.
- * Returns NULL if no channel.
- */
-struct bActionChannel *get_action_channel(struct bAction *act, const char *name);
-/**
- * Iterate through the action channels of the action
- * and return the channel with the given name.
- * Returns and adds new channel if no channel.
- */
-struct bActionChannel *verify_action_channel(struct bAction *act, const char *name);
-
- /* baking */
-struct bAction *bake_obIPO_to_action(struct Object *ob);
-
/* exported for game engine */
void blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode);
void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
@@ -164,10 +145,7 @@ void rest_pose(struct bPose *pose);
float get_action_frame(struct Object *ob, float cframe);
/* map strip time to global time (frame nr) */
float get_action_frame_inv(struct Object *ob, float cframe);
-/* builds a list of NlaIpoChannel with ipo values to write in datablock */
-void extract_ipochannels_from_action(ListBase *lb, struct ID *id, struct bAction *act, const char *name, float ctime);
-/* write values returned by extract_ipochannels_from_action, returns the number of value written */
-int execute_ipochannels(ListBase *lb);
+
/* functions used by the game engine */
void game_copy_pose(struct bPose **dst, struct bPose *src);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
new file mode 100644
index 00000000000..bdb39cd5982
--- /dev/null
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -0,0 +1,34 @@
+/* Testing code for new animation system in 2.5
+ * Copyright 2009, Joshua Leung
+ */
+
+#ifndef BKE_ANIM_SYS_H
+#define BKE_ANIM_SYS_H
+
+struct ID;
+struct ListBase;
+struct Main;
+struct AnimData;
+
+/* ************************************* */
+/* AnimData API */
+
+/* Get AnimData from the given ID-block. */
+struct AnimData *BKE_animdata_from_id(struct ID *id);
+
+/* ************************************* */
+// TODO: overrides, remapping, and path-finding api's
+
+/* ************************************* */
+/* Evaluation API */
+
+/* Evaluation loop for evaluating animation data */
+void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, float ctime, short recalc);
+
+/* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */
+void BKE_animsys_evaluate_all_animation(struct Main *main, float ctime);
+
+
+/* ************************************* */
+
+#endif /* BKE_ANIM_SYS_H*/
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 043062a2871..0d8c81a5a75 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -35,7 +35,6 @@ struct bConstraintTarget;
struct ListBase;
struct Object;
struct Scene;
-struct bConstraintChannel;
struct bPoseChannel;
/* ---------------------------------------------------------------------------- */
@@ -120,15 +119,6 @@ void free_constraint_data(struct bConstraint *con);
void extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src);
short proxylocked_constraints_owner(struct Object *ob, struct bPoseChannel *pchan);
-/* Constraint Channel function prototypes */
-struct bConstraintChannel *get_constraint_channel(struct ListBase *list, const char *name);
-struct bConstraintChannel *verify_constraint_channel(struct ListBase *list, const char *name);
-void do_constraint_channels(struct ListBase *conbase, struct ListBase *chanbase, float ctime, short onlydrivers);
-void copy_constraint_channels(struct ListBase *dst, struct ListBase *src);
-void clone_constraint_channels(struct ListBase *dst, struct ListBase *src);
-void free_constraint_channels(struct ListBase *chanbase);
-
-
/* Constraint Evaluation function prototypes */
struct bConstraintOb *constraints_make_evalob(struct Scene *scene, struct Object *ob, void *subdata, short datatype);
void constraints_clear_evalob(struct bConstraintOb *cob);
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
new file mode 100644
index 00000000000..82914cbfd59
--- /dev/null
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -0,0 +1,100 @@
+/* Testing code for new animation system in 2.5
+ * Copyright 2009, Joshua Leung
+ */
+
+#ifndef BKE_FCURVE_H
+#define BKE_FCURVE_H
+
+//struct ListBase;
+struct FCurve;
+struct FModifier;
+struct ChannelDriver;
+struct BezTriple;
+
+/* ************** Keyframe Tools ***************** */
+
+// XXX this stuff is defined in BKE_ipo.h too, so maybe skip for now?
+typedef struct CfraElem {
+ struct CfraElem *next, *prev;
+ float cfra;
+ int sel;
+} CfraElem;
+
+void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
+
+/* ************** F-Curve Drivers ***************** */
+
+void fcurve_free_driver(struct FCurve *fcu);
+
+/* ************** F-Curve Modifiers *************** */
+
+/* F-Curve Modifier Type-Info (fmi):
+ * This struct provides function pointers for runtime, so that functions can be
+ * written more generally (with fewer/no special exceptions for various modifiers).
+ *
+ * Callers of these functions must check that they actually point to something useful,
+ * as some constraints don't define some of these.
+ *
+ * Warning: it is not too advisable to reorder order of members of this struct,
+ * as you'll have to edit quite a few ($FMODIFIER_NUM_TYPES) of these
+ * structs.
+ */
+typedef struct FModifierTypeInfo {
+ /* admin/ident */
+ short type; /* FMODIFIER_TYPE_### */
+ short size; /* size in bytes of the struct */
+ char name[32]; /* name of modifier in interface */
+ char structName[32]; /* name of struct for SDNA */
+
+ /* data management function pointers - special handling */
+ /* free any data that is allocated separately (optional) */
+ void (*free_data)(struct FModifier *fcm);
+ /* copy any special data that is allocated separately (optional) */
+ void (*copy_data)(struct FModifier *fcm, struct FModifier *src);
+ /* set settings for data that will be used for FCuModifier.data (memory already allocated using MEM_callocN) */
+ void (*new_data)(void *mdata);
+
+ /* evaluation */
+ /* evaluate the modifier for the given time and 'accumulated' value */
+ void (*evaluate_modifier)(struct FCurve *fcu, struct FModifier *fcm, float *cvalue, float evaltime);
+} FModifierTypeInfo;
+
+/* Function Prototypes for FModifierTypeInfo's */
+FModifierTypeInfo *fmodifier_get_typeinfo(struct FModifier *fcm);
+FModifierTypeInfo *get_fmodifier_typeinfo(int type);
+
+/* ---------------------- */
+
+// TODO... general API here..
+struct FModifier *fcurve_add_modifier(struct FCurve *fcu, int type);
+void fcurve_copy_modifiers(ListBase *dst, ListBase *src);
+void fcurve_remove_modifier(struct FCurve *fcu, struct FModifier *fcm);
+void fcurve_free_modifiers(struct FCurve *fcu);
+void fcurve_bake_modifiers(struct FCurve *fcu, int start, int end);
+
+/* ************** F-Curves API ******************** */
+
+/* -------- Data Managemnt -------- */
+
+void free_fcurve(struct FCurve *fcu);
+struct FCurve *copy_fcurve(struct FCurve *fcu);
+
+/* find matching F-Curve in the given list of F-Curves */
+struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index);
+
+/* -------- Curve Sanity -------- */
+
+void calchandles_fcurve(struct FCurve *fcu);
+void testhandles_fcurve(struct FCurve *fcu);
+void sort_time_fcurve(struct FCurve *fcu);
+short test_time_fcurve(struct FCurve *fcu);
+
+/* -------- Evaluation -------- */
+
+/* evaluate fcurve */
+float evaluate_fcurve(struct FCurve *fcu, float evaltime);
+/* evaluate fcurve and store value */
+void calculate_fcurve(struct FCurve *fcu, float ctime);
+
+
+#endif /* BKE_FCURVE_H*/
diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h
index 21e80708113..845ff9bbb77 100644
--- a/source/blender/blenkernel/BKE_ipo.h
+++ b/source/blender/blenkernel/BKE_ipo.h
@@ -35,6 +35,8 @@
extern "C" {
#endif
+#if 0 // XXX old animation system
+
typedef struct CfraElem {
struct CfraElem *next, *prev;
float cfra;
@@ -145,6 +147,8 @@ void clear_delta_obipo(struct Ipo *ipo);
short IPO_GetChannels(struct Ipo *ipo, short *channels);
float IPO_GetFloatValue(struct Ipo *ipo, short c, float ctime);
+#endif // XXX old animation system
+
#ifdef __cplusplus
};
#endif
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 06597c983ca..d468daef52a 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -35,11 +35,11 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_nla_types.h"
#include "DNA_object_types.h"
@@ -52,7 +52,7 @@
#include "BKE_constraint.h"
#include "BKE_displist.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -81,63 +81,34 @@
/* ***************** Library data level operations on action ************** */
-bAction *add_empty_action(const char name[])
+nAction *add_empty_action(const char name[])
{
- bAction *act;
+ nAction *act;
act= alloc_libblock(&G.main->action, ID_AC, name);
- act->id.flag |= LIB_FAKEUSER;
+ act->id.flag |= LIB_FAKEUSER; // XXX this is nasty for new users... maybe we don't want this anymore
act->id.us++;
return act;
}
-static void make_local_action_channels(bAction *act)
-{
- bActionChannel *chan;
- bConstraintChannel *conchan;
-
- for (chan=act->chanbase.first; chan; chan=chan->next) {
- if(chan->ipo) {
- if(chan->ipo->id.us==1) {
- chan->ipo->id.lib= NULL;
- chan->ipo->id.flag= LIB_LOCAL;
- new_id(0, (ID *)chan->ipo, 0);
- }
- else {
- chan->ipo= copy_ipo(chan->ipo);
- }
- }
- for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) {
- if(conchan->ipo) {
- if(conchan->ipo->id.us==1) {
- conchan->ipo->id.lib= NULL;
- conchan->ipo->id.flag= LIB_LOCAL;
- new_id(0, (ID *)conchan->ipo, 0);
- }
- else {
- conchan->ipo= copy_ipo(conchan->ipo);
- }
- }
- }
- }
-}
-
-void make_local_action(bAction *act)
+// does copy_fcurve...
+void make_local_action(nAction *act)
{
Object *ob;
- bAction *actn;
+ nAction *actn;
int local=0, lib=0;
- if(act->id.lib==0) return;
- if(act->id.us==1) {
+ if (act->id.lib==0) return;
+ if (act->id.us==1) {
act->id.lib= 0;
act->id.flag= LIB_LOCAL;
- make_local_action_channels(act);
+ //make_local_action_channels(act);
new_id(0, (ID *)act, 0);
return;
}
+#if 0 // XXX old animation system
ob= G.main->object.first;
while(ob) {
if(ob->action==act) {
@@ -146,17 +117,19 @@ void make_local_action(bAction *act)
}
ob= ob->id.next;
}
+#endif
if(local && lib==0) {
act->id.lib= 0;
act->id.flag= LIB_LOCAL;
- make_local_action_channels(act);
+ //make_local_action_channels(act);
new_id(0, (ID *)act, 0);
}
else if(local && lib) {
actn= copy_action(act);
actn->id.us= 0;
+#if 0 // XXX old animation system
ob= G.main->object.first;
while(ob) {
if(ob->action==act) {
@@ -169,24 +142,25 @@ void make_local_action(bAction *act)
}
ob= ob->id.next;
}
+#endif // XXX old animation system
}
}
-void free_action (bAction *act)
+void free_action (nAction *act)
{
- bActionChannel *chan;
+ FCurve *fcu, *fcn;
+
+ /* sanity check */
+ if (act == NULL)
+ return;
- /* Free channels */
- for (chan=act->chanbase.first; chan; chan=chan->next) {
- if (chan->ipo)
- chan->ipo->id.us--;
- free_constraint_channels(&chan->constraintChannels);
+ /* Free F-Curves */
+ for (fcu= act->curves.first; fcu; fcu= fcn) {
+ fcn= fcu->next;
+ free_fcurve(fcu);
}
- if (act->chanbase.first)
- BLI_freelistN(&act->chanbase);
-
/* Free groups */
if (act->groups.first)
BLI_freelistN(&act->groups);
@@ -196,10 +170,10 @@ void free_action (bAction *act)
BLI_freelistN(&act->markers);
}
-bAction *copy_action (bAction *src)
+nAction *copy_action (nAction *src)
{
- bAction *dst = NULL;
- bActionChannel *dchan, *schan;
+ nAction *dst = NULL;
+ //bActionChannel *dchan, *schan;
bActionGroup *dgrp, *sgrp;
if (!src) return NULL;
@@ -210,6 +184,7 @@ bAction *copy_action (bAction *src)
BLI_duplicatelist(&(dst->groups), &(src->groups));
BLI_duplicatelist(&(dst->markers), &(src->markers));
+#if 0 // XXX old animation system
for (dchan=dst->chanbase.first, schan=src->chanbase.first; dchan; dchan=dchan->next, schan=schan->next) {
for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && sgrp; dgrp=dgrp->next, sgrp=sgrp->next) {
if (dchan->grp == sgrp) {
@@ -227,8 +202,9 @@ bAction *copy_action (bAction *src)
dchan->ipo = copy_ipo(dchan->ipo);
copy_constraint_channels(&dchan->constraintChannels, &schan->constraintChannels);
}
+#endif // XXX old animation system
- dst->id.flag |= LIB_FAKEUSER;
+ dst->id.flag |= LIB_FAKEUSER; // XXX this is nasty for new users... maybe we don't want this anymore
dst->id.us++;
return dst;
@@ -284,7 +260,7 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name)
Mat4One(chan->constinv);
- BLI_addtail (&pose->chanbase, chan);
+ BLI_addtail(&pose->chanbase, chan);
return chan;
}
@@ -528,53 +504,24 @@ void framechange_poses_clear_unkeyed(void)
/* ************************ END Pose channels *************** */
-/* ************************ Action channels *************** */
-
-
-bActionChannel *get_action_channel(bAction *act, const char *name)
-{
- bActionChannel *chan;
-
- if (!act || !name)
- return NULL;
-
- for (chan = act->chanbase.first; chan; chan=chan->next) {
- if (!strcmp (chan->name, name))
- return chan;
- }
-
- return NULL;
-}
-
-/* returns existing channel, or adds new one. In latter case it doesnt activate it, context is required for that */
-bActionChannel *verify_action_channel(bAction *act, const char *name)
-{
- bActionChannel *chan;
-
- chan= get_action_channel(act, name);
- if (chan == NULL) {
- chan = MEM_callocN (sizeof(bActionChannel), "actionChannel");
- strncpy(chan->name, name, 31);
- BLI_addtail(&act->chanbase, chan);
- }
- return chan;
-}
-
/* ************** time ****************** */
static bActionStrip *get_active_strip(Object *ob)
{
+#if 0 // XXX old animation system
bActionStrip *strip;
if(ob->action==NULL)
return NULL;
-
+
for (strip=ob->nlastrips.first; strip; strip=strip->next)
if(strip->flag & ACTSTRIP_ACTIVE)
break;
if(strip && strip->act==ob->action)
return strip;
+#endif // XXX old animation system
+
return NULL;
}
@@ -621,6 +568,174 @@ float get_action_frame_inv(Object *ob, float cframe)
}
+
+
+/* Calculate the extents of given action */
+void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden)
+{
+ FCurve *fcu;
+ float min=999999999.0f, max=-999999999.0f;
+ int foundvert=0;
+
+ if (act) {
+#if 0 // XXX old animation system
+ for (chan=act->chanbase.first; chan; chan=chan->next) {
+ if ((incl_hidden) || (chan->flag & ACHAN_HIDDEN)==0) {
+ if (chan->ipo) {
+ for (icu=chan->ipo->curve.first; icu; icu=icu->next) {
+ if (icu->totvert) {
+ min= MIN2(min, icu->bezt[0].vec[1][0]);
+ max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
+ foundvert=1;
+ }
+ }
+ }
+ for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) {
+ if (conchan->ipo) {
+ for (icu=conchan->ipo->curve.first; icu; icu=icu->next) {
+ if (icu->totvert) {
+ min= MIN2(min, icu->bezt[0].vec[1][0]);
+ max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
+ foundvert=1;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif // XXX old animation system
+ }
+ if (foundvert) {
+ if(min==max) max+= 1.0f;
+ *start= min;
+ *end= max;
+ }
+ else {
+ *start= 0.0f;
+ *end= 1.0f;
+ }
+}
+
+/* Copy the data from the action-pose (src) into the pose */
+/* both args are assumed to be valid */
+/* exported to game engine */
+void extract_pose_from_pose(bPose *pose, const bPose *src)
+{
+ const bPoseChannel *schan;
+ bPoseChannel *pchan= pose->chanbase.first;
+
+ if (pose==src) {
+ printf("extract_pose_from_pose source and target are the same\n");
+ return;
+ }
+
+ for (schan=src->chanbase.first; schan; schan=schan->next, pchan= pchan->next) {
+ copy_pose_channel_data(pchan, schan);
+ }
+}
+
+/* Pose should exist, can have any number of channels too (used for constraint) */
+void extract_pose_from_action(bPose *pose, bAction *act, float ctime)
+{
+#if 0 // XXX old animation system
+ bActionChannel *achan;
+ bPoseChannel *pchan;
+ Ipo *ipo;
+
+ if (!act)
+ return;
+ if (!pose)
+ return;
+
+ /* Copy the data from the action into the pose */
+ for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) {
+ /* skip this pose channel if it has been tagged as having unkeyed poses */
+ if ((pchan->bone) && (pchan->bone->flag & BONE_UNKEYED))
+ continue;
+
+ /* get action channel and clear pchan-transform flags */
+ achan= get_action_channel(act, pchan->name);
+ pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
+
+ if (achan) {
+ ipo = achan->ipo;
+ if (ipo) {
+ /* Evaluates and sets the internal ipo value */
+ calc_ipo(ipo, ctime);
+ /* This call also sets the pchan flags */
+ execute_action_ipo(achan, pchan);
+ }
+ /* 0 = do all ipos, not only drivers */
+ do_constraint_channels(&pchan->constraints, &achan->constraintChannels, ctime, 0);
+ }
+ }
+#endif // XXX old animation system
+
+ pose->ctime= ctime; /* used for cyclic offset matching */
+}
+
+/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
+void rest_pose(bPose *pose)
+{
+ bPoseChannel *pchan;
+ int i;
+
+ if (!pose)
+ return;
+
+ memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
+ memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
+
+ for (pchan=pose->chanbase.first; pchan; pchan= pchan->next){
+ for (i=0; i<3; i++) {
+ pchan->loc[i]= 0.0f;
+ pchan->quat[i+1]= 0.0f;
+ pchan->eul[i]= 0.0f;
+ pchan->size[i]= 1.0f;
+ }
+ pchan->quat[0]= 1.0f;
+
+ pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
+ }
+}
+
+/* both poses should be in sync */
+void copy_pose_result(bPose *to, bPose *from)
+{
+ bPoseChannel *pchanto, *pchanfrom;
+
+ if(to==NULL || from==NULL) {
+ printf("pose result copy error\n"); // debug temp
+ return;
+ }
+
+ if (to==from) {
+ printf("copy_pose_result source and target are the same\n");
+ return;
+ }
+
+
+ for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
+ pchanto= get_pose_channel(to, pchanfrom->name);
+ if(pchanto) {
+ Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat);
+ Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat);
+ /* used for local constraints */
+ VECCOPY(pchanto->loc, pchanfrom->loc);
+ QUATCOPY(pchanto->quat, pchanfrom->quat);
+ VECCOPY(pchanto->size, pchanfrom->size);
+
+ VECCOPY(pchanto->pose_head, pchanfrom->pose_head);
+ VECCOPY(pchanto->pose_tail, pchanfrom->pose_tail);
+ pchanto->flag= pchanfrom->flag;
+ }
+ }
+}
+
+/* ********** NLA with non-poses works with ipo channels ********** */
+
+#if 0 // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
+
/* ************************ Blending with NLA *************** */
static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mode)
@@ -790,168 +905,6 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
dst->ctime= src->ctime;
}
-/* Calculate the extents of given action */
-void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden)
-{
- bActionChannel *chan;
- bConstraintChannel *conchan;
- IpoCurve *icu;
- float min=999999999.0f, max=-999999999.0f;
- int foundvert=0;
-
- if (act) {
- for (chan=act->chanbase.first; chan; chan=chan->next) {
- if ((incl_hidden) || (chan->flag & ACHAN_HIDDEN)==0) {
- if (chan->ipo) {
- for (icu=chan->ipo->curve.first; icu; icu=icu->next) {
- if (icu->totvert) {
- min= MIN2(min, icu->bezt[0].vec[1][0]);
- max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
- foundvert=1;
- }
- }
- }
- for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) {
- if (conchan->ipo) {
- for (icu=conchan->ipo->curve.first; icu; icu=icu->next) {
- if (icu->totvert) {
- min= MIN2(min, icu->bezt[0].vec[1][0]);
- max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
- foundvert=1;
- }
- }
- }
- }
- }
- }
- }
- if (foundvert) {
- if(min==max) max+= 1.0f;
- *start= min;
- *end= max;
- }
- else {
- *start= 0.0f;
- *end= 1.0f;
- }
-}
-
-/* Copy the data from the action-pose (src) into the pose */
-/* both args are assumed to be valid */
-/* exported to game engine */
-void extract_pose_from_pose(bPose *pose, const bPose *src)
-{
- const bPoseChannel *schan;
- bPoseChannel *pchan= pose->chanbase.first;
-
- if (pose==src) {
- printf("extract_pose_from_pose source and target are the same\n");
- return;
- }
-
- for (schan=src->chanbase.first; schan; schan=schan->next, pchan= pchan->next) {
- copy_pose_channel_data(pchan, schan);
- }
-}
-
-/* Pose should exist, can have any number of channels too (used for constraint) */
-void extract_pose_from_action(bPose *pose, bAction *act, float ctime)
-{
- bActionChannel *achan;
- bPoseChannel *pchan;
- Ipo *ipo;
-
- if (!act)
- return;
- if (!pose)
- return;
-
- /* Copy the data from the action into the pose */
- for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) {
- /* skip this pose channel if it has been tagged as having unkeyed poses */
- if ((pchan->bone) && (pchan->bone->flag & BONE_UNKEYED))
- continue;
-
- /* get action channel and clear pchan-transform flags */
- achan= get_action_channel(act, pchan->name);
- pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
-
- if (achan) {
- ipo = achan->ipo;
- if (ipo) {
- /* Evaluates and sets the internal ipo value */
- calc_ipo(ipo, ctime);
- /* This call also sets the pchan flags */
- execute_action_ipo(achan, pchan);
- }
- /* 0 = do all ipos, not only drivers */
- do_constraint_channels(&pchan->constraints, &achan->constraintChannels, ctime, 0);
- }
- }
-
- pose->ctime= ctime; /* used for cyclic offset matching */
-}
-
-/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
-void rest_pose(bPose *pose)
-{
- bPoseChannel *pchan;
- int i;
-
- if (!pose)
- return;
-
- memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
- memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
-
- for (pchan=pose->chanbase.first; pchan; pchan= pchan->next){
- for (i=0; i<3; i++) {
- pchan->loc[i]= 0.0f;
- pchan->quat[i+1]= 0.0f;
- pchan->eul[i]= 0.0f;
- pchan->size[i]= 1.0f;
- }
- pchan->quat[0]= 1.0f;
-
- pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
- }
-}
-
-/* both poses should be in sync */
-void copy_pose_result(bPose *to, bPose *from)
-{
- bPoseChannel *pchanto, *pchanfrom;
-
- if(to==NULL || from==NULL) {
- printf("pose result copy error\n"); // debug temp
- return;
- }
-
- if (to==from) {
- printf("copy_pose_result source and target are the same\n");
- return;
- }
-
-
- for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
- pchanto= get_pose_channel(to, pchanfrom->name);
- if(pchanto) {
- Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat);
- Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat);
- /* used for local constraints */
- VECCOPY(pchanto->loc, pchanfrom->loc);
- QUATCOPY(pchanto->quat, pchanfrom->quat);
- VECCOPY(pchanto->size, pchanfrom->size);
-
- VECCOPY(pchanto->pose_head, pchanfrom->pose_head);
- VECCOPY(pchanto->pose_tail, pchanfrom->pose_tail);
- pchanto->flag= pchanfrom->flag;
- }
- }
-}
-
-/* ********** NLA with non-poses works with ipo channels ********** */
-
typedef struct NlaIpoChannel {
struct NlaIpoChannel *next, *prev;
float val;
@@ -1490,55 +1443,4 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
BLI_freelistN(&chanbase);
}
-void do_all_pose_actions(Scene *scene, Object *ob)
-{
- /* only to have safe calls from editor */
- if(ELEM(NULL, scene, ob)) return;
- if((ob->type!=OB_ARMATURE) || (ob->pose==NULL)) return;
-
- if(ob->pose->flag & POSE_LOCKED) { /* no actions to execute while transform */
- if(ob->pose->flag & POSE_DO_UNLOCK)
- ob->pose->flag &= ~(POSE_LOCKED|POSE_DO_UNLOCK);
- }
- else if( (ob->action) && ((ob->nlaflag & OB_NLA_OVERRIDE)==0 || (ob->nlastrips.first==NULL)) ) {
- float cframe= (float) scene->r.cfra;
-
- cframe= get_action_frame(ob, cframe);
-
- extract_pose_from_action(ob->pose, ob->action, bsystem_time(scene, ob, cframe, 0.0));
- }
- else if(ob->nlastrips.first) {
- do_nla(scene, ob, ID_AR);
- }
-
- /* clear POSE_DO_UNLOCK flags that might have slipped through (just in case) */
- ob->pose->flag &= ~POSE_DO_UNLOCK;
-}
-
-/* called from where_is_object */
-void do_all_object_actions(Scene *scene, Object *ob)
-{
- if(ob==NULL) return;
- if(ob->dup_group) return; /* prevent conflicts, might add smarter check later */
-
- /* Do local action */
- if(ob->action && ((ob->nlaflag & OB_NLA_OVERRIDE)==0 || ob->nlastrips.first==NULL) ) {
- ListBase tchanbase= {NULL, NULL};
- Key *key= ob_get_key(ob);
- float cframe= (float) scene->r.cfra;
-
- cframe= get_action_frame(ob, cframe);
-
- extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(scene, ob, cframe, 0.0));
- if(key)
- extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(scene, ob, cframe, 0.0));
-
- if(tchanbase.first) {
- execute_ipochannels(&tchanbase);
- BLI_freelistN(&tchanbase);
- }
- }
- else if(ob->nlastrips.first) {
- do_nla(scene, ob, ID_OB);
- }
-}
+#endif // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 6a6d8c46f9e..e9d0fc7c95a 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -368,7 +368,9 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
else ok= 0;
}
if(ok) {
+#if 0 // XXX old animation system
do_ob_ipo(scene, ob);
+#endif // XXX old animation system
where_is_object_time(scene, ob, (float)scene->r.cfra);
dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
Mat4CpyMat4(dob->omat, copyob.obmat);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
new file mode 100644
index 00000000000..d377ce044fd
--- /dev/null
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -0,0 +1,549 @@
+/* Testing code for new animation system in 2.5
+ * Copyright 2009, Joshua Leung
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_dynstr.h"
+
+#include "BKE_animsys.h"
+#include "BKE_fcurve.h"
+#include "BKE_main.h"
+#include "BKE_utildefines.h"
+
+#include "RNA_access.h"
+#include "RNA_types.h"
+
+#include "DNA_anim_types.h"
+
+/* ***************************************** */
+/* AnimData API */
+
+/* Get AnimData from the given ID-block. In order for this to work, we assume that
+ * the AnimData block is stored immediately after the given ID-block in the struct,
+ * as per IdAdtTemplate.
+ */
+AnimData *BKE_animdata_from_id (ID *id)
+{
+ /* sanity check */
+ if (id == NULL)
+ return NULL;
+
+ /* only some ID-blocks have this info for now, so we cast the
+ * types that do to be of type IdAdtTemplate, and extract the
+ * animdata that way
+ */
+ // TODO: finish adding this for the other blocktypes
+ switch (GS(id->name)) {
+ case ID_OB:
+ case ID_KE:
+ case ID_MA: case ID_TE:
+ case ID_LA: case ID_CA: case ID_WO:
+ case ID_SCE:
+ {
+ IdAdtTemplate *iat= (IdAdtTemplate *)id;
+ return &(iat->adt);
+ }
+ break;
+ }
+
+ /* no AnimData (ID-block does not contain this data) */
+ return NULL;
+}
+
+/* Obtain an RNA-Path from the given ID-block to the property of interest
+ * - id: ID block that will be used as the 'root' of the path
+ * - ptr: pointer to struct where setting is stored
+ * - prop: property to get path for
+ */
+// TODO: should this be part of RNA Access API instead? or through editors only?
+char *BKE_animsys_get_rnapath (ID *id, PointerRNA *ptr, PropertyRNA *prop)
+{
+ // FIXME: this could be quite messy to do right :/
+ return NULL;
+}
+
+/* ***************************************** */
+/* Evaluation Data-Setting Backend */
+
+/* Retrieve string to act as RNA-path, adjusted using mapping-table if provided
+ * It returns whether the string needs to be freed (i.e. if it was a temp remapped one)
+ * // FIXME: maybe it would be faster if we didn't have to alloc/free strings like this all the time, but for now it's safer
+ *
+ * - remap: remapping table to use
+ * - path: original path string (as stored in F-Curve data)
+ * - dst: destination string to write data to
+ */
+short animsys_remap_path (AnimMapper *remap, char *path, char **dst)
+{
+ /* is there a valid remapping table to use? */
+ if (remap) {
+ /* find a matching entry... to use to remap */
+ // ...TODO...
+ }
+
+ /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */
+ *dst= path;
+ return 0;
+}
+
+
+/* Write the given value to a setting using RNA */
+static void animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
+{
+ PropertyRNA *prop;
+ PointerRNA new_ptr;
+
+ /* get property to write to */
+ if (RNA_path_resolve(ptr, path, &new_ptr, &prop))
+ {
+ /* set value - only for animatable numerical values */
+ // FIXME: probably 'editable' might not be enough in future...
+ if (RNA_property_editable(&new_ptr, prop))
+ {
+ switch (RNA_property_type(&new_ptr, prop))
+ {
+ case PROP_BOOLEAN:
+ if (RNA_property_array_length(&new_ptr, prop))
+ RNA_property_boolean_set_array(&new_ptr, prop, array_index, (int)value);
+ else
+ RNA_property_boolean_set(&new_ptr, prop, (int)value);
+ break;
+ case PROP_INT:
+ if (RNA_property_array_length(&new_ptr, prop))
+ RNA_property_int_set_array(&new_ptr, prop, array_index, (int)value);
+ else
+ RNA_property_int_set(&new_ptr, prop, (int)value);
+ break;
+ case PROP_FLOAT:
+ if (RNA_property_array_length(&new_ptr, prop))
+ RNA_property_float_set_array(&new_ptr, prop, array_index, value);
+ else
+ RNA_property_float_set(&new_ptr, prop, value);
+ break;
+ case PROP_ENUM:
+ RNA_property_enum_set(&new_ptr, prop, (int)value);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+/* Simple replacement based data-setting of the FCurve using RNA */
+static void animsys_execute_fcurve (PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
+{
+ char *path = NULL;
+ short free_path=0;
+
+ /* get path, remapped as appropriate to work in its new environment */
+ free_path= animsys_remap_path(remap, fcu->rna_path, &path);
+
+ /* write value to setting */
+ animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
+
+ /* free temp path-info */
+ if (free_path)
+ MEM_freeN(path);
+}
+
+/* Evaluate all the F-Curves in the given list
+ * This performs a set of standard checks. If extra checks are required, separate code should be used
+ */
+static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
+{
+ FCurve *fcu;
+
+ /* calculate then execute each curve */
+ for (fcu= list->first; fcu; fcu= fcu->next)
+ {
+ /* check if this curve should be skipped */
+ if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
+ {
+ calculate_fcurve(fcu, ctime);
+ animsys_execute_fcurve(ptr, remap, fcu);
+ }
+ }
+}
+
+/* ***************************************** */
+/* Driver Evaluation */
+
+/* Evaluate Drivers */
+static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctime)
+{
+ FCurve *fcu;
+
+ /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
+ * the depsgraph requested that this driver be evaluated...
+ */
+ for (fcu= adt->drivers.first; fcu; fcu= fcu->next)
+ {
+ ChannelDriver *driver= fcu->driver;
+
+ /* check if this driver's curve should be skipped */
+ // FIXME: maybe we shouldn't check for muted, though that would make things more confusing, as there's already too many ways to disable?
+ if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
+ {
+ /* check if driver itself is tagged for recalculation */
+ if ((driver) && (driver->flag & DRIVER_FLAG_RECALC)) {
+ /* evaluate this using values set already in other places */
+ // NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
+ calculate_fcurve(fcu, ctime);
+ animsys_execute_fcurve(ptr, NULL, fcu);
+
+ /* clear recalc flag */
+ driver->flag &= ~DRIVER_FLAG_RECALC;
+ }
+ }
+ }
+}
+
+/* ***************************************** */
+/* Actions Evaluation */
+
+/* Evaluate Action (F-Curve Bag) */
+static void animsys_evaluate_action (PointerRNA *ptr, nAction *act, AnimMapper *remap, float ctime)
+{
+ /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
+ if (act == NULL) return;
+ if ((remap) && (remap->target != act)) remap= NULL;
+
+ /* calculate then execute each curve */
+ animsys_evaluate_fcurves(ptr, &act->curves, remap, ctime);
+}
+
+/* ***************************************** */
+/* NLA System - Evaluation */
+
+/* used for list of strips to accumulate at current time */
+typedef struct NlaEvalStrip {
+ struct NlaEvalStrip *next, *prev;
+
+ NlaTrack *track; /* track that this strip belongs to */
+ NlaStrip *strip; /* strip that's being used */
+ NlaStrip *sblend; /* strip that's being blended towards (if applicable) */
+
+ short track_index; /* the index of the track within the list */
+ short strip_mode; /* which end of the strip are we looking at */
+} NlaEvalStrip;
+
+/* bNlaEvalStrip->strip_mode */
+enum {
+ NES_TIME_BEFORE = -1,
+ NES_TIME_WITHIN,
+ NES_TIME_AFTER,
+ NES_TIME_AFTER_BLEND
+} eNlaEvalStrip_StripMode;
+
+
+/* temp channel for accumulating data from NLA (avoids needing to clear all values first) */
+// TODO: maybe this will be used as the 'cache' stuff needed for editable values too?
+typedef struct NlaEvalChannel {
+ struct NlaEvalChannel *next, *prev;
+
+ char *path; /* ready-to-use path (i.e. remapped already) */
+ int array_index; /* if applicable... */
+
+ float value; /* value of this channel */
+} NlaEvalChannel;
+
+
+/* ---------------------- */
+
+/* evaluate the F-Curves controlling settings for the NLA-strips (currently, not relinkable) */
+static void nlastrip_evaluate_fcurves (NlaStrip *strip, float ctime)
+{
+ //PointerRNA actstrip_ptr;
+ //FCurve *fcu;
+
+ /* create RNA-pointer needed to set values */
+ //RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &actstrip_ptr);
+
+ /* execute these settings as per normal */
+ //animsys_evaluate_fcurves(&actstrip_ptr, &strip->fcurves, NULL, ctime);
+}
+
+
+/* gets the strip active at the current time for a track */
+static void nlatrack_ctime_get_strip (ListBase *list, NlaTrack *nlt, short index, float ctime)
+{
+ NlaStrip *strip, *astrip=NULL, *bstrip=NULL;
+ NlaEvalStrip *nes;
+ short side= 0;
+
+ /* skip if track is muted */
+ if (nlt->flag & NLATRACK_MUTED)
+ return;
+
+ /* loop over strips, checking if they fall within the range */
+ for (strip= nlt->strips.first; strip; strip= strip->next) {
+ /* only consider if:
+ * - current time occurs within strip's extents
+ * - current time occurs before strip (if it is the first)
+ * - current time occurs after strip (if hold is on)
+ * - current time occurs between strips (1st of those isn't holding) - blend!
+ */
+ if (IN_RANGE(ctime, strip->start, strip->end)) {
+ astrip= strip;
+ side= NES_TIME_WITHIN;
+ break;
+ }
+ else if (ctime < strip->start) {
+ if (strip == nlt->strips.first) {
+ astrip= strip;
+ side= NES_TIME_BEFORE;
+ break;
+ }
+ else {
+ astrip= strip->prev;
+
+ if (astrip->flag & NLASTRIP_HOLDLASTFRAME) {
+ side= NES_TIME_AFTER;
+ break;
+ }
+ else {
+ bstrip= strip;
+ side= NES_TIME_AFTER_BLEND;
+ break;
+ }
+ }
+ }
+ }
+
+ /* check if strip has been found (and whether it has data worth considering) */
+ if (ELEM(NULL, astrip, astrip->act))
+ return;
+ if (astrip->flag & NLASTRIP_MUTE)
+ return;
+
+ /* check if blending between strips */
+ if (side == NES_TIME_AFTER_BLEND) {
+ /* blending between strips... so calculate influence+act_time of both */
+ nlastrip_evaluate_fcurves(astrip, ctime);
+ nlastrip_evaluate_fcurves(bstrip, ctime);
+
+ if ((astrip->influence <= 0.0f) && (bstrip->influence <= 0.0f))
+ return;
+ }
+ else {
+ /* calculate/set the influence+act_time of this strip - don't consider if 0 influence */
+ nlastrip_evaluate_fcurves(astrip, ctime);
+
+ if (astrip->influence <= 0.0f)
+ return;
+ }
+
+
+ /* allocate new eval-strip for this strip + add to stack */
+ nes= MEM_callocN(sizeof(NlaEvalStrip), "bNlaEvalStrip");
+
+ nes->track= nlt;
+ nes->strip= astrip;
+ nes->sblend= bstrip;
+ nes->track_index= index;
+ nes->strip_mode= side;
+
+ BLI_addtail(list, nes);
+}
+
+/* ---------------------- */
+
+/* evaluates the given evaluation strip */
+// FIXME: will we need the evaluation cache table set up to blend stuff in?
+// TODO: only evaluate here, but flush in one go using the accumulated channels at end...
+static void nlastrip_ctime_evaluate (ListBase *channels, NlaEvalStrip *nes, float ctime)
+{
+ // 1. (in old code) was to extract 'IPO-channels' from actions
+ // 2. blend between the 'accumulated' data, and the new data
+}
+
+/* write the accumulated settings to */
+static void nladata_flush_channels (PointerRNA *ptr, ListBase *channels)
+{
+
+}
+
+/* ---------------------- */
+
+/* NLA Evaluation function (mostly for use through do_animdata)
+ * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
+ * some temp channels, where values can be accumulated in one go.
+ */
+static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
+{
+ NlaTrack *nlt;
+ short track_index=0;
+
+ ListBase estrips= {NULL, NULL};
+ ListBase echannels= {NULL, NULL};
+ NlaEvalStrip *nes;
+
+ /* 1. get the stack of strips to evaluate at current time (influence calculated here) */
+ for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++)
+ nlatrack_ctime_get_strip(&estrips, nlt, track_index, ctime);
+
+ /* only continue if there are strips to evaluate */
+ if (estrips.first == NULL)
+ return;
+
+
+ /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
+ for (nes= estrips.first; nes; nes= nes->next)
+ nlastrip_ctime_evaluate(&echannels, nes, ctime);
+
+ /* 3. flush effects of accumulating channels in NLA to the actual data they affect */
+ nladata_flush_channels(ptr, &echannels);
+
+ /* 4. free temporary evaluation data */
+ BLI_freelistN(&estrips);
+ BLI_freelistN(&echannels);
+}
+
+/* ***************************************** */
+/* Overrides System - Public API */
+
+/* Clear all overides */
+
+/* Add or get existing Override for given setting */
+AnimOverride *BKE_animsys_validate_override (PointerRNA *ptr, char *path, int array_index)
+{
+ // FIXME: need to define how to get overrides
+ return NULL;
+}
+
+/* -------------------- */
+
+/* Evaluate Overrides */
+static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt, float ctime)
+{
+ AnimOverride *aor;
+
+ /* for each override, simply execute... */
+ for (aor= adt->overrides.first; aor; aor= aor->next)
+ animsys_write_rna_setting(ptr, aor->rna_path, aor->array_index, aor->value);
+}
+
+/* ***************************************** */
+/* Evaluation System - Public API */
+
+/* Overview of how this system works:
+ * 1) Depsgraph sorts data as necessary, so that data is in an order that means
+ * that all dependences are resolved before dependants.
+ * 2) All normal animation is evaluated, so that drivers have some basis values to
+ * work with
+ * a. NLA stacks are done first, as the Active Actions act as 'tweaking' tracks
+ * which modify the effects of the NLA-stacks
+ * b. Active Action is evaluated as per normal, on top of the results of the NLA tracks
+ *
+ * --------------< often in a separate phase... >------------------
+ *
+ * 3) Drivers/expressions are evaluated on top of this, in an order where dependences are
+ * resolved nicely.
+ * Note: it may be necessary to have some tools to handle the cases where some higher-level
+ * drivers are added and cause some problematic dependencies that didn't exist in the local levels...
+ *
+ * --------------< always executed >------------------
+ *
+ * Maintainance of editability of settings (XXX):
+ * In order to ensure that settings that are animated can still be manipulated in the UI without requiring
+ * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
+ *
+ * Unresolved things:
+ * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids or nodal system? but stored where?
+ * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
+ */
+
+/* Evaluation loop for evaluation animation data
+ *
+ * This assumes that the animation-data provided belongs to the ID block in question,
+ * and that the flags for which parts of the anim-data settings need to be recalculated
+ * have been set already by the depsgraph. Now, we use the recalc
+ */
+void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short recalc)
+{
+ PointerRNA id_ptr;
+
+ /* sanity checks */
+ if ELEM(NULL, id, adt)
+ return;
+
+ /* get pointer to ID-block for RNA to use */
+ RNA_id_pointer_create(id, &id_ptr);
+
+ /* recalculate keyframe data:
+ * - NLA before Active Action, as Active Action behaves as 'tweaking track'
+ * that overrides 'rough' work in NLA
+ */
+ if ((recalc & ADT_RECALC_ANIM) /*|| (adt->recalc & ADT_RECALC_ANIM)*/) // XXX for now,don't check yet, as depsgraph doesn't know this yet
+ {
+ /* evaluate NLA data */
+ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
+ {
+ animsys_evaluate_nla(&id_ptr, adt, ctime);
+ }
+
+ /* evaluate Action data */
+ // FIXME: what if the solo track was not tweaking one, then nla-solo should be checked too?
+ if (adt->action)
+ animsys_evaluate_action(&id_ptr, adt->action, adt->remap, ctime);
+ }
+
+ /* recalculate drivers
+ * - Drivers need to be evaluated afterwards, as they can either override
+ * or be layered on top of existing animation data.
+ * - Drivers should be in the appropriate order to be evaluated without problems...
+ */
+ if ((recalc & ADT_RECALC_DRIVERS) && (adt->recalc & ADT_RECALC_DRIVERS))
+ {
+ animsys_evaluate_drivers(&id_ptr, adt, ctime);
+ }
+
+ /* always execute 'overrides'
+ * - Overrides allow editing, by overwriting the value(s) set from animation-data, with the
+ * value last set by the user (and not keyframed yet).
+ * - Overrides are cleared upon frame change and/or keyframing
+ * - It is best that we execute this everytime, so that no errors are likely to occur.
+ */
+ animsys_evaluate_overrides(&id_ptr, adt, ctime);
+
+ /* clear recalc flag now */
+ adt->recalc= 0;
+}
+
+/* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only
+ *
+ * This will evaluate only the animation info available in the animation data-blocks
+ * encountered. In order to enforce the system by which some settings controlled by a
+ * 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a
+ * standard 'root') block are overridden by a larger 'user'
+ */
+// TODO: we currently go over entire 'main' database...
+void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
+{
+ ID *id;
+
+ //printf("Evaluate all animation - %f \n", ctime);
+
+ /* cameras */
+
+ /* textures */
+
+ /* lamps */
+
+ /* materials */
+
+ /* objects */
+ for (id= main->object.first; id; id= id->next) {
+ IdAdtTemplate *iat= (IdAdtTemplate *)id;
+ BKE_animsys_evaluate_animdata(id, &iat->adt, ctime, ADT_RECALC_ANIM);
+ }
+}
+
+/* ***************************************** */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 65225471d0f..d256e8dc8e7 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2231,9 +2231,6 @@ static void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, fl
if (pchan->constraints.first) {
bConstraintOb *cob;
- /* local constraints */
- do_constraint_channels(&pchan->constraints, NULL, ctime, 0);
-
/* make a copy of location of PoseChannel for later */
VECCOPY(vec, pchan->pose_mat[3]);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index f83428766f9..f5613a34700 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -80,157 +80,6 @@
#endif
-/* ******************* Constraint Channels ********************** */
-/* Constraint Channels exist in one of two places:
- * - Under Action Channels in an Action (act->chanbase->achan->constraintChannels)
- * - Under Object without Object-level Action yet (ob->constraintChannels)
- *
- * The main purpose that Constraint Channels serve is to act as a link
- * between an IPO-block (which provides values to interpolate between for some settings)
- */
-
-/* ------------ Data Management ----------- */
-
-/* Free constraint channels, and reduce the number of users of the related ipo-blocks */
-void free_constraint_channels (ListBase *chanbase)
-{
- bConstraintChannel *chan;
-
- for (chan=chanbase->first; chan; chan=chan->next) {
- if (chan->ipo) {
- chan->ipo->id.us--;
- }
- }
-
- BLI_freelistN(chanbase);
-}
-
-/* Make a copy of the constraint channels from dst to src, and also give the
- * new constraint channels their own copy of the original's IPO.
- */
-void copy_constraint_channels (ListBase *dst, ListBase *src)
-{
- bConstraintChannel *dchan, *schan;
-
- dst->first = dst->last = NULL;
- BLI_duplicatelist(dst, src);
-
- for (dchan=dst->first, schan=src->first; dchan; dchan=dchan->next, schan=schan->next) {
- dchan->ipo = copy_ipo(schan->ipo);
- }
-}
-
-/* Make a copy of the constraint channels from dst to src, but make the
- * new constraint channels use the same IPO-data as their twin.
- */
-void clone_constraint_channels (ListBase *dst, ListBase *src)
-{
- bConstraintChannel *dchan, *schan;
-
- dst->first = dst->last = NULL;
- BLI_duplicatelist(dst, src);
-
- for (dchan=dst->first, schan=src->first; dchan; dchan=dchan->next, schan=schan->next) {
- id_us_plus((ID *)dchan->ipo);
- }
-}
-
-/* ------------- Constraint Channel Tools ------------ */
-
-/* Find the constraint channel with a given name */
-bConstraintChannel *get_constraint_channel (ListBase *list, const char name[])
-{
- bConstraintChannel *chan;
-
- if (list) {
- for (chan = list->first; chan; chan=chan->next) {
- if (!strcmp(name, chan->name)) {
- return chan;
- }
- }
- }
-
- return NULL;
-}
-
-/* Find or create a new constraint channel */
-bConstraintChannel *verify_constraint_channel (ListBase *list, const char name[])
-{
- bConstraintChannel *chan;
-
- chan= get_constraint_channel(list, name);
-
- if (chan == NULL) {
- chan= MEM_callocN(sizeof(bConstraintChannel), "new constraint channel");
- BLI_addtail(list, chan);
- strcpy(chan->name, name);
- }
-
- return chan;
-}
-
-/* --------- Constraint Channel Evaluation/Execution --------- */
-
-/* IPO-system call: calculate IPO-block for constraint channels, and flush that
- * info onto the corresponding constraint.
- */
-void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime, short onlydrivers)
-{
- bConstraint *con;
-
- /* for each Constraint, calculate its Influence from the corresponding ConstraintChannel */
- for (con=conbase->first; con; con=con->next) {
- Ipo *ipo= NULL;
-
- if (con->flag & CONSTRAINT_OWN_IPO)
- ipo= con->ipo;
- else {
- bConstraintChannel *chan = get_constraint_channel(chanbase, con->name);
- if (chan) ipo= chan->ipo;
- }
-
- if (ipo) {
- IpoCurve *icu;
-
- calc_ipo(ipo, ctime);
-
- for (icu=ipo->curve.first; icu; icu=icu->next) {
- if (!onlydrivers || icu->driver) {
- switch (icu->adrcode) {
- case CO_ENFORCE:
- {
- /* Influence is clamped to 0.0f -> 1.0f range */
- con->enforce = CLAMPIS(icu->curval, 0.0f, 1.0f);
- }
- break;
- case CO_HEADTAIL:
- {
- /* we need to check types of constraints that can get this here, as user
- * may have created an IPO-curve for this from IPO-editor but for a constraint
- * that cannot support this
- */
- switch (con->type) {
- /* supported constraints go here... */
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_MINMAX:
- case CONSTRAINT_TYPE_STRETCHTO:
- case CONSTRAINT_TYPE_DISTLIMIT:
- con->headtail = icu->curval;
- break;
-
- default:
- /* not supported */
- break;
- }
- }
- break;
- }
- }
- }
- }
- }
-}
/* ************************ Constraints - General Utilities *************************** */
/* These functions here don't act on any specific constraints, and are therefore should/will
@@ -1303,10 +1152,12 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
if (cu->path && cu->path->data) {
curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset;
+#if 0 // XXX old animation system
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
curvetime /= cu->pathlen;
CLAMP(curvetime, 0.0, 1.0);
}
+#endif // XXX old animation system
if ( where_on_path(ct->tar, curvetime, vec, dir) ) {
if (data->followflag) {
@@ -2053,7 +1904,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) {
Object workob;
/* evaluate using workob */
- what_does_obaction(cob->scene, cob->ob, &workob, data->act, t);
+ //what_does_obaction(cob->scene, cob->ob, &workob, data->act, t); // FIXME: missing func...
object_to_mat4(&workob, ct->matrix);
}
else {
@@ -3550,7 +3401,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime)
if (con->enforce == 0.0f) continue;
/* influence of constraint
- * - value should have been set from IPO's/Constraint Channels already
+ * - value should have been set from animation data already
*/
enf = con->enforce;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 4fba2c3d746..d52d91e40e9 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -49,7 +49,6 @@
/* for dereferencing pointers */
#include "DNA_ID.h"
#include "DNA_key_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
@@ -57,7 +56,6 @@
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -85,8 +83,10 @@ void unlink_curve(Curve *cu)
cu->vfont= 0;
if(cu->key) cu->key->id.us--;
cu->key= 0;
+#if 0 // XXX old animation system
if(cu->ipo) cu->ipo->id.us--;
cu->ipo= 0;
+#endif // XXX old animation system
}
@@ -162,8 +162,10 @@ Curve *copy_curve(Curve *cu)
cun->bev.first= cun->bev.last= 0;
cun->path= 0;
+#if 0 // XXX old animation system
/* single user ipo too */
if(cun->ipo) cun->ipo= copy_ipo(cun->ipo);
+#endif // XXX old animation system
id_us_plus((ID *)cun->vfont);
id_us_plus((ID *)cun->vfontb);
@@ -1981,7 +1983,7 @@ void makeBevelList(Object *ob)
* 1: nothing, 1:auto, 2:vector, 3:aligned
*/
-/* mode: is not zero when IpoCurve, is 2 when forced horizontal for autohandles */
+/* mode: is not zero when FCurve, is 2 when forced horizontal for autohandles */
void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
{
float *p1,*p2,*p3, pt[3];
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 01dd6c0c657..4567717ea7a 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -38,6 +38,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
@@ -1954,6 +1955,7 @@ static int object_modifiers_use_time(Object *ob)
static int exists_channel(Object *ob, char *name)
{
+#if 0 // XXX old animation system
bActionStrip *strip;
if(ob->action)
@@ -1963,14 +1965,32 @@ static int exists_channel(Object *ob, char *name)
for (strip=ob->nlastrips.first; strip; strip=strip->next)
if(get_action_channel(strip->act, name))
return 1;
+#endif // XXX old animation system
+
return 0;
}
-static void dag_object_time_update_flags(Object *ob)
+
+static short animdata_use_time(AnimData *adt)
{
+ NlaTrack *nlt;
- if(ob->ipo) ob->recalc |= OB_RECALC_OB;
- else if(ob->constraints.first) {
+ /* check action - only if assigned, and it has anim curves */
+ if (adt->action && adt->action->curves.first)
+ return 1;
+
+ /* check NLA tracks + strips */
+ for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
+ if (nlt->strips.first)
+ return 1;
+ }
+
+ return 0;
+}
+
+static void dag_object_time_update_flags(Object *ob)
+{
+ if(ob->constraints.first) {
bConstraint *con;
for (con = ob->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
@@ -2000,6 +2020,7 @@ static void dag_object_time_update_flags(Object *ob)
if(ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB;
}
+#if 0 // XXX old animation system
if(ob->action || ob->nlastrips.first) {
/* since actions now are mixed, we set the recalcs on the safe side */
ob->recalc |= OB_RECALC_OB;
@@ -2016,6 +2037,8 @@ static void dag_object_time_update_flags(Object *ob)
}
}
}
+#endif // XXX old animation system
+ if(animdata_use_time(&ob->adt)) ob->recalc |= OB_RECALC;
if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
if((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
new file mode 100644
index 00000000000..0e94faf0c4d
--- /dev/null
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -0,0 +1,1492 @@
+/* Testing code for new animation system in 2.5
+ * Copyright 2009, Joshua Leung
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "BKE_fcurve.h"
+#include "BKE_curve.h"
+#include "BKE_idprop.h"
+#include "BKE_utildefines.h"
+
+#include "RNA_access.h"
+#include "RNA_types.h"
+
+#ifndef DISABLE_PYTHON
+#include "BPY_extern.h" /* for BPY_pydriver_eval() */
+#endif
+
+#define SMALL -1.0e-10
+#define SELECT 1
+
+/* ************************** Data-Level Functions ************************* */
+
+/* ---------------------- Freeing --------------------------- */
+
+/* Frees the F-Curve itself too */
+void free_fcurve (FCurve *fcu)
+{
+ if (fcu == NULL)
+ return;
+
+ /* free curve data */
+ if (fcu) {
+ if (fcu->bezt) MEM_freeN(fcu->bezt);
+ if (fcu->fpt) MEM_freeN(fcu->fpt);
+ }
+
+ /* free RNA-path, as this were allocated when getting the path string */
+ if (fcu->rna_path)
+ MEM_freeN(fcu->rna_path);
+
+ /* free extra data - i.e. modifiers, and driver */
+ fcurve_free_driver(fcu);
+ fcurve_free_modifiers(fcu);
+
+ /* free f-cruve itself */
+ MEM_freeN(fcu);
+}
+
+/* ---------------------- Copy --------------------------- */
+
+/* duplicate an F-Curve */
+FCurve *copy_fcurve (FCurve *fcu)
+{
+ FCurve *fcu_d;
+
+ /* sanity check */
+ if (fcu == NULL)
+ return NULL;
+
+ /* make a copy */
+ fcu_d= MEM_dupallocN(fcu);
+
+ /* copy curve data */
+ fcu_d->bezt= MEM_dupallocN(fcu_d->bezt);
+ fcu_d->fpt= MEM_dupallocN(fcu_d->fpt);
+
+ /* copy rna-path */
+ fcu_d->rna_path= MEM_dupallocN(fcu_d->rna_path);
+
+ /* copy driver */
+ //fcurve_copy_driver();
+
+ /* copy modifiers */
+ fcurve_copy_modifiers(&fcu_d->modifiers, &fcu->modifiers);
+
+ /* return new data */
+ return fcu_d;
+}
+
+/* ---------------------- Relink --------------------------- */
+
+#if 0
+/* uses id->newid to match pointers with other copied data
+ * - called after single-user or other such
+ */
+ if (icu->driver)
+ ID_NEW(icu->driver->ob);
+#endif
+
+/* --------------------- Finding -------------------------- */
+
+/* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
+FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index)
+{
+ FCurve *fcu;
+
+ /* sanity checks */
+ if ( ELEM(NULL, list, rna_path) || (array_index < 0) )
+ return NULL;
+
+ /* check paths of curves, then array indices... */
+ for (fcu= list->first; fcu; fcu= fcu->next) {
+ /* simple string-compare (this assumes that they have the same root...) */
+ if (strcmp(fcu->rna_path, rna_path) == 0) {
+ /* now check indicies */
+ if (fcu->array_index == array_index)
+ return fcu;
+ }
+ }
+
+ /* return */
+ return NULL;
+}
+
+/* ***************************** Keyframe Column Tools ********************************* */
+
+/* add a BezTriple to a column */
+void bezt_add_to_cfra_elem (ListBase *lb, BezTriple *bezt)
+{
+ CfraElem *ce, *cen;
+
+ for (ce= lb->first; ce; ce= ce->next) {
+ /* double key? */
+ if (ce->cfra == bezt->vec[1][0]) {
+ if (bezt->f2 & SELECT) ce->sel= bezt->f2;
+ return;
+ }
+ /* should key be inserted before this column? */
+ else if (ce->cfra > bezt->vec[1][0]) break;
+ }
+
+ /* create a new column */
+ cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
+ if (ce) BLI_insertlinkbefore(lb, ce, cen);
+ else BLI_addtail(lb, cen);
+
+ cen->cfra= bezt->vec[1][0];
+ cen->sel= bezt->f2;
+}
+
+/* ***************************** F-Curve Sanity ********************************* */
+/* The functions here are used in various parts of Blender, usually after some editing
+ * of keyframe data has occurred. They ensure that keyframe data is properly ordered and
+ * that the handles are correctly
+ */
+
+/* This function recalculates the handles of an F-Curve
+ * If the BezTriples have been rearranged, sort them first before using this.
+ */
+void calchandles_fcurve (FCurve *fcu)
+{
+ BezTriple *bezt, *prev, *next;
+ int a= fcu->totvert;
+
+ /* Error checking:
+ * - need at least two points
+ * - need bezier keys
+ * - only bezier-interpolation has handles (for now)
+ */
+ if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/)
+ return;
+
+ /* get initial pointers */
+ bezt= fcu->bezt;
+ prev= NULL;
+ next= (bezt + 1);
+
+ /* loop over all beztriples, adjusting handles */
+ while (a--) {
+ /* clamp timing of handles to be on either side of beztriple */
+ if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0]= bezt->vec[1][0];
+ if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0];
+
+ /* calculate auto-handles */
+ if (fcu->flag & FCURVE_AUTO_HANDLES)
+ calchandleNurb(bezt, prev, next, 2); /* 2==special autohandle && keep extrema horizontal */
+ else
+ calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */
+
+ /* for automatic ease in and out */
+ if ((bezt->h1==HD_AUTO) && (bezt->h2==HD_AUTO)) {
+ /* only do this on first or last beztriple */
+ if ((a == 0) || (a == fcu->totvert-1)) {
+ /* set both handles to have same horizontal value as keyframe */
+ if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) {
+ bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
+ }
+ }
+ }
+
+ /* advance pointers for next iteration */
+ prev= bezt;
+ if (a == 1) next= NULL;
+ else next++;
+ bezt++;
+ }
+}
+
+/* Use when F-Curve with handles has changed
+ * It treats all BezTriples with the following rules:
+ * - PHASE 1: do types have to be altered?
+ * -> Auto handles: become aligned when selection status is NOT(000 || 111)
+ * -> Vector handles: become 'nothing' when (one half selected AND other not)
+ * - PHASE 2: recalculate handles
+*/
+void testhandles_fcurve (FCurve *fcu)
+{
+ BezTriple *bezt;
+ int a;
+
+ /* only beztriples have handles (bpoints don't though) */
+ if ELEM(NULL, fcu, fcu->bezt)
+ return;
+
+ /* loop over beztriples */
+ for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) {
+ short flag= 0;
+
+ /* flag is initialised as selection status
+ * of beztriple control-points (labelled 0,1,2)
+ */
+ if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
+ if (bezt->f2 & SELECT) flag |= (1<<1); // == 2
+ if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
+
+ /* one or two handles selected only */
+ if (ELEM(flag, 0, 7)==0) {
+ /* auto handles become aligned */
+ if (bezt->h1==HD_AUTO)
+ bezt->h1= HD_ALIGN;
+ if (bezt->h2==HD_AUTO)
+ bezt->h2= HD_ALIGN;
+
+ /* vector handles become 'free' when only one half selected */
+ if (bezt->h1==HD_VECT) {
+ /* only left half (1 or 2 or 1+2) */
+ if (flag < 4)
+ bezt->h1= 0;
+ }
+ if (bezt->h2==HD_VECT) {
+ /* only right half (4 or 2+4) */
+ if (flag > 3)
+ bezt->h2= 0;
+ }
+ }
+ }
+
+ /* recalculate handles */
+ calchandles_fcurve(fcu);
+}
+
+/* This function sorts BezTriples so that they are arranged in chronological order,
+ * as tools working on F-Curves expect that the BezTriples are in order.
+ */
+void sort_time_fcurve (FCurve *fcu)
+{
+ short ok= 1;
+
+ /* keep adjusting order of beztriples until nothing moves (bubble-sort) */
+ while (ok) {
+ ok= 0;
+
+ /* currently, will only be needed when there are beztriples */
+ if (fcu->bezt) {
+ BezTriple *bezt;
+ int a;
+
+ /* loop over ALL points to adjust position in array and recalculate handles */
+ for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) {
+ /* check if thee's a next beztriple which we could try to swap with current */
+ if (a < (fcu->totvert-1)) {
+ /* swap if one is after the other (and indicate that order has changed) */
+ if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) {
+ SWAP(BezTriple, *bezt, *(bezt+1));
+ ok= 1;
+ }
+
+ /* if either one of both of the points exceeds crosses over the keyframe time... */
+ if ( (bezt->vec[0][0] > bezt->vec[1][0]) && (bezt->vec[2][0] < bezt->vec[1][0]) ) {
+ /* swap handles if they have switched sides for some reason */
+ SWAP(float, bezt->vec[0][0], bezt->vec[2][0]);
+ SWAP(float, bezt->vec[0][1], bezt->vec[2][1]);
+ }
+ else {
+ /* clamp handles */
+ if (bezt->vec[0][0] > bezt->vec[1][0])
+ bezt->vec[0][0]= bezt->vec[1][0];
+ if (bezt->vec[2][0] < bezt->vec[1][0])
+ bezt->vec[2][0]= bezt->vec[1][0];
+ }
+ }
+ }
+ }
+ }
+}
+
+/* This function tests if any BezTriples are out of order, thus requiring a sort */
+short test_time_fcurve (FCurve *fcu)
+{
+ int a;
+
+ /* sanity checks */
+ if (fcu == NULL)
+ return 0;
+
+ /* currently, only need to test beztriples */
+ if (fcu->bezt) {
+ BezTriple *bezt;
+
+ /* loop through all BezTriples, stopping when one exceeds the one after it */
+ for (a=0, bezt= fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) {
+ if (bezt->vec[1][0] > (bezt+1)->vec[1][0])
+ return 1;
+ }
+ }
+ else if (fcu->fpt) {
+ FPoint *fpt;
+
+ /* loop through all FPoints, stopping when one exceeds the one after it */
+ for (a=0, fpt= fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) {
+ if (fpt->vec[0] > (fpt+1)->vec[0])
+ return 1;
+ }
+ }
+
+ /* none need any swapping */
+ return 0;
+}
+
+/* ***************************** Drivers ********************************* */
+
+/* Driver API --------------------------------- */
+
+/* This frees the driver itself */
+void fcurve_free_driver(FCurve *fcu)
+{
+ ChannelDriver *driver;
+
+ /* sanity checks */
+ if ELEM(NULL, fcu, fcu->driver)
+ return;
+ driver= fcu->driver;
+
+ /* free RNA-paths, as these were allocated when getting the path string */
+ if (driver->rna_path) MEM_freeN(driver->rna_path);
+ if (driver->rna_path2) MEM_freeN(driver->rna_path2);
+
+ /* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */
+ MEM_freeN(driver);
+ fcu->driver= NULL;
+}
+
+/* Driver Evaluation -------------------------- */
+
+/* Helper function to obtain a value using RNA from the specified source (for evaluating drivers)
+ * - target: used to specify which of the two driver-targets to use
+ */
+static float driver_get_driver_value (ChannelDriver *driver, short target)
+{
+ PointerRNA id_ptr, ptr;
+ PropertyRNA *prop;
+ char *path;
+ int index;
+ float value= 0.0f;
+
+ /* get RNA-pointer for the ID-block given in driver */
+ if (target == 2) {
+ /* second target */
+ RNA_id_pointer_create(driver->id2, &id_ptr);
+ path= driver->rna_path2;
+ index= driver->array_index2;
+ }
+ else {
+ /* first/main target */
+ RNA_id_pointer_create(driver->id, &id_ptr);
+ path= driver->rna_path;
+ index= driver->array_index;
+ }
+
+ /* get property to read from, and get value as appropriate */
+ if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) {
+ switch (RNA_property_type(&ptr, prop)) {
+ case PROP_BOOLEAN:
+ if (RNA_property_array_length(&ptr, prop))
+ value= (float)RNA_property_boolean_get_array(&ptr, prop, index);
+ else
+ value= (float)RNA_property_boolean_get(&ptr, prop);
+ break;
+ case PROP_INT:
+ if (RNA_property_array_length(&ptr, prop))
+ value= (float)RNA_property_int_get_array(&ptr, prop, index);
+ else
+ value= (float)RNA_property_int_get(&ptr, prop);
+ break;
+ case PROP_FLOAT:
+ if (RNA_property_array_length(&ptr, prop))
+ value= RNA_property_float_get_array(&ptr, prop, index);
+ else
+ value= RNA_property_float_get(&ptr, prop);
+ break;
+ case PROP_ENUM:
+ value= (float)RNA_property_enum_get(&ptr, prop);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return value;
+}
+
+/* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime"
+ * - "evaltime" is the frame at which F-Curve is being evaluated
+ * - has to return a float value
+ */
+static float evaluate_driver (ChannelDriver *driver, float evaltime)
+{
+ /* check if driver can be evaluated */
+ if (driver->flag & DRIVER_FLAG_DISABLED)
+ return 0.0f;
+
+ switch (driver->type) {
+ case DRIVER_TYPE_CHANNEL: /* channel/setting drivers channel/setting */
+ return driver_get_driver_value(driver, 0);
+
+#ifndef DISABLE_PYTHON
+ case DRIVER_TYPE_PYTHON: /* expression */
+ {
+ /* check for empty or invalid expression */
+ if ( (driver->expression[0] == '\0') ||
+ (driver->flag & DRIVER_FLAG_INVALID) )
+ {
+ return 0.0f;
+ }
+
+ /* this evaluates the expression using Python,and returns its result:
+ * - on errors it reports, then returns 0.0f
+ */
+ //return BPY_pydriver_eval(driver); // XXX old func
+ return 1.0f;
+ }
+#endif /* DISABLE_PYTHON*/
+
+ case DRIVER_TYPE_ROTDIFF: /* difference of rotations of 2 bones (should be in same armature) */
+ {
+ /*
+ float q1[4], q2[4], quat[4], angle;
+
+ Mat4ToQuat(pchan->pose_mat, q1);
+ Mat4ToQuat(pchan2->pose_mat, q2);
+
+ QuatInv(q1);
+ QuatMul(quat, q1, q2);
+ angle = 2.0f * (saacos(quat[0]));
+ angle= ABS(angle);
+
+ return (angle > M_PI) ? (float)((2.0f * M_PI) - angle) : (float)(angle);
+ */
+ }
+ break;
+
+ default:
+ {
+ /* special 'hack' - just use stored value
+ * This is currently used as the mechanism which allows animated settings to be able
+ * to be changed via the UI.
+ */
+ return driver->curval;
+ }
+ }
+
+ /* return 0.0f, as couldn't find relevant data to use */
+ return 0.0f;
+}
+
+/* ***************************** Curve Calculations ********************************* */
+
+/* The total length of the handles is not allowed to be more
+ * than the horizontal distance between (v1-v4).
+ * This is to prevent curve loops.
+*/
+void correct_bezpart (float *v1, float *v2, float *v3, float *v4)
+{
+ float h1[2], h2[2], len1, len2, len, fac;
+
+ /* calculate handle deltas */
+ h1[0]= v1[0] - v2[0];
+ h1[1]= v1[1] - v2[1];
+
+ h2[0]= v4[0] - v3[0];
+ h2[1]= v4[1] - v3[1];
+
+ /* calculate distances:
+ * - len = span of time between keyframes
+ * - len1 = length of handle of start key
+ * - len2 = length of handle of end key
+ */
+ len= v4[0]- v1[0];
+ len1= (float)fabs(h1[0]);
+ len2= (float)fabs(h2[0]);
+
+ /* if the handles have no length, no need to do any corrections */
+ if ((len1+len2) == 0.0f)
+ return;
+
+ /* the two handles cross over each other, so force them
+ * apart using the proportion they overlap
+ */
+ if ((len1+len2) > len) {
+ fac= len / (len1+len2);
+
+ v2[0]= (v1[0] - fac*h1[0]);
+ v2[1]= (v1[1] - fac*h1[1]);
+
+ v3[0]= (v4[0] - fac*h2[0]);
+ v3[1]= (v4[1] - fac*h2[1]);
+ }
+}
+
+/* find root ('zero') */
+int findzero (float x, float q0, float q1, float q2, float q3, float *o)
+{
+ double c0, c1, c2, c3, a, b, c, p, q, d, t, phi;
+ int nr= 0;
+
+ c0= q0 - x;
+ c1= 3.0 * (q1 - q0);
+ c2= 3.0 * (q0 - 2.0*q1 + q2);
+ c3= q3 - q0 + 3.0 * (q1 - q2);
+
+ if (c3 != 0.0) {
+ a= c2/c3;
+ b= c1/c3;
+ c= c0/c3;
+ a= a/3;
+
+ p= b/3 - a*a;
+ q= (2*a*a*a - a*b + c) / 2;
+ d= q*q + p*p*p;
+
+ if (d > 0.0) {
+ t= sqrt(d);
+ o[0]= (float)(Sqrt3d(-q+t) + Sqrt3d(-q-t) - a);
+
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1;
+ else return 0;
+ }
+ else if (d == 0.0) {
+ t= Sqrt3d(-q);
+ o[0]= (float)(2*t - a);
+
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++;
+ o[nr]= (float)(-t-a);
+
+ if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1;
+ else return nr;
+ }
+ else {
+ phi= acos(-q / sqrt(-(p*p*p)));
+ t= sqrt(-p);
+ p= cos(phi/3);
+ q= sqrt(3 - 3*p*p);
+ o[0]= (float)(2*t*p - a);
+
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++;
+ o[nr]= (float)(-t * (p + q) - a);
+
+ if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) nr++;
+ o[nr]= (float)(-t * (p - q) - a);
+
+ if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1;
+ else return nr;
+ }
+ }
+ else {
+ a=c2;
+ b=c1;
+ c=c0;
+
+ if (a != 0.0) {
+ // discriminant
+ p= b*b - 4*a*c;
+
+ if (p > 0) {
+ p= sqrt(p);
+ o[0]= (float)((-b-p) / (2 * a));
+
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++;
+ o[nr]= (float)((-b+p)/(2*a));
+
+ if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1;
+ else return nr;
+ }
+ else if (p == 0) {
+ o[0]= (float)(-b / (2 * a));
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1;
+ else return 0;
+ }
+ }
+ else if (b != 0.0) {
+ o[0]= (float)(-c/b);
+
+ if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1;
+ else return 0;
+ }
+ else if (c == 0.0) {
+ o[0]= 0.0;
+ return 1;
+ }
+
+ return 0;
+ }
+}
+
+void berekeny (float f1, float f2, float f3, float f4, float *o, int b)
+{
+ float t, c0, c1, c2, c3;
+ int a;
+
+ c0= f1;
+ c1= 3.0f * (f2 - f1);
+ c2= 3.0f * (f1 - 2.0f*f2 + f3);
+ c3= f4 - f1 + 3.0f * (f2 - f3);
+
+ for (a=0; a < b; a++) {
+ t= o[a];
+ o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3;
+ }
+}
+
+void berekenx (float *f, float *o, int b)
+{
+ float t, c0, c1, c2, c3;
+ int a;
+
+ c0= f[0];
+ c1= 3.0f * (f[3] - f[0]);
+ c2= 3.0f * (f[0] - 2.0f*f[3] + f[6]);
+ c3= f[9] - f[0] + 3.0f * (f[3] - f[6]);
+
+ for (a=0; a < b; a++) {
+ t= o[a];
+ o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3;
+ }
+}
+
+
+/* -------------------------- */
+
+/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
+static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltime)
+{
+ BezTriple *bezt, *prevbezt, *lastbezt;
+ float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
+ int a, b;
+ float cvalue = 0.0f;
+
+ /* get pointers */
+ a= fcu->totvert-1;
+ prevbezt= bezts;
+ bezt= prevbezt+1;
+ lastbezt= prevbezt + a;
+
+ /* evaluation time at or past endpoints? */
+ if (prevbezt->vec[1][0] >= evaltime) {
+ /* before or on first keyframe */
+ if ((fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (prevbezt->ipo != BEZT_IPO_CONST)) {
+ /* linear or bezier interpolation */
+ if (prevbezt->ipo==BEZT_IPO_LIN) {
+ /* Use the next center point instead of our own handle for
+ * linear interpolated extrapolate
+ */
+ if (fcu->totvert == 1)
+ cvalue= prevbezt->vec[1][1];
+ else {
+ bezt = prevbezt+1;
+ dx= prevbezt->vec[1][0] - evaltime;
+ fac= bezt->vec[1][0] - prevbezt->vec[1][0];
+
+ /* prevent division by zero */
+ if (fac) {
+ fac= (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
+ cvalue= prevbezt->vec[1][1] - (fac * dx);
+ }
+ else
+ cvalue= prevbezt->vec[1][1];
+ }
+ }
+ else {
+ /* Use the first handle (earlier) of first BezTriple to calculate the
+ * gradient and thus the value of the curve at evaltime
+ */
+ dx= prevbezt->vec[1][0] - evaltime;
+ fac= prevbezt->vec[1][0] - prevbezt->vec[0][0];
+
+ /* prevent division by zero */
+ if (fac) {
+ fac= (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac;
+ cvalue= prevbezt->vec[1][1] - (fac * dx);
+ }
+ else
+ cvalue= prevbezt->vec[1][1];
+ }
+ }
+ else {
+ /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation,
+ * so just extend first keyframe's value
+ */
+ cvalue= prevbezt->vec[1][1];
+ }
+ }
+ else if (lastbezt->vec[1][0] <= evaltime) {
+ /* after or on last keyframe */
+ if ((fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (lastbezt->ipo != BEZT_IPO_CONST)) {
+ /* linear or bezier interpolation */
+ if (lastbezt->ipo==BEZT_IPO_LIN) {
+ /* Use the next center point instead of our own handle for
+ * linear interpolated extrapolate
+ */
+ if (fcu->totvert == 1)
+ cvalue= lastbezt->vec[1][1];
+ else {
+ prevbezt = lastbezt - 1;
+ dx= evaltime - lastbezt->vec[1][0];
+ fac= lastbezt->vec[1][0] - prevbezt->vec[1][0];
+
+ /* prevent division by zero */
+ if (fac) {
+ fac= (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac;
+ cvalue= lastbezt->vec[1][1] + (fac * dx);
+ }
+ else
+ cvalue= lastbezt->vec[1][1];
+ }
+ }
+ else {
+ /* Use the gradient of the second handle (later) of last BezTriple to calculate the
+ * gradient and thus the value of the curve at evaltime
+ */
+ dx= evaltime - lastbezt->vec[1][0];
+ fac= lastbezt->vec[2][0] - lastbezt->vec[1][0];
+
+ /* prevent division by zero */
+ if (fac) {
+ fac= (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac;
+ cvalue= lastbezt->vec[1][1] + (fac * dx);
+ }
+ else
+ cvalue= lastbezt->vec[1][1];
+ }
+ }
+ else {
+ /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation,
+ * so just extend last keyframe's value
+ */
+ cvalue= lastbezt->vec[1][1];
+ }
+ }
+ else {
+ /* evaltime occurs somewhere in the middle of the curve */
+ for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) {
+ /* evaltime occurs within the interval defined by these two keyframes */
+ if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) {
+ /* value depends on interpolation mode */
+ if (prevbezt->ipo == BEZT_IPO_CONST) {
+ /* constant (evaltime not relevant, so no interpolation needed) */
+ cvalue= prevbezt->vec[1][1];
+ }
+ else if (prevbezt->ipo == BEZT_IPO_LIN) {
+ /* linear - interpolate between values of the two keyframes */
+ fac= bezt->vec[1][0] - prevbezt->vec[1][0];
+
+ /* prevent division by zero */
+ if (fac) {
+ fac= (evaltime - prevbezt->vec[1][0]) / fac;
+ cvalue= prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1]));
+ }
+ else
+ cvalue= prevbezt->vec[1][1];
+ }
+ else {
+ /* bezier interpolation */
+ /* v1,v2 are the first keyframe and its 2nd handle */
+ v1[0]= prevbezt->vec[1][0];
+ v1[1]= prevbezt->vec[1][1];
+ v2[0]= prevbezt->vec[2][0];
+ v2[1]= prevbezt->vec[2][1];
+ /* v3,v4 are the last keyframe's 1st handle + the last keyframe */
+ v3[0]= bezt->vec[0][0];
+ v3[1]= bezt->vec[0][1];
+ v4[0]= bezt->vec[1][0];
+ v4[1]= bezt->vec[1][1];
+
+ /* adjust handles so that they don't overlap (forming a loop) */
+ correct_bezpart(v1, v2, v3, v4);
+
+ /* try to get a value for this position - if failure, try another set of points */
+ b= findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl);
+ if (b) {
+ berekeny(v1[1], v2[1], v3[1], v4[1], opl, 1);
+ cvalue= opl[0];
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* return value */
+ return cvalue;
+}
+
+/* Calculate F-Curve value for 'evaltime' using FPoint samples */
+static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime)
+{
+ FPoint *prevfpt, *lastfpt, *fpt;
+ float cvalue= 0.0f;
+
+ /* get pointers */
+ prevfpt= fpts;
+ lastfpt= prevfpt + fcu->totvert-1;
+
+ /* evaluation time at or past endpoints? */
+ if (prevfpt->vec[0] >= evaltime) {
+ /* before or on first sample, so just extend value */
+ cvalue= prevfpt->vec[1];
+ }
+ else if (lastfpt->vec[0] <= evaltime) {
+ /* after or on last sample, so just extend value */
+ cvalue= lastfpt->vec[1];
+ }
+ else {
+ /* find the one on the right frame (assume that these are spaced on 1-frame intervals) */
+ fpt= prevfpt + (int)(evaltime - prevfpt->vec[0]);
+ cvalue= fpt->vec[1];
+ }
+
+ /* return value */
+ return cvalue;
+}
+
+/* ******************************** F-Curve Modifiers ********************************* */
+
+/* Template --------------------------- */
+
+/* Each modifier defines a set of functions, which will be called at the appropriate
+ * times. In addition to this, each modifier should have a type-info struct, where
+ * its functions are attached for use.
+ */
+
+/* Template for type-info data:
+ * - make a copy of this when creating new modifiers, and just change the functions
+ * pointed to as necessary
+ * - although the naming of functions doesn't matter, it would help for code
+ * readability, to follow the same naming convention as is presented here
+ * - any functions that a constraint doesn't need to define, don't define
+ * for such cases, just use NULL
+ * - these should be defined after all the functions have been defined, so that
+ * forward-definitions/prototypes don't need to be used!
+ * - keep this copy #if-def'd so that future constraints can get based off this
+ */
+#if 0
+static FModifierTypeInfo FMI_MODNAME = {
+ FMODIFIER_TYPE_MODNAME, /* type */
+ sizeof(FMod_ModName), /* size */
+ "Modifier Name", /* name */
+ "FMod_ModName", /* struct name */
+ fcm_modname_free, /* free data */
+ fcm_modname_relink, /* relink data */
+ fcm_modname_copy, /* copy data */
+ fcm_modname_new_data, /* new data */
+ fcm_modname_evaluate /* evaluate */
+};
+#endif
+
+/* Generator F-Curve Modifier --------------------------- */
+
+static void fcm_generator_free (FModifier *fcm)
+{
+ FMod_Generator *data= (FMod_Generator *)fcm->data;
+
+ /* free polynomial coefficients array */
+ if (data->poly_coefficients)
+ MEM_freeN(data->poly_coefficients);
+}
+
+static void fcm_generator_copy (FModifier *fcm, FModifier *src)
+{
+ FMod_Generator *gen= (FMod_Generator *)fcm->data;
+ FMod_Generator *ogen= (FMod_Generator *)src->data;
+
+ /* copy polynomial coefficients array? */
+ if (ogen->poly_coefficients)
+ gen->poly_coefficients= MEM_dupallocN(ogen->poly_coefficients);
+}
+
+static void fcm_generator_new_data (void *mdata)
+{
+ FMod_Generator *data= (FMod_Generator *)mdata;
+ float *cp;
+
+ /* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */
+ data->poly_order= 1;
+ cp= data->poly_coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs");
+ cp[0] = 0; // y-offset
+ cp[1] = 1; // gradient
+}
+
+
+static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+ FMod_Generator *data= (FMod_Generator *)fcm->data;
+
+ /* behaviour depends on mode (NOTE: we don't need to do anything...) */
+ switch (data->mode) {
+ case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
+ {
+ /* we overwrite cvalue with the sum of the polynomial */
+ float value= 0.0f, *cp = NULL;
+ unsigned int i;
+
+ /* for each coefficient, add to value, which we'll write to *cvalue in one go */
+ // TODO: could this be more efficient (i.e. without need to recalc pow() everytime)
+ cp= data->poly_coefficients;
+ for (i=0; (i <= data->poly_order) && (cp); i++, cp++)
+ value += (*cp) * pow(evaltime, i);
+
+ /* only if something changed */
+ if (data->poly_order)
+ *cvalue= value;
+ }
+ break;
+
+#ifndef DISABLE_PYTHON
+ case FCM_GENERATOR_EXPRESSION: /* py-expression */
+ // TODO...
+ break;
+#endif /* DISABLE_PYTHON */
+ }
+}
+
+static FModifierTypeInfo FMI_GENERATOR = {
+ FMODIFIER_TYPE_GENERATOR, /* type */
+ sizeof(FMod_Generator), /* size */
+ "Generator", /* name */
+ "FMod_Generator", /* struct name */
+ fcm_generator_free, /* free data */
+ fcm_generator_copy, /* copy data */
+ fcm_generator_new_data, /* new data */
+ fcm_generator_evaluate /* evaluate */
+};
+
+/* Envelope F-Curve Modifier --------------------------- */
+
+static void fcm_envelope_free (FModifier *fcm)
+{
+ FMod_Envelope *data= (FMod_Envelope *)fcm->data;
+
+ /* free envelope data array */
+ if (data->data)
+ MEM_freeN(data->data);
+}
+
+static void fcm_envelope_copy (FModifier *fcm, FModifier *src)
+{
+ FMod_Envelope *gen= (FMod_Envelope *)fcm->data;
+ FMod_Envelope *ogen= (FMod_Envelope *)src->data;
+
+ /* copy envelope data array */
+ if (ogen->data)
+ gen->data= MEM_dupallocN(ogen->data);
+}
+
+static void fcm_envelope_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+ FMod_Envelope *env= (FMod_Envelope *)fcm->data;
+ FCM_EnvelopeData *fed, *prevfed, *lastfed;
+ float min=0.0f, max=0.0f, fac=0.0f;
+ int a;
+
+ /* get pointers */
+ if (env->data == NULL) return;
+ prevfed= env->data;
+ fed= prevfed + 1;
+ lastfed= prevfed + env->totvert-1;
+
+ /* get min/max values for envelope at evaluation time (relative to mid-value) */
+ if (prevfed->time >= evaltime) {
+ /* before or on first sample, so just extend value */
+ min= prevfed->min;
+ max= prevfed->max;
+ }
+ else if (lastfed->time <= evaltime) {
+ /* after or on last sample, so just extend value */
+ min= lastfed->min;
+ max= lastfed->max;
+ }
+ else {
+ /* evaltime occurs somewhere between segments */
+ for (a=0; prevfed && fed && (a < env->totvert-1); a++, prevfed=fed, fed++) {
+ /* evaltime occurs within the interval defined by these two envelope points */
+ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) {
+ float afac, bfac, diff;
+
+ diff= fed->time - prevfed->time;
+ afac= (evaltime - prevfed->time) / diff;
+ bfac= (fed->time - evaltime)/(diff);
+
+ min= afac*prevfed->min + bfac*fed->min;
+ max= afac*prevfed->max + bfac*fed->max;
+
+ break;
+ }
+ }
+ }
+
+ /* adjust *cvalue
+ * NOTE: env->min/max are relative to env->midval, and can be either +ve OR -ve, so we add...
+ */
+ fac= (*cvalue - min) / (max - min);
+ *cvalue= (env->midval + env->min) + (fac * (env->max - env->min));
+}
+
+static FModifierTypeInfo FMI_ENVELOPE = {
+ FMODIFIER_TYPE_ENVELOPE, /* type */
+ sizeof(FMod_Envelope), /* size */
+ "Envelope", /* name */
+ "FMod_Envelope", /* struct name */
+ fcm_envelope_free, /* free data */
+ fcm_envelope_copy, /* copy data */
+ NULL, /* new data */
+ fcm_envelope_evaluate /* evaluate */
+};
+
+/* Cycles F-Curve Modifier --------------------------- */
+
+/* This modifier changes evaltime to something that exists within the curve's frame-range,
+ * then re-evaluates modifier stack up to this point using the new time. This re-entrant behaviour
+ * is very likely to be more time-consuming than the original approach... (which was tighly integrated into
+ * the calculation code...).
+ *
+ * NOTE: this needs to be at the start of the stack to be of use, as it needs to know the extents of the keyframes/sample-data
+ * Possible TODO - store length of cycle information that can be initialised from the extents of the keyframes/sample-data, and adjusted
+ * as appropriate
+ */
+
+static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+ FMod_Cycles *data= (FMod_Cycles *)fcm->data;
+ ListBase mods = {NULL, NULL};
+ float prevkey[2], lastkey[2], cycyofs=0.0f;
+ float new_value;
+ short side=0, mode=0;
+ int cycles=0;
+
+ /* check if modifier is first in stack, otherwise disable ourself... */
+ // FIXME...
+ if (fcm->prev) {
+ fcm->flag |= FMODIFIER_FLAG_DISABLED;
+ return;
+ }
+
+ /* calculate new evaltime due to cyclic interpolation */
+ if (fcu && fcu->bezt) {
+ BezTriple *prevbezt= fcu->bezt;
+ BezTriple *lastbezt= prevbezt + fcu->totvert-1;
+
+ prevkey[0]= prevbezt->vec[1][0];
+ prevkey[1]= prevbezt->vec[1][1];
+
+ lastkey[0]= lastbezt->vec[1][0];
+ lastkey[1]= lastbezt->vec[1][1];
+ }
+ else if (fcu && fcu->fpt) {
+ FPoint *prevfpt= fcu->fpt;
+ FPoint *lastfpt= prevfpt + fcu->totvert-1;
+
+ prevkey[0]= prevfpt->vec[0];
+ prevkey[1]= prevfpt->vec[1];
+
+ lastkey[0]= lastfpt->vec[0];
+ lastkey[1]= lastfpt->vec[1];
+ }
+ else
+ return;
+
+ /* check if modifier will do anything
+ * 1) if in data range, definitely don't do anything
+ * 2) if before first frame or after last frame, make sure some cycling is in use
+ */
+ if (evaltime < prevkey[0]) {
+ if (data->before_mode) {
+ side= -1;
+ mode= data->before_mode;
+ cycles= data->before_cycles;
+ }
+ }
+ else if (evaltime > lastkey[0]) {
+ if (data->after_mode) {
+ side= 1;
+ mode= data->after_mode;
+ cycles= data->after_cycles;
+ }
+ }
+ if ELEM3(0, side, mode, cycles)
+ return;
+
+ /* extrapolation mode is 'cyclic' - find relative place within a cycle */
+ // FIXME: adding the more fine-grained control of extrpolation mode
+ {
+ float cycdx=0, cycdy=0, ofs=0;
+
+ /* ofs is start frame of cycle */
+ ofs= prevkey[0];
+
+ /* calculate period and amplitude (total height) of a cycle */
+ cycdx= lastkey[0] - prevkey[0];
+ cycdy= lastkey[1] - prevkey[1];
+
+ /* check if cycle is infinitely small, to be point of being impossible to use */
+ if (cycdx == 0)
+ return;
+ /* check that cyclic is still enabled for the specified time */
+ if ( ((float)side * (evaltime - ofs) / cycdx) > cycles )
+ return;
+
+
+ /* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
+ if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
+ cycyofs = (float)floor((evaltime - ofs) / cycdx);
+ cycyofs *= cycdy;
+ }
+
+ /* calculate where in the cycle we are (overwrite evaltime to reflect this) */
+ evaltime= (float)(fmod(evaltime-ofs, cycdx) + ofs);
+ if (evaltime < ofs) evaltime += cycdx;
+ }
+
+
+ /* store modifiers after (and including ourself) before recalculating curve with new evaltime */
+ mods= fcu->modifiers;
+ fcu->modifiers.first= fcu->modifiers.last= NULL;
+
+ /* re-enter the evaluation loop (but without the burden of evaluating any modifiers, so 'should' be relatively quick) */
+ new_value= evaluate_fcurve(fcu, evaltime);
+
+ /* restore modifiers, and set new value (don't assume everything is still ok after being re-entrant) */
+ fcu->modifiers= mods;
+ *cvalue= new_value + cycyofs;
+}
+
+static FModifierTypeInfo FMI_CYCLES = {
+ FMODIFIER_TYPE_CYCLES, /* type */
+ sizeof(FMod_Cycles), /* size */
+ "Cycles", /* name */
+ "FMod_Cycles", /* struct name */
+ NULL, /* free data */
+ NULL, /* copy data */
+ NULL, /* new data */
+ fcm_cycles_evaluate /* evaluate */
+};
+
+/* Noise F-Curve Modifier --------------------------- */
+
+#if 0 // XXX not yet implemented
+static FModifierTypeInfo FMI_NOISE = {
+ FMODIFIER_TYPE_NOISE, /* type */
+ sizeof(FMod_Noise), /* size */
+ "Noise", /* name */
+ "FMod_Noise", /* struct name */
+ NULL, /* free data */
+ NULL, /* copy data */
+ fcm_noise_new_data, /* new data */
+ fcm_noise_evaluate /* evaluate */
+};
+#endif // XXX not yet implemented
+
+/* Filter F-Curve Modifier --------------------------- */
+
+#if 0 // XXX not yet implemented
+static FModifierTypeInfo FMI_FILTER = {
+ FMODIFIER_TYPE_FILTER, /* type */
+ sizeof(FMod_Filter), /* size */
+ "Filter", /* name */
+ "FMod_Filter", /* struct name */
+ NULL, /* free data */
+ NULL, /* copy data */
+ NULL, /* new data */
+ fcm_filter_evaluate /* evaluate */
+};
+#endif // XXX not yet implemented
+
+
+/* Python F-Curve Modifier --------------------------- */
+
+static void fcm_python_free (FModifier *fcm)
+{
+ FMod_Python *data= (FMod_Python *)fcm->data;
+
+ /* id-properties */
+ IDP_FreeProperty(data->prop);
+ MEM_freeN(data->prop);
+}
+
+static void fcm_python_new_data (void *mdata)
+{
+ FMod_Python *data= (FMod_Python *)mdata;
+
+ /* everything should be set correctly by calloc, except for the prop->type constant.*/
+ data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps");
+ data->prop->type = IDP_GROUP;
+}
+
+static void fcm_python_copy (FModifier *fcm, FModifier *src)
+{
+ FMod_Python *pymod = (FMod_Python *)fcm->data;
+ FMod_Python *opymod = (FMod_Python *)src->data;
+
+ pymod->prop = IDP_CopyProperty(opymod->prop);
+}
+
+static void fcm_python_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
+{
+#ifndef DISABLE_PYTHON
+ //FMod_Python *data= (FMod_Python *)fcm->data;
+
+ /* FIXME... need to implement this modifier...
+ * It will need it execute a script using the custom properties
+ */
+#endif /* DISABLE_PYTHON */
+}
+
+static FModifierTypeInfo FMI_PYTHON = {
+ FMODIFIER_TYPE_PYTHON, /* type */
+ sizeof(FMod_Python), /* size */
+ "Python", /* name */
+ "FMod_Python", /* struct name */
+ fcm_python_free, /* free data */
+ fcm_python_copy, /* copy data */
+ fcm_python_new_data, /* new data */
+ fcm_python_evaluate /* evaluate */
+};
+
+
+/* F-Curve Modifier API --------------------------- */
+/* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out
+ * and operations that involve F-Curve modifier specifc code.
+ */
+
+/* These globals only ever get directly accessed in this file */
+static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES];
+static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */
+
+/* This function only gets called when FMI_INIT is non-zero */
+static void fmods_init_typeinfo () {
+ fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */
+ fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */
+ fmodifiersTypeInfo[2]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
+ fmodifiersTypeInfo[3]= &FMI_CYCLES; /* Cycles F-Curve Modifier */
+ fmodifiersTypeInfo[4]= NULL/*&FMI_NOISE*/; /* Apply-Noise F-Curve Modifier */ // XXX unimplemented
+ fmodifiersTypeInfo[5]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
+ fmodifiersTypeInfo[6]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
+}
+
+/* This function should be used for getting the appropriate type-info when only
+ * a F-Curve modifier type is known
+ */
+FModifierTypeInfo *get_fmodifier_typeinfo (int type)
+{
+ /* initialise the type-info list? */
+ if (FMI_INIT) {
+ fmods_init_typeinfo();
+ FMI_INIT = 0;
+ }
+
+ /* only return for valid types */
+ if ( (type >= FMODIFIER_TYPE_NULL) &&
+ (type <= FMODIFIER_NUM_TYPES ) )
+ {
+ /* there shouldn't be any segfaults here... */
+ return fmodifiersTypeInfo[type];
+ }
+ else {
+ printf("No valid F-Curve Modifier type-info data available. Type = %i \n", type);
+ }
+
+ return NULL;
+}
+
+/* This function should always be used to get the appropriate type-info, as it
+ * has checks which prevent segfaults in some weird cases.
+ */
+FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm)
+{
+ /* only return typeinfo for valid modifiers */
+ if (fcm)
+ return get_fmodifier_typeinfo(fcm->type);
+ else
+ return NULL;
+}
+
+/* API --------------------------- */
+
+/* Add a new F-Curve Modifier to the given F-Curve of a certain type */
+FModifier *fcurve_add_modifier (FCurve *fcu, int type)
+{
+ FModifierTypeInfo *fmi= get_fmodifier_typeinfo(type);
+ FModifier *fcm;
+
+ /* sanity checks */
+ if ELEM(NULL, fcu, fmi)
+ return NULL;
+
+ /* special checks for whether modifier can be added */
+ if ((fcu->modifiers.first) && (type == FMODIFIER_TYPE_CYCLES)) {
+ /* cycles modifier must be first in stack, so for now, don't add if it can't be */
+ // TODO: perhaps there is some better way, but for now,
+ printf("Error: Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be first in stack. \n");
+ return NULL;
+ }
+
+ /* add modifier data */
+ fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
+ BLI_addtail(&fcu->modifiers, fcm);
+
+ /* init custom settings if necessary */
+ if (fmi->new_data)
+ fmi->new_data(fcm->data);
+
+ /* return modifier for further editing */
+ return fcm;
+}
+
+/* Duplicate all of the F-Curve Modifiers in the Modifier stacks */
+void fcurve_copy_modifiers (ListBase *dst, ListBase *src)
+{
+ FModifier *fcm, *srcfcm;
+
+ if ELEM(NULL, dst, src)
+ return;
+
+ dst->first= dst->last= NULL;
+ BLI_duplicatelist(dst, src);
+
+ for (fcm=dst->first, srcfcm=src->first; fcm && srcfcm; srcfcm=srcfcm->next, fcm=fcm->next) {
+ FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
+
+ /* make a new copy of the F-Modifier's data */
+ fcm->data = MEM_dupallocN(fcm->data);
+
+ /* only do specific constraints if required */
+ if (fmi && fmi->copy_data)
+ fmi->copy_data(fcm, srcfcm);
+ }
+}
+
+/* Remove and free the given F-Curve Modifier from the given F-Curve's stack */
+void fcurve_remove_modifier (FCurve *fcu, FModifier *fcm)
+{
+ FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
+
+ /* sanity checks */
+ if ELEM3(NULL, fcu, fcm, fmi)
+ return;
+
+ /* free modifier's special data */
+ if (fmi->free_data)
+ fmi->free_data(fcm);
+
+ /* remove modifier from stack */
+ BLI_freelinkN(&fcu->modifiers, fcm);
+}
+
+/* Remove all of a given F-Curve's modifiers */
+void fcurve_free_modifiers (FCurve *fcu)
+{
+ FModifier *fcm, *fmn;
+
+ /* sanity check */
+ if (fcu == NULL)
+ return;
+
+ /* free each modifier in order */
+ for (fcm= fcu->modifiers.first; fcm; fcm= fmn) {
+ fmn= fcm->next;
+ fcurve_remove_modifier(fcu, fcm);
+ }
+}
+
+/* Bake modifiers for given F-Curve to curve sample data, in the frame range defined
+ * by start and end (inclusive).
+ */
+void fcurve_bake_modifiers (FCurve *fcu, int start, int end)
+{
+ FPoint *fpt, *new_fpt;
+ int cfra;
+
+ /* sanity checks */
+ // TODO: make these tests report errors using reports not printf's
+ if ELEM(NULL, fcu, fcu->modifiers.first) {
+ printf("Error: No F-Curve with F-Curve Modifiers to Bake\n");
+ return;
+ }
+ if (start >= end) {
+ printf("Error: Frame range for F-Curve Modifier Baking inappropriate \n");
+ return;
+ }
+
+ /* set up sample data */
+ fpt= new_fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "FPoint FModifier Samples");
+
+ /* sample the curve at 1-frame intervals from start to end frames
+ * - assume that any ChannelDriver possibly present did not interfere in any way
+ */
+ for (cfra= start; cfra <= end; cfra++, fpt++) {
+ fpt->vec[0]= (float)cfra;
+ fpt->vec[1]= evaluate_fcurve(fcu, (float)cfra);
+ }
+
+ /* free any existing sample/keyframe data on curve, and all modifiers */
+ if (fcu->bezt) MEM_freeN(fcu->bezt);
+ if (fcu->fpt) MEM_freeN(fcu->fpt);
+ fcurve_free_modifiers(fcu);
+
+ /* store the samples */
+ fcu->fpt= new_fpt;
+ fcu->totvert= end - start + 1;
+}
+
+/* ***************************** F-Curve - Evaluation ********************************* */
+
+/* Evaluate and return the value of the given F-Curve at the specified frame ("evaltime")
+ * Note: this is also used for drivers
+ */
+// TODO: set up the modifier system...
+float evaluate_fcurve (FCurve *fcu, float evaltime)
+{
+ FModifier *fcm;
+ float cvalue = 0.0f;
+
+ /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime"
+ * - this value will also be returned as the value of the 'curve', if there are no keyframes
+ */
+ if (fcu->driver) {
+ /* evaltime now serves as input for the curve */
+ evaltime= cvalue= evaluate_driver(fcu->driver, evaltime);
+ }
+
+ /* evaluate curve-data */
+ if (fcu->bezt)
+ cvalue= fcurve_eval_keyframes(fcu, fcu->bezt, evaltime);
+ else if (fcu->fpt)
+ cvalue= fcurve_eval_samples(fcu, fcu->fpt, evaltime);
+
+ /* evaluate modifiers */
+ for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
+ FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
+
+ /* only evaluate if there's a callback for this */
+ if (fmi && fmi->evaluate_modifier) {
+ if ((fcm->flag & FMODIFIER_FLAG_DISABLED) == 0)
+ fmi->evaluate_modifier(fcu, fcm, &cvalue, evaltime);
+ }
+ }
+
+ /* return evaluated value */
+ return cvalue;
+}
+
+/* Calculate the value of the given F-Curve at the given frame, and set its curval */
+// TODO: will this be necessary?
+void calculate_fcurve (FCurve *fcu, float ctime)
+{
+ /* calculate and set curval (evaluates driver too) */
+ fcu->curval= evaluate_fcurve(fcu, ctime);
+}
+
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 78b1423e6bc..16d173bf5d6 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -28,6 +28,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#if 0 // XXX old animation system
+
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -838,6 +840,7 @@ void correct_bezpart (float *v1, float *v2, float *v3, float *v4)
* It is primarily used for patching old files, but is also used in the interface
* to make sure that all segments of the curve use the same interpolation.
*/
+// XXX move to readfile.c for patching old files only..
void set_interpolation_ipocurve (IpoCurve *icu, short ipo)
{
BezTriple *bezt;
@@ -2929,3 +2932,5 @@ float IPO_GetFloatValue (Ipo *ipo, IPO_Channel channel, float ctime)
/* return the value of this channel */
return ctime;
}
+
+#endif // XXX old animation system
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index baf6e4630ee..f06583a6ace 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -36,7 +36,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
@@ -48,7 +47,6 @@
#include "BKE_blender.h"
#include "BKE_curve.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -67,6 +65,11 @@
#define KEY_BPOINT 1
#define KEY_BEZTRIPLE 2
+ // old defines from DNA_ipo_types.h for data-type
+#define IPO_FLOAT 4
+#define IPO_BEZTRIPLE 100
+#define IPO_BPOINT 101
+
int slurph_opt= 1;
@@ -74,8 +77,9 @@ void free_key(Key *key)
{
KeyBlock *kb;
+#if 0 // XXX old animation system
if(key->ipo) key->ipo->id.us--;
-
+#endif // XXX old animation system
while( (kb= key->block.first) ) {
@@ -110,6 +114,7 @@ Key *add_key(ID *id) /* common function */
key->type= KEY_NORMAL;
key->from= id;
+ // XXX the code here uses some defines which will soon be depreceated...
if( GS(id->name)==ID_ME) {
el= key->elemstr;
@@ -150,8 +155,10 @@ Key *copy_key(Key *key)
keyn= copy_libblock(key);
+#if 0 // XXX old animation system
keyn->ipo= copy_ipo(key->ipo);
-
+#endif // XXX old animation system
+
BLI_duplicatelist(&keyn->block, &key->block);
kb= key->block.first;
@@ -179,11 +186,13 @@ void make_local_key(Key *key)
key->id.lib= 0;
new_id(0, (ID *)key, 0);
+
+#if 0 // XXX old animation system
make_local_ipo(key->ipo);
+#endif // XXX old animation system
}
-/*
- * Sort shape keys and Ipo curves after a change. This assumes that at most
+/* Sort shape keys and Ipo curves after a change. This assumes that at most
* one key was moved, which is a valid assumption for the places it's
* currently being called.
*/
@@ -191,30 +200,30 @@ void make_local_key(Key *key)
void sort_keys(Key *key)
{
KeyBlock *kb;
- short i, adrcode;
- IpoCurve *icu = NULL;
+ //short i, adrcode;
+ //IpoCurve *icu = NULL;
KeyBlock *kb2;
/* locate the key which is out of position */
- for( kb= key->block.first; kb; kb= kb->next )
- if( kb->next && kb->pos > kb->next->pos )
+ for (kb= key->block.first; kb; kb= kb->next)
+ if ((kb->next) && (kb->pos > kb->next->pos))
break;
/* if we find a key, move it */
- if( kb ) {
+ if (kb) {
kb = kb->next; /* next key is the out-of-order one */
BLI_remlink(&key->block, kb);
-
+
/* find the right location and insert before */
- for( kb2=key->block.first; kb2; kb2= kb2->next ) {
- if( kb2->pos > kb->pos ) {
+ for (kb2=key->block.first; kb2; kb2= kb2->next) {
+ if (kb2->pos > kb->pos) {
BLI_insertlink(&key->block, kb2->prev, kb);
break;
}
}
-
+
/* if more than one Ipo curve, see if this key had a curve */
-
+#if 0 // XXX old animation system
if(key->ipo && key->ipo->curve.first != key->ipo->curve.last ) {
for(icu= key->ipo->curve.first; icu; icu= icu->next) {
/* if we find the curve, remove it and reinsert in the
@@ -232,13 +241,13 @@ void sort_keys(Key *key)
}
}
}
-
+
/* kb points at the moved key, icu at the moved ipo (if it exists).
* go back now and renumber adrcodes */
/* first new code */
adrcode = kb2->adrcode;
- for( i = kb->adrcode - adrcode; i >= 0; --i, ++adrcode ) {
+ for (i = kb->adrcode - adrcode; i >= 0; i--, adrcode++) {
/* if the next ipo curve matches the current key, renumber it */
if(icu && icu->adrcode == kb->adrcode ) {
icu->adrcode = adrcode;
@@ -248,6 +257,7 @@ void sort_keys(Key *key)
kb->adrcode = adrcode;
kb = kb->next;
}
+#endif // XXX old animation system
}
/* new rule; first key is refkey, this to match drawing channels... */
@@ -1021,11 +1031,13 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
for(a=0; a<me->totvert; a+=step, cfra+= delta) {
- ctime= bsystem_time(scene, 0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0); // xxx ugly cruft!
+#if 0 // XXX old animation system
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
flag= setkeys(ctime, &me->key->block, k, t, 0);
if(flag==0) {
@@ -1056,13 +1068,15 @@ static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
}
}
else {
- ctime= bsystem_time(scene, ob, scene->r.cfra, 0.0);
-
+ ctime= bsystem_time(scene, ob, scene->r.cfra, 0.0); // xxx old cruft
+
+#if 0 // XXX old animation system
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
-
+#endif // XXX old animation system
+
flag= setkeys(ctime, &me->key->block, k, t, 0);
if(flag==0) {
do_key(0, me->totvert, me->totvert, (char *)me->mvert->co, me->key, k, t, 0);
@@ -1175,12 +1189,13 @@ static int do_curve_key(Scene *scene, Curve *cu)
cfra= scene->r.cfra;
for(a=0; a<tot; a+=step, cfra+= delta) {
-
- ctime= bsystem_time(scene, 0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0); // XXX old cruft
+#if 0 // XXX old animation system
if(calc_ipo_spec(cu->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
flag= setkeys(ctime, &cu->key->block, k, t, 0);
if(flag==0) {
@@ -1204,10 +1219,12 @@ static int do_curve_key(Scene *scene, Curve *cu)
do_rel_cu_key(cu, ctime);
}
else {
+#if 0 // XXX old animation system
if(calc_ipo_spec(cu->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
flag= setkeys(ctime, &cu->key->block, k, t, 0);
@@ -1240,11 +1257,13 @@ static int do_latt_key(Scene *scene, Object *ob, Lattice *lt)
for(a=0; a<tot; a++, cfra+= delta) {
- ctime= bsystem_time(scene, 0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0); // XXX old cruft
+#if 0 // XXX old animation system
if(calc_ipo_spec(lt->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
flag= setkeys(ctime, &lt->key->block, k, t, 0);
if(flag==0) {
@@ -1273,10 +1292,12 @@ static int do_latt_key(Scene *scene, Object *ob, Lattice *lt)
}
}
else {
+#if 0 // XXX old animation system
if(calc_ipo_spec(lt->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
flag= setkeys(ctime, &lt->key->block, k, t, 0);
if(flag==0) {
@@ -1338,12 +1359,15 @@ int do_ob_key(Scene *scene, Object *ob)
return 1;
}
else {
+#if 0 // XXX old animation system
+ // NOTE: this stuff was NEVER reliable at all...
if(ob->ipoflag & OB_ACTION_KEY)
do_all_object_actions(scene, ob);
else {
calc_ipo(key->ipo, bsystem_time(scene, ob, scene->r.cfra, 0.0));
execute_ipo((ID *)key, key->ipo);
}
+#endif // XXX old animation system
if(ob->type==OB_MESH) return do_mesh_key(scene, ob, ob->data);
else if(ob->type==OB_CURVE) return do_curve_key(scene, ob->data);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 134d9f7155a..6e5f7c82aed 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -42,7 +42,6 @@
#include "BLI_arithb.h"
#include "DNA_armature_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
@@ -60,7 +59,6 @@
#include "BKE_deform.h"
#include "BKE_displist.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -213,7 +211,9 @@ Lattice *copy_lattice(Lattice *lt)
ltn= copy_libblock(lt);
ltn->def= MEM_dupallocN(lt->def);
+#if 0 // XXX old animation system
id_us_plus((ID *)ltn->ipo);
+#endif // XXX old animation system
ltn->key= copy_key(ltn->key);
if(ltn->key) ltn->key->from= (ID *)ltn;
@@ -564,13 +564,16 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
fac= (cd->dloc[index])/(cu->path->totdist) + (co[index]-cd->dmin[index])/(cu->path->totdist);
}
+#if 0 // XXX old animation system
/* we want the ipo to work on the default 100 frame range, because there's no
actual time involved in path position */
+ // huh? by WHY!!!!???? - Aligorith
if(cu->ipo) {
fac*= 100.0f;
if(calc_ipo_spec(cu->ipo, CU_SPEED, &fac)==0)
fac/= 100.0;
}
+#endif // XXX old animation system
if( where_on_path_deform(par, fac, loc, dir)) { /* returns OK */
float q[4], mat[3][3], quat[4];
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 317ec5b4659..fa728f1a951 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -358,7 +358,7 @@ static ID *alloc_libblock_notest(short type)
id = MEM_callocN(sizeof(bArmature), "armature");
break;
case ID_AC:
- id = MEM_callocN(sizeof(bAction), "action");
+ id = MEM_callocN(sizeof(nAction), "action"); // XXX animation system
break;
case ID_NT:
id = MEM_callocN(sizeof(bNodeTree), "nodetree");
@@ -489,7 +489,7 @@ void free_libblock(ListBase *lb, void *idv)
free_camera((Camera*) id);
break;
case ID_IP:
- free_ipo((Ipo *)id);
+ /*free_ipo((Ipo *)id);*/
break;
case ID_KE:
free_key((Key *)id);
@@ -519,7 +519,7 @@ void free_libblock(ListBase *lb, void *idv)
free_armature((bArmature *)id);
break;
case ID_AC:
- free_action((bAction *)id);
+ free_action((nAction *)id); // XXX animation system...
break;
case ID_NT:
ntreeFreeTree((bNodeTree *)id);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index d34bd02cbcd..66339cd977d 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -193,7 +193,9 @@ Material *copy_material(Material *ma)
man= copy_libblock(ma);
+#if 0 // XXX old animation system
id_us_plus((ID *)man->ipo);
+#endif // XXX old animation system
id_us_plus((ID *)man->group);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ae73de892be..9ebf6a5bec3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -39,13 +39,13 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
@@ -68,14 +68,6 @@
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
-#include "BKE_armature.h"
-#include "BKE_action.h"
-#include "BKE_bullet.h"
-#include "BKE_colortools.h"
-#include "BKE_deform.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_nla.h"
-
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_editVert.h"
@@ -85,6 +77,14 @@
#include "BKE_main.h"
#include "BKE_global.h"
+#include "BKE_armature.h"
+#include "BKE_action.h"
+#include "BKE_bullet.h"
+#include "BKE_colortools.h"
+#include "BKE_deform.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_nla.h"
+#include "BKE_animsys.h"
#include "BKE_anim.h"
#include "BKE_blender.h"
#include "BKE_constraint.h"
@@ -92,7 +92,6 @@
#include "BKE_displist.h"
#include "BKE_group.h"
#include "BKE_icons.h"
-#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -249,8 +248,10 @@ void free_object(Object *ob)
ob->bb= 0;
if(ob->path) free_path(ob->path);
ob->path= 0;
+#if 0 // XXX old animation system
if(ob->ipo) ob->ipo->id.us--;
if(ob->action) ob->action->id.us--;
+#endif // XXX old animation system
if(ob->poselib) ob->poselib->id.us--;
if(ob->dup_group) ob->dup_group->id.us--;
if(ob->defbase.first)
@@ -265,8 +266,9 @@ void free_object(Object *ob)
free_actuators(&ob->actuators);
free_constraints(&ob->constraints);
- free_constraint_channels(&ob->constraintChannels);
+#if 0 // XXX old animation system
free_nlastrips(&ob->nlastrips);
+#endif
#ifndef DISABLE_PYTHON
BPY_free_scriptlink(&ob->scriptlink);
@@ -300,11 +302,10 @@ void unlink_object(Scene *scene, Object *ob)
Scene *sce;
Curve *cu;
Tex *tex;
- Ipo *ipo;
Group *group;
Camera *camera;
bConstraint *con;
- bActionStrip *strip;
+ //bActionStrip *strip; // XXX animsys
ModifierData *md;
int a;
@@ -414,6 +415,7 @@ void unlink_object(Scene *scene, Object *ob)
}
/* strips */
+#if 0 // XXX old animation system
for(strip= obt->nlastrips.first; strip; strip= strip->next) {
if(strip->object==ob)
strip->object= NULL;
@@ -425,6 +427,7 @@ void unlink_object(Scene *scene, Object *ob)
amod->ob= NULL;
}
}
+#endif // XXX old animation system
/* particle systems */
if(obt->particlesystem.first) {
@@ -520,6 +523,8 @@ void unlink_object(Scene *scene, Object *ob)
}
sce= sce->id.next;
}
+
+#if 0 // XXX old animation system
/* ipos */
ipo= G.main->ipo.first;
while(ipo) {
@@ -532,6 +537,7 @@ void unlink_object(Scene *scene, Object *ob)
}
ipo= ipo->id.next;
}
+#endif // XXX old animation system
/* screens */
sc= G.main->screen.first;
@@ -554,6 +560,7 @@ void unlink_object(Scene *scene, Object *ob)
}
}
else if(sl->spacetype==SPACE_IPO) {
+ // XXX animsys this is likely to change...
SpaceIpo *sipo= (SpaceIpo *)sl;
if(sipo->from == (ID *)ob) sipo->from= NULL;
}
@@ -636,7 +643,11 @@ Camera *copy_camera(Camera *cam)
Camera *camn;
camn= copy_libblock(cam);
+
+#if 0 // XXX old animation system
id_us_plus((ID *)camn->ipo);
+#endif // XXX old animation system
+
#ifndef DISABLE_PYTHON
BPY_copy_scriptlink(&camn->scriptlink);
#endif
@@ -783,7 +794,9 @@ Lamp *copy_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
+#if 0 // XXX old animation system
id_us_plus((ID *)lan->ipo);
+#endif // XXX old animation system
if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
#ifndef DISABLE_PYTHON
@@ -866,7 +879,10 @@ void free_lamp(Lamp *la)
if(mtex && mtex->tex) mtex->tex->id.us--;
if(mtex) MEM_freeN(mtex);
}
+
+#if 0 // XXX old animation system
la->ipo= 0;
+#endif // XXX old animation system
curvemapping_free(la->curfalloff);
@@ -962,8 +978,12 @@ Object *add_only_object(int type, char *name)
ob->trackflag= OB_POSY;
ob->upflag= OB_POSZ;
}
+
+#if 0 // XXX old animation system
ob->ipoflag = OB_OFFS_OB+OB_OFFS_PARENT;
ob->ipowin= ID_OB; /* the ipowin shown */
+#endif // XXX old animation system
+
ob->dupon= 1; ob->dupoff= 0;
ob->dupsta= 1; ob->dupend= 100;
ob->dupfacesca = 1.0;
@@ -1126,6 +1146,7 @@ static void copy_object_pose(Object *obn, Object *ob)
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
+#if 0 // XXX old animation system
/* note that we can't change lib linked ipo blocks. for making
* proxies this still works correct however because the object
* is changed to object->proxy_from when evaluating the driver. */
@@ -1136,6 +1157,7 @@ static void copy_object_pose(Object *obn, Object *ob)
icu->driver->ob= obn;
}
}
+#endif // XXX old animation system
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
@@ -1192,15 +1214,17 @@ Object *copy_object(Object *ob)
armature_rebuild_pose(obn, obn->data);
}
copy_defgroups(&obn->defbase, &ob->defbase);
+#if 0 // XXX old animation system
copy_nlastrips(&obn->nlastrips, &ob->nlastrips);
- copy_constraints (&obn->constraints, &ob->constraints);
-
- clone_constraint_channels (&obn->constraintChannels, &ob->constraintChannels);
+#endif // XXX old animation system
+ copy_constraints(&obn->constraints, &ob->constraints);
/* increase user numbers */
id_us_plus((ID *)obn->data);
+#if 0 // XXX old animation system
id_us_plus((ID *)obn->ipo);
id_us_plus((ID *)obn->action);
+#endif // XXX old animation system
id_us_plus((ID *)obn->dup_group);
for(a=0; a<obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
@@ -1227,21 +1251,25 @@ Object *copy_object(Object *ob)
void expand_local_object(Object *ob)
{
- bActionStrip *strip;
+ //bActionStrip *strip;
ParticleSystem *psys;
int a;
-
+
+#if 0 // XXX old animation system
id_lib_extern((ID *)ob->action);
id_lib_extern((ID *)ob->ipo);
+#endif // XXX old animation system
id_lib_extern((ID *)ob->data);
id_lib_extern((ID *)ob->dup_group);
for(a=0; a<ob->totcol; a++) {
id_lib_extern((ID *)ob->mat[a]);
}
+#if 0 // XXX old animation system
for (strip=ob->nlastrips.first; strip; strip=strip->next) {
id_lib_extern((ID *)strip->act);
}
+#endif // XXX old animation system
for(psys=ob->particlesystem.first; psys; psys=psys->next)
id_lib_extern((ID *)psys->part);
}
@@ -1363,7 +1391,9 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
ob->parent= target->parent; /* libdata */
Mat4CpyMat4(ob->parentinv, target->parentinv);
+#if 0 // XXX old animation system
ob->ipo= target->ipo; /* libdata */
+#endif // XXX old animation system
/* skip constraints, constraintchannels, nla? */
@@ -1424,6 +1454,7 @@ void disable_speed_curve(int val)
no_speed_curve= val;
}
+// XXX THIS CRUFT NEEDS SERIOUS RECODING ASAP!
/* ob can be NULL */
float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs)
{
@@ -1435,6 +1466,7 @@ float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs)
/* global time */
cfra*= scene->r.framelen;
+#if 0 // XXX old animation system
if (ob) {
if (no_speed_curve==0 && ob->ipo)
cfra= calc_ipo_time(ob->ipo, cfra);
@@ -1443,6 +1475,7 @@ float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs)
if ((ob->ipoflag & OB_OFFS_PARENT) && (ob->partype & PARSLOW)==0)
cfra-= give_timeoffset(ob);
}
+#endif // XXX old animation system
cfra-= ofs;
@@ -1548,10 +1581,12 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
else if(enable_cu_speed) {
ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0);
+#if 0 // XXX old animation system
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
ctime /= cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
}
+#endif // XXX old animation system
}
else {
ctime= scene->r.cfra - give_timeoffset(ob);
@@ -1766,6 +1801,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
}
}
+// XXX what the hell is this?
static int no_parent_ipo=0;
void set_no_parent_ipo(int val)
{
@@ -1795,7 +1831,7 @@ int during_scriptlink(void) {
void where_is_object_time(Scene *scene, Object *ob, float ctime)
{
float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY;
- float stime, fac1, fac2, vec[3];
+ float stime=ctime, fac1, fac2, vec[3];
int a;
int pop;
@@ -1805,6 +1841,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
if(ob==NULL) return;
+#if 0 // XXX old animation system
/* this is needed to be able to grab objects with ipos, otherwise it always freezes them */
stime= bsystem_time(scene, ob, ctime, 0.0);
if(stime != ob->ctime) {
@@ -1827,10 +1864,15 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* do constraint ipos ..., note it needs stime (1 = only drivers ipos) */
do_constraint_channels(&ob->constraints, &ob->constraintChannels, stime, 1);
}
+#endif // XXX old animation system
+
+ /* execute drivers only, as animation has already been done */
+ BKE_animsys_evaluate_animdata(&ob->id, &ob->adt, ctime, ADT_RECALC_DRIVERS);
if(ob->parent) {
Object *par= ob->parent;
+ // XXX depreceated - animsys
if(ob->ipoflag & OB_OFFS_PARENT) ctime-= give_timeoffset(ob);
/* hurms, code below conflicts with depgraph... (ton) */
@@ -2019,7 +2061,7 @@ void where_is_object_simul(Scene *scene, Object *ob)
for a lamp that is the child of another object */
{
Object *par;
- Ipo *ipo;
+ //Ipo *ipo;
float *fp1, *fp2;
float slowmat[4][4];
float fac1, fac2;
@@ -2028,8 +2070,9 @@ for a lamp that is the child of another object */
/* NO TIMEOFFS */
/* no ipo! (because of dloc and realtime-ipos) */
- ipo= ob->ipo;
- ob->ipo= NULL;
+ // XXX old animation system
+ //ipo= ob->ipo;
+ //ob->ipo= NULL;
if(ob->parent) {
par= ob->parent;
@@ -2065,7 +2108,8 @@ for a lamp that is the child of another object */
}
/* WATCH IT!!! */
- ob->ipo= ipo;
+ // XXX old animation system
+ //ob->ipo= ipo;
}
/* for calculation of the inverse parent transform, only used for editor */
@@ -2287,14 +2331,22 @@ void object_handle_update(Scene *scene, Object *ob)
lattice_calc_modifiers(scene, ob);
}
else if(ob->type==OB_CAMERA) {
- Camera *cam = (Camera *)ob->data;
- calc_ipo(cam->ipo, frame_to_float(scene, scene->r.cfra));
- execute_ipo(&cam->id, cam->ipo);
+ //Camera *cam = (Camera *)ob->data;
+
+ // xxx old animation code here
+ //calc_ipo(cam->ipo, frame_to_float(scene, scene->r.cfra));
+ //execute_ipo(&cam->id, cam->ipo);
+
+ // in new system, this has already been done! - aligorith
}
else if(ob->type==OB_LAMP) {
- Lamp *la = (Lamp *)ob->data;
- calc_ipo(la->ipo, frame_to_float(scene, scene->r.cfra));
- execute_ipo(&la->id, la->ipo);
+ //Lamp *la = (Lamp *)ob->data;
+
+ // xxx old animation code here
+ //calc_ipo(la->ipo, frame_to_float(scene, scene->r.cfra));
+ //execute_ipo(&la->id, la->ipo);
+
+ // in new system, this has already been done! - aligorith
}
else if(ob->type==OB_ARMATURE) {
/* this happens for reading old files and to match library armatures with poses */
@@ -2306,7 +2358,7 @@ void object_handle_update(Scene *scene, Object *ob)
// printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
}
else {
- do_all_pose_actions(scene, ob);
+ //do_all_pose_actions(scene, ob); // xxx old animation system
where_is_pose(scene, ob);
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 9e8651d9847..6b8f7bfecc7 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -46,7 +46,7 @@
#include "DNA_object_types.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_ipo_types.h" // XXX old animation system stuff to remove!
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
@@ -65,7 +65,6 @@
#include "BKE_displist.h"
#include "BKE_particle.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_ipo.h"
#include "BKE_object.h"
#include "BKE_softbody.h"
#include "BKE_material.h"
@@ -1922,10 +1921,12 @@ int psys_threads_init_path(ParticleThread *threads, Scene *scene, float cfra, in
}
/* set correct ipo timing */
+#if 0 // XXX old animation system
if(part->flag&PART_ABS_TIME && part->ipo){
calc_ipo(part->ipo, cfra);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
return 1;
}
@@ -2040,11 +2041,13 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
keys->steps = ctx->steps;
/* correct child ipo timing */
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
float dsta=part->end-part->sta;
calc_ipo(part->ipo, 100.0f*(ctx->cfra-(part->sta+dsta*cpa->rand[1]))/(part->lifetime*(1.0f - part->randlife*cpa->rand[0])));
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
/* get different child parameters from textures & vgroups */
ptex.length=part->length*(1.0f - part->randlength*cpa->rand[0]);
@@ -2922,7 +2925,9 @@ static void default_particle_settings(ParticleSettings *part)
part->boidfac[i]=0.5;
}
+#if 0 // XXX old animation system
part->ipo = NULL;
+#endif // XXX old animation system
part->simplify_refsize= 1920;
part->simplify_rate= 1.0f;
@@ -3257,10 +3262,12 @@ float psys_get_size(Object *ob, Material *ma, ParticleSystemModifierData *psmd,
size=ptex.size;
}
+#if 0 // XXX old animation system
if(icu_size){
calc_icu(icu_size,pa->time);
size*=icu_size->curval;
}
+#endif // XXX old animation system
if(vg_size)
size*=psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_size);
@@ -3298,6 +3305,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra,
if(part->childtype==PART_CHILD_FACES){
size=part->size;
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
IpoCurve *icu;
@@ -3314,6 +3322,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra,
size = icu->curval;
}
}
+#endif // XXX old animation system
}
else
size=psys->particles[cpa->parent].size;
@@ -3536,11 +3545,13 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
}
/* correct child ipo timing */
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
calc_ipo(part->ipo, 100.0f*t);
execute_ipo((ID *)part, part->ipo);
}
-
+#endif // XXX old animation system
+
/* get different child parameters from textures & vgroups */
ptex.clump=1.0;
ptex.kink=1.0;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 20826b6e268..2dea71856e9 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -42,11 +42,11 @@
#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_material_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed!
#include "BLI_rand.h"
#include "BLI_jitter.h"
@@ -68,7 +68,6 @@
#include "BKE_DerivedMesh.h"
#include "BKE_object.h"
#include "BKE_material.h"
-#include "BKE_ipo.h"
#include "BKE_softbody.h"
#include "BKE_depsgraph.h"
#include "BKE_lattice.h"
@@ -1528,7 +1527,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps
ParticleSettings *part;
ParticleTexture ptex;
Material *ma=0;
- IpoCurve *icu=0;
+ //IpoCurve *icu=0; // XXX old animation system
int totpart;
float rand,length;
@@ -1569,11 +1568,13 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps
pa->lifetime=100.0f;
}
else{
+#if 0 // XXX old animation system
icu=find_ipocurve(psys->part->ipo,PART_EMIT_LIFE);
if(icu){
calc_icu(icu,100*ptex.time);
pa->lifetime*=icu->curval;
}
+#endif // XXX old animation system
/* need to get every rand even if we don't use them so that randoms don't affect eachother */
rand= BLI_frand();
@@ -1626,7 +1627,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps
}
static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd)
{
- IpoCurve *icu=0;
+ //IpoCurve *icu=0; // XXX old animation system
ParticleData *pa;
int p, totpart=psys->totpart;
@@ -1634,6 +1635,7 @@ static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleS
initialize_particle(pa,p,ob,psys,psmd);
if(psys->part->type != PART_FLUID) {
+#if 0 // XXX old animation system
icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ);
if(icu){
float time=psys->part->sta, end=psys->part->end;
@@ -1642,6 +1644,7 @@ static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleS
p=0;
pa=psys->particles;
+
calc_icu(icu,time);
v1=icu->curval;
if(v1<0.0f) v1=0.0f;
@@ -1682,6 +1685,7 @@ static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleS
pa->flag |= PARS_UNEXIST;
}
}
+#endif // XXX old animation system
}
}
/* sets particle to the emitter surface with initial velocity & rotation */
@@ -1691,7 +1695,7 @@ static void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys,
ParticleSettings *part;
ParticleTexture ptex;
ParticleKey state;
- IpoCurve *icu=0;
+ //IpoCurve *icu=0; // XXX old animation system
float fac, phasefac, nor[3]={0,0,0},loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4];
float r_vel[3],r_ave[3],r_rot[4],p_vel[3]={0.0,0.0,0.0};
float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0};
@@ -1834,11 +1838,13 @@ static void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys,
if(part->partfac!=0.0)
VECADDFAC(vel,vel,p_vel,part->partfac);
+#if 0 // XXX old animation system
icu=find_ipocurve(psys->part->ipo,PART_EMIT_VEL);
if(icu){
calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta)));
ptex.ivel*=icu->curval;
}
+#endif // XXX old animation system
VecMulf(vel,ptex.ivel);
@@ -1908,11 +1914,13 @@ static void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys,
Normalize(pa->state.ave);
VecMulf(pa->state.ave,part->avefac);
+#if 0 // XXX old animation system
icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE);
if(icu){
calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta)));
VecMulf(pa->state.ave,icu->curval);
}
+#endif // XXX old animation system
}
pa->dietime = pa->time + pa->lifetime;
@@ -3928,12 +3936,12 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
ParticleSettings *part=psys->part;
KDTree *tree=0;
BoidVecFunc bvf;
- IpoCurve *icu_esize=find_ipocurve(part->ipo,PART_EMIT_SIZE);
+ IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system
Material *ma=give_current_material(ob,part->omat);
float timestep;
int p, totpart;
/* current time */
- float ctime, ipotime;
+ float ctime, ipotime; // XXX old animation system
/* frame & time changes */
float dfra, dtime, pa_dtime, pa_dfra=0.0;
float birthtime, dietime;
@@ -3946,12 +3954,14 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
timestep=psys_get_timestep(part);
dtime= dfra*timestep;
ctime= cfra*timestep;
- ipotime= cfra;
+ ipotime= cfra; // XXX old animation system
+#if 0 // XXX old animation system
if(part->flag&PART_ABS_TIME && part->ipo){
calc_ipo(part->ipo, cfra);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
if(dfra<0.0){
float *vg_size=0;
@@ -3962,11 +3972,13 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
if(pa->flag & PARS_UNEXIST) continue;
/* set correct ipo timing */
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
ipotime=100.0f*(cfra-pa->time)/pa->lifetime;
calc_ipo(part->ipo, ipotime);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
pa->size=psys_get_size(ob,ma,psmd,icu_esize,psys,part,pa,vg_size);
reset_particle(scene, pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
@@ -4024,11 +4036,13 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
copy_particle_key(&pa->prev_state,&pa->state,1);
/* set correct ipo timing */
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
ipotime=100.0f*(cfra-pa->time)/pa->lifetime;
calc_ipo(part->ipo, ipotime);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
pa->size=psys_get_size(ob,ma,psmd,icu_esize,psys,part,pa,vg_size);
/* reactions can change birth time so they need to be checked first */
@@ -4198,7 +4212,7 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps
ParticleSettings *part=psys->part;
ParticleData *pa;
ParticleKey state;
- IpoCurve *icu_esize=find_ipocurve(part->ipo,PART_EMIT_SIZE);
+ IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system
Material *ma=give_current_material(ob,part->omat);
int p;
float ipotime=cfra, disp, birthtime, dietime, *vg_size= NULL;
@@ -4218,11 +4232,13 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps
disp= (float)get_current_display_percentage(psys)/50.0f-1.0f;
for(p=0, pa=psys->particles; p<psys->totpart; p++,pa++){
+#if 0 // XXX old animation system
if((part->flag&PART_ABS_TIME)==0 && part->ipo){
ipotime=100.0f*(cfra-pa->time)/pa->lifetime;
calc_ipo(part->ipo, ipotime);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
pa->size= psys_get_size(ob,ma,psmd,icu_esize,psys,part,pa,vg_size);
psys->lattice= psys_get_lattice(scene, ob, psys);
@@ -4437,10 +4453,12 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
BKE_ptcache_id_time(&pid, scene, 0.0f, &startframe, &endframe, NULL);
/* update ipo's */
+#if 0 // XXX old animation system
if((part->flag & PART_ABS_TIME) && part->ipo) {
calc_ipo(part->ipo, cfra);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
/* hair if it's already done is handled separate */
if(part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)) {
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 059aeadb24f..9c74014853d 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -404,7 +404,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
*startframe= cache->startframe;
*endframe= cache->endframe;
- if ((ob->ipoflag & OB_OFFS_PARENT) && (ob->partype & PARSLOW)==0) {
+ // XXX ipoflag is depreceated - old animation system stuff
+ if (/*(ob->ipoflag & OB_OFFS_PARENT) &&*/ (ob->partype & PARSLOW)==0) {
offset= give_timeoffset(ob);
*startframe += (int)(offset+0.5f);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index efd27342aed..8fbbe83373e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -43,6 +43,7 @@
#endif
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_color_types.h"
#include "DNA_constraint_types.h"
@@ -59,6 +60,7 @@
#include "BKE_action.h"
#include "BKE_anim.h"
+#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_colortools.h"
#include "BKE_colortools.h"
@@ -577,22 +579,54 @@ static void scene_update(Scene *sce, unsigned int lay)
object_handle_update(sce, ob); // bke_object.h
/* only update layer when an ipo */
- if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
- base->lay= ob->lay;
- }
+ // XXX old animation system
+ //if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
+ // base->lay= ob->lay;
+ //}
}
}
+/* This (evil) function is needed to cope with two legacy Blender rendering features
+ * mblur (motion blur that renders 'subframes' and blurs them together), and fields
+ * rendering. Thus, the use of ugly globals from object.c
+ */
+// BAD... EVIL... JUJU...!!!!
+// XXX moved here temporarily
+float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */
+{
+ extern float bluroffs; /* bad stuff borrowed from object.c */
+ extern float fieldoffs;
+ float ctime;
+
+ ctime= (float)cfra;
+ ctime+= bluroffs+fieldoffs;
+ ctime*= scene->r.framelen;
+
+ return ctime;
+}
+
/* applies changes right away, does all sets too */
void scene_update_for_newframe(Scene *sce, unsigned int lay)
{
Scene *scene= sce;
+ float ctime = frame_to_float(sce, sce->r.cfra);
/* clears all BONE_UNKEYED flags for every pose's pchans */
- framechange_poses_clear_unkeyed();
+ // xxx old animation system
+ //framechange_poses_clear_unkeyed();
+
+ /* clear animation overrides */
+ // XXX TODO...
+
+ /* All 'standard' (i.e. without any dependencies) animation is handled here,
+ * with an 'local' to 'macro' order of evaluation. This should ensure that
+ * settings stored nestled within a hierarchy (i.e. settings in a Texture block
+ * can be overridden by settings from Scene, which owns the Texture through a hierarchy
+ * such as Scene->World->MTex/Texture) can still get correctly overridden.
+ */
+ BKE_animsys_evaluate_all_animation(G.main, ctime);
+
- /* object ipos are calculated in where_is_object */
- do_all_data_ipos(sce);
#ifndef DISABLE_PYTHON
if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
#endif
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 9036156d6b6..01effda2e30 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -41,7 +41,6 @@
#include "BLI_arithb.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
#include "BKE_plugin_types.h"
#include "BKE_sequence.h"
#include "BKE_texture.h"
@@ -2776,7 +2775,7 @@ static void store_icu_yrange_speed(struct Sequence * seq,
void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
{
float facf0 = seq->facf0;
- float ctime, div;
+ //float ctime, div;
int cfra;
float fallback_fac;
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
@@ -2801,8 +2800,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
/* if there is no IPO, try to make retiming easy by stretching the
strip */
-
- if (!seq->ipo && seq->seq1 && seq->seq1->enddisp != seq->seq1->start
+ // XXX old animation system - seq
+ if (/*!seq->ipo &&*/ seq->seq1 && seq->seq1->enddisp != seq->seq1->start
&& seq->seq1->len != 0) {
fallback_fac = (float) seq->seq1->len /
(float) (seq->seq1->enddisp - seq->seq1->start);
@@ -2825,6 +2824,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
v->lastValidFrame = 0;
for (cfra = 1; cfra < v->length; cfra++) {
+#if 0 // XXX old animation system
if(seq->ipo) {
if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
ctime = frame_to_float(scene, seq->startdisp + cfra);
@@ -2837,7 +2837,9 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
calc_ipo(seq->ipo, ctime/div);
execute_ipo((ID *)seq, seq->ipo);
- } else {
+ } else
+#endif // XXX old animation system
+ {
seq->facf0 = fallback_fac;
}
seq->facf0 *= v->globalSpeed;
@@ -2854,6 +2856,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
} else {
v->lastValidFrame = 0;
for (cfra = 0; cfra < v->length; cfra++) {
+#if 0 // XXX old animation system
if(seq->ipo) {
if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
ctime = frame_to_float(scene, seq->startdisp + cfra);
@@ -2867,11 +2870,12 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
calc_ipo(seq->ipo, ctime/div);
execute_ipo((ID *)seq, seq->ipo);
}
+#endif // XXX old animation system
if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
seq->facf0 *= v->length;
}
- if (!seq->ipo) {
+ if (/*!seq->ipo*/ 1) { // XXX old animation system - seq
seq->facf0 = (float) cfra * fallback_fac;
}
seq->facf0 *= v->globalSpeed;
diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c
index 5cc087e857e..9fd924f7e7a 100644
--- a/source/blender/blenkernel/intern/sequence.c
+++ b/source/blender/blenkernel/intern/sequence.c
@@ -33,14 +33,12 @@
#include "MEM_guardedalloc.h"
-#include "DNA_ipo_types.h"
#include "DNA_listBase.h"
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
#include "BKE_global.h"
#include "BKE_image.h"
-#include "BKE_ipo.h"
#include "BKE_main.h"
#include "BKE_sequence.h"
#include "BKE_utildefines.h"
@@ -790,11 +788,14 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se)
return;
}
+#if 0 // XXX old animation system
if(seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(scene, seq, cfra);
fac= seq->facf0;
facf= seq->facf1;
- } else {
+ } else
+#endif // XXX old animation system
+ {
sh.get_default_fac(seq, cfra, &fac, &facf);
}
@@ -956,8 +957,8 @@ TStripElem *give_tstripelem(Sequence *seq, int cfra)
alpha over mode...
*/
if (seq->blend_mode != SEQ_BLEND_REPLACE ||
- (seq->ipo && seq->ipo->curve.first && (
- !(seq->type & SEQ_EFFECT) || !seq->seq1))) {
+ (/*seq->ipo && seq->ipo->curve.first &&*/
+ (!(seq->type & SEQ_EFFECT) || !seq->seq1))) {
Strip * s = seq->strip;
if (cfra < seq->start) {
se = s->tstripdata_startstill;
@@ -1503,10 +1504,12 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se
mul = seq->mul;
if(seq->blend_mode == SEQ_BLEND_REPLACE) {
+#if 0 // XXX old animation system
if (seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(scene, seq, cfra);
mul *= seq->facf0;
}
+#endif // XXX old animation system
mul *= seq->blend_opacity / 100.0;
}
@@ -1591,10 +1594,12 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf
mul = seq->mul;
if(seq->blend_mode == SEQ_BLEND_REPLACE) {
+#if 0 // XXX old animation system
if (seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(scene, seq, cfra);
mul *= seq->facf0;
}
+#endif // XXX old animation system
mul *= seq->blend_opacity / 100.0;
}
@@ -1988,11 +1993,14 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s
se->se2 = 0;
se->se3 = 0;
+#if 0 // XXX old animation system
if(seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(scene, seq, cfra);
fac= seq->facf0;
facf= seq->facf1;
- } else {
+ } else
+#endif // XXX old animation system
+ {
sh.get_default_fac(seq, cfra, &fac, &facf);
}
@@ -2248,9 +2256,11 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
seq->facf0 = seq->facf1 = 1.0;
+#if 0 // XXX old animation system
if(seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(scene, seq, cfra);
}
+#endif
if( scene->r.mode & R_FIELDS ); else seq->facf0 = seq->facf1;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 70ced6e59d6..495d50725d0 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -72,7 +72,6 @@
#include "BKE_texture.h"
#include "BKE_key.h"
#include "BKE_icons.h"
-#include "BKE_ipo.h"
#include "BKE_brush.h"
#include "BKE_node.h"
@@ -570,7 +569,9 @@ Tex *copy_texture(Tex *tex)
if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
else texn->ima= 0;
+#if 0 // XXX old animation system
id_us_plus((ID *)texn->ipo);
+#endif // XXX old animation system
if(texn->plugin) {
texn->plugin= MEM_dupallocN(texn->plugin);
@@ -888,13 +889,17 @@ int BKE_texture_dependsOnTime(const struct Tex *texture)
if(texture->plugin) {
// assume all plugins depend on time
return 1;
- } else if( texture->ima &&
+ }
+ else if( texture->ima &&
ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
return 1;
- } else if(texture->ipo) {
+ }
+#if 0 // XXX old animation system
+ else if(texture->ipo) {
// assume any ipo means the texture is animated
return 1;
}
+#endif // XXX old animation system
return 0;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index bef372e39f1..bd747bc1b61 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -76,7 +76,10 @@ void free_world(World *wrld)
}
BKE_previewimg_free(&wrld->preview);
+#if 0 // XXX old animation system
wrld->ipo= 0;
+#endif // XXX old animation system
+
BKE_icon_delete((struct ID*)wrld);
wrld->id.icon_id = 0;
}
@@ -129,7 +132,10 @@ World *copy_world(World *wrld)
#ifndef DISABLE_PYTHON
BPY_copy_scriptlink(&wrld->scriptlink);
#endif
+
+#if 0 // XXX old animation system
id_us_plus((ID *)wrldn->ipo);
+#endif // XXX old animation system
return wrldn;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8e5b7ff06ed..5fb5ada09c0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8452,10 +8452,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
IpoCurve *icu;
/* fix IPO-curves to work with new interpolation options */
- for (ipo=main->ipo.first; ipo; ipo= ipo->id.next) {
- for (icu= ipo->curve.first; icu; icu= icu->next)
- set_interpolation_ipocurve(icu, icu->ipo);
- }
+ //for (ipo=main->ipo.first; ipo; ipo= ipo->id.next) {
+ // for (icu= ipo->curve.first; icu; icu= icu->next)
+ // set_interpolation_ipocurve(icu, icu->ipo); // function removed (XXX add it here)
+ //}
/* adjust default settings for Animation Editors */
for (sc= main->screen.first; sc; sc= sc->id.next) {
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index e6b8293071f..2bf433dab46 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -524,7 +524,7 @@ static int animdata_filter_ipocurves (ListBase *anim_data, Ipo *ipo, int filter_
/* 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))) {
+ if (!(filter_mode & ANIMFILTER_SEL) || (filter_mode & ANIMFILTER_ONLYFCU) || (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);
@@ -556,7 +556,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
/* 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) {
+ if ((filter_mode & ANIMFILTER_ONLYFCU)==0) {
ale= make_new_animlistelem(achan, ANIMTYPE_ACHAN, achan, ANIMTYPE_ACHAN);
if (ale) {
@@ -572,7 +572,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
}
/* check if expanded - if not, continue on to next animion channel */
- if (EXPANDED_ACHAN(achan) == 0 && (filter_mode & ANIMFILTER_ONLYICU)==0) {
+ if (EXPANDED_ACHAN(achan) == 0 && (filter_mode & ANIMFILTER_ONLYFCU)==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 items;
@@ -581,7 +581,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
/* ipo channels */
if ((achan->ipo) && (filter_mode & ANIMFILTER_IPOKEYS)==0) {
/* include ipo-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && (filter_mode & ANIMFILTER_ONLYICU)==0) {
+ if ((filter_mode & ANIMFILTER_CHANNELS) && (filter_mode & ANIMFILTER_ONLYFCU)==0) {
ale= make_new_animlistelem(achan, ANIMTYPE_FILLIPO, achan, ANIMTYPE_ACHAN);
if (ale) {
@@ -592,7 +592,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
}
/* add ipo-curve channels? */
- if (FILTER_IPO_ACHAN(achan) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ if (FILTER_IPO_ACHAN(achan) || (filter_mode & ANIMFILTER_ONLYFCU)) {
/* loop through ipo-curve channels, adding them */
items += animdata_filter_ipocurves(anim_data, achan->ipo, filter_mode, achan, ANIMTYPE_ACHAN, (owned)?(owner):(NULL));
}
@@ -601,7 +601,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
/* constraint channels */
if (achan->constraintChannels.first) {
/* include constraint-expand widget? */
- if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYICU)
+ if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYFCU)
&& !(filter_mode & ANIMFILTER_IPOKEYS) )
{
ale= make_new_animlistelem(achan, ANIMTYPE_FILLCON, achan, ANIMTYPE_ACHAN);
@@ -614,7 +614,7 @@ static int animdata_filter_actionchannel (ListBase *anim_data, bActionChannel *a
}
/* add constraint channels? */
- if (FILTER_CON_ACHAN(achan) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ if (FILTER_CON_ACHAN(achan) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) {
/* loop through constraint channels, checking and adding them */
for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next) {
/* only work with this channel and its subchannels if it is editable */
@@ -662,7 +662,7 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
/* loop over groups */
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
/* add this group as a channel first */
- if (!(filter_mode & ANIMFILTER_ONLYICU) && !(filter_mode & ANIMFILTER_IPOKEYS)) {
+ if (!(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS)) {
/* check if filtering by selection */
if ( !(filter_mode & ANIMFILTER_SEL) || SEL_AGRP(agrp) ) {
ale= make_new_animlistelem(agrp, ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE);
@@ -691,7 +691,7 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
* - we're interested in keyframes, but not if they appear in selected channels
*/
if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(agrp)) ||
- ( ((filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ ( ((filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
(!(filter_mode & ANIMFILTER_SEL) || (SEL_AGRP(agrp))) ) )
{
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
@@ -798,7 +798,7 @@ static int animdata_filter_gpencil (ListBase *anim_data, bScreen *sc, int filter
int items = 0;
/* check if filtering types are appropriate */
- if ( !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU|ANIMFILTER_ACTGROUPED)) )
+ if ( !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU|ANIMFILTER_ACTGROUPED)) )
{
/* special hack for fullscreen area (which must be this one then):
* - we use the curarea->full as screen to get spaces from, since the
@@ -859,7 +859,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
int items = 0;
/* include materials-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) {
+ if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) {
ale= make_new_animlistelem(ob, ANIMTYPE_FILLMATD, base, ANIMTYPE_OBJECT);
if (ale) {
BLI_addtail(anim_data, ale);
@@ -868,7 +868,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
}
/* add materials? */
- if (FILTER_MAT_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ if (FILTER_MAT_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) {
short a;
/* for each material, either add channels separately, or as ipo-block */
@@ -889,7 +889,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
}
/* add material's ipo-curve channels? */
- if ( (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ if ( (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
items += animdata_filter_ipocurves(anim_data, ma->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ma);
@@ -919,7 +919,7 @@ static int animdata_filter_dopesheet_cam (ListBase *anim_data, bDopeSheet *ads,
}
/* add camera ipo-curve channels? */
- if ( (FILTER_CAM_OBJD(ca) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ if ( (FILTER_CAM_OBJD(ca) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
items += animdata_filter_ipocurves(anim_data, ca->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ca);
@@ -946,7 +946,7 @@ static int animdata_filter_dopesheet_lamp (ListBase *anim_data, bDopeSheet *ads,
}
/* add lamp ipo-curve channels? */
- if ( (FILTER_LAM_OBJD(la) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ if ( (FILTER_LAM_OBJD(la) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
items += animdata_filter_ipocurves(anim_data, la->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)la);
@@ -973,7 +973,7 @@ static int animdata_filter_dopesheet_curve (ListBase *anim_data, bDopeSheet *ads
}
/* add curve ipo-curve channels? */
- if ( (FILTER_CUR_OBJD(cu) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ if ( (FILTER_CUR_OBJD(cu) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
items += animdata_filter_ipocurves(anim_data, cu->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)cu);
@@ -992,7 +992,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
int items = 0;
/* add this object as a channel first */
- if (!(filter_mode & ANIMFILTER_ONLYICU) && !(filter_mode & ANIMFILTER_IPOKEYS)) {
+ if (!(filter_mode & ANIMFILTER_ONLYFCU) && !(filter_mode & ANIMFILTER_IPOKEYS)) {
/* check if filtering by selection */
if ( !(filter_mode & ANIMFILTER_SEL) || ((base->flag & SELECT) || (base == sce->basact)) ) {
ale= make_new_animlistelem(base, ANIMTYPE_OBJECT, NULL, ANIMTYPE_NONE);
@@ -1004,7 +1004,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
}
/* if collapsed, don't go any further (unless adding keyframes only) */
- if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU)) )
+ if ( (EXPANDED_OBJC(ob) == 0) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU)) )
return items;
/* IPO? */
@@ -1019,7 +1019,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
}
/* add ipo-curve channels? */
- if ( (FILTER_IPO_OBJC(ob) || (filter_mode & ANIMFILTER_ONLYICU)) &&
+ if ( (FILTER_IPO_OBJC(ob) || (filter_mode & ANIMFILTER_ONLYFCU)) &&
!(filter_mode & ANIMFILTER_IPOKEYS) )
{
items += animdata_filter_ipocurves(anim_data, ob->ipo, filter_mode, base, ANIMTYPE_OBJECT, NULL); // err... why not set ob?
@@ -1029,7 +1029,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* Action? */
if ((ob->action) && !(ads->filterflag & ADS_FILTER_NOACTS)) {
/* include animion-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) {
+ if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) {
ale= make_new_animlistelem(ob->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT);
if (ale) {
ale->id= (ID *)ob; // err.... is this a good idea?
@@ -1048,7 +1048,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
/* ShapeKeys? */
if ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
/* include shapekey-expand widget? */
- if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYICU))) {
+ if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & (ANIMFILTER_IPOKEYS|ANIMFILTER_ONLYFCU))) {
ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT);
if (ale) {
BLI_addtail(anim_data, ale);
@@ -1057,7 +1057,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
}
/* add channels */
- if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) {
items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT);
}
}
@@ -1096,7 +1096,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
bConstraintChannel *conchan;
/* include constraint-expand widget? */
- if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYICU)
+ if ( (filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_ONLYFCU)
&& !(filter_mode & ANIMFILTER_IPOKEYS) )
{
ale= make_new_animlistelem(ob, ANIMTYPE_FILLCOND, base, ANIMTYPE_OBJECT);
@@ -1107,7 +1107,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
}
/* add constraint channels? */
- if (FILTER_CON_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYICU)) {
+ if (FILTER_CON_OBJC(ob) || (filter_mode & ANIMFILTER_IPOKEYS) || (filter_mode & ANIMFILTER_ONLYFCU)) {
/* loop through constraint channels, checking and adding them */
for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) {
/* only work with this channel and its subchannels if it is editable */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 503e083d061..8ef7eedb4c0 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -52,6 +52,7 @@
#include "WM_types.h"
#include "ED_anim_api.h"
+#include "ED_keyframing.h" // XXX remove?
#include "ED_markers.h"
#include "ED_screen.h"
@@ -359,6 +360,10 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_previewrange_define);
WM_operatortype_append(ANIM_OT_previewrange_clear);
+
+ // XXX this is used all over... maybe for screen instead?
+ WM_operatortype_append(ANIM_OT_insert_keyframe);
+ WM_operatortype_append(ANIM_OT_delete_keyframe);
}
void ED_keymap_anim(wmWindowManager *wm)
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 6f1f454b907..b38cbde7410 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -34,17 +34,18 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_ipo_types.h" // XXX to be phased out
#include "DNA_key_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "BKE_action.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_utildefines.h"
@@ -218,16 +219,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
int filter;
/* filter animation data */
- filter= ANIMFILTER_ONLYICU;
+ filter= ANIMFILTER_ONLYFCU;
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* loop over ipo-curves that are likely to have been edited, and check them */
for (ale= anim_data.first; ale; ale= ale->next) {
- IpoCurve *icu= ale->key_data;
+ FCurve *fcu= ale->key_data;
/* make sure keyframes in IPO-curve are all in order, and handles are in valid positions */
- sort_time_ipocurve(icu);
- testhandles_ipocurve(icu);
+ sort_time_fcurve(fcu);
+ testhandles_fcurve(fcu);
}
/* free temp data */
@@ -404,56 +405,6 @@ BeztEditFunc ANIM_editkeyframes_mirror(short type)
}
}
-/* --------- */
-
-/* This function is called to calculate the average location of the
- * selected keyframes, and place the current frame at that location.
- *
- * It must be called like so:
- * snap_cfra_ipo_keys(scene, NULL, -1); // initialise the static vars first
- * for (ipo...) snap_cfra_ipo_keys(scene, ipo, 0); // sum up keyframe times
- * snap_cfra_ipo_keys(scene, NULL, 1); // set current frame after taking average
- */
-// XXX this thing needs to be refactored!
-void snap_cfra_ipo_keys(BeztEditData *bed, Ipo *ipo, short mode)
-{
- static int cfra;
- static int tot;
-
- Scene *scene= bed->scene;
- IpoCurve *icu;
- BezTriple *bezt;
- int a;
-
-
- if (mode == -1) {
- /* initialise a new snap-operation */
- cfra= 0;
- tot= 0;
- }
- else if (mode == 1) {
- /* set current frame - using average frame */
- if (tot != 0)
- CFRA = cfra / tot;
- }
- else {
- /* loop through keys in ipo, summing the frame
- * numbers of those that are selected
- */
- if (ipo == NULL)
- return;
-
- for (icu= ipo->curve.first; icu; icu= icu->next) {
- for (a=0, bezt=icu->bezt; a < icu->totvert; a++, bezt++) {
- if (BEZSELECTED(bezt)) {
- cfra += (int)floor(bezt->vec[1][0] + 0.5f);
- tot++;
- }
- }
- }
- }
-}
-
/* ******************************************* */
/* Settings */
@@ -548,7 +499,7 @@ void ANIM_editkeyframes_ipocurve_ipotype(IpoCurve *icu)
icu->ipo= IPO_MIXED;
/* recalculate handles, as some changes may have occurred */
- calchandles_ipocurve(icu);
+ //calchandles_ipocurve(icu); // XXX
}
static short set_bezt_constant(BeztEditData *bed, BezTriple *bezt)
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 57a4d6952c7..8ff65a2a008 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -35,16 +35,17 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_ipo_types.h" // XXX to be removed
#include "DNA_key_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "BKE_action.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_utildefines.h"
@@ -69,25 +70,26 @@
* Not recommended to be used many times successively. For that
* there is delete_ipo_keys().
*/
-void delete_icu_key(IpoCurve *icu, int index, short do_recalc)
+void delete_fcurve_key(FCurve *fcu, int index, short do_recalc)
{
/* firstly check that index is valid */
if (index < 0)
index *= -1;
- if (icu == NULL)
+ if (fcu == NULL)
return;
- if (index >= icu->totvert)
+ if (index >= fcu->totvert)
return;
/* Delete this key */
- memmove(&icu->bezt[index], &icu->bezt[index+1], sizeof(BezTriple)*(icu->totvert-index-1));
- icu->totvert--;
+ memmove(&fcu->bezt[index], &fcu->bezt[index+1], sizeof(BezTriple)*(fcu->totvert-index-1));
+ fcu->totvert--;
/* recalc handles - only if it won't cause problems */
if (do_recalc)
- calchandles_ipocurve(icu);
+ calchandles_fcurve(fcu);
}
+#if 0 // XXX obsolete
/* Delete selected keyframes in given IPO block */
void delete_ipo_keys(Ipo *ipo)
{
@@ -117,6 +119,7 @@ void delete_ipo_keys(Ipo *ipo)
}
}
}
+#endif // XXX obsolete
/* ---------------- */
@@ -160,26 +163,31 @@ void duplicate_ipo_keys(Ipo *ipo)
/* **************************************************** */
/* Various Tools */
+// XXX - stub... until keyframing code is fixed...
+static void insert_vert_fcu(FCurve *fcu, float x, float y, short flag)
+{
+}
+
/* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */
-void clean_ipo_curve(IpoCurve *icu, float thresh)
+void clean_fcurve(FCurve *fcu, float thresh)
{
BezTriple *old_bezts, *bezt, *beztn;
BezTriple *lastb;
int totCount, i;
/* check if any points */
- if ((icu == NULL) || (icu->totvert <= 1))
+ if ((fcu == NULL) || (fcu->totvert <= 1))
return;
/* make a copy of the old BezTriples, and clear IPO curve */
- old_bezts = icu->bezt;
- totCount = icu->totvert;
- icu->bezt = NULL;
- icu->totvert = 0;
+ old_bezts = fcu->bezt;
+ totCount = fcu->totvert;
+ fcu->bezt = NULL;
+ fcu->totvert = 0;
/* now insert first keyframe, as it should be ok */
bezt = old_bezts;
- insert_vert_icu(icu, bezt->vec[1][0], bezt->vec[1][1], 0);
+ insert_vert_fcu(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
/* Loop through BezTriples, comparing them. Skip any that do
* not fit the criteria for "ok" points.
@@ -196,7 +204,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh)
beztn = NULL;
next[0] = next[1] = 0.0f;
}
- lastb= (icu->bezt + (icu->totvert - 1));
+ lastb= (fcu->bezt + (fcu->totvert - 1));
bezt= (old_bezts + i);
/* get references for quicker access */
@@ -216,7 +224,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh)
if (cur[1] > next[1]) {
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
/* add new keyframe */
- insert_vert_icu(icu, cur[0], cur[1], 0);
+ insert_vert_fcu(fcu, cur[0], cur[1], 0);
}
}
}
@@ -224,7 +232,7 @@ void clean_ipo_curve(IpoCurve *icu, float thresh)
/* only add if values are a considerable distance apart */
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
/* add new keyframe */
- insert_vert_icu(icu, cur[0], cur[1], 0);
+ insert_vert_fcu(fcu, cur[0], cur[1], 0);
}
}
}
@@ -234,18 +242,18 @@ void clean_ipo_curve(IpoCurve *icu, float thresh)
/* does current have same value as previous and next? */
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
/* add new keyframe*/
- insert_vert_icu(icu, cur[0], cur[1], 0);
+ insert_vert_fcu(fcu, cur[0], cur[1], 0);
}
else if (IS_EQT(cur[1], next[1], thresh) == 0) {
/* add new keyframe */
- insert_vert_icu(icu, cur[0], cur[1], 0);
+ insert_vert_fcu(fcu, cur[0], cur[1], 0);
}
}
else {
/* add if value doesn't equal that of previous */
if (IS_EQT(cur[1], prev[1], thresh) == 0) {
/* add new keyframe */
- insert_vert_icu(icu, cur[0], cur[1], 0);
+ insert_vert_fcu(fcu, cur[0], cur[1], 0);
}
}
}
@@ -264,8 +272,8 @@ typedef struct tSmooth_Bezt {
} tSmooth_Bezt;
/* Use a weighted moving-means method to reduce intensity of fluctuations */
-//mode= pupmenu("Smooth IPO%t|Tweak Points%x1|Flatten Handles%x2");
-void smooth_ipo_curve(IpoCurve *icu, short mode)
+//mode= pupmenu("Smooth F-Curve%t|Tweak Points%x1|Flatten Handles%x2");
+void smooth_fcurve(FCurve *fcu, short mode)
{
BezTriple *bezt;
int i, x, totSel = 0;
@@ -273,8 +281,8 @@ void smooth_ipo_curve(IpoCurve *icu, short mode)
/* first loop through - count how many verts are selected, and fix up handles
* this is done for both modes
*/
- bezt= icu->bezt;
- for (i=0; i < icu->totvert; i++, bezt++) {
+ bezt= fcu->bezt;
+ for (i=0; i < fcu->totvert; i++, bezt++) {
if (BEZSELECTED(bezt)) {
/* line point's handles up with point's vertical position */
bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
@@ -296,8 +304,8 @@ void smooth_ipo_curve(IpoCurve *icu, short mode)
tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array");
/* populate tarray with data of selected points */
- bezt= icu->bezt;
- for (i=0, x=0; (i < icu->totvert) && (x < totSel); i++, bezt++) {
+ bezt= fcu->bezt;
+ for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) {
if (BEZSELECTED(bezt)) {
/* tsb simply needs pointer to vec, and index */
tsb->h1 = &bezt->vec[0][1];
@@ -358,7 +366,7 @@ void smooth_ipo_curve(IpoCurve *icu, short mode)
}
/* recalculate handles */
- calchandles_ipocurve(icu);
+ calchandles_fcurve(fcu);
}
/* **************************************************** */
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 5121932d0cc..4f62368c2b2 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1,123 +1,48 @@
-/**
- * $Id: keyframing.c 17745 2008-12-08 09:16:09Z aligorith $
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2008, Blender Foundation
- * This is a new part of Blender (with some old code)
- *
- * Contributor(s): Joshua Leung
- *
- * ***** END GPL LICENSE BLOCK *****
+/* Testing code for 2.5 animation system
+ * Copyright 2009, Joshua Leung
*/
-
-
-
+
#include <stdio.h>
#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
#include <math.h>
#include <float.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "MEM_guardedalloc.h"
-#include "BLI_arithb.h"
#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
#include "BLI_dynstr.h"
-#include "DNA_listBase.h"
-#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
-#include "DNA_lamp_types.h"
#include "DNA_object_types.h"
-#include "DNA_object_fluidsim.h"
-#include "DNA_particle_types.h"
#include "DNA_material_types.h"
-#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_space_types.h"
-#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
-#include "DNA_vec_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
#include "DNA_windowmanager_types.h"
-#include "BKE_context.h"
-#include "BKE_utildefines.h"
-#include "BKE_blender.h"
+#include "BKE_animsys.h"
#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_constraint.h"
-#include "BKE_curve.h"
-#include "BKE_depsgraph.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
+#include "BKE_utildefines.h"
+#include "BKE_context.h"
#include "BKE_key.h"
-#include "BKE_object.h"
-#include "BKE_particle.h"
#include "BKE_material.h"
-#include "BKE_modifier.h"
#include "ED_anim_api.h"
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
+#include "ED_screen.h"
+#include "ED_util.h"
#include "WM_api.h"
#include "WM_types.h"
-#if 0 // XXX resolve these old dependencies!
- #include "BIF_butspace.h"
- #include "BIF_editaction.h"
- #include "BIF_editkey.h"
- #include "BIF_interface.h"
- #include "BIF_mywindow.h"
- #include "BIF_poseobject.h"
- #include "BIF_screen.h"
- #include "BIF_space.h"
- #include "BIF_toolbox.h"
- #include "BIF_toets.h"
-
- #include "BSE_editipo.h"
- #include "BSE_node.h"
- #include "BSE_time.h"
- #include "BSE_view.h"
-
- #include "blendef.h"
-
- #include "PIL_time.h" /* sleep */
- #include "mydevice.h"
-#endif // XXX resolve these old dependencies!
-
-/* ****************************************** */
-
-/* note for Joshua: add_ipo() wants scene pointer to init the view2d 'cur' for
- the ipo data, which restores views. Needs to be resolved nicer? */
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_types.h"
/* ************************************************** */
/* LOCAL TYPES AND DEFINES */
@@ -130,34 +55,15 @@ typedef struct bCommonKeySrc {
/* general data/destination-source settings */
ID *id; /* id-block this comes from */
- char *actname; /* name of action channel */
- char *constname; /* name of constraint channel */
+ char *rna_path; /* base path to use */ // xxx.... maybe we don't need this?
- /* general destination source settings */
- Ipo *ipo; /* ipo-block that id-block has (optional) */
- bAction *act; /* action-block that id-block has (optional) */
-
- /* pose-level settings */
- bPoseChannel *pchan; /* pose channel */
-
- /* buttons-window settings */
- int map; /* offset to apply to certain adrcodes */
+ /* specific cases */
+ bPoseChannel *pchan; /* only needed when doing recalcs... */
} bCommonKeySrc;
/* -------------- Keying Sets ------------------- */
-/* storage for iterator for looping over keyingset channels */
-typedef struct bKS_AdrcodeGetter {
- struct bKeyingSet *ks; /* keyingset this applies to */
- struct bCommonKeySrc *cks; /* data to insert/delete keyframes... */
-
- short index; /* index of current channel to resume from */
- short tot; /* index after which we start returning from some special collection */
-} bKS_AdrcodeGetter;
-
-/* flags to look out for in keyingset channels... */
-#define KAG_CHAN_EXTEND (-1)
-
+#if 0 // XXX I'm not sure how these will work for now...
/* keying set - a set of channels that will be keyframed together */
// TODO: move this to a header to allow custom sets someday?
@@ -168,11 +74,11 @@ typedef struct bKeyingSet {
short (*include_cb)(struct bKeyingSet *, const char *);
char name[48]; /* name of keyingset */
- int blocktype; /* blocktype that all channels belong to */ // in future, this may be eliminated
+ int blocktype; /* nearest ID-blocktype to where data can be found */
short flag; /* flags to use when setting keyframes */
short chan_num; /* number of channels to insert keyframe in */
- short adrcodes[32]; /* adrcodes for channels to insert keys for (ideally would be variable-len, but limit of 32 will suffice) */
+ char (*paths)[256]; /* adrcodes for channels to insert keys for (ideally would be variable-len, but limit of 32 will suffice) */
} bKeyingSet;
/* keying set context - an array of keying sets and the number of them */
@@ -182,282 +88,57 @@ typedef struct bKeyingContext {
int tot; /* number of keyingsets in */
} bKeyingContext;
+#endif
-/* ************************************************** */
-/* IPO DATA VERIFICATION */
-// XXX these will need to be modified for use with RNA-IPO...
-
-/* depending type, it returns ipo, if needed it creates one */
-/* returns either action ipo or "real" ipo */
-/* arguments define full context;
- - *from has to be set always, to Object in case of Actions
- - blocktype defines available channels of Ipo struct (blocktype ID_OB can be in action too)
- - if actname, use this to locate actionchannel, and optional constname
- - if bonename, the constname is the ipo to the constraint
-*/
-
-/* note: check header_ipo.c, spaceipo_assign_ipo() too */
-Ipo *verify_ipo(ID *from, short blocktype, char actname[], char constname[], char bonename[], short add)
-{
- /* lib-linked data is not appropriate here */
- if ((from==NULL) || (from->lib))
- return NULL;
-
- /* first check action ipos */
- if (actname && actname[0]) {
- Object *ob= (Object *)from;
- bActionChannel *achan;
-
- if (GS(from->name)!=ID_OB) {
- printf("called ipo system for action with wrong base pointer\n");
- return NULL;
- }
-
- if ((ob->action==NULL) && (add))
- ob->action= add_empty_action("Action");
-
- if (add)
- achan= verify_action_channel(ob->action, actname);
- else
- achan= get_action_channel(ob->action, actname);
-
- if (achan) {
- /* automatically assign achan to act-group based on pchan's grouping */
- //if ((blocktype == ID_PO) && (add))
- // verify_pchan2achan_grouping(ob->action, ob->pose, actname);
-
- /* constraint exception */
- if (blocktype==ID_CO) {
- bConstraintChannel *conchan;
-
- if (add)
- conchan= verify_constraint_channel(&achan->constraintChannels, constname);
- else
- conchan= get_constraint_channel(&achan->constraintChannels, constname);
-
- if (conchan) {
- if ((conchan->ipo==NULL) && (add))
- conchan->ipo= add_ipo(NULL, "CoIpo", ID_CO);
- return conchan->ipo;
- }
- }
- else {
- if ((achan->ipo==NULL) && (add))
- achan->ipo= add_ipo(NULL, "ActIpo", blocktype);
- return achan->ipo;
- }
- }
- }
- else {
- switch (GS(from->name)) {
- case ID_OB:
- {
- Object *ob= (Object *)from;
-
- /* constraint exception */
- if (blocktype==ID_CO) {
- /* check the local constraint ipo */
- if (bonename && bonename[0] && ob->pose) {
- bPoseChannel *pchan= get_pose_channel(ob->pose, bonename);
- bConstraint *con;
-
- for (con= pchan->constraints.first; con; con= con->next) {
- if (strcmp(con->name, constname)==0)
- break;
- }
-
- if (con) {
- if ((con->ipo==NULL) && (add))
- con->ipo= add_ipo(NULL, "CoIpo", ID_CO);
- return con->ipo;
- }
- }
- else { /* the actionchannel */
- bConstraintChannel *conchan;
-
- if (add)
- conchan= verify_constraint_channel(&ob->constraintChannels, constname);
- else
- conchan= get_constraint_channel(&ob->constraintChannels, constname);
-
- if (conchan) {
- if ((conchan->ipo==NULL) && (add))
- conchan->ipo= add_ipo(NULL, "CoIpo", ID_CO);
- return conchan->ipo;
- }
- }
- }
- else if (blocktype==ID_OB) {
- if ((ob->ipo==NULL) && (add))
- ob->ipo= add_ipo(NULL, "ObIpo", ID_OB);
- return ob->ipo;
- }
- else if (blocktype==ID_KE) {
- Key *key= ob_get_key((Object *)from);
-
- if (key) {
- if ((key->ipo==NULL) && (add))
- key->ipo= add_ipo(NULL, "KeyIpo", ID_KE);
- return key->ipo;
- }
- return NULL;
- }
- else if (blocktype== ID_FLUIDSIM) {
- Object *ob= (Object *)from;
-
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- if(fluidmd) {
- FluidsimSettings *fss= fluidmd->fss;
-
- if ((fss->ipo==NULL) && (add))
- fss->ipo= add_ipo(NULL, "FluidsimIpo", ID_FLUIDSIM);
- return fss->ipo;
- }
- }
- else if(blocktype== ID_PA) {
- Object *ob= (Object *)from;
- ParticleSystem *psys= psys_get_current(ob);
-
- if (psys) {
- if ((psys->part->ipo==NULL) && (add))
- psys->part->ipo= add_ipo(NULL, "ParticleIpo", ID_PA);
- return psys->part->ipo;
- }
- return NULL;
- }
- }
- break;
- case ID_MA:
- {
- Material *ma= (Material *)from;
-
- if ((ma->ipo==NULL) && (add))
- ma->ipo= add_ipo(NULL, "MatIpo", ID_MA);
- return ma->ipo;
- }
- break;
- case ID_TE:
- {
- Tex *tex= (Tex *)from;
-
- if ((tex->ipo==NULL) && (add))
- tex->ipo= add_ipo(NULL, "TexIpo", ID_TE);
- return tex->ipo;
- }
- break;
- case ID_SEQ:
- {
- Sequence *seq= (Sequence *)from; /* note, sequence is mimicing Id */
-
- if ((seq->ipo==NULL) && (add))
- seq->ipo= add_ipo(NULL, "SeqIpo", ID_SEQ);
- //update_seq_ipo_rect(seq); // XXX
- return seq->ipo;
- }
- break;
- case ID_CU:
- {
- Curve *cu= (Curve *)from;
-
- if ((cu->ipo==NULL) && (add))
- cu->ipo= add_ipo(NULL, "CuIpo", ID_CU);
- return cu->ipo;
- }
- break;
- case ID_WO:
- {
- World *wo= (World *)from;
-
- if ((wo->ipo==NULL) && (add))
- wo->ipo= add_ipo(NULL, "WoIpo", ID_WO);
- return wo->ipo;
- }
- break;
- case ID_LA:
- {
- Lamp *la= (Lamp *)from;
-
- if ((la->ipo==NULL) && (add))
- la->ipo= add_ipo(NULL, "LaIpo", ID_LA);
- return la->ipo;
- }
- break;
- case ID_CA:
- {
- Camera *ca= (Camera *)from;
-
- if ((ca->ipo==NULL) && (add))
- ca->ipo= add_ipo(NULL, "CaIpo", ID_CA);
- return ca->ipo;
- }
- break;
- case ID_SO:
- {
-#if 0 // depreceated
- bSound *snd= (bSound *)from;
-
- if ((snd->ipo==NULL) && (add))
- snd->ipo= add_ipo(NULL, "SndIpo", ID_SO);
- return snd->ipo;
-#endif // depreceated
- }
- break;
- }
- }
-
- return NULL;
-}
+/* ******************************************* */
+/* Animation Data Validation */
-/* Returns and creates
- * Make sure functions check for NULL or they will crash!
+/* Get (or add relevant data to be able to do so) F-Curve from the Active Action,
+ * for the given Animation Data block
*/
-IpoCurve *verify_ipocurve(ID *from, short blocktype, char actname[], char constname[], char bonename[], int adrcode, short add)
+// TODO: should we check if path is valid? For now, assume that it's already set OK by caller...
+FCurve *verify_fcurve (AnimData *adt, const char rna_path[], const int array_index, short add)
{
- Ipo *ipo;
- IpoCurve *icu= NULL;
+ nAction *act;
+ FCurve *fcu;
- /* return 0 if lib */
- /* creates ipo too (if add) */
- ipo= verify_ipo(from, blocktype, actname, constname, bonename, add);
+ /* sanity checks */
+ if ELEM(NULL, adt, rna_path)
+ return NULL;
+
+ /* init action if none available yet */
+ // TODO: need some wizardry to handle NLA stuff correct
+ if ((adt->action == NULL) && (add))
+ adt->action= add_empty_action("Action");
+ act= adt->action;
+
+ /* try to find f-curve matching for this setting
+ * - add if not found and allowed to add one
+ * TODO: add auto-grouping support? how this works will need to be resolved
+ */
+ if (act)
+ fcu= list_find_fcurve(&act->curves, rna_path, array_index);
+ else
+ fcu= NULL;
- if ((ipo) && (ipo->id.lib==NULL) && (from->lib==NULL)) {
- /* try to find matching curve */
- icu= find_ipocurve(ipo, adrcode);
+ if ((fcu == NULL) && (add)) {
+ /* use default settings */
+ fcu= MEM_callocN(sizeof(FCurve), "FCurve");
- /* make a new one if none found (and can add) */
- if ((icu==NULL) && (add)) {
- icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
-
- /* set default settings */
- icu->flag |= (IPO_VISIBLE|IPO_AUTO_HORIZ);
- if (ipo->curve.first==NULL)
- icu->flag |= IPO_ACTIVE; /* first one added active */
-
- icu->blocktype= blocktype;
- icu->adrcode= adrcode;
+ fcu->flag |= (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES);
+ if (act->curves.first==NULL)
+ fcu->flag |= FCURVE_ACTIVE; /* first one added active */
- set_icu_vars(icu);
-
- /* default curve interpolation - from userpref */
- icu->ipo= U.ipo_new;
-
- /* add curve to IPO-block */
- BLI_addtail(&ipo->curve, icu);
-
- /* special type-dependent stuff */
- switch (GS(from->name)) {
- case ID_SEQ: {
- //Sequence *seq= (Sequence *)from;
-
- //update_seq_icu_rects(seq); // XXX
- break;
- }
- }
- }
+ /* store path - make copy, and store that */
+ fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
+ fcu->array_index= array_index;
+
+ /* add curve */
+ BLI_addtail(&act->curves, fcu); // XXX it might be better to add this in order, for easier UI coding...
}
- /* return ipo-curve */
- return icu;
+ /* return the F-Curve */
+ return fcu;
}
/* ************************************************** */
@@ -544,54 +225,55 @@ static int binarysearch_bezt_index (BezTriple array[], float frame, int arraylen
return start;
}
-/* This function adds a given BezTriple to an IPO-Curve. It will allocate
+/* This function adds a given BezTriple to an F-Curve. It will allocate
* memory for the array if needed, and will insert the BezTriple into a
* suitable place in chronological order.
*
- * NOTE: any recalculate of the IPO-Curve that needs to be done will need to
+ * NOTE: any recalculate of the F-Curve that needs to be done will need to
* be done by the caller.
*/
-int insert_bezt_icu (IpoCurve *icu, BezTriple *bezt)
+int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt)
{
BezTriple *newb;
int i= 0;
- if (icu->bezt) {
+ if (fcu->bezt) {
short replace = -1;
- i = binarysearch_bezt_index(icu->bezt, bezt->vec[1][0], icu->totvert, &replace);
+ i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
// FIXME: do not overwrite handletype if just replacing...?
- if ((i >= 0) && (i < icu->totvert))
- *(icu->bezt + i) = *bezt;
+ if ((i >= 0) && (i < fcu->totvert))
+ *(fcu->bezt + i) = *bezt;
}
else {
/* add new */
- newb= MEM_callocN((icu->totvert+1)*sizeof(BezTriple), "beztriple");
+ newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple");
/* add the beztriples that should occur before the beztriple to be pasted (originally in ei->icu) */
if (i > 0)
- memcpy(newb, icu->bezt, i*sizeof(BezTriple));
+ memcpy(newb, fcu->bezt, i*sizeof(BezTriple));
/* add beztriple to paste at index i */
*(newb + i)= *bezt;
/* add the beztriples that occur after the beztriple to be pasted (originally in icu) */
- if (i < icu->totvert)
- memcpy(newb+i+1, icu->bezt+i, (icu->totvert-i)*sizeof(BezTriple));
+ if (i < fcu->totvert)
+ memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple));
/* replace (+ free) old with new */
- MEM_freeN(icu->bezt);
- icu->bezt= newb;
+ MEM_freeN(fcu->bezt);
+ fcu->bezt= newb;
- icu->totvert++;
+ fcu->totvert++;
}
}
else {
- icu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple");
- *(icu->bezt)= *bezt;
- icu->totvert= 1;
+ // TODO: need to check for old sample-data now...
+ fcu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple");
+ *(fcu->bezt)= *bezt;
+ fcu->totvert= 1;
}
@@ -607,10 +289,10 @@ int insert_bezt_icu (IpoCurve *icu, BezTriple *bezt)
*
* 'fast' - is only for the python API where importing BVH's would take an extreamly long time.
*/
-void insert_vert_icu (IpoCurve *icu, float x, float y, short fast)
+void insert_vert_fcurve (FCurve *fcu, float x, float y, short fast)
{
BezTriple beztr;
- int a, h1, h2;
+ int a;
/* set all three points, for nicer start position */
memset(&beztr, 0, sizeof(BezTriple));
@@ -620,12 +302,12 @@ void insert_vert_icu (IpoCurve *icu, float x, float y, short fast)
beztr.vec[1][1]= y;
beztr.vec[2][0]= x;
beztr.vec[2][1]= y;
- beztr.hide= IPO_BEZ;
+ beztr.ipo= U.ipo_new; /* use default interpolation mode here... */
beztr.f1= beztr.f2= beztr.f3= SELECT;
- beztr.h1= beztr.h2= HD_AUTO;
+ beztr.h1= beztr.h2= HD_AUTO; // XXX what about when we replace an old one?
/* add temp beztriple to keyframes */
- a= insert_bezt_icu(icu, &beztr);
+ a= insert_bezt_fcurve(fcu, &beztr);
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
@@ -636,125 +318,34 @@ void insert_vert_icu (IpoCurve *icu, float x, float y, short fast)
* - this is a hack to make importers faster
* - we may calculate twice (see editipo_changed(), due to autohandle needing two calculations)
*/
- if (!fast) calchandles_ipocurve(icu);
+ if (!fast) calchandles_fcurve(fcu);
/* set handletype and interpolation */
- if (icu->totvert > 2) {
- BezTriple *bezt= (icu->bezt + a);
+ if (fcu->totvert > 2) {
+ BezTriple *bezt= (fcu->bezt + a);
+ short h1, h2;
/* set handles (autohandles by default) */
h1= h2= HD_AUTO;
if (a > 0) h1= (bezt-1)->h2;
- if (a < icu->totvert-1) h2= (bezt+1)->h1;
+ if (a < fcu->totvert-1) h2= (bezt+1)->h1;
bezt->h1= h1;
bezt->h2= h2;
- /* set interpolation (if curve is using IPO_MIXED, then take from previous) */
- if (icu->ipo == IPO_MIXED) {
- if (a > 0) bezt->ipo= (bezt-1)->ipo;
- else if (a < icu->totvert-1) bezt->ipo= (bezt+1)->ipo;
- }
- else
- bezt->ipo= icu->ipo;
+ /* set interpolation from previous (if available) */
+ if (a > 0) bezt->ipo= (bezt-1)->ipo;
+ else if (a < fcu->totvert-1) bezt->ipo= (bezt+1)->ipo;
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (see editipo_changed(), due to autohandle needing two calculations)
*/
- if (!fast) calchandles_ipocurve(icu);
- }
- else {
- BezTriple *bezt= (icu->bezt + a);
-
- /* set interpolation directly from ipo-curve */
- bezt->ipo= icu->ipo;
- }
-}
-
-
-/* ------------------- Get Data ------------------------ */
-
-/* Get pointer to use to get values from */
-// FIXME: this should not be possible with Data-API
-static void *get_context_ipo_poin (ID *id, int blocktype, char *actname, char *constname, IpoCurve *icu, int *vartype)
-{
- switch (blocktype) {
- case ID_PO: /* posechannel */
- if (GS(id->name)==ID_OB) {
- Object *ob= (Object *)id;
- bPoseChannel *pchan= get_pose_channel(ob->pose, actname);
-
- if (pchan) {
- if (ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))
- *vartype= IPO_FLOAT_DEGR;
- else
- *vartype= IPO_FLOAT;
- return get_pchan_ipo_poin(pchan, icu->adrcode);
- }
- }
- break;
-
- case ID_CO: /* constraint */
- if ((GS(id->name)==ID_OB) && (constname && constname[0])) {
- Object *ob= (Object *)id;
- bConstraint *con;
-
- /* assume that we only want the influence (as only used for Constraint Channels) */
- if ((ob->ipoflag & OB_ACTION_OB) && !strcmp(actname, "Object")) {
- for (con= ob->constraints.first; con; con= con->next) {
- if (strcmp(constname, con->name)==0) {
- *vartype= IPO_FLOAT;
- return &con->enforce;
- }
- }
- }
- else if (ob->pose) {
- bPoseChannel *pchan= get_pose_channel(ob->pose, actname);
-
- if (pchan) {
- for (con= pchan->constraints.first; con; con= con->next) {
- if (strcmp(constname, con->name)==0) {
- *vartype= IPO_FLOAT;
- return &con->enforce;
- }
- }
- }
- }
- }
- break;
-
- case ID_OB: /* object */
- /* hack: layer channels for object need to be keyed WITHOUT localview flag...
- * tsk... tsk... why must we just dump bitflags upon users :/
- */
- if ((GS(id->name)==ID_OB) && (icu->adrcode==OB_LAY)) {
- Object *ob= (Object *)id;
- static int layer = 0;
-
- /* init layer to be the object's layer var, then remove local view from it */
- layer = ob->lay;
- layer &= 0xFFFFFF;
- *vartype= IPO_INT_BIT;
-
- /* return pointer to this static var
- * - assumes that this pointer won't be stored for use later, so may not be threadsafe
- * if multiple keyframe calls are made, but that is unlikely to happen in the near future
- */
- return (void *)(&layer);
- }
- /* no break here for other ob channel-types - as they can be done normally */
-
- default: /* normal data-source */
- return get_ipo_poin(id, icu, vartype);
+ if (!fast) calchandles_fcurve(fcu);
}
-
- /* not valid... */
- return NULL;
}
-
/* -------------- 'Smarter' Keyframing Functions -------------------- */
/* return codes for new_key_needed */
enum {
@@ -770,19 +361,19 @@ enum {
* 2. Keyframe to be added on frame where two keyframes are already situated
* 3. Keyframe lies at point that intersects the linear line between two keyframes
*/
-static short new_key_needed (IpoCurve *icu, float cFrame, float nValue)
+static short new_key_needed (FCurve *fcu, float cFrame, float nValue)
{
BezTriple *bezt=NULL, *prev=NULL;
int totCount, i;
float valA = 0.0f, valB = 0.0f;
/* safety checking */
- if (icu == NULL) return KEYNEEDED_JUSTADD;
- totCount= icu->totvert;
+ if (fcu == NULL) return KEYNEEDED_JUSTADD;
+ totCount= fcu->totvert;
if (totCount == 0) return KEYNEEDED_JUSTADD;
/* loop through checking if any are the same */
- bezt= icu->bezt;
+ bezt= fcu->bezt;
for (i=0; i<totCount; i++) {
float prevPosi=0.0f, prevVal=0.0f;
float beztPosi=0.0f, beztVal=0.0f;
@@ -813,7 +404,7 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue)
float realVal;
/* get real value of curve at that point */
- realVal= eval_icu(icu, cFrame);
+ realVal= evaluate_fcurve(fcu, cFrame);
/* compare whether it's the same as proposed */
if (IS_EQ(realVal, nValue))
@@ -859,7 +450,7 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue)
* -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last
* keyframe is not equal to last keyframe.
*/
- bezt= (icu->bezt + (icu->totvert - 1));
+ bezt= (fcu->bezt + (fcu->totvert - 1));
valA= bezt->vec[1][1];
if (prev)
@@ -873,13 +464,49 @@ static short new_key_needed (IpoCurve *icu, float cFrame, float nValue)
return KEYNEEDED_JUSTADD;
}
+/* ------------------ RNA Data-Access Functions ------------------ */
+
+/* Try to read value using RNA-properties obtained already */
+static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int index)
+{
+ float value= 0.0f;
+
+ switch (RNA_property_type(ptr, prop)) {
+ case PROP_BOOLEAN:
+ if (RNA_property_array_length(ptr, prop))
+ value= (float)RNA_property_boolean_get_array(ptr, prop, index);
+ else
+ value= (float)RNA_property_boolean_get(ptr, prop);
+ break;
+ case PROP_INT:
+ if (RNA_property_array_length(ptr, prop))
+ value= (float)RNA_property_int_get_array(ptr, prop, index);
+ else
+ value= (float)RNA_property_int_get(ptr, prop);
+ break;
+ case PROP_FLOAT:
+ if (RNA_property_array_length(ptr, prop))
+ value= RNA_property_float_get_array(ptr, prop, index);
+ else
+ value= RNA_property_float_get(ptr, prop);
+ break;
+ case PROP_ENUM:
+ value= (float)RNA_property_enum_get(ptr, prop);
+ break;
+ default:
+ break;
+ }
+
+ return value;
+}
+
/* ------------------ 'Visual' Keyframing Functions ------------------ */
/* internal status codes for visualkey_can_use */
enum {
VISUALKEY_NONE = 0,
VISUALKEY_LOC,
- VISUALKEY_ROT
+ VISUALKEY_ROT,
};
/* This helper function determines if visual-keyframing should be used when
@@ -888,15 +515,16 @@ enum {
* blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying
* settings is on.
*/
-static short visualkey_can_use (ID *id, int blocktype, char *actname, char *constname, int adrcode)
+static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop)
{
- Object *ob= NULL;
+ //Object *ob= NULL;
bConstraint *con= NULL;
short searchtype= VISUALKEY_NONE;
+#if 0 // XXX old animation system
/* validate data */
if ((id == NULL) || (GS(id->name)!=ID_OB) || !(ELEM(blocktype, ID_OB, ID_PO)))
- return 0;
+ return 0;
/* get first constraint and determine type of keyframe constraints to check for*/
ob= (Object *)id;
@@ -918,6 +546,7 @@ static short visualkey_can_use (ID *id, int blocktype, char *actname, char *cons
else if (ELEM4(adrcode, AC_QUAT_W, AC_QUAT_X, AC_QUAT_Y, AC_QUAT_Z))
searchtype= VISUALKEY_ROT;
}
+#endif
/* only search if a searchtype and initial constraint are available */
if (searchtype && con) {
@@ -976,10 +605,12 @@ static short visualkey_can_use (ID *id, int blocktype, char *actname, char *cons
/* This helper function extracts the value to use for visual-keyframing
* In the event that it is not possible to perform visual keying, try to fall-back
- * to using the poin method. Assumes that all data it has been passed is valid.
+ * to using the default method. Assumes that all data it has been passed is valid.
*/
-static float visualkey_get_value (ID *id, int blocktype, char *actname, char *constname, int adrcode, IpoCurve *icu)
+// xxx... ptr here should be struct that data is in.... prop is the channel that's being used
+static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index)
{
+#if 0 // XXX old animation system
Object *ob;
void *poin = NULL;
int index, vartype;
@@ -1053,13 +684,10 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co
return quat[index];
}
}
+#endif // XXX old animation system
- /* as the function hasn't returned yet, try reading from poin */
- poin= get_context_ipo_poin(id, blocktype, actname, constname, icu, &vartype);
- if (poin)
- return read_ipo_poin(poin, vartype);
- else
- return 0.0;
+ /* as the function hasn't returned yet, read value from system in the default way */
+ return setting_get_rna_value(ptr, prop, array_index);
}
/* ------------------------- Insert Key API ------------------------- */
@@ -1072,25 +700,35 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
* and extra keyframe filtering.
*/
-short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag)
+short insertkey (ID *id, const char rna_path[], int array_index, float cfra, short flag)
{
- IpoCurve *icu;
+ PointerRNA id_ptr, ptr;
+ PropertyRNA *prop;
+ AnimData *adt;
+ FCurve *fcu;
+
+ /* validate pointer first - exit if failure*/
+ RNA_id_pointer_create(id, &id_ptr);
+ if (RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) {
+ printf("Insert Key: Could not insert keyframe, as RNA Path is invalid for the given ID \n");
+ return 0;
+ }
- /* get ipo-curve */
- icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 1);
+ /* get F-Curve */
+ adt= BKE_animdata_from_id(id);
+ fcu= verify_fcurve(adt, rna_path, array_index, 1);
- /* only continue if we have an ipo-curve to add keyframe to */
- if (icu) {
- float cfra =1.0f;//= frame_to_float(CFRA);
+ /* only continue if we have an F-Curve to add keyframe to */
+ if (fcu) {
float curval= 0.0f;
/* apply special time tweaking */
+ // XXX check on this stuff...
if (GS(id->name) == ID_OB) {
- Object *ob= (Object *)id;
+ //Object *ob= (Object *)id;
/* apply NLA-scaling (if applicable) */
- if (actname && actname[0])
- cfra= get_action_frame(ob, cfra);
+ //cfra= get_action_frame(ob, cfra);
/* ancient time-offset cruft */
//if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) {
@@ -1101,29 +739,17 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
/* obtain value to give keyframe */
if ( (flag & INSERTKEY_MATRIX) &&
- (visualkey_can_use(id, blocktype, actname, constname, adrcode)) )
+ (visualkey_can_use(&ptr, prop)) )
{
/* visual-keying is only available for object and pchan datablocks, as
* it works by keyframing using a value extracted from the final matrix
* instead of using the kt system to extract a value.
*/
- curval= visualkey_get_value(id, blocktype, actname, constname, adrcode, icu);
+ curval= visualkey_get_value(&ptr, prop, array_index);
}
else {
- void *poin;
- int vartype;
-
- /* get pointer to data to read from */
- poin = get_context_ipo_poin(id, blocktype, actname, constname, icu, &vartype);
- if (poin == NULL) {
- printf("Insert Key: No pointer to variable obtained \n");
- return 0;
- }
-
- /* use kt's read_poin function to extract value (kt->read_poin should
- * exist in all cases, but it never hurts to check)
- */
- curval= read_ipo_poin(poin, vartype);
+ /* read value from system */
+ curval= setting_get_rna_value(&ptr, prop, array_index);
}
/* only insert keyframes where they are needed */
@@ -1131,19 +757,19 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
short insert_mode;
/* check whether this curve really needs a new keyframe */
- insert_mode= new_key_needed(icu, cfra, curval);
+ insert_mode= new_key_needed(fcu, cfra, curval);
/* insert new keyframe at current frame */
if (insert_mode)
- insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST));
+ insert_vert_fcurve(fcu, cfra, curval, (flag & INSERTKEY_FAST));
/* delete keyframe immediately before/after newly added */
switch (insert_mode) {
case KEYNEEDED_DELPREV:
- delete_icu_key(icu, icu->totvert-2, 1);
+ delete_fcurve_key(fcu, fcu->totvert-2, 1);
break;
case KEYNEEDED_DELNEXT:
- delete_icu_key(icu, 1, 1);
+ delete_fcurve_key(fcu, 1, 1);
break;
}
@@ -1153,7 +779,7 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
}
else {
/* just insert keyframe */
- insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST));
+ insert_vert_fcurve(fcu, cfra, curval, (flag & INSERTKEY_FAST));
/* return success */
return 1;
@@ -1164,7 +790,6 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
return 0;
}
-
/* ************************************************** */
/* KEYFRAME DELETION */
@@ -1175,31 +800,31 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
* The flag argument is used for special settings that alter the behaviour of
* the keyframe deletion. These include the quick refresh options.
*/
-short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag)
+short deletekey (ID *id, const char rna_path[], int array_index, float cfra, short flag)
{
- Ipo *ipo;
- IpoCurve *icu;
+ AnimData *adt= BKE_animdata_from_id(id);
+ nAction *act;
+ FCurve *fcu;
- /* get ipo-curve
- * Note: here is one of the places where we don't want new ipo + ipo-curve added!
+ /* get F-Curve
+ * Note: here is one of the places where we don't want new Action + F-Curve added!
* so 'add' var must be 0
*/
- ipo= verify_ipo(id, blocktype, actname, constname, NULL, 0);
- icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 0);
+ // XXX we don't check the validity of the path here yet, but it should be ok...
+ fcu= verify_fcurve(adt, rna_path, array_index, 0);
+ act= adt->action;
/* only continue if we have an ipo-curve to remove keyframes from */
- if (icu) {
- float cfra = 1.0f;//frame_to_float(CFRA);
+ if (act && fcu) {
short found = -1;
int i;
/* apply special time tweaking */
if (GS(id->name) == ID_OB) {
- Object *ob= (Object *)id;
+ //Object *ob= (Object *)id;
/* apply NLA-scaling (if applicable) */
- if (actname && actname[0])
- cfra= get_action_frame(ob, cfra);
+ // cfra= get_action_frame(ob, cfra);
/* ancient time-offset cruft */
//if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) {
@@ -1209,15 +834,16 @@ short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrc
}
/* try to find index of beztriple to get rid of */
- i = binarysearch_bezt_index(icu->bezt, cfra, icu->totvert, &found);
+ i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
- /* delete the key at the index (will sanity check + do recalc afterwards ) */
- delete_icu_key(icu, i, 1);
-
- /* Only delete curve too if there isn't an ipo-driver still hanging around on an empty curve */
- if (icu->totvert==0 && icu->driver==NULL) {
- BLI_remlink(&ipo->curve, icu);
- free_ipo_curve(icu);
+ /* delete the key at the index (will sanity check + do recalc afterwards) */
+ delete_fcurve_key(fcu, i, 1);
+
+ /* Only delete curve too if there are no points (we don't need to check for drivers, as they're kept separate) */
+ // XXX how do we handle drivers then?
+ if (fcu->totvert == 0) {
+ BLI_remlink(&act->curves, fcu);
+ free_fcurve(fcu);
}
/* return success */
@@ -1229,8 +855,8 @@ short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrc
return 0;
}
-/* ************************************************** */
-/* COMMON KEYFRAME MANAGEMENT (common_insertkey/deletekey) */
+/* ******************************************* */
+/* KEYFRAME MODIFICATION */
/* mode for common_modifykey */
enum {
@@ -1238,6 +864,8 @@ enum {
COMMONKEY_MODE_DELETE,
} eCommonModifyKey_Modes;
+#if 0 // XXX old keyingsets code based on adrcodes... to be restored in due course
+
/* --------- KeyingSet Adrcode Getters ------------ */
/* initialise a channel-getter storage */
@@ -2096,7 +1724,7 @@ static void commonkey_context_finish (const bContext *C, ListBase *sources)
}
/* flush refreshes after undo */
-static void commonkey_context_refresh (const bContext *C)
+static void commonkey_context_refresh (bContext *C)
{
ScrArea *curarea= CTX_wm_area(C);
@@ -2190,7 +1818,7 @@ static bKeyingSet *get_keyingset_fromcontext (bKeyingContext *ksc, short index)
/* ---------------- Keyframe Management API -------------------- */
/* Display a menu for handling the insertion of keyframes based on the active view */
-void common_modifykey (const bContext *C, short mode)
+void common_modifykey (bContext *C, short mode)
{
ListBase dsources = {NULL, NULL};
bKeyingContext *ksc= NULL;
@@ -2349,46 +1977,176 @@ void common_modifykey (const bContext *C, short mode)
ob->pose->flag |= POSE_RECALCPATHS;
/* clear unkeyed flag (it doesn't matter if it's set or not) */
- if (pchan->bone)
- pchan->bone->flag &= ~BONE_UNKEYED;
+ // XXX old animation system
+ //if (pchan->bone)
+ // pchan->bone->flag &= ~BONE_UNKEYED;
}
+
+ // XXX for new system, need to remove overrides
}
}
/* apply post-keying flushes for this data sources */
commonkey_context_finish(C, &dsources);
- ksc->lastused= ks;
/* free temp data */
BLI_freelistN(&dsources);
- /* undo pushes */
- if (mode == COMMONKEY_MODE_DELETE)
- BLI_snprintf(buf, 64, "Delete %s Key", ks->name);
- else
- BLI_snprintf(buf, 64, "Insert %s Key", ks->name);
- //BIF_undo_push(buf);
-
/* queue updates for contexts */
commonkey_context_refresh(C);
}
-/* ---- */
+#endif // XXX old keyingsets code based on adrcodes... to be restored in due course
+
+/* Insert Key Operator ------------------------ */
+
+/* XXX WARNING:
+ * This is currently just a basic operator, which work in 3d-view context on objects only
+ * and will insert keyframes for a few settings only. This is until it becomes clear how
+ * to separate (or not) the process for RNA-path creation between context + keyingsets.
+ *
+ * -- Joshua Leung, Jan 2009
+ */
+
+/* defines for basic insert-key testing operator */
+ // XXX this will definitely be replaced
+EnumPropertyItem prop_insertkey_types[] = {
+ {0, "LOC", "Location", ""},
+ {1, "ROT", "Rotation", ""},
+ {2, "SCALE", "Scale", ""},
+ {3, "MAT_COL", "Active Material - Color", ""},
+ {0, NULL, NULL, NULL}
+};
+
+static int insert_key_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ short mode= RNA_enum_get(op->ptr, "type");
+ float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+
+ // XXX more comprehensive tests will be needed
+ CTX_DATA_BEGIN(C, Base*, base, selected_bases)
+ {
+ Object *ob= base->object;
+ ID *id= (ID *)ob;
+ short success= 0;
+
+ /* check which keyframing mode chosen for this object */
+ switch (mode) {
+ case 3: /* color of active material */
+ // NOTE: this is just a demo... but ideally we'd go through materials instead of active one only so reference stays same
+ success+= insertkey(id, "active_material.diffuse_color", 0, cfra, 0);
+ success+= insertkey(id, "active_material.diffuse_color", 1, cfra, 0);
+ success+= insertkey(id, "active_material.diffuse_color", 2, cfra, 0);
+ break;
+ case 2: /* scale */
+ success+= insertkey(id, "scale", 0, cfra, 0);
+ success+= insertkey(id, "scale", 1, cfra, 0);
+ success+= insertkey(id, "scale", 2, cfra, 0);
+ case 1: /* rotation */
+ success+= insertkey(id, "rotation", 0, cfra, 0);
+ success+= insertkey(id, "rotation", 1, cfra, 0);
+ success+= insertkey(id, "rotation", 2, cfra, 0);
+ default: /* location */
+ success+= insertkey(id, "location", 0, cfra, 0);
+ success+= insertkey(id, "location", 1, cfra, 0);
+ success+= insertkey(id, "location", 2, cfra, 0);
+ break;
+ }
+
+ printf("Ob '%s' - Successfully added %d Keyframes \n", id->name+2, success);
+
+ ob->recalc |= OB_RECALC_OB;
+ }
+ CTX_DATA_END;
+
+ /* send updates */
+ ED_anim_dag_flush_update(C);
+ ED_undo_push(C, "Insert Keyframe");
+
+ if (mode == 3) // material color requires different notifiers
+ WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+ else
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+
+ return OPERATOR_FINISHED;
+}
-/* used to insert keyframes from any view */
-void common_insertkey (const bContext *C)
+void ANIM_OT_insert_keyframe (wmOperatorType *ot)
{
- common_modifykey(C, COMMONKEY_MODE_INSERT);
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name= "Insert Keyframe";
+ ot->idname= "ANIM_OT_insert_keyframe";
+
+ /* callbacks */
+ ot->invoke= WM_menu_invoke; // XXX we will need our own one eventually, to cope with the dynamic menus...
+ ot->exec= insert_key_exec;
+
+ /* properties */
+ // XXX update this for the latest RNA stuff styles...
+ prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, prop_insertkey_types);
}
-/* used to insert keyframes from any view */
-void common_deletekey (const bContext *C)
+/* Delete Key Operator ------------------------ */
+
+/* XXX WARNING:
+ * This is currently just a basic operator, which work in 3d-view context on objects only.
+ * -- Joshua Leung, Jan 2009
+ */
+
+static int delete_key_exec (bContext *C, wmOperator *op)
{
- common_modifykey(C, COMMONKEY_MODE_DELETE);
+ Scene *scene= CTX_data_scene(C);
+ float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+
+ // XXX more comprehensive tests will be needed
+ CTX_DATA_BEGIN(C, Base*, base, selected_bases)
+ {
+ Object *ob= base->object;
+ ID *id= (ID *)ob;
+ nAction *act= ob->adt.action;
+ FCurve *fcu, *fcn;
+ short success= 0;
+
+ /* loop through all curves in animdata and delete keys on this frame */
+ if (act) {
+ for (fcu= act->curves.first; fcu; fcu= fcn) {
+ fcn= fcu->next;
+ success+= deletekey(id, fcu->rna_path, fcu->array_index, cfra, 0);
+ }
+ }
+
+ printf("Ob '%s' - Successfully removed %d keyframes \n", id->name+2, success);
+
+ ob->recalc |= OB_RECALC_OB;
+ }
+ CTX_DATA_END;
+
+ /* send updates */
+ ED_anim_dag_flush_update(C);
+ ED_undo_push(C, "Delete Keyframe");
+
+ // XXX what if it was a material keyframe?
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+
+ return OPERATOR_FINISHED;
}
+void ANIM_OT_delete_keyframe (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Delete Keyframe";
+ ot->idname= "ANIM_OT_delete_keyframe";
+
+ /* callbacks */
+ ot->invoke= WM_operator_confirm; // XXX we will need our own one eventually, to cope with the dynamic menus...
+ ot->exec= delete_key_exec;
+}
-/* ************************************************** */
+/* ******************************************* */
/* KEYFRAME DETECTION */
/* --------------- API/Per-Datablock Handling ------------------- */
@@ -2396,35 +2154,35 @@ void common_deletekey (const bContext *C)
/* Checks whether an IPO-block has a keyframe for a given frame
* Since we're only concerned whether a keyframe exists, we can simply loop until a match is found...
*/
-short ipo_frame_has_keyframe (Ipo *ipo, float frame, short filter)
+short action_frame_has_keyframe (nAction *act, float frame, short filter)
{
- IpoCurve *icu;
+ FCurve *fcu;
/* can only find if there is data */
- if (ipo == NULL)
+ if (act == NULL)
return 0;
/* if only check non-muted, check if muted */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (ipo->muteipo))
+ if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED))
return 0;
- /* loop over IPO-curves, using binary-search to try to find matches
+ /* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
*/
- for (icu= ipo->curve.first; icu; icu= icu->next) {
+ for (fcu= act->curves.first; fcu; fcu= fcu->next) {
/* only check if there are keyframes (currently only of type BezTriple) */
- if (icu->bezt) {
+ if (fcu->bezt) {
/* we either include all regardless of muting, or only non-muted */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (icu->flag & IPO_MUTE)==0) {
+ if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) {
short replace = -1;
- int i = binarysearch_bezt_index(icu->bezt, frame, icu->totvert, &replace);
+ int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace);
/* binarysearch_bezt_index will set replace to be 0 or 1
* - obviously, 1 represents a match
*/
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
- if ((i >= 0) && (i < icu->totvert))
+ if ((i >= 0) && (i < fcu->totvert))
return 1;
}
}
@@ -2435,32 +2193,6 @@ short ipo_frame_has_keyframe (Ipo *ipo, float frame, short filter)
return 0;
}
-/* Checks whether an action-block has a keyframe for a given frame
- * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found...
- */
-short action_frame_has_keyframe (bAction *act, float frame, short filter)
-{
- bActionChannel *achan;
-
- /* error checking */
- if (act == NULL)
- return 0;
-
- /* check thorugh action-channels for match */
- for (achan= act->chanbase.first; achan; achan= achan->next) {
- /* we either include all regardless of muting, or only non-muted
- * - here we include 'hidden' channels in the muted definition
- */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (achan->flag & ACHAN_HIDDEN)==0) {
- if (ipo_frame_has_keyframe(achan->ipo, frame, filter))
- return 1;
- }
- }
-
- /* nothing found */
- return 0;
-}
-
/* Checks whether an Object has a keyframe for a given frame */
short object_frame_has_keyframe (Object *ob, float frame, short filter)
{
@@ -2468,35 +2200,9 @@ short object_frame_has_keyframe (Object *ob, float frame, short filter)
if (ob == NULL)
return 0;
- /* check for an action - actions take priority over normal IPO's */
- if (ob->action) {
- float aframe;
-
- /* apply nla-action scaling if needed */
- if ((ob->nlaflag & OB_NLA_OVERRIDE) && (ob->nlastrips.first))
- aframe= get_action_frame(ob, frame);
- else
- aframe= frame;
-
- /* priority check here goes to pose-channel checks (for armatures) */
- if ((ob->pose) && (ob->flag & OB_POSEMODE)) {
- /* only relevant check here is to only show active... */
- if (filter & ANIMFILTER_KEYS_ACTIVE) {
- bPoseChannel *pchan= get_active_posechannel(ob);
- bActionChannel *achan= (pchan) ? get_action_channel(ob->action, pchan->name) : NULL;
-
- /* since we're only interested in whether the selected one has any keyframes... */
- return (achan && ipo_frame_has_keyframe(achan->ipo, aframe, filter));
- }
- }
-
- /* for everything else, just use the standard test (only return if success) */
- if (action_frame_has_keyframe(ob->action, aframe, filter))
- return 1;
- }
- else if (ob->ipo) {
- /* only return if success */
- if (ipo_frame_has_keyframe(ob->ipo, frame, filter))
+ /* check own animation data - specifically, the action it contains */
+ if (ob->adt.action) {
+ if (action_frame_has_keyframe(ob->adt.action, frame, filter))
return 1;
}
@@ -2548,40 +2254,32 @@ short object_frame_has_keyframe (Object *ob, float frame, short filter)
/* Checks whether a keyframe exists for the given ID-block one the given frame */
short id_frame_has_keyframe (ID *id, float frame, short filter)
{
- /* error checking */
+ /* sanity checks */
if (id == NULL)
return 0;
- /* check for a valid id-type */
+ /* perform special checks for 'macro' types */
switch (GS(id->name)) {
- /* animation data-types */
- case ID_IP: /* ipo */
- return ipo_frame_has_keyframe((Ipo *)id, frame, filter);
- case ID_AC: /* action */
- return action_frame_has_keyframe((bAction *)id, frame, filter);
-
case ID_OB: /* object */
return object_frame_has_keyframe((Object *)id, frame, filter);
-
- case ID_MA: /* material */
- {
- Material *ma= (Material *)id;
-
- /* currently, material's only have an ipo-block */
- return ipo_frame_has_keyframe(ma->ipo, frame, filter);
- }
break;
- case ID_KE: /* shapekey */
+ case ID_SCE: /* scene */
+ // XXX TODO... for now, just use 'normal' behaviour
+ // break;
+
+ default: /* 'normal type' */
{
- Key *key= (Key *)id;
+ AnimData *adt= BKE_animdata_from_id(id);
- /* currently, shapekey's only have an ipo-block */
- return ipo_frame_has_keyframe(key->ipo, frame, filter);
+ /* only check keyframes in active action */
+ if (adt)
+ return action_frame_has_keyframe(adt->action, frame, filter);
}
break;
}
+
/* no keyframe found */
return 0;
}
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 5548700b2e1..5a751236e6e 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -99,8 +99,6 @@ static void error_libdata() {}
static void BIF_undo_push() {}
static void adduplicate() {}
static void countall() {}
-static void deselect_actionchannels() {}
-static void select_actionchannel_by_name() {}
/* ************* XXX *************** */
/* **************** tools on Editmode Armature **************** */
@@ -599,7 +597,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* action constraint? */
if (con->type == CONSTRAINT_TYPE_ACTION) {
- bActionConstraint *data= con->data;
+ bActionConstraint *data= con->data; // XXX old animation system
bAction *act;
bActionChannel *achan;
@@ -1330,7 +1328,8 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone)
if (!(bone->flag & BONE_CONNECTED))
return;
- select_actionchannel_by_name (ob->action, bone->name, !(shift));
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name (ob->action, bone->name, !(shift));
if (shift)
bone->flag &= ~BONE_SELECTED;
@@ -1359,7 +1358,8 @@ void selectconnected_posearmature(bContext *C)
/* Select parents */
for (curBone=bone; curBone; curBone=next){
- select_actionchannel_by_name (ob->action, curBone->name, !(shift));
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name (ob->action, curBone->name, !(shift));
if (shift)
curBone->flag &= ~BONE_SELECTED;
else
@@ -3568,7 +3568,9 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
if (!(extend) || (base != scene->basact)) {
ED_pose_deselectall(ob, 0, 0);
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
- select_actionchannel_by_name(ob->action, nearBone->name, 1);
+
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
else {
if (nearBone->flag & BONE_SELECTED) {
@@ -3579,14 +3581,18 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
}
else {
nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
- select_actionchannel_by_name(ob->action, nearBone->name, 0);
+
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name(ob->action, nearBone->name, 0);
}
}
else {
bone_looper(ob, arm->bonebase.first, NULL, clear_active_flag);
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
- select_actionchannel_by_name(ob->action, nearBone->name, 1);
+
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
}
@@ -3647,16 +3653,6 @@ void ED_pose_deselectall (Object *ob, int test, int doundo)
}
}
- /* action editor */
- if (test == 3) {
- deselect_actionchannels(ob->action, 2); /* inverts selection */
- }
- else {
- deselect_actionchannels(ob->action, 0); /* deselects for sure */
- if (selectmode == 1)
- deselect_actionchannels(ob->action, 1); /* swaps */
- }
-
countall();
if (doundo) {
@@ -4187,7 +4183,6 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
{
bArmature *arm= ob->data;
- Ipo *ipo;
char newname[MAXBONENAME];
char oldname[MAXBONENAME];
@@ -4225,11 +4220,12 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
/* we have the object using the armature */
if (arm==ob->data) {
Object *cob;
- bAction *act;
- bActionChannel *achan;
- bActionStrip *strip;
+ //bAction *act;
+ //bActionChannel *achan;
+ //bActionStrip *strip;
/* Rename action channel if necessary */
+#if 0 // XXX old animation system
act = ob->action;
if (act && !act->id.lib) {
/* Find the appropriate channel */
@@ -4237,6 +4233,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
if (achan)
BLI_strncpy(achan->name, newname, MAXBONENAME);
}
+#endif // XXX old animation system
/* Rename the pose channel, if it exists */
if (ob->pose) {
@@ -4246,6 +4243,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
}
/* check all nla-strips too */
+#if 0 // XXX old animation system
for (strip= ob->nlastrips.first; strip; strip= strip->next) {
/* Rename action channel if necessary */
act = strip->act;
@@ -4256,6 +4254,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
BLI_strncpy(achan->name, newname, MAXBONENAME);
}
}
+#endif // XXX old animation system
/* Update any object constraints to use the new bone name */
for (cob= G.main->object.first; cob; cob= cob->id.next) {
@@ -4290,6 +4289,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
}
/* do entire db - ipo's for the drivers */
+#if 0 // XXX old animation system
for (ipo= G.main->ipo.first; ipo; ipo= ipo->id.next) {
IpoCurve *icu;
@@ -4310,6 +4310,7 @@ void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep)
}
}
}
+#endif // XXX old animation system
}
}
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index c6ac1adb446..ffbc787f01c 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -82,8 +82,8 @@ static int extern_qread_ext() {return 0;}
static void persptoetsen() {}
static void headerprint() {}
-static void remake_action_ipos() {}
-static void verify_pchan2achan_grouping() {}
+static void remake_action_ipos() {} // xxx depreceated
+//static void verify_pchan2achan_grouping() {} // xxx depreceated
static void action_set_activemarker() {}
/* ******* XXX ********** */
@@ -276,6 +276,7 @@ void poselib_validate_act (bAction *act)
/* This function adds an ipo-curve of the right type where it's needed */
static IpoCurve *poselib_verify_icu (Ipo *ipo, int adrcode)
{
+#if 0 // XXX old animation system
IpoCurve *icu;
for (icu= ipo->curve.first; icu; icu= icu->next) {
@@ -296,6 +297,8 @@ static IpoCurve *poselib_verify_icu (Ipo *ipo, int adrcode)
}
return icu;
+#endif // XXX old animation system
+ return NULL;
}
/* This tool adds the current pose to the poselib
@@ -385,6 +388,7 @@ void poselib_add_current_pose (Scene *scene, Object *ob, int val)
/* check if available */
if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) {
+#if 0 // XXX old animation system
/* make action-channel if needed (action groups are also created) */
achan= verify_action_channel(act, pchan->name);
verify_pchan2achan_grouping(act, pose, pchan->name);
@@ -409,6 +413,7 @@ void poselib_add_current_pose (Scene *scene, Object *ob, int val)
INSERT_KEY_ICU(AC_QUAT_X, pchan->quat[1])
INSERT_KEY_ICU(AC_QUAT_Y, pchan->quat[2])
INSERT_KEY_ICU(AC_QUAT_Z, pchan->quat[3])
+#endif // XXX old animation system
}
}
}
@@ -456,6 +461,7 @@ void poselib_remove_pose (Object *ob, TimeMarker *marker)
}
/* remove relevant keyframes */
+#if 0 // XXX old animation system
for (achan= act->chanbase.first; achan; achan= achan->next) {
Ipo *ipo= achan->ipo;
IpoCurve *icu;
@@ -472,6 +478,7 @@ void poselib_remove_pose (Object *ob, TimeMarker *marker)
}
}
}
+#endif // XXX old animation system
/* remove poselib from list */
BLI_freelinkN(&act->markers, marker);
@@ -687,10 +694,12 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
ok= 1;
if (ok) {
+#if 0 // XXX old animation system
/* Evaluates and sets the internal ipo values */
calc_ipo(achan->ipo, (float)frame);
/* This call also sets the pchan flags */
execute_action_ipo(achan, pchan);
+#endif // XXX old animation system
}
}
}
@@ -719,6 +728,7 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld)
pchan= get_pose_channel(pose, achan->name);
if (pchan) {
+#if 0 // XXX old animation system
// TODO: use a standard autokeying function in future (to allow autokeying-editkeys to work)
if (IS_AUTOKEY_MODE(NORMAL)) {
ID *id= &pld->ob->id;
@@ -750,6 +760,7 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld)
if (pchan->bone)
pchan->bone->flag |= BONE_UNKEYED;
}
+#endif // XXX old animation system
}
}
}
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 08a670b9582..80b67ac70ac 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -36,6 +36,7 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -57,11 +58,11 @@
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
-#include "BKE_ipo.h"
#include "BIF_transform.h" /* for autokey TFM_TRANSLATION, etc */
#include "BIF_gl.h"
@@ -851,6 +852,7 @@ void paste_posebuf (Scene *scene, int flip)
EulToQuat(eul, pchan->quat);
}
+#if 0 // XXX old animation system
if (autokeyframe_cfra_can_key(ob)) {
ID *id= &ob->id;
@@ -881,6 +883,7 @@ void paste_posebuf (Scene *scene, int flip)
if (chan->bone)
chan->bone->flag |= BONE_UNKEYED;
}
+#endif // XXX old animation system
}
}
}
@@ -1513,6 +1516,7 @@ void pose_relax(Scene *scene)
if (pchan->bone->layer & arm->layer) {
if (pchan->bone->flag & BONE_SELECTED) {
/* do we have an ipo curve? */
+#if 0 // XXX old animation system
achan= get_action_channel(act, pchan->name);
if (achan && achan->ipo) {
@@ -1563,6 +1567,8 @@ void pose_relax(Scene *scene)
/* apply BONE_TRANSFORM tag so that autokeying will pick it up */
pchan->bone->flag |= BONE_TRANSFORM;
}
+
+#endif // XXX old animation system
}
}
}
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 4f67a31b8a3..e1455d7dfb0 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -46,7 +46,6 @@
#include "BLI_rand.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
@@ -59,7 +58,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_global.h"
@@ -77,7 +76,7 @@
/* still need to eradicate a few :( */
#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
-/* for curve objects in editmode that can have hidden handles - may use for IPO's later */
+/* for curve objects in editmode that can have hidden handles */
#define BEZSELECTED_HIDDENHANDLES(bezt) ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
/* XXX */
@@ -4456,6 +4455,7 @@ Nurb *addNurbprim(Scene *scene, int type, int stype, int newname)
void default_curve_ipo(Scene *scene, Curve *cu)
{
+#if 0 // XXX old animation system
IpoCurve *icu;
BezTriple *bezt;
@@ -4486,6 +4486,7 @@ void default_curve_ipo(Scene *scene, Curve *cu)
bezt->h1= bezt->h2= HD_AUTO;
calchandles_ipocurve(icu);
+#endif // XXX old animation system
}
void add_primitiveCurve(Scene *scene, int stype)
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index e23f8500571..33ab06c0f67 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -50,7 +50,7 @@
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BKE_blender.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -68,10 +68,10 @@
#include "gpencil_intern.h"
/* XXX */
-static void actdata_filter() {}
+static void actdata_filter() {} // is now ANIM_animdata_filter()
static void BIF_undo_push() {}
static void error() {}
-static void *get_action_context() {return NULL;}
+static void *get_action_context() {return NULL;} // is now ANIM_animdata_get_context()
/* XXX */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 8b3d5df61ba..20c72c9f0e2 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -158,7 +158,7 @@ typedef enum eAnimFilter_Flags {
ANIMFILTER_FOREDIT = (1<<2), /* does editable status matter */
ANIMFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */
ANIMFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */
- ANIMFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */
+ ANIMFILTER_ONLYFCU = (1<<5), /* only reference ipo-curves */
ANIMFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */
ANIMFILTER_ACTGROUPED = (1<<7), /* belongs to the active actiongroup */
} eAnimFilter_Flags;
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index eb6f422e425..77d41ace857 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -32,6 +32,7 @@
struct bAnimContext;
struct Ipo;
struct IpoCurve;
+struct FCurve;
struct BezTriple;
struct Scene;
@@ -130,12 +131,12 @@ void ANIM_editkeyframes_ipocurve_ipotype(struct IpoCurve *icu);
/* ************************************************ */
/* Destructive Editing API (keyframes_general.c) */
-void delete_icu_key(struct IpoCurve *icu, int index, short do_recalc);
+void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc);
void delete_ipo_keys(struct Ipo *ipo);
void duplicate_ipo_keys(struct Ipo *ipo);
-void clean_ipo_curve(struct IpoCurve *icu, float thresh);
-void smooth_ipo_curve(struct IpoCurve *icu, short mode);
+void clean_fcurve(struct FCurve *fcu, float thresh);
+void smooth_fcurve(struct FCurve *fcu, short mode);
/* ************************************************ */
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index fe456c7ea4b..e7bdbb86ffa 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -31,15 +31,10 @@
struct ListBase;
struct ID;
-struct Ipo;
-struct IpoCurve;
+struct FCurve;
struct BezTriple;
-/* ************ IPO/IPO-Curve Management ************** */
-// XXX these will need to be updated for RNA-IPO stuff
-
-struct Ipo *verify_ipo(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], short add);
-struct IpoCurve *verify_ipocurve(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], int adrcode, short add);
+struct wmOperatorType;
/* ************ Keyframing Management **************** */
@@ -47,13 +42,13 @@ struct IpoCurve *verify_ipocurve(struct ID *from, short blocktype, char actname[
* Use this when validation of necessary animation data isn't necessary as it already
* exists, and there is a beztriple that can be directly copied into the array.
*/
-int insert_bezt_icu(struct IpoCurve *icu, struct BezTriple *bezt);
+int insert_bezt_fcurve(struct FCurve *fcu, struct BezTriple *bezt);
/* 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_vert_icu(struct IpoCurve *icu, float x, float y, short flag);
+void insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag);
/* flags for use by keyframe creation/deletion calls */
@@ -78,21 +73,20 @@ enum {
* Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place. Returns success.
*/
- // TODO: adapt this for new data-api -> this blocktype, etc. stuff is evil!
-short insertkey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag);
+short insertkey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag);
/* Main Keyframing API call:
* Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
*/
-short deletekey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag);
+short deletekey(struct ID *id, const char rna_path[], int array_index, float cfra, short flag);
-/* Main Keyframe Management calls:
+/* Main Keyframe Management operators:
* These handle keyframes management from various spaces. They will handle the menus
* required for each space.
*/
-void common_insertkey(const struct bContext *C);
-void common_deletekey(const struct bContext *C);
+void ANIM_OT_insert_keyframe(struct wmOperatorType *ot);
+void ANIM_OT_delete_keyframe(struct wmOperatorType *ot);
/* ************ Auto-Keyframing ********************** */
/* Notes:
diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c
index 75134a470d7..c8d8ece30dc 100644
--- a/source/blender/editors/object/editconstraint.c
+++ b/source/blender/editors/object/editconstraint.c
@@ -52,7 +52,6 @@
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_main.h"
-#include "BKE_ipo.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
@@ -72,63 +71,6 @@ static int pupmenu() {return 0;}
/* -------------- Get Active Constraint Data ---------------------- */
-ListBase *get_active_constraint_channels (Scene *scene, Object *ob, int forcevalid)
-{
- char ipstr[64];
-
- if (ob == NULL)
- return NULL;
-
- /* See if we are a bone constraint */
- if (ob->flag & OB_POSEMODE) {
- bActionChannel *achan;
- bPoseChannel *pchan;
-
- pchan = get_active_posechannel(ob);
- if (pchan) {
- /* Make sure we have an action */
- if (ob->action == NULL) {
- if (forcevalid == 0)
- return NULL;
-
- ob->action= add_empty_action("Action");
- }
-
- /* Make sure we have an actionchannel */
- achan = get_action_channel(ob->action, pchan->name);
- if (achan == NULL) {
- if (forcevalid == 0)
- return NULL;
-
- achan = MEM_callocN (sizeof(bActionChannel), "ActionChannel");
-
- strcpy(achan->name, pchan->name);
- sprintf(ipstr, "%s.%s", ob->action->id.name+2, achan->name);
- ipstr[23]=0;
- achan->ipo= add_ipo(scene, ipstr, ID_AC);
-
- BLI_addtail(&ob->action->chanbase, achan);
- }
-
- return &achan->constraintChannels;
- }
- else
- return NULL;
- }
- /* else we return object constraints */
- else {
- if (ob->ipoflag & OB_ACTION_OB) {
- bActionChannel *achan = get_action_channel(ob->action, "Object");
- if (achan)
- return &achan->constraintChannels;
- else
- return NULL;
- }
-
- return &ob->constraintChannels;
- }
-}
-
/* if object in posemode, active bone constraints, else object constraints */
ListBase *get_active_constraints (Object *ob)
@@ -170,10 +112,9 @@ bConstraint *get_active_constraint (Object *ob)
bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob)
{
bConstraint *con;
- bConstraintChannel *chan;
if (ob->flag & OB_POSEMODE) {
- if (ob->action) {
+ //if (ob->action) { // XXX old animation system
bPoseChannel *pchan;
pchan = get_active_posechannel(ob);
@@ -184,6 +125,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob)
}
if (con) {
+#if 0 // XXX old animation system
bActionChannel *achan = get_action_channel(ob->action, pchan->name);
if (achan) {
for (chan= achan->constraintChannels.first; chan; chan= chan->next) {
@@ -192,9 +134,10 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob)
}
return chan;
}
+#endif // XXX old animation system
}
}
- }
+ //} // xxx old animation system
}
else {
for (con= ob->constraints.first; con; con= con->next) {
@@ -203,6 +146,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob)
}
if (con) {
+#if 0 // XXX old animation system
ListBase *lb= get_active_constraint_channels(scene, ob, 0);
if (lb) {
@@ -213,6 +157,7 @@ bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob)
return chan;
}
+#endif // XXX old animation system
}
}
@@ -645,7 +590,6 @@ void ob_clear_constraints (Scene *scene)
void rename_constraint (Object *ob, bConstraint *con, char *oldname)
{
bConstraint *tcon;
- bConstraintChannel *conchan;
ListBase *conlist= NULL;
int from_object= 0;
char *channame="";
@@ -686,24 +630,6 @@ void rename_constraint (Object *ob, bConstraint *con, char *oldname)
/* first make sure it's a unique name within context */
unique_constraint_name (con, conlist);
-
- /* own channels */
- if (from_object) {
- for (conchan= ob->constraintChannels.first; conchan; conchan= conchan->next) {
- if ( strcmp(oldname, conchan->name)==0 )
- BLI_strncpy(conchan->name, con->name, sizeof(conchan->name));
- }
- }
-
- /* own action */
- if (ob->action) {
- bActionChannel *achan= get_action_channel(ob->action, channame);
- if (achan) {
- conchan= get_constraint_channel(&achan->constraintChannels, oldname);
- if (conchan)
- BLI_strncpy(conchan->name, con->name, sizeof(conchan->name));
- }
- }
}
diff --git a/source/blender/editors/object/editkey.c b/source/blender/editors/object/editkey.c
index 20e2dbebe2e..913046c5ab8 100644
--- a/source/blender/editors/object/editkey.c
+++ b/source/blender/editors/object/editkey.c
@@ -77,6 +77,7 @@ static void BIF_undo_push() {}
static void error() {}
/* XXX */
+#if 0 // XXX old animation system
static void default_key_ipo(Scene *scene, Key *key)
{
IpoCurve *icu;
@@ -108,7 +109,7 @@ static void default_key_ipo(Scene *scene, Key *key)
calchandles_ipocurve(icu);
}
-
+#endif // XXX old animation system
/* **************************************** */
@@ -170,10 +171,11 @@ static KeyBlock *add_keyblock(Scene *scene, Key *key)
key->totkey++;
if(key->totkey==1) key->refkey= kb;
-
+ // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor...
if(key->type == KEY_RELATIVE)
kb->pos= curpos+0.1;
else {
+#if 0 // XXX old animation system
curpos= bsystem_time(scene, 0, (float)CFRA, 0.0);
if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) {
curpos /= 100.0;
@@ -181,6 +183,7 @@ static KeyBlock *add_keyblock(Scene *scene, Key *key)
kb->pos= curpos;
sort_keys(key);
+#endif // XXX old animation system
}
return kb;
}
@@ -195,8 +198,8 @@ void insert_meshkey(Scene *scene, Mesh *me, short rel)
if(rel)
me->key->type = KEY_RELATIVE;
- else
- default_key_ipo(scene, me->key);
+// else
+// default_key_ipo(scene, me->key); // XXX old animation system
}
key= me->key;
@@ -254,7 +257,7 @@ void insert_lattkey(Scene *scene, Lattice *lt, short rel)
if(lt->key==NULL) {
lt->key= add_key( (ID *)lt);
- default_key_ipo(scene, lt->key);
+// default_key_ipo(scene, lt->key); // XXX old animation system
}
key= lt->key;
@@ -377,8 +380,8 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
if (rel)
cu->key->type = KEY_RELATIVE;
- else
- default_key_ipo(scene, cu->key);
+// else
+// default_key_ipo(scene, cu->key); // XXX old animation system
}
key= cu->key;
@@ -414,7 +417,7 @@ void delete_key(Scene *scene, Object *ob)
{
KeyBlock *kb, *rkb;
Key *key;
- IpoCurve *icu;
+ //IpoCurve *icu;
key= ob_get_key(ob);
if(key==NULL) return;
@@ -438,6 +441,7 @@ void delete_key(Scene *scene, Object *ob)
kb->adrcode--;
}
+#if 0 // XXX old animation system
if(key->ipo) {
for(icu= key->ipo->curve.first; icu; icu= icu->next) {
@@ -450,7 +454,8 @@ void delete_key(Scene *scene, Object *ob)
for(icu= key->ipo->curve.first; icu; icu= icu->next)
if(icu->adrcode>=ob->shapenr)
icu->adrcode--;
- }
+ }
+#endif // XXX old animation system
if(ob->shapenr>1) ob->shapenr--;
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 7aab8bf8365..2f0f224b033 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -41,7 +41,6 @@
#include "DNA_effect_types.h"
#include "DNA_group_types.h"
#include "DNA_image_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
@@ -89,7 +88,6 @@
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_group.h"
-#include "BKE_ipo.h"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
@@ -432,8 +430,10 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag)
Object *ob;
Material *ma, *mao;
ID *id;
+#if 0 // XXX old animation system
Ipo *ipo;
bActionStrip *strip;
+#endif // XXX old animation system
int a;
/* check object pointers */
@@ -453,11 +453,13 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag)
ID_NEW(ob->proxy);
ID_NEW(ob->proxy_group);
+#if 0 // XXX old animation system
for(strip= ob->nlastrips.first; strip; strip= strip->next) {
bActionModifier *amod;
for(amod= strip->modifiers.first; amod; amod= amod->next)
ID_NEW(amod->ob);
}
+#endif // XXX old animation system
}
}
@@ -481,17 +483,20 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag)
}
}
}
+#if 0 // XXX old animation system
id= (ID *)ma->ipo;
if(id) {
ID_NEW_US(ma->ipo)
else ma->ipo= copy_ipo(ma->ipo);
id->us--;
}
+#endif // XXX old animation system
}
mao= mao->id.next;
}
}
+#if 0 // XXX old animation system
/* lamps */
if( dupflag & USER_DUP_IPO) {
Lamp *la= G.main->lamp.first;
@@ -523,6 +528,7 @@ static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag)
}
ipo= ipo->id.next;
}
+#endif // XXX old animation system
set_sca_new_poins();
@@ -1191,7 +1197,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot)
/* ****** selection by links *******/
static EnumPropertyItem prop_select_linked_types[] = {
- {1, "IPO", "Object IPO", ""},
+ {1, "IPO", "Object IPO", ""}, // XXX depreceated animation system stuff...
{2, "OBDATA", "Ob Data", ""},
{3, "MATERIAL", "Material", ""},
{4, "TEXTURE", "Texture", ""},
@@ -1205,7 +1211,6 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *ob;
void *obdata = NULL;
- Ipo *ipo = NULL;
Material *mat = NULL, *mat1;
Tex *tex=0;
int a, b;
@@ -1224,9 +1229,11 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
ob= OBACT;
if(ob==0) return OPERATOR_CANCELLED;
- if(nr==1) {
- ipo= ob->ipo;
- if(ipo==0) return OPERATOR_CANCELLED;
+ if(nr==1) {
+ // XXX old animation system
+ //ipo= ob->ipo;
+ //if(ipo==0) return OPERATOR_CANCELLED;
+ return OPERATOR_CANCELLED;
}
else if(nr==2) {
if(ob->data==0) return OPERATOR_CANCELLED;
@@ -1251,8 +1258,9 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
if (!(base->flag & SELECT)) {
if(nr==1) {
- if(base->object->ipo==ipo) base->flag |= SELECT;
- changed = 1;
+ // XXX old animation system
+ //if(base->object->ipo==ipo) base->flag |= SELECT;
+ //changed = 1;
}
else if(nr==2) {
if(base->object->data==obdata) base->flag |= SELECT;
@@ -2076,12 +2084,6 @@ void make_proxy(Scene *scene)
/* ******************** make parent operator *********************** */
-#if 0
-oldcode()
-{
-}
-#endif
-
#define PAR_OBJECT 0
#define PAR_ARMATURE 1
#define PAR_BONE 2
@@ -4422,10 +4424,6 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
else if(event==22) {
/* Copy the constraint channels over */
copy_constraints(&base->object->constraints, &ob->constraints);
- if (U.dupflag& USER_DUP_IPO)
- copy_constraint_channels(&base->object->constraintChannels, &ob->constraintChannels);
- else
- clone_constraint_channels (&base->object->constraintChannels, &ob->constraintChannels);
do_scene_sort= 1;
}
@@ -4440,7 +4438,9 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
}
}
else if(event==26) {
+#if 0 // XXX old animation system
copy_nlastrips(&base->object->nlastrips, &ob->nlastrips);
+#endif // XXX old animation system
}
else if(event==27) { /* autosmooth */
if (base->object->type==OB_MESH) {
@@ -4657,12 +4657,14 @@ void make_links(Scene *scene, View3D *v3d, short event)
}
}
else if(event==4) { /* ob ipo */
+#if 0 // XXX old animation system
if(obt->ipo) obt->ipo->id.us--;
obt->ipo= ob->ipo;
if(obt->ipo) {
id_us_plus((ID *)obt->ipo);
do_ob_ipo(scene, obt);
}
+#endif // XXX old animation system
}
else if(event==6) {
if(ob->dup_group) ob->dup_group->id.us--;
@@ -5044,7 +5046,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag)
Object *ob;
Lamp *la;
Curve *cu;
- Camera *cam;
+ //Camera *cam;
Base *base;
Mesh *me;
ID *id;
@@ -5074,8 +5076,8 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag)
break;
case OB_MESH:
me= ob->data= copy_mesh(ob->data);
- if(me && me->key)
- ipo_idnew(me->key->ipo); /* drivers */
+ //if(me && me->key)
+ // ipo_idnew(me->key->ipo); /* drivers */
break;
case OB_MBALL:
ob->data= copy_mball(ob->data);
@@ -5106,6 +5108,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag)
}
+#if 0 // XXX old animation system
id= (ID *)ob->action;
if (id && id->us>1 && id->lib==NULL){
if(id->newid){
@@ -5150,7 +5153,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag)
}
break;
}
-
+#endif // XXX old animation system
}
}
@@ -5163,6 +5166,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag)
void single_ipo_users(Scene *scene, View3D *v3d, int flag)
{
+#if 0 // XXX old animation system
Object *ob;
Base *base;
ID *id;
@@ -5180,6 +5184,7 @@ void single_ipo_users(Scene *scene, View3D *v3d, int flag)
}
}
}
+#endif // XXX old animation system
}
void single_mat_users(Scene *scene, View3D *v3d, int flag)
@@ -5205,12 +5210,14 @@ void single_mat_users(Scene *scene, View3D *v3d, int flag)
man->id.us= 0;
assign_material(ob, man, a);
-
+
+#if 0 // XXX old animation system
if(ma->ipo) {
man->ipo= copy_ipo(ma->ipo);
ma->ipo->id.us--;
ipo_idnew(ma->ipo); /* drivers */
}
+#endif // XXX old animation system
for(b=0; b<MAX_MTEX; b++) {
if(ma->mtex[b] && ma->mtex[b]->tex) {
@@ -5394,7 +5401,7 @@ void single_user(Scene *scene, View3D *v3d)
/* helper for below, ma was checked to be not NULL */
static void make_local_makelocalmaterial(Material *ma)
{
- ID *id;
+ //ID *id;
int b;
make_local_material(ma);
@@ -5405,8 +5412,10 @@ static void make_local_makelocalmaterial(Material *ma)
}
}
+#if 0 // XXX old animation system
id= (ID *)ma->ipo;
- if(id && id->lib) make_local_ipo(ma->ipo);
+ if(id && id->lib) make_local_ipo(ma->ipo);
+#endif // XXX old animation system
/* nodetree? XXX */
}
@@ -5415,7 +5424,7 @@ void make_local(Scene *scene, View3D *v3d, int mode)
{
Base *base;
Object *ob;
- bActionStrip *strip;
+ //bActionStrip *strip;
ParticleSystem *psys;
Material *ma, ***matarar;
Lamp *la;
@@ -5467,9 +5476,10 @@ void make_local(Scene *scene, View3D *v3d, int mode)
make_local_lamp((Lamp *)id);
la= ob->data;
+#if 0 // XXX old animation system
id= (ID *)la->ipo;
if(id && id->lib) make_local_ipo(la->ipo);
-
+#endif // XXX old animation system
break;
case OB_CAMERA:
make_local_camera((Camera *)id);
@@ -5486,8 +5496,10 @@ void make_local(Scene *scene, View3D *v3d, int mode)
case OB_FONT:
cu= (Curve *)id;
make_local_curve(cu);
+#if 0 // XXX old animation system
id= (ID *)cu->ipo;
if(id && id->lib) make_local_ipo(cu->ipo);
+#endif // XXX old animation system
make_local_key( cu->key );
break;
case OB_LATTICE:
@@ -5502,6 +5514,8 @@ void make_local(Scene *scene, View3D *v3d, int mode)
for(psys=ob->particlesystem.first; psys; psys=psys->next)
make_local_particlesettings(psys->part);
}
+
+#if 0 // XXX old animation system
id= (ID *)ob->ipo;
if(id && id->lib) make_local_ipo(ob->ipo);
@@ -5512,6 +5526,7 @@ void make_local(Scene *scene, View3D *v3d, int mode)
if(strip->act && strip->act->id.lib)
make_local_action(strip->act);
}
+#endif // XXX old animation system
}
}
@@ -5622,7 +5637,7 @@ void adduplicate(Scene *scene, View3D *v3d, int mode, int dupflag)
if(BASACT==base) BASACT= basen;
/* duplicates using userflags */
-
+#if 0 // XXX old animation system
if(dupflag & USER_DUP_IPO) {
bConstraintChannel *chan;
id= (ID *)obn->ipo;
@@ -5652,6 +5667,7 @@ void adduplicate(Scene *scene, View3D *v3d, int mode, int dupflag)
id->us--;
}
}
+#endif // XXX old animation system
if(dupflag & USER_DUP_MAT) {
for(a=0; a<obn->totcol; a++) {
id= (ID *)obn->mat[a];
@@ -5862,6 +5878,7 @@ void image_aspect(Scene *scene, View3D *v3d)
void set_ob_ipoflags(Scene *scene, View3D *v3d)
{
+#if 0 // XXX old animation system
Base *base;
int set= 1;
@@ -5897,10 +5914,13 @@ void set_ob_ipoflags(Scene *scene, View3D *v3d)
allqueue (REDRAWACTION, 0);
// allspace(REMAKEIPO, 0);
allqueue(REDRAWIPO, 0);
+#endif // XXX old animation system
}
+
void select_select_keys(Scene *scene, View3D *v3d)
{
+#if 0 // XXX old animation system
Base *base;
IpoCurve *icu;
BezTriple *bezt;
@@ -5943,7 +5963,7 @@ void select_select_keys(Scene *scene, View3D *v3d)
allqueue(REDRAWIPO, 0);
BIF_undo_push("Select keys");
-
+#endif // XXX old animation system
}
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 2e1e9845701..d10f3730318 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -120,6 +120,8 @@ void ED_keymap_object(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "OBJECT_OT_object_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+ // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
+ WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe", IKEY, KM_PRESS, KM_ALT, 0);
}
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index a1d4c09b9eb..6e19982c7c7 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -41,12 +41,11 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
-#include "DNA_listBase.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
@@ -64,7 +63,7 @@
#include "BKE_action.h"
#include "BKE_depsgraph.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
#include "BKE_object.h"
@@ -110,11 +109,12 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
Object *nob= ANIM_nla_mapping_get(ac, ale);
- Ipo *ipo= (Ipo *)ale->key_data;
+ //Ipo *ipo= (Ipo *)ale->key_data; // XXX fixme
float tmin, tmax;
/* get range and apply necessary scaling before */
- calc_ipo_range(ipo, &tmin, &tmax);
+ //calc_ipo_range(ipo, &tmin, &tmax);
+ tmin= tmax= 0.0f; // xxx
if (nob) {
tmin= get_action_frame_inv(nob, tmin);
@@ -258,6 +258,7 @@ void free_actcopybuf ()
bActionChannel *achan, *anext;
bConstraintChannel *conchan, *cnext;
+#if 0 // XXX old animation system
for (achan= actcopybuf.first; achan; achan= anext) {
anext= achan->next;
@@ -279,6 +280,7 @@ void free_actcopybuf ()
BLI_freelinkN(&actcopybuf, achan);
}
+#endif // XXX old animation system
actcopybuf.first= actcopybuf.last= NULL;
actcopy_firstframe= 999999999.0f;
@@ -353,7 +355,7 @@ static short copy_action_keys (bAnimContext *ac)
for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) {
if (BEZSELECTED(bezt)) {
/* add to buffer ipo-curve */
- insert_bezt_icu(icn, bezt);
+ //insert_bezt_icu(icn, bezt); // XXX
/* check if this is the earliest frame encountered so far */
if (bezt->vec[1][0] < actcopy_firstframe)
@@ -454,7 +456,8 @@ static short paste_action_keys (bAnimContext *ac)
/* loop over curves, pasting keyframes */
for (ico= ipo_src->curve.first; ico; ico= ico->next) {
/* get IPO-curve to paste to (IPO-curve might not exist for destination, so gets created) */
- icu= verify_ipocurve(ale->id, ico->blocktype, actname, conname, NULL, ico->adrcode, 1);
+ //icu= verify_ipocurve(ale->id, ico->blocktype, actname, conname, NULL, ico->adrcode, 1);
+
if (icu) {
/* just start pasting, with the the first keyframe on the current frame, and so on */
@@ -465,7 +468,7 @@ static short paste_action_keys (bAnimContext *ac)
bezt->vec[2][0] += offset;
/* insert the keyframe */
- insert_bezt_icu(icu, bezt);
+ //insert_bezt_icu(icu, bezt); // XXX
/* un-apply offset from src beztriple after copying */
bezt->vec[0][0] -= offset;
@@ -474,7 +477,7 @@ static short paste_action_keys (bAnimContext *ac)
}
/* recalculate channel's handles? */
- calchandles_ipocurve(icu);
+ //calchandles_fcurve(fcu);
}
}
}
@@ -600,7 +603,7 @@ static void delete_action_keys (bAnimContext *ac)
//if (ale->type == ANIMTYPE_GPLAYER)
// delete_gplayer_frames((bGPDlayer *)ale->data);
//else
- delete_ipo_keys((Ipo *)ale->key_data);
+ // delete_ipo_keys((Ipo *)ale->key_data); // XXX fixme for the new animsys...
}
/* free filtered list */
@@ -652,12 +655,12 @@ static void clean_action_keys (bAnimContext *ac, float thresh)
int filter;
/* filter data */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* loop through filtered data and clean curves */
for (ale= anim_data.first; ale; ale= ale->next)
- clean_ipo_curve((IpoCurve *)ale->key_data, thresh);
+ clean_fcurve((FCurve *)ale->key_data, thresh);
/* free temp data */
BLI_freelistN(&anim_data);
@@ -724,19 +727,19 @@ static void sample_action_keys (bAnimContext *ac)
int filter;
/* filter data */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale= anim_data.first; ale; ale= ale->next) {
- IpoCurve *icu= (IpoCurve *)ale->key_data;
+ FCurve *fcu= (FCurve *)ale->key_data;
BezTriple *bezt, *start=NULL, *end=NULL;
tempFrameValCache *value_cache, *fp;
int sfra, range;
int i, n;
/* find selected keyframes... once pair has been found, add keyframes */
- for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) {
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if selected, and which end this is */
if (BEZSELECTED(bezt)) {
if (start) {
@@ -755,19 +758,19 @@ static void sample_action_keys (bAnimContext *ac)
/* sample values */
for (n=0, fp=value_cache; n<range && fp; n++, fp++) {
fp->frame= (float)(sfra + n);
- fp->val= eval_icu(icu, fp->frame);
+ fp->val= evaluate_fcurve(fcu, fp->frame);
}
/* add keyframes with these */
for (n=0, fp=value_cache; n<range && fp; n++, fp++) {
- insert_vert_icu(icu, fp->frame, fp->val, 1);
+ insert_vert_fcurve(fcu, fp->frame, fp->val, 1);
}
/* free temp cache */
MEM_freeN(value_cache);
/* as we added keyframes, we need to compensate so that bezt is at the right place */
- bezt = icu->bezt + i + range - 1;
+ bezt = fcu->bezt + i + range - 1;
i += (range - 1);
}
@@ -784,7 +787,7 @@ static void sample_action_keys (bAnimContext *ac)
}
/* recalculate channel's handles? */
- calchandles_ipocurve(icu);
+ calchandles_fcurve(fcu);
}
/* admin and redraws */
@@ -1028,11 +1031,11 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
toggle_cb= ANIM_editkeyframes_handles(HD_ALIGN);
/* set handle-type */
- ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, toggle_cb, calchandles_ipocurve);
+ ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, toggle_cb, calchandles_fcurve);
}
else {
/* directly set handle-type */
- ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_ipocurve);
+ ANIM_ipo_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
}
}
@@ -1183,7 +1186,7 @@ static void snap_action_keys(bAnimContext *ac, short mode)
if (ac->datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
else
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* get beztriple editing callbacks */
@@ -1198,13 +1201,13 @@ static void snap_action_keys(bAnimContext *ac, short mode)
if (nob) {
ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1);
- ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve);
+ ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
else
- ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve);
+ ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
}
BLI_freelistN(&anim_data);
}
@@ -1304,7 +1307,7 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
if (ac->datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
else
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* mirror keyframes */
@@ -1313,13 +1316,13 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
if (nob) {
ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1);
- ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve);
+ ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
else
- ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_ipocurve);
+ ANIM_icu_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
}
BLI_freelistN(&anim_data);
}
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index a8a2a56887f..f3a9ceb21ba 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -91,6 +91,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
{
/* action_select.c - selection tools */
/* click-select */
+ // TODO: column to alt, left-right to ctrl (for select-linked consistency)
WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "column_select", 1);
RNA_boolean_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 7932690e1ff..58574df7788 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -38,12 +38,11 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
-#include "DNA_listBase.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
@@ -61,7 +60,7 @@
#include "BKE_action.h"
#include "BKE_depsgraph.h"
-#include "BKE_ipo.h"
+#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
#include "BKE_object.h"
@@ -662,7 +661,7 @@ static void columnselect_action_keys (bAnimContext *ac, short mode)
if (ac->datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE);
else
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
@@ -1011,7 +1010,7 @@ static void mouse_columnselect_action_keys (bAnimContext *ac, float selx)
if (ac->datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE);
else
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 9fa045830ab..16372791736 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -64,7 +64,6 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
-#include "BKE_ipo.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
@@ -1742,7 +1741,7 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, Base *base, int dt)
/* extra draw service for pose mode */
constflag= pchan->constflag;
- if (pchan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE))
+ if (pchan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) // XXX this is useless crap
constflag |= PCHAN_HAS_ACTION;
if (pchan->flag & POSE_STRIDE)
constflag |= PCHAN_HAS_STRIDE;
@@ -2025,7 +2024,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, Object *ob)
{
bArmature *arm= ob->data;
bPoseChannel *pchan;
- bAction *act;
+ bAction *act; // XXX old animsys - watch it!
bActionChannel *achan;
ActKeyColumn *ak;
ListBase keys;
@@ -2173,12 +2172,15 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, Object *ob)
if (arm->pathflag & ARM_PATH_KFRAS) {
/* build list of all keyframes in active action for pchan */
keys.first = keys.last = NULL;
+
+ #if 0 // XXX old animation system
act= ob->action;
if (act) {
achan= get_action_channel(act, pchan->name);
if (achan)
ipo_to_keylist(achan->ipo, &keys, NULL, NULL);
}
+ #endif // XXX old animation system
/* Draw slightly-larger yellow dots at each keyframe */
UI_ThemeColor(TH_VERTEX_SELECT);
@@ -2294,7 +2296,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, Base *base)
colfac = (end-CFRA)/range;
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0f*sqrt(colfac)));
- do_all_pose_actions(scene, ob);
+ //do_all_pose_actions(scene, ob); // XXX old animation system
where_is_pose(scene, ob);
draw_pose_channels(scene, v3d, base, OB_WIRE);
}
@@ -2319,14 +2321,14 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, Base *base)
static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base)
{
Object *ob= base->object;
- bAction *act= ob->action;
+ bAction *act= ob->action; // XXX old animsys stuff... watch it!
bArmature *arm= ob->data;
bPose *posen, *poseo;
ListBase keys= {NULL, NULL};
ActKeysInc aki = {0, 0, 0};
ActKeyColumn *ak, *akn;
float start, end, range, colfac, i;
- int cfrao, flago, ipoflago;
+ int cfrao, flago;
aki.start= start = arm->ghostsf;
aki.end= end = arm->ghostef;
@@ -2351,7 +2353,6 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base)
cfrao= CFRA;
flago= arm->flag;
arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
- ipoflago= ob->ipoflag;
ob->ipoflag |= OB_DISABLE_PATH;
/* copy the pose */
@@ -2371,7 +2372,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base)
CFRA= (int)ak->cfra;
- do_all_pose_actions(scene, ob);
+ //do_all_pose_actions(scene, ob); // XXX old animation system
where_is_pose(scene, ob);
draw_pose_channels(scene, v3d, base, OB_WIRE);
}
@@ -2388,7 +2389,6 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, Base *base)
arm->flag= flago;
armature_rebuild_pose(ob, ob->data);
ob->flag |= OB_POSEMODE;
- ob->ipoflag= ipoflago;
}
/* draw ghosts around current frame
@@ -2399,13 +2399,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
Object *ob= base->object;
bArmature *arm= ob->data;
bPose *posen, *poseo;
- bActionStrip *strip;
+ //bActionStrip *strip;
float cur, start, end, stepsize, range, colfac, actframe, ctime;
- int cfrao, maptime, flago, ipoflago;
+ int cfrao, maptime, flago;
/* pre conditions, get an action with sufficient frames */
- if (ob->action==NULL)
- return;
+ //if (ob->action==NULL)
+ // return;
calc_action_range(ob->action, &start, &end, 0);
if (start == end)
@@ -2414,12 +2414,15 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
stepsize= (float)(arm->ghostsize);
range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */
+#if 0 // XXX old animation system
/* we only map time for armature when an active strip exists */
for (strip=ob->nlastrips.first; strip; strip=strip->next)
if (strip->flag & ACTSTRIP_ACTIVE)
break;
+#endif // XXX old animsys
- maptime= (strip!=NULL);
+ //maptime= (strip!=NULL);
+ maptime= 0;
/* store values */
ob->flag &= ~OB_POSEMODE;
@@ -2428,8 +2431,6 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
else actframe= CFRA;
flago= arm->flag;
arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
- ipoflago= ob->ipoflag;
- ob->ipoflag |= OB_DISABLE_PATH;
/* copy the pose */
poseo= ob->pose;
@@ -2453,7 +2454,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
else CFRA= (int)floor(actframe+ctime);
if (CFRA!=cfrao) {
- do_all_pose_actions(scene, ob);
+ //do_all_pose_actions(scene, ob); // xxx old animation system crap
where_is_pose(scene, ob);
draw_pose_channels(scene, v3d, base, OB_WIRE);
}
@@ -2469,7 +2470,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
else CFRA= (int)floor(actframe-ctime);
if (CFRA != cfrao) {
- do_all_pose_actions(scene, ob);
+ //do_all_pose_actions(scene, ob); // XXX old animation system crap...
where_is_pose(scene, ob);
draw_pose_channels(scene, v3d, base, OB_WIRE);
}
@@ -2487,7 +2488,6 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, Base *base)
arm->flag= flago;
armature_rebuild_pose(ob, ob->data);
ob->flag |= OB_POSEMODE;
- ob->ipoflag= ipoflago;
}
/* ********************************** Armature Drawing - Main ************************* */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8282e021dad..7a01e1ada7a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -46,7 +46,6 @@
#include "DNA_curve_types.h"
#include "DNA_constraint_types.h" // for drawing constraint
#include "DNA_effect_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
@@ -82,7 +81,6 @@
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_image.h"
-#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_mesh.h"
@@ -3040,7 +3038,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part
pa_time=(cfra-pa->time)/pa->lifetime;
pa_size=pa->size;
- if((part->flag&PART_ABS_TIME)==0){
+ if((part->flag&PART_ABS_TIME)==0){
+#if 0 // XXX old animation system
if(ma && ma->ipo){
IpoCurve *icu;
@@ -3067,6 +3066,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part
pa_size = icu->curval;
}
}
+#endif // XXX old animation system
}
r_tilt=1.0f+pa->r_ave[0];
@@ -3083,6 +3083,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part
if((part->flag&PART_ABS_TIME)==0) {
if(ma && ma->ipo){
+#if 0 // XXX old animation system
IpoCurve *icu;
/* correction for lifetime */
@@ -3096,6 +3097,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part
else if(icu->adrcode == MA_COL_B)
ma_b = icu->curval;
}
+#endif // XXX old animation system
}
}
@@ -4009,6 +4011,7 @@ static void draw_empty_cone (float size)
/* draw points on curve speed handles */
static void curve_draw_speed(Scene *scene, Object *ob)
{
+#if 0 // XXX old animation system stuff
Curve *cu= ob->data;
IpoCurve *icu;
BezTriple *bezt;
@@ -4034,6 +4037,7 @@ static void curve_draw_speed(Scene *scene, Object *ob)
glPointSize(1.0);
bglEnd();
+#endif // XXX old animation system stuff
}
@@ -4267,9 +4271,9 @@ static void draw_forcefield(Scene *scene, Object *ob)
Mat4One(tmat);
UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
- if (has_ipo_code(ob->ipo, OB_PD_FSTR))
- force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
- else
+ //if (has_ipo_code(ob->ipo, OB_PD_FSTR))
+ // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
+ //else
force_val = pd->f_strength;
force_val*= 0.1;
drawcircball(GL_LINE_LOOP, vec, size, tmat);
@@ -4285,9 +4289,9 @@ static void draw_forcefield(Scene *scene, Object *ob)
else if (pd->forcefield == PFIELD_FORCE) {
float ffall_val;
- if (has_ipo_code(ob->ipo, OB_PD_FFALL))
- ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra);
- else
+ //if (has_ipo_code(ob->ipo, OB_PD_FFALL))
+ // ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra);
+ //else
ffall_val = pd->f_power;
UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
@@ -4301,14 +4305,14 @@ static void draw_forcefield(Scene *scene, Object *ob)
float ffall_val, force_val;
Mat4One(tmat);
- if (has_ipo_code(ob->ipo, OB_PD_FFALL))
- ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra);
- else
+ //if (has_ipo_code(ob->ipo, OB_PD_FFALL))
+ // ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra);
+ //else
ffall_val = pd->f_power;
- if (has_ipo_code(ob->ipo, OB_PD_FSTR))
- force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
- else
+ //if (has_ipo_code(ob->ipo, OB_PD_FSTR))
+ // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
+ //else
force_val = pd->f_strength;
UI_ThemeColorBlend(curcol, TH_BACK, 0.7);
@@ -4326,9 +4330,9 @@ static void draw_forcefield(Scene *scene, Object *ob)
if((cu->flag & CU_PATH) && cu->path && cu->path->data) {
float mindist, guidevec1[4], guidevec2[3];
- if (has_ipo_code(ob->ipo, OB_PD_FSTR))
- mindist = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
- else
+ //if (has_ipo_code(ob->ipo, OB_PD_FSTR))
+ // mindist = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
+ //else
mindist = pd->f_strength;
/*path end*/
@@ -4697,10 +4701,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
static int warning_recursive= 0;
Object *ob;
Curve *cu;
- float cfraont;
+ //float cfraont;
float vec1[3], vec2[3];
unsigned int col=0;
- int sel, drawtype, colindex= 0, ipoflag;
+ int /*sel, drawtype,*/ colindex= 0;
int i, selstart, selend, empty_object=0;
short dt, dtx, zbufoff= 0;
@@ -4728,6 +4732,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
/* draw keys? */
+#if 0 // XXX old animation system
if(base==(scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) {
if(flag==0 && warning_recursive==0 && ob!=scene->obedit) {
if(ob->ipo && ob->ipo->showkey && (ob->ipoflag & OB_DRAWKEY)) {
@@ -4800,6 +4805,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
}
}
+#endif // XXX old animation system
/* patch? children objects with a timeoffs change the parents. How to solve! */
/* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index d85be9406d7..618d30eea60 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -802,7 +802,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d)
}
/* colour depends on whether there is a keyframe */
- if (id_frame_has_keyframe((ID *)ob, frame_to_float(scene, CFRA), v3d->keyflags))
+ if (id_frame_has_keyframe((ID *)ob, /*frame_to_float(scene, CFRA)*/(float)(CFRA), v3d->keyflags))
UI_ThemeColor(TH_VERTEX_SELECT);
else
UI_ThemeColor(TH_TEXT_HI);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index d69f318aa3f..d8421bb7a60 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -37,13 +37,13 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
#include "DNA_effect_types.h"
#include "DNA_image_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
@@ -81,8 +81,8 @@
#include "BKE_DerivedMesh.h"
#include "BKE_effect.h"
#include "BKE_font.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
-#include "BKE_ipo.h"
#include "BKE_lattice.h"
#include "BKE_key.h"
#include "BKE_main.h"
@@ -2698,16 +2698,16 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* Called during special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
*/
-static void posttrans_icu_clean (IpoCurve *icu)
+static void posttrans_fcurve_clean (FCurve *fcu)
{
float *selcache; /* cache for frame numbers of selected frames (icu->totvert*sizeof(float)) */
int len, index, i; /* number of frames in cache, item index */
/* allocate memory for the cache */
// TODO: investigate using GHash for this instead?
- if (icu->totvert == 0)
+ if (fcu->totvert == 0)
return;
- selcache= MEM_callocN(sizeof(float)*icu->totvert, "IcuSelFrameNums");
+ selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums");
len= 0;
index= 0;
@@ -2717,8 +2717,8 @@ static void posttrans_icu_clean (IpoCurve *icu)
*/
/* Loop 1: find selected keyframes */
- for (i = 0; i < icu->totvert; i++) {
- BezTriple *bezt= &icu->bezt[i];
+ for (i = 0; i < fcu->totvert; i++) {
+ BezTriple *bezt= &fcu->bezt[i];
if (BEZSELECTED(bezt)) {
selcache[index]= bezt->vec[1][0];
@@ -2729,14 +2729,14 @@ static void posttrans_icu_clean (IpoCurve *icu)
/* Loop 2: delete unselected keyframes on the same frames (if any keyframes were found) */
if (len) {
- for (i = 0; i < icu->totvert; i++) {
- BezTriple *bezt= &icu->bezt[i];
+ for (i = 0; i < fcu->totvert; i++) {
+ BezTriple *bezt= &fcu->bezt[i];
if (BEZSELECTED(bezt) == 0) {
/* check beztriple should be removed according to cache */
for (index= 0; index < len; index++) {
if (IS_EQ(bezt->vec[1][0], selcache[index])) {
- delete_icu_key(icu, i, 0);
+ //delete_icu_key(icu, i, 0);
break;
}
else if (bezt->vec[1][0] > selcache[index])
@@ -2745,31 +2745,13 @@ static void posttrans_icu_clean (IpoCurve *icu)
}
}
- testhandles_ipocurve(icu);
+ testhandles_fcurve(fcu);
}
/* free cache */
MEM_freeN(selcache);
}
-/* Called by special_aftertrans_update to make sure selected keyframes replace
- * any other keyframes which may reside on that frame (that is not selected).
- * remake_action_ipos should have already been called
- */
-static void posttrans_ipo_clean (Ipo *ipo)
-{
- IpoCurve *icu;
-
- if (ipo == NULL)
- return;
-
- /* loop through relevant data, removing keyframes from the ipocurves
- * - all keyframes are converted in/out of global time
- */
- for (icu= ipo->curve.first; icu; icu= icu->next) {
- posttrans_icu_clean(icu);
- }
-}
/* Called by special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
@@ -2782,7 +2764,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
int filter;
/* filter data */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, act, ANIMCONT_ACTION);
/* loop through relevant data, removing keyframes from the ipo-blocks that were attached
@@ -2792,12 +2774,12 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
Object *nob= ANIM_nla_mapping_get(ac, ale);
if (nob) {
- ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1);
- posttrans_icu_clean(ale->key_data);
- ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1);
+ //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 0, 1);
+ posttrans_fcurve_clean(ale->key_data);
+ //ANIM_nla_mapping_apply_ipocurve(nob, ale->key_data, 1, 1);
}
else
- posttrans_icu_clean(ale->key_data);
+ posttrans_fcurve_clean(ale->key_data);
}
/* free temp data */
@@ -2820,16 +2802,16 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
-static int count_icu_keys(IpoCurve *icu, char side, float cfra)
+static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
{
BezTriple *bezt;
int i, count = 0;
- if (icu == NULL)
+ if (fcu == NULL)
return count;
/* only include points that occur on the right side of cfra */
- for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) {
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (bezt->f2 & SELECT) {
/* fully select the other two keys */
bezt->f1 |= SELECT;
@@ -2885,15 +2867,15 @@ static void TimeToTransData(TransData *td, float *time, Object *ob)
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
* on the named side are used.
*/
-static TransData *IcuToTransData(TransData *td, IpoCurve *icu, Object *ob, char side, float cfra)
+static TransData *FCurveToTransData(TransData *td, FCurve *fcu, Object *ob, char side, float cfra)
{
BezTriple *bezt;
int i;
- if (icu == NULL)
+ if (fcu == NULL)
return td;
- for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) {
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
if (BEZSELECTED(bezt)) {
/* only add if on the right 'side' of the current frame */
@@ -2995,7 +2977,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
if (ac.datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
else
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
ANIM_animdata_filter(&anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
@@ -3026,7 +3008,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
//if (ale->type == ANIMTYPE_GPLAYER)
// count += count_gplayer_frames(ale->data, side, cfra);
//else
- count += count_icu_keys(ale->key_data, side, cfra);
+ count += count_fcurve_keys(ale->key_data, side, cfra);
}
/* stop if trying to build list if nothing selected */
@@ -3067,7 +3049,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
//}
//else {
Object *nob= ANIM_nla_mapping_get(&ac, ale);
- IpoCurve *icu= (IpoCurve *)ale->key_data;
+ FCurve *fcu= (FCurve *)ale->key_data;
/* convert current-frame to action-time (slightly less accurate, espcially under
* higher scaling ratios, but is faster than converting all points)
@@ -3077,7 +3059,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
else
cfra = (float)CFRA;
- td= IcuToTransData(td, icu, nob, side, cfra);
+ td= FCurveToTransData(td, fcu, nob, side, cfra);
//}
}
@@ -3701,20 +3683,6 @@ void autokeyframe_pose_cb_func(Object *ob, int tmode, short targetless_ik)
#endif
}
-/* very bad call!!! - copied from editnla.c! */
-static void recalc_all_ipos(void)
-{
- Ipo *ipo;
- IpoCurve *icu;
-
- /* Go to each ipo */
- for (ipo=G.main->ipo.first; ipo; ipo=ipo->id.next){
- for (icu = ipo->curve.first; icu; icu=icu->next){
- sort_time_ipocurve(icu);
- testhandles_ipocurve(icu);
- }
- }
-}
/* inserting keys, refresh ipo-keys, pointcache, redraw events... (ton) */
/* note: transdata has been freed already! */
@@ -3761,7 +3729,7 @@ void special_aftertrans_update(TransInfo *t)
if (ac.datatype == ANIMCONT_DOPESHEET) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYICU);
+ short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ONLYFCU);
/* get channels to work on */
ANIM_animdata_filter(&anim_data, filter, ac.data, ac.datatype);
@@ -3769,18 +3737,18 @@ void special_aftertrans_update(TransInfo *t)
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
Object *nob= ANIM_nla_mapping_get(&ac, ale);
- IpoCurve *icu= (IpoCurve *)ale->key_data;
+ FCurve *fcu= (FCurve *)ale->key_data;
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
if (nob) {
- ANIM_nla_mapping_apply_ipocurve(nob, icu, 0, 1);
- posttrans_icu_clean(icu);
- ANIM_nla_mapping_apply_ipocurve(nob, icu, 1, 1);
+ //ANIM_nla_mapping_apply_ipocurve(nob, icu, 0, 1);
+ posttrans_fcurve_clean(fcu);
+ //ANIM_nla_mapping_apply_ipocurve(nob, icu, 1, 1);
}
else
- posttrans_icu_clean(icu);
+ posttrans_fcurve_clean(fcu);
}
}
@@ -3810,6 +3778,7 @@ void special_aftertrans_update(TransInfo *t)
/* fix up the Ipocurves and redraw stuff */
Key *key= (Key *)ac.data;
+#if 0 // XXX old animation system
if (key->ipo) {
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
@@ -3817,6 +3786,7 @@ void special_aftertrans_update(TransInfo *t)
posttrans_ipo_clean(key->ipo);
}
}
+#endif // XXX old animation system
DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
}
@@ -4206,12 +4176,14 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_IPO) {
t->flag |= T_POINTS|T_2D_EDIT;
- createTransIpoData(C, t);
+ createTransIpoData(C, t);
+#if 0
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
+#endif
}
else if(t->spacetype == SPACE_NODE) {
t->flag |= T_2D_EDIT|T_POINTS;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index c7e9c06813c..08c4a2ff820 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -63,9 +63,6 @@
//#include "BIF_meshtools.h"
#include "BIF_retopo.h"
-//#include "BSE_editipo.h"
-//#include "BSE_editipo_types.h"
-
#include "BKE_action.h"
#include "BKE_anim.h"
#include "BKE_armature.h"
@@ -76,7 +73,6 @@
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_group.h"
-#include "BKE_ipo.h"
#include "BKE_lattice.h"
#include "BKE_key.h"
#include "BKE_mesh.h"
@@ -585,6 +581,7 @@ void recalcData(TransInfo *t)
if(base->flag & BA_HAS_RECALC_DATA)
ob->recalc |= OB_RECALC_DATA;
+#if 0 // XXX old animation system
/* thanks to ob->ctime usage, ipos are not called in where_is_object,
unless we edit ipokeys */
if(base->flag & BA_DO_IPO) {
@@ -600,6 +597,7 @@ void recalcData(TransInfo *t)
}
}
}
+#endif // XXX old animation system
/* proxy exception */
if(ob->proxy)
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
new file mode 100644
index 00000000000..71c71f905a2
--- /dev/null
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -0,0 +1,587 @@
+/* Testing code for new animation system in 2.5
+ * Copyright 2009, Joshua Leung
+ */
+
+#ifndef DNA_ANIM_TYPES_H
+#define DNA_ANIM_TYPES_H
+
+#include "DNA_ID.h"
+#include "DNA_listBase.h"
+#include "DNA_curve_types.h"
+
+/* ************************************************ */
+/* F-Curve DataTypes */
+
+/* Modifiers -------------------------------------- */
+
+/* F-Curve Modifiers (fcm)
+ *
+ * These alter the way F-Curves behave, by altering the value that is returned
+ * when evaluating the curve's data at some time (t).
+ */
+typedef struct FModifier {
+ struct FModifier *next, *prev;
+
+ void *data; /* pointer to modifier data */
+
+ char name[64]; /* user-defined description for the modifier */
+ short type; /* type of f-curve modifier */
+ short flag; /* settings for the modifier */
+
+ float influence; /* the amount that the modifier should influence the value */
+} FModifier;
+
+/* Types of F-Curve modifier
+ * WARNING: order here is important!
+ */
+enum {
+ FMODIFIER_TYPE_NULL = 0,
+ FMODIFIER_TYPE_GENERATOR,
+ FMODIFIER_TYPE_ENVELOPE,
+ FMODIFIER_TYPE_CYCLES,
+ FMODIFIER_TYPE_NOISE, /* unimplemented - generate variations using some basic noise generator... */
+ FMODIFIER_TYPE_FILTER, /* unimplemented - for applying: fft, high/low pass filters, etc. */
+ FMODIFIER_TYPE_PYTHON,
+
+ /* NOTE: all new modifiers must be added above this line */
+ FMODIFIER_NUM_TYPES
+} eFModifier_Types;
+
+/* F-Curve Modifier Settings */
+enum {
+ /* modifier is not able to be evaluated for some reason, and should be skipped (internal) */
+ FMODIFIER_FLAG_DISABLED = (1<<0),
+ /* modifier's data is expanded (in UI) */
+ FMODIFIER_FLAG_EXPANDED = (1<<1),
+ /* modifier is active one (in UI) for editing purposes */
+ FMODIFIER_FLAG_ACTIVE = (1<<2),
+} eFModifier_Flags;
+
+/* --- */
+
+/* generator modifier data */
+typedef struct FMod_Generator {
+ /* generator based on PyExpression */
+ char expression[256]; /* python expression to use as generator */
+
+ /* simple polynomial generator (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... C[n]) */
+ float *poly_coefficients; /* array of the coefficients for the polynomial (poly_order + 1 items long) */
+ unsigned int poly_order; /* order of the polynomial (i.e. 1 for linear, 2 for quadratic) */
+
+ /* settings */
+ short flag; /* settings */
+ short mode; /* which 'generator' to use */
+} FMod_Generator;
+
+/* generator modes */
+enum {
+ FCM_GENERATOR_POLYNOMIAL = 0,
+ FCM_GENERATOR_EXPRESSION,
+} eFMod_Generator_Modes;
+
+
+/* envelope modifier - envelope data */
+typedef struct FCM_EnvelopeData {
+ float min, max; /* min/max values for envelope at this point (absolute values) */
+ float time; /* time for that this sample-point occurs */
+
+ short f1; /* settings for 'min' control point */
+ short f2; /* settings for 'max' control point */
+} FCM_EnvelopeData;
+
+/* envelope-like adjustment to values (for fade in/out) */
+typedef struct FMod_Envelope {
+ FCM_EnvelopeData *data; /* data-points defining envelope to apply (array) */
+ int totvert; /* number of envelope points */
+
+ float midval; /* value that envelope's influence is centered around / based on */
+ float min, max; /* distances from 'middle-value' for 1:1 envelope influence */
+} FMod_Envelope;
+
+
+/* cycling/repetition modifier data */
+// TODO: we can only do complete cycles...
+typedef struct FMod_Cycles {
+ short before_mode; /* extrapolation mode to use before first keyframe */
+ short after_mode; /* extrapolation mode to use after last keyframe */
+ short before_cycles; /* number of 'cycles' before first keyframe to do */
+ short after_cycles; /* number of 'cycles' after last keyframe to do */
+} FMod_Cycles;
+
+/* cycling modes */
+enum {
+ FCM_EXTRAPOLATE_NONE = 0, /* don't do anything */
+ FCM_EXTRAPOLATE_CYCLIC, /* repeat keyframe range as-is */
+ FCM_EXTRAPOLATE_CYCLIC_OFFSET, /* repeat keyframe range, but with offset based on gradient between values */
+} eFMod_Cycling_Modes;
+
+
+/* Python-script modifier data */
+typedef struct FMod_Python {
+ struct Text *script; /* text buffer containing script to execute */
+ IDProperty *prop; /* ID-properties to provide 'custom' settings */
+} FMod_Python;
+
+/* Drivers -------------------------------------- */
+
+/* Channel Driver (i.e. Drivers / Expressions) (driver)
+ *
+ * Channel Drivers are part of the dependency system, and are executed in addition to
+ * normal user-defined animation. They take the animation result of some channel(s), and
+ * use that (optionally combined with its own F-Curve for modification of results) to define
+ * the value of some setting semi-procedurally.
+ *
+ * Drivers are stored as part of F-Curve data, so that the F-Curve's RNA-path settings (for storing
+ * what setting the driver will affect). The order in which they are stored defines the order that they're
+ * evaluated in. This order is set by the Depsgraph's sorting stuff.
+ */
+typedef struct ChannelDriver {
+ /* primary target */
+ ID *id; /* ID-block which owns the target */
+ char *rna_path; /* target channel to use as driver value */
+ int array_index; /* if applicable, the index of the RNA-array item to use as driver */
+
+ /* value cache (placed here for alignment reasons) */
+ float curval; /* result of previous evaluation, for subtraction from result under certain circumstances */
+
+ /* secondary target (for rotational difference) */
+ ID *id2; /* ID-block which owns the second target */
+ char *rna_path2; /* second target channel to use as driver value */
+ int array_index2; /* if applicable, the index of the RNA-array item to use as driver */
+
+ /* general settings (placed here for alignment reasons) */
+ int type; /* type of driver */
+ int flag; /* settings of driver */
+
+ float influence; /* influence of driver on result */ // XXX to be implemented... this is like the constraint influence setting
+
+ /* settings for Python Drivers (PyDrivers) */
+ char expression[256]; /* python expression to execute (may call functions defined in an accessory file) */
+} ChannelDriver;
+
+/* driver type */
+enum {
+ /* channel drives channel */
+ DRIVER_TYPE_CHANNEL = 0,
+ /* py-expression used as driver */
+ DRIVER_TYPE_PYTHON,
+ /* rotational difference (must use rotation channels only) */
+ DRIVER_TYPE_ROTDIFF,
+} eDriver_Types;
+
+/* driver flags */
+enum {
+ /* driver has invalid settings (internal flag) */
+ DRIVER_FLAG_INVALID = (1<<0),
+ /* driver was disabled temporarily, so shouldn't be evaluated (set by user) */
+ DRIVER_FLAG_DISABLED = (1<<1),
+ /* driver needs recalculation (set by depsgraph) */
+ DRIVER_FLAG_RECALC = (1<<2),
+ /* driver does replace value, but overrides (for layering of animation over driver) */
+ // TODO: is this necessary?
+ DRIVER_FLAG_LAYERING = (1<<3),
+} eDriver_Flags;
+
+/* F-Curves -------------------------------------- */
+
+/* FPoint (fpt)
+ *
+ * This is the bare-minimum data required storing motion samples. Should be more efficient
+ * than using BPoints, which contain a lot of other unnecessary data...
+ */
+typedef struct FPoint {
+ float vec[2]; /* time + value */
+ int flag; /* selection info */
+ int pad;
+} FPoint;
+
+/* 'Function-Curve' - defines values over time for a given setting (fcu) */
+typedef struct FCurve {
+ struct FCurve *next, *prev;
+
+ /* driver settings */
+ ChannelDriver *driver; /* only valid for drivers (i.e. stored in AnimData not Actions) */
+ /* evaluation settings */
+ ListBase modifiers; /* FCurve Modifiers */
+
+ /* motion data */
+ BezTriple *bezt; /* user-editable keyframes (array) */
+ FPoint *fpt; /* 'baked/imported' motion samples (array) */
+ int totvert; /* total number of points which define the curve (i.e. size of arrays in FPoints) */
+
+ /* value cache + settings */
+ float curval; /* value stored from last time curve was evaluated */
+ short flag; /* user-editable settings for this curve */
+ short extend; /* value-extending mode for this curve (does not cover */
+
+ /* RNA - data link */
+ int array_index; /* if applicable, the index of the RNA-array item to get */
+ char *rna_path; /* RNA-path to resolve data-access */
+} FCurve;
+
+
+/* user-editable flags/settings */
+enum {
+ /* curve/keyframes are visible in editor */
+ FCURVE_VISIBLE = (1<<0),
+ /* curve is selected for editing */
+ FCURVE_SELECTED = (1<<1),
+ /* curve is active one */
+ FCURVE_ACTIVE = (1<<2),
+ /* keyframes (beztriples) cannot be edited */
+ FCURVE_PROTECTED = (1<<3),
+ /* fcurve will not be evaluated for the next round */
+ FCURVE_MUTED = (1<<4),
+ /* fcurve uses 'auto-handles', which stay horizontal... */
+ FCURVE_AUTO_HANDLES = (1<<5),
+
+ /* skip evaluation, as RNA-path cannot be resolved (similar to muting, but cannot be set by user) */
+ FCURVE_DISABLED = (1<<10),
+ /* curve can only have whole-number values (int or boolean types) */
+ FCURVE_INT_VALUES = (1<<11),
+} eFCurve_Flags;
+
+/* extrapolation modes (only simple value 'extending') */
+enum {
+ FCURVE_EXTRAPOLATE_CONSTANT = 0, /* just extend min/max keyframe value */
+ FCURVE_EXTRAPOLATE_LINEAR, /* just extend gradient of segment between first segment keyframes */
+} eFCurve_Extend;
+
+/* interpolation modes (used only for BezTriple->ipo) */
+// TODO: move this to curve-types file?
+enum {
+ BEZT_IPO_CONST = 0, /* constant interpolation */
+ BEZT_IPO_LIN, /* linear interpolation */
+ BEZT_IPO_BEZ, /* bezier interpolation */
+} eBezTriple_Interpolation;
+
+/* ************************************************ */
+/* 'Action' Datatypes */
+
+/* Groups -------------------------------------- */
+
+#if 0
+
+/* Action-Channel Group (agrp)
+
+ * These are stored as a list per-Action, and are only used to
+ * group that Action's channels in an Animation Editor.
+ *
+ * Even though all FCurves live in a big list per Action, each group they are in also
+ * holds references to the achans within that list which belong to it. Care must be taken to
+ * ensure that action-groups never end up being the sole 'owner' of a channel.
+ *
+ * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used
+ * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related
+ * to Action-Groups.
+ */
+typedef struct bActionGroup {
+ struct ActionGroup *next, *prev;
+
+ ListBase channels; /* Note: this must not be touched by standard listbase functions which would clear links to other channels */
+
+ int flag; /* settings for this action-group */
+ int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */
+ char name[64]; /* name of the group */
+
+ ThemeWireColor cs; /* color set to use when customCol == -1 */
+} bActionGroup;
+
+/* Action Group flags */
+enum {
+ AGRP_SELECTED = (1<<0),
+ AGRP_ACTIVE = (1<<1),
+ AGRP_PROTECTED = (1<<2),
+ AGRP_EXPANDED = (1<<3),
+
+ AGRP_TEMP = (1<<30),
+ AGRP_MOVED = (1<<31)
+} eActionGroup_Flag;
+
+#endif
+
+/* Actions -------------------------------------- */
+
+/* Action - reusable F-Curve 'bag' (act)
+ *
+ * This contains F-Curves that may affect settings from more than one ID blocktype and/or
+ * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
+ * but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to
+ * by the source ID block).
+ *
+ * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
+ * affects a group of related settings (as defined by the user).
+ */
+// XXX use this as drop-in replacement at some point...
+typedef struct nAction {
+ ID id; /* ID-serialisation for relinking */
+
+ ListBase curves; /* function-curves (FCurve) */
+ ListBase chanbase; /* legacy data - Action Channels (bActionChannel) in pre-2.5 animation system */
+ ListBase groups; /* groups of function-curves (bActionGroup) */
+ ListBase markers; /* markers local to the Action (used to provide Pose-Libraries) */
+
+ int flag; /* settings for this action */
+ int active_marker; /* index of the active marker */
+} nAction;
+
+
+/* Flags for the action */
+enum {
+ /* flags for displaying in UI */
+ ACT_EXPANDED = (1<<0),
+ ACT_SELECTED = (1<<1),
+
+ /* flags for evaluation/editing */
+ ACT_MUTED = (1<<9),
+ ACT_PROTECTED = (1<<10),
+} eAction_Flags;
+
+/* ************************************************ */
+/* Animation Reuse - i.e. users of Actions */
+
+/* Retargetting ----------------------------------- */
+
+/* Retargetting Pair
+ *
+ * Defines what parts of the paths should be remapped from 'abc' to 'xyz'.
+ * TODO:
+ * - Regrex (possibly provided through PY, though having our own module might be faster)
+ * would be important to have at some point. Current replacements are just simple
+ * string matches...
+ */
+typedef struct AnimMapPair {
+ char from[128]; /* part of path to bed replaced */
+ char to[128]; /* part of path to replace with */
+} AnimMapPair;
+
+/* Retargetting Information for Actions
+ *
+ * This should only be used if it is strictly necessary (i.e. user will need to explictly
+ * add this when they find that some channels do not match, or motion is not going to right
+ * places). When executing an action, this will be checked to see if it provides any useful
+ * remaps for the given paths.
+ *
+ * NOTE: we currently don't store this in the Action itself, as that causes too many problems.
+ */
+// FIXME: will this be too clumsy or slow? If we're using RNA paths anyway, we'll have to accept
+// such consequences...
+typedef struct AnimMapper {
+ struct AnimMapper *next, *prev;
+
+ nAction *target; /* target action */
+ ListBase mappings; /* remapping table (bAnimMapPair) */
+} AnimMapper;
+
+/* ************************************************ */
+/* NLA - Non-Linear Animation */
+// TODO: the concepts here still need to be refined to solve any unresolved items
+
+/* NLA Modifiers ---------------------------------- */
+
+/* These differ from F-Curve modifiers, as although F-Curve modifiers also operate on a
+ * per-channel basis too (in general), they are part of the animation data itself, which
+ * means that their effects are inherited by all of their users. In order to counteract this,
+ * the modifiers here should be used to provide variation to pre-created motions only.
+ */
+
+/* NLA Strips ------------------------------------- */
+
+/* NLA Strip (strip)
+ *
+ * A NLA Strip is a container for the reuse of Action data, defining parameters
+ * to control the remapping of the Action data to some destination. Actions being
+ * referenced by NLA-Strips SHOULD-NOT be editable, unless they were created in such
+ * a way that results in very little mapping distortion (i.e. for layered animation only,
+ * opposed to prebuilt 'blocks' which are quickly dumped into the NLA for crappymatic machima-type
+ * stuff)
+ */
+typedef struct NlaStrip {
+ struct NlaStrip *next, *prev;
+
+ nAction *act; /* Action that is referenced by this strip */
+ AnimMapper *remap; /* Remapping info this strip (for tweaking correspondance of action with context) */
+
+ ListBase modifiers; /* NLA Modifiers */
+
+ ListBase fcurves; /* F-Curves for controlling this strip's influence and timing */
+ float influence; /* Influence of strip */
+ float act_time; /* Current 'time' within action being used */
+
+ float start, end; /* extents of the strip */
+ float actstart, actend; /* range of the action to use */
+
+ float repeat; /* The number of times to repeat the action range (only when no F-Curves) */
+ float scale; /* The amount the action range is scaled by (only when no F-Curves) */
+
+ float blendin, blendout; /* strip blending length (only used when there are no F-Curves) */
+ int blendmode; /* strip blending mode */
+
+ int flag; /* settings */
+
+ // umm... old unused cruft?
+ int stride_axis; /* axis for stridebone stuff - 0=x, 1=y, 2=z */
+ int pad;
+
+ float actoffs; /* Offset within action, for cycles and striding (only set for ACT_USESTRIDE) */
+ float stridelen; /* The stridelength (considered when flag & ACT_USESTRIDE) */
+
+ char stridechannel[32]; /* Instead of stridelen, it uses an action channel */
+ char offs_bone[32]; /* if repeat, use this bone/channel for defining offset */
+} NlaStrip;
+
+/* NLA Strip Blending Mode */
+enum {
+ NLASTRIPMODE_BLEND = 0,
+ NLASTRIPMODE_ADD,
+ NLASTRIPMODE_SUBTRACT,
+} eActStrip_Mode;
+
+/* NLA Strip Settings */
+// TODO: check on which of these are still useful...
+enum {
+ NLASTRIP_SELECT = (1<<0),
+ NLASTRIP_USESTRIDE = (1<<1),
+ NLASTRIP_BLENDTONEXT = (1<<2), /* Not implemented. Is not used anywhere */
+ NLASTRIP_HOLDLASTFRAME = (1<<3),
+ NLASTRIP_ACTIVE = (1<<4),
+ NLASTRIP_LOCK_ACTION = (1<<5),
+ NLASTRIP_MUTE = (1<<6),
+ NLASTRIP_REVERSE = (1<<7), /* This has yet to be implemented. To indicate that a strip should be played backwards */
+ NLASTRIP_CYCLIC_USEX = (1<<8),
+ NLASTRIP_CYCLIC_USEY = (1<<9),
+ NLASTRIP_CYCLIC_USEZ = (1<<10),
+ NLASTRIP_AUTO_BLENDS = (1<<11),
+ NLASTRIP_TWEAK = (1<<12), /* This strip is a tweaking strip (only set if owner track is a tweak track) */
+} eActionStrip_Flag;
+
+/* NLA Tracks ------------------------------------- */
+
+/* NLA Track (nlt)
+ *
+ * A track groups a bunch of 'strips', which should form a continous set of
+ * motion, on top of which other such groups can be layered. This should allow
+ * for animators to work in a non-destructive manner, layering tweaks, etc. over
+ * 'rough' blocks of their work.
+ */
+typedef struct NlaTrack {
+ struct NlaTrack *next, *prev;
+
+ ListBase strips; /* bActionStrips in this track */
+
+ int flag; /* settings for this track */
+ int index; /* index of the track in the stack (NOTE: not really useful, but we need a pad var anyways!) */
+
+ char info[64]; /* short user-description of this track */
+} NlaTrack;
+
+/* settings for track */
+enum {
+ /* track is the one that settings can be modified on (doesn't indicate
+ * that it's for 'tweaking' though)
+ */
+ NLATRACK_ACTIVE = (1<<0),
+ /* track is selected in UI for relevant editing operations */
+ NLATRACK_SELECTED = (1<<1),
+ /* track is not evaluated */
+ NLATRACK_MUTED = (1<<2),
+ /* track is the only one evaluated (must be used in conjunction with adt->flag) */
+ NLATRACK_SOLO = (1<<3),
+ /* track's settings (and strips) cannot be edited (to guard against unwanted changes) */
+ NLATRACK_PROTECTED = (1<<4),
+ /* strip is the 'last' one that should be evaluated, as the active action
+ * is being used to tweak the animation of the strips up to here
+ */
+ NLATRACK_TWEAK = (1<<5),
+} eNlaTrack_Flag;
+
+/* ************************************************ */
+/* Animation Data */
+
+/* AnimOverride ------------------------------------- */
+
+/* Animation Override (aor)
+ *
+ * This is used to as temporary storage of values which have been changed by the user, but not
+ * yet keyframed (thus, would get overwritten by the animation system before the user had a chance
+ * to see the changes that were made).
+ *
+ * It is probably not needed for overriding keyframed values in most cases, as those will only get evaluated
+ * on frame-change now. That situation may change in future.
+ */
+typedef struct AnimOverride {
+ struct AnimOverride *next, *prev;
+
+ char *rna_path; /* RNA-path to use to resolve data-access */
+ int array_index; /* if applicable, the index of the RNA-array item to get */
+
+ float value; /* value to override setting with */
+} AnimOverride;
+
+/* AnimData ------------------------------------- */
+
+/* Animation data for some ID block (adt)
+ *
+ * This block of data is used to provide all of the necessary animation data for a datablock.
+ * Currently, this data will not be reusable, as there shouldn't be any need to do so.
+ *
+ * This information should be made available for most if not all ID-blocks, which should
+ * enable all of its settings to be animatable locally. Animation from 'higher-up' ID-AnimData
+ * blocks may override local settings.
+ *
+ * This datablock should be placed immediately after the ID block where it is used, so that
+ * the code which retrieves this data can do so in an easier manner. See blenkernel/internal/anim_sys.c for details.
+ */
+typedef struct AnimData {
+ /* active action - acts as the 'tweaking track' for the NLA */
+ nAction *action;
+ /* remapping-info for active action - should only be used if needed
+ * (for 'foreign' actions that aren't working correctly)
+ */
+ AnimMapper *remap;
+
+ /* nla-tracks */
+ ListBase nla_tracks;
+
+ /* 'drivers' for this ID-block's settings - FCurves, but are completely
+ * separate from those for animation data
+ */
+ ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */
+ ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */
+
+ /* settings for animation evaluation */
+ int flag; /* user-defined settings */
+ int recalc; /* depsgraph recalculation flags */
+} AnimData;
+
+/* Animation Data settings (mostly for NLA) */
+enum {
+ /* only evaluate a single track in the NLA */
+ ADT_NLA_SOLO_TRACK = (1<<0),
+ /* don't use NLA */
+ ADT_NLA_EVAL_OFF = (1<<1),
+ /* don't execute drivers */
+ ADT_DRIVERS_DISABLED = (1<<2),
+} eAnimData_Flag;
+
+/* Animation Data recalculation settings (to be set by depsgraph) */
+enum {
+ ADT_RECALC_DRIVERS = (1<<0),
+ ADT_RECALC_ANIM = (1<<1),
+ ADT_RECALC_ALL = (ADT_RECALC_DRIVERS|ADT_RECALC_ANIM),
+} eAnimData_Recalc;
+
+/* Base Struct for Anim ------------------------------------- */
+
+/* Used for BKE_animdata_from_id()
+ * All ID-datablocks which have their own 'local' AnimData
+ * should have the same arrangement in their structs.
+ */
+typedef struct IdAdtTemplate {
+ ID id;
+ AnimData adt;
+} IdAdtTemplate;
+
+/* ************************************************ */
+
+#endif /* DNA_ANIM_TYPES_H */
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index cfca4523dd8..2e79d9c5a42 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -32,17 +32,20 @@
#define DNA_CAMERA_TYPES_H
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_scriptlink_types.h"
#ifdef __cplusplus
extern "C" {
#endif
-struct Ipo;
struct Object;
+struct AnimData;
+struct Ipo;
typedef struct Camera {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
short type, flag;
float passepartalpha, angle;
@@ -57,7 +60,7 @@ typedef struct Camera {
short YF_bkhtype, YF_bkhbias;
float YF_bkhrot;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
ScriptLink scriptlink;
struct Object *dof_ob;
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index 6d928646b3d..58c26f06e4c 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -28,6 +28,17 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+
+/* ==============================================
+ * ATTENTION:
+ *
+ * The contents of this file are now officially depreceated. They were used for the 'old' animation system,
+ * which has (as of 2.50) been replaced with a completely new system by Joshua Leung (aligorith). All defines,
+ * etc. are only still maintained to provide backwards compatability for old files...
+ *
+ * =============================================
+ */
+
#ifndef DNA_IPO_TYPES_H
#define DNA_IPO_TYPES_H
diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h
index 13379c44a89..4487c0c3247 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -33,6 +33,7 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
struct Ipo;
@@ -56,6 +57,7 @@ typedef struct KeyBlock {
typedef struct Key {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
KeyBlock *refkey;
char elemstr[32];
@@ -63,7 +65,7 @@ typedef struct Key {
float curval;
ListBase block;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
ID *from;
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index c544be7e388..cfedb9cc0ac 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -32,6 +32,7 @@
#define DNA_LAMP_TYPES_H
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_scriptlink_types.h"
#ifndef MAX_MTEX
@@ -39,11 +40,12 @@
#endif
struct MTex;
-struct Ipo;
struct CurveMapping;
+struct Ipo;
typedef struct Lamp {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
short type, flag;
int mode;
@@ -103,7 +105,7 @@ typedef struct Lamp {
short YF_glowtype, YF_pad2;
struct MTex *mtex[18]; /* MAX_MTEX */
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
/* preview */
struct PreviewImage *preview;
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index d3c294a3d36..655d10a5310 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -32,6 +32,7 @@
#define DNA_MATERIAL_TYPES_H
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_scriptlink_types.h"
#include "DNA_listBase.h"
@@ -40,15 +41,16 @@
#endif
struct MTex;
-struct Ipo;
struct ColorBand;
struct Group;
struct bNodeTree;
+struct Ipo;
/* WATCH IT: change type? also make changes in ipo.h */
typedef struct Material {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
short colormodel, flag;
/* note, keep this below synced with render_types.h */
@@ -113,7 +115,7 @@ typedef struct Material {
struct MTex *mtex[18]; /* MAX_MTEX */
struct bNodeTree *nodetree;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
struct Group *group; /* light group */
struct PreviewImage * preview;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 7deea1899d1..69291c1e025 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -35,6 +35,7 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_scriptlink_types.h"
#ifdef __cplusplus
@@ -90,7 +91,8 @@ typedef struct BoundBox {
typedef struct Object {
ID id;
-
+ AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
+
short type, partype;
int par1, par2, par3; /* can be vertexnrs */
char parsubstr[32]; /* String describing subobject info */
@@ -98,15 +100,15 @@ typedef struct Object {
/* if ob->proxy (or proxy_group), this object is proxy for object ob->proxy */
/* proxy_from is set in target back to the proxy. */
struct Object *proxy, *proxy_group, *proxy_from;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
struct Path *path;
struct BoundBox *bb;
- struct bAction *action;
+ struct bAction *action; // XXX depreceated... old animation system
struct bAction *poselib;
struct bPose *pose;
void *data;
- ListBase constraintChannels;
+ ListBase constraintChannels; // XXX depreceated... old animation system
ListBase effect;
ListBase disp;
ListBase defbase;
@@ -129,15 +131,15 @@ typedef struct Object {
short flag; /* copy of Base */
short colbits; /* when zero, from obdata */
- short transflag, ipoflag; /* transformation and ipo settings */
+ short transflag, protectflag; /* transformation settings and transform locks */
short trackflag, upflag;
- short nlaflag, protectflag; /* nlaflag defines NLA override, protectflag is bits to lock transform */
+ short nlaflag, ipoflag; // xxx depreceated... old animation system
short ipowin, scaflag; /* ipowin: blocktype last ipowindow */
short scavisflag, boundtype;
int dupon, dupoff, dupsta, dupend;
- float sf, ctime; /* sf is time-offset, ctime is the objects current time */
+ float sf, ctime; /* sf is time-offset, ctime is the objects current time (XXX timing needs to be revised) */
/* during realtime */
@@ -200,7 +202,7 @@ typedef struct Object {
float anisotropicFriction[3];
ListBase constraints;
- ListBase nlastrips;
+ ListBase nlastrips; // XXX depreceated... old animation system
ListBase hooks;
ListBase particlesystem; /* particle systems */
@@ -302,6 +304,7 @@ extern Object workob;
#define OB_RENDER_DUPLI 4096
/* (short) ipoflag */
+ // XXX depreceated - old animation system crap
#define OB_DRAWKEY 1
#define OB_DRAWKEYSEL 2
#define OB_OFFS_OB 4
@@ -472,6 +475,7 @@ extern Object workob;
#define OB_SHAPE_TEMPLOCK 2
/* ob->nlaflag */
+ // XXX depreceated - old animation system
#define OB_NLA_OVERRIDE (1<<0)
#define OB_NLA_COLLAPSED (1<<1)
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 759a0f7a452..f9359ac61fa 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -38,6 +38,7 @@ extern "C" {
#include "DNA_listBase.h"
#include "DNA_scriptlink_types.h"
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
struct Radio;
struct Object;
@@ -523,6 +524,8 @@ typedef struct bStats {
typedef struct Scene {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
+
struct Object *camera;
struct World *world;
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 6e07336a4b1..c8cfc31cc3e 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -32,6 +32,7 @@
#define DNA_TEXTURE_TYPES_H
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_image_types.h"
struct Ipo;
@@ -129,6 +130,7 @@ typedef struct EnvMap {
typedef struct Tex {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
float noisesize, turbul;
float bright, contrast, rfac, gfac, bfac;
@@ -167,7 +169,7 @@ typedef struct Tex {
struct ImageUser iuser;
struct bNodeTree *nodetree;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
struct Image *ima;
struct PluginTex *plugin;
struct ColorBand *coba;
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index ab7e25190ad..14947ec3b2d 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -32,6 +32,7 @@
#define DNA_WORLD_TYPES_H
#include "DNA_ID.h"
+#include "DNA_anim_types.h"
#include "DNA_scriptlink_types.h"
struct Ipo;
@@ -48,6 +49,7 @@ struct MTex;
* data and modeling data. */
typedef struct World {
ID id;
+ struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */
short colormodel, totex;
short texact, mistype;
@@ -107,7 +109,7 @@ typedef struct World {
float *aosphere, *aotables;
- struct Ipo *ipo;
+ struct Ipo *ipo; // XXX depreceated... old animation system
struct MTex *mtex[18]; /* MAX_MTEX */
/* previews */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index dd5aa518e24..17547c4eb1d 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -132,6 +132,7 @@ char *includefiles[] = {
// if you add files here, please add them at the end
// of makesdna.c (this file) as well
"DNA_windowmanager_types.h",
+ "DNA_anim_types.h",
// empty string to indicate end of includefiles
""
@@ -1153,4 +1154,5 @@ int main(int argc, char ** argv)
#include "DNA_cloth_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_windowmanager_types.h"
+#include "DNA_anim_types.h"
/* end of list */
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 4de6c770cdc..6afc0ac472f 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1520,10 +1520,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(part->bb_ob)
bb_ob=part->bb_ob;
+#if 0 // XXX old animation system
if(ma->ipo){
calc_ipo(ma->ipo, cfra);
execute_ipo((ID *)ma, ma->ipo);
}
+#endif // XXX old animation system
RE_set_customdata_names(obr, &psmd->dm->faceData);
totuv=CustomData_number_of_layers(&psmd->dm->faceData,CD_MTFACE);
@@ -1563,10 +1565,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
}
}
+#if 0 // XXX old animation system
if(part->flag&PART_ABS_TIME && part->ipo){
calc_ipo(part->ipo, cfra);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
if(part->flag&PART_GLOB_TIME)
cfra=bsystem_time(re->scene, 0, (float)re->scene->r.cfra, 0.0);
@@ -1684,6 +1688,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
pa_time=(cfra-pa->time)/pa->lifetime;
if((part->flag&PART_ABS_TIME)==0){
+#if 0 // XXX old animation system
if(ma->ipo){
/* correction for lifetime */
calc_ipo(ma->ipo, 100.0f*pa_time);
@@ -1694,6 +1699,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
calc_ipo(part->ipo, 100.0f*pa_time);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
}
hasize = ma->hasize;
@@ -1758,6 +1764,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
pa_time=psys_get_child_time(psys, cpa, cfra);
if((part->flag&PART_ABS_TIME)==0){
+#if 0 // XXX old animation system
if(ma->ipo){
/* correction for lifetime */
calc_ipo(ma->ipo, 100.0f*pa_time);
@@ -1768,6 +1775,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
calc_ipo(part->ipo, 100.0f*pa_time);
execute_ipo((ID *)part, part->ipo);
}
+#endif // XXX old animation system
}
pa_size=psys_get_child_size(psys, cpa, cfra, &pa_time);
@@ -2021,8 +2029,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset);
/* 4. clean up */
+#if 0 // XXX old animation system
if(ma) do_mat_ipo(re->scene, ma);
-
+#endif // XXX old animation system
+
if(orco1)
MEM_freeN(orco);
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index eb1e80948f6..a0185a64659 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -458,10 +458,12 @@ void RE_SetCamera(Render *re, Object *camera)
* Need to update the camera early because it's used for projection matrices
* and other stuff BEFORE the animation update loop is done
* */
+#if 0 // XXX old animation system
if(cam->ipo) {
calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra));
execute_ipo(&cam->id, cam->ipo);
}
+#endif // XXX old animation system
lens= cam->lens;
shiftx=cam->shiftx;
shifty=cam->shifty;
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index 19973e972d2..afe732d885b 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -93,7 +93,7 @@ void init_render_texture(Render *re, Tex *tex)
if(tex->type==TEX_PLUGIN) {
if(tex->plugin && tex->plugin->doit) {
if(tex->plugin->cfra) {
- *(tex->plugin->cfra)= frame_to_float(re->scene, cfra);
+ *(tex->plugin->cfra)= (float)cfra; //frame_to_float(re->scene, cfra); // XXX old animsys - timing stuff to be fixed
}
}
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index f9f73e8d31d..4afe8fb806e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -49,7 +49,8 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
-#include "DNA_ipo_types.h"
+#include "DNA_anim_types.h"
+#include "DNA_ipo_types.h" // XXX old animation system
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@@ -334,7 +335,7 @@ static void init_userdef_themes(void)
U.gp_euclideandist= 2;
/* adjust default interpolation for new IPO-curves */
- U.ipo_new= IPO_BEZ;
+ U.ipo_new= BEZT_IPO_BEZ;
}
/* GL Texture Garbage Collection (variable abused above!) */