[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12953] branches/animsys-aligorith/source/ blender: == AnimSys Branch - Restoring action evaluation + other fixes ==
Joshua Leung
aligorith at gmail.com
Thu Dec 20 10:15:43 CET 2007
Revision: 12953
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12953
Author: aligorith
Date: 2007-12-20 10:15:43 +0100 (Thu, 20 Dec 2007)
Log Message:
-----------
== AnimSys Branch - Restoring action evaluation + other fixes ==
* Coded new methods to evaluate non-nla animations. Each animdata block has a driver action and a normal action, in addition to its NLA data. Drivers cannot exist in normal actions, and normal actions cannot contain drivers. The do_action and do_driver_action functions are used to execute these in practically the same way
* Fixed up some typos which were preventing compiling. Having said that.
Despite these changes, there's still quite a bit of work to do before the whole branch can compile nicely...
Modified Paths:
--------------
branches/animsys-aligorith/source/blender/blenkernel/BKE_action.h
branches/animsys-aligorith/source/blender/blenkernel/BKE_ipo.h
branches/animsys-aligorith/source/blender/blenkernel/BKE_nla.h
branches/animsys-aligorith/source/blender/blenkernel/intern/action.c
branches/animsys-aligorith/source/blender/blenkernel/intern/ipo.c
branches/animsys-aligorith/source/blender/blenkernel/intern/keyabletypes.c
branches/animsys-aligorith/source/blender/blenkernel/intern/keyingsets.c
branches/animsys-aligorith/source/blender/blenkernel/intern/nla.c
branches/animsys-aligorith/source/blender/makesdna/DNA_animdata_types.h
branches/animsys-aligorith/source/blender/makesdna/DNA_constraint_types.h
branches/animsys-aligorith/source/blender/makesdna/DNA_ipo_types.h
branches/animsys-aligorith/source/blender/makesdna/DNA_nla_types.h
branches/animsys-aligorith/source/blender/makesdna/intern/_sdna2kt_extras.py
branches/animsys-aligorith/source/blender/src/keyframing.c
Modified: branches/animsys-aligorith/source/blender/blenkernel/BKE_action.h
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/BKE_action.h 2007-12-19 23:29:42 UTC (rev 12952)
+++ branches/animsys-aligorith/source/blender/blenkernel/BKE_action.h 2007-12-20 09:15:43 UTC (rev 12953)
@@ -145,6 +145,10 @@
/* map strip time to global time (frame nr) */
float get_action_frame_inv(struct bAnimData *adt, float cframe);
+/* action execution */
+void do_action(struct bAnimData *adt, void *data, struct bAction *act, float ctime);
+void do_driver_action(struct bAnimData *adt, void *data, float ctime);
+
#ifdef __cplusplus
};
#endif
Modified: branches/animsys-aligorith/source/blender/blenkernel/BKE_ipo.h
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/BKE_ipo.h 2007-12-19 23:29:42 UTC (rev 12952)
+++ branches/animsys-aligorith/source/blender/blenkernel/BKE_ipo.h 2007-12-20 09:15:43 UTC (rev 12953)
@@ -132,10 +132,10 @@
/* ------------- Keying-Set Tools -------------------- */
void free_keyingset(struct bKeyingSet *ks);
-struct bKeyingSet *make_new_keyingset(char name[]);
+struct bKeyingSet *make_new_keyingset(char name[], int blocktype);
void keyingset_add_kt(struct bKeyingSet *ks, struct bKeyableType *kt);
-void keyingset_default_getdata(struct bKeyingSet *ks, int blocktype);
+void keyingset_default_getdata(struct bKeyingSet *ks);
void keyingset_default_freedata(struct bKeyingSet *ks);
void keyingsets_blocktype_default(struct ListBase *list, int blocktype);
@@ -153,7 +153,6 @@
/* ------------- IPO - Execution ------------------ */
void apply_anim_ipo(struct Ipo *ipo, void *destination);
-void apply_driven_ipo(struct Ipo *ipo, void *destination, float ctime);
void apply_poseanim_ipo(struct bActionChannel *achan, struct bPoseChannel *pchan);
/* ------------- Old-Cruft Function Prototypes ---------- */
Modified: branches/animsys-aligorith/source/blender/blenkernel/BKE_nla.h
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/BKE_nla.h 2007-12-19 23:29:42 UTC (rev 12952)
+++ branches/animsys-aligorith/source/blender/blenkernel/BKE_nla.h 2007-12-20 09:15:43 UTC (rev 12953)
@@ -36,12 +36,17 @@
struct bAnimData;
struct bNlaTrack;
struct bActionStrip;
+struct ListBase;
-void free_nlastrip (struct bActionStrip *strip)
-void free_nlatrack(struct bNlaTrack *nlt)
+void free_nlastrip(struct bActionStrip *strip);
+void free_nlatrack(struct bNlaTrack *nlt);
void free_animdata(struct bAnimData *adt);
struct bAnimData *add_animdata(char name[], int blocktype);
+void copy_nlastrips(struct ListBase *src, struct ListBase *dst);
+short adt_has_nladata(struct bAnimData *adt);
+struct bActionStrip *adt_get_active_strip(struct bAnimData *adt);
+
void do_nla(struct bAnimData *adt, void *data, float ctime);
void do_animdata(struct bAnimData *adt, void *data, float ctime);
Modified: branches/animsys-aligorith/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/intern/action.c 2007-12-19 23:29:42 UTC (rev 12952)
+++ branches/animsys-aligorith/source/blender/blenkernel/intern/action.c 2007-12-20 09:15:43 UTC (rev 12953)
@@ -45,6 +45,7 @@
#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_nla_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -61,6 +62,7 @@
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
@@ -415,26 +417,6 @@
/* ************** time ****************** */
-static bActionStrip *get_active_strip (bAnimData *adt)
-{
- bNlaTrack *nlt;
- bActionStrip *strip= NULL;
-
- if (adt->act==NULL)
- return NULL;
-
- for (nlt=adt->nlatracks.first; nlt; nlt=nlt->next) {
- for (strip=nlt->strips.first; strip; strip=strip->next) {
- if (strip->flag & ACTSTRIP_ACTIVE)
- break;
- }
- }
-
- if (strip && strip->act == adt->act)
- return strip;
- return NULL;
-}
-
/* non clipped mapping of strip */
static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert)
{
@@ -457,21 +439,23 @@
/* if the conditions match, it converts current time to strip time */
float get_action_frame(bAnimData *adt, float cframe)
{
- bActionStrip *strip= get_active_strip(adt);
+ bActionStrip *strip= adt_get_active_strip(adt);
if (strip)
return get_actionstrip_frame(strip, cframe, 0);
- return cframe;
+ else
+ return cframe;
}
/* inverted, strip time to current time */
float get_action_frame_inv(bAnimData *adt, float cframe)
{
- bActionStrip *strip= get_active_strip(adt);
+ bActionStrip *strip= adt_get_active_strip(adt);
if (strip)
return get_actionstrip_frame(strip, cframe, 1);
- return cframe;
+ else
+ return cframe;
}
@@ -998,8 +982,7 @@
/* calculate the min/max */
for (icu=achan->ipo->curve.first; icu; icu=icu->next) {
- if (icu->totvert>1) {
-
+ if (icu->totvert > 1) {
if (strcmp(icu->kt.shortname, "LocX")==0)
index= 0;
else if(strcmp(icu->kt.shortname, "LocY")==0)
@@ -1008,13 +991,13 @@
index= 2;
else
continue;
-
+
foundvert= 1;
min[index]= icu->bezt[0].vec[1][1];
max[index]= icu->bezt[icu->totvert-1].vec[1][1];
}
}
- if(foundvert) {
+ if (foundvert) {
/* bring it into armature space */
VecSubf(min, max, min);
bone= get_named_bone(ob->data, strip->offs_bone); /* weak */
@@ -1060,8 +1043,9 @@
return NULL;
}
-/* ************** do the action ************ */
+/* ************** do the action - old nla code! ************ */
+#if 0
static void do_nla(Object *ob, int blocktype)
{
bPose *tpose= NULL;
@@ -1279,58 +1263,116 @@
if(chanbase.first)
BLI_freelistN(&chanbase);
}
+#endif
-void do_all_pose_actions(Object *ob)
+/* **************************** Action Execution ******************************************* */
+
+/* find the name to search for in action - note: name must not be longer than 32 chars! */
+static short adt_find_name (bAnimData *adt, void *data, char name[])
{
- /* only to have safe calls from editor */
- if(ob==NULL) 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) G.scene->r.cfra;
+ switch (adt->blocktype) {
+ /* these blocktypes directly refer to ID-blocks, and
+ * derive their names from id->name+2
+ */
+ case IPOB_OB:
+ case IPOB_MAT:
+ case IPOB_TEX:
+ case IPOB_CURVE:
+ case IPOB_WORLD:
+ case IPOB_LAMP:
+ case IPOB_CAM:
+ {
+ ID *id= (ID *)data;
+ BLI_strncpy(name, id->name+2, 32);
+ return 1;
+ }
+ break;
- cframe= get_action_frame(ob, cframe);
+ /* types with a name value - just use that */
+ case IPOB_CONS:
+ {
+ bConstraint *con= (bConstraint *)data;
+ BLI_strncpy(name, con->name, 32);
+ return 1;
+ }
+ break;
+ case IPOB_MOD:
+ {
+ ModifierData *md= (ModifierData *)data;
+ BLI_strncpy(name, md->name, 32);
+ return 1;
+ }
+ break;
- extract_pose_from_action (ob->pose, ob->action, bsystem_time(ob, cframe, 0.0));
+ /* FIXME!!! other types that are not that simple to identify */
}
- else if(ob->nlastrips.first) {
- do_nla(ob, ID_AR);
- }
- /* clear POSE_DO_UNLOCK flags that might have slipped through (just in case) */
- ob->pose->flag &= ~POSE_DO_UNLOCK;
+ return 0;
}
-/* called from where_is_object */
-void do_all_object_actions(Object *ob)
+/* used to execute actions (without regard to blending, etc.) */
+void do_action (bAnimData *adt, void *data, bAction *act, float ctime)
{
- if(ob==NULL) return;
- if(ob->dup_group) return; /* prevent conflicts, might add smarter check later */
+ bActionChannel *achan;
- /* 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) G.scene->r.cfra;
+ /* standard error checks */
+ if (ELEM3(NULL, adt, data, act))
+ return;
+
+ /* some blocktypes handle more than one action channel */
+ if (adt->blocktype == IPOB_POSE) {
+ /* each posechannel is an action channel */
+ Object *ob= (Object *)data;
+ bPoseChannel *pchan;
- cframe= get_action_frame(ob, cframe);
+ for (achan= act->chanbase.first; achan; achan= achan->next) {
+ /* check if appropriate blocktype */
+ if ((achan->ipo) && (achan->ipo->blocktype==IPOB_POSE)) {
+ /* find matching pose-channel */
+ pchan= get_pose_channel(ob->pose, achan->name);
+
+ /* calculate ipo */
+ calc_ipo(achan->ipo, ctime);
+
+ /* execute ipo */
+ apply_poseanim_ipo(achan, pchan);
+ }
+ }
+ }
+ else if (adt->blocktype == IPOB_KEY) {
+ // shapekeys... TODO...
+ }
+ else {
+ /* 'normal' blocktypes only need to worry about one */
+ char name[32];
- extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(ob, cframe, 0.0));
- if(key)
- extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(ob, cframe, 0.0));
-
- if(tchanbase.first) {
- execute_ipochannels(&tchanbase);
- BLI_freelistN(&tchanbase);
+ /* get name */
+ if (adt_find_name(adt, data, name)) {
+ /* get actionchannel */
+ achan= get_action_channel(act, name);
+
+ /* check if appropriate blocktype */
+ if ((achan->ipo) && (achan->ipo->blocktype==adt->blocktype)) {
+ /* calculate ipo */
+ calc_ipo(achan->ipo, ctime);
+
+ /* execute ipo */
+ apply_anim_ipo(achan->ipo, data);
+ }
}
}
- else if(ob->nlastrips.first) {
- do_nla(ob, ID_OB);
- }
+}
+
+/* call to calculate and execute animdata block's drivers */
+void do_driver_action (bAnimData *adt, void *data, float ctime)
+{
+ /* check if there's a driver action to execute */
+ if (ELEM3(NULL, adt, data, adt->drivers))
+ return;
+
+ /* execute action as if it were a normal one */
+ do_action(adt, data, adt->drivers, ctime);
}
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list