Revision: 18568
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18568
Author: aligorith
Date: 2009-01-19 03:26:46 +0100 (Mon, 19 Jan 2009)
Log Message:
-----------
2.5 - More work on getting file read/write support for Animato running
* Reorganised all animation-related file-writing code to be in the same area in
the code, and clearly marked which parts of code are only used to ensure we can
load old files to version-patch.
* Added file reading code for new datatypes, so it is possible to load the
quit.blend file saved from the previous session. Version patching to work with
the new system has yet to be done...
* Assorted whitespace fixes in places I skimmed through...
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
Modified:
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
2009-01-18 22:09:29 UTC (rev 18567)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
2009-01-19 02:26:46 UTC (rev 18568)
@@ -1718,8 +1718,45 @@
}
}
-/* ************ READ ARMATURE ***************** */
+/* ************ READ ANIMATION STUFF ***************** */
+/* Legacy Data Support (for Version Patching) ----------------------------- */
+
+// XXX depreceated - old animation system
+static void lib_link_ipo(FileData *fd, Main *main)
+{
+ Ipo *ipo;
+
+ ipo= main->ipo.first;
+ while(ipo) {
+ if(ipo->id.flag & LIB_NEEDLINK) {
+ IpoCurve *icu;
+ for(icu= ipo->curve.first; icu; icu= icu->next) {
+ if(icu->driver)
+ icu->driver->ob= newlibadr(fd,
ipo->id.lib, icu->driver->ob);
+ }
+ ipo->id.flag -= LIB_NEEDLINK;
+ }
+ ipo= ipo->id.next;
+ }
+}
+
+// XXX depreceated - old animation system
+static void direct_link_ipo(FileData *fd, Ipo *ipo)
+{
+ IpoCurve *icu;
+
+ link_list(fd, &(ipo->curve));
+ icu= ipo->curve.first;
+ while(icu) {
+ icu->bezt= newdataadr(fd, icu->bezt);
+ icu->bp= newdataadr(fd, icu->bp);
+ icu->driver= newdataadr(fd, icu->driver);
+ icu= icu->next;
+ }
+}
+
+// XXX depreceated - old animation system
static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
{
bActionStrip *strip;
@@ -1734,6 +1771,18 @@
}
}
+// XXX depreceated - old animation system
+static void direct_link_nlastrips(FileData *fd, ListBase *strips)
+{
+ bActionStrip *strip;
+
+ link_list(fd, strips);
+
+ for(strip= strips->first; strip; strip= strip->next)
+ link_list(fd, &strip->modifiers);
+}
+
+// XXX depreceated - old animation system
static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase
*chanbase)
{
bConstraintChannel *chan;
@@ -1743,6 +1792,175 @@
}
}
+/* Data Linking ----------------------------- */
+
+static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
+{
+ FCurve *fcu;
+ FModifier *fcm;
+
+ /* relink ID-block references... */
+ for (fcu= list->first; fcu; fcu= fcu->next) {
+ /* driver data */
+ if (fcu->driver) {
+ ChannelDriver *driver= fcu->driver;
+ driver->id= newlibadr(fd, id->lib, driver->id);
+ driver->id2= newlibadr(fd, id->lib, driver->id2);
+ }
+
+ /* modifiers */
+ for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
+ /* data for specific modifiers */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_PYTHON:
+ {
+ FMod_Python *data= (FMod_Python
*)fcm->data;
+ data->script = newlibadr(fd, id->lib,
data->script);
+ }
+ break;
+ }
+ }
+ }
+}
+
+static void direct_link_fcurves(FileData *fd, ListBase *list)
+{
+ FCurve *fcu;
+ FModifier *fcm;
+
+ /* link F-Curve data to F-Curve again (non ID-libs) */
+ for (fcu= list->first; fcu; fcu= fcu->next) {
+ /* curve data */
+ fcu->bezt= newdataadr(fd, fcu->bezt);
+ fcu->fpt= newdataadr(fd, fcu->fpt);
+
+ /* rna path */
+ fcu->rna_path= newdataadr(fd, fcu->rna_path);
+
+ /* driver */
+ fcu->driver= newdataadr(fd, fcu->driver);
+ if (fcu->driver) {
+ ChannelDriver *driver= fcu->driver;
+
+ driver->rna_path= newdataadr(fd, driver->rna_path);
+ driver->rna_path2= newdataadr(fd, driver->rna_path2);
+ }
+
+ /* modifiers */
+ link_list(fd, &fcu->modifiers);
+ for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
+ /* relink general data */
+ fcm->data = newdataadr(fd, fcm->data);
+
+ /* do relinking of data for specific types */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_GENERATOR:
+ {
+ FMod_Generator *data= (FMod_Generator
*)fcm->data;
+
+ data->poly_coefficients= newdataadr(fd,
data->poly_coefficients);
+ }
+ break;
+ case FMODIFIER_TYPE_PYTHON:
+ {
+ FMod_Python *data= (FMod_Python
*)fcm->data;
+
+ data->prop = newdataadr(fd, data->prop);
+ IDP_DirectLinkProperty(data->prop,
(fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+ break;
+ }
+ }
+ }
+}
+
+
+static void lib_link_action(FileData *fd, Main *main)
+{
+ bAction *act;
+ bActionChannel *chan;
+
+ for (act= main->action.first; act; act= act->id.next) {
+ if (act->id.flag & LIB_NEEDLINK) {
+ act->id.flag -= LIB_NEEDLINK;
+
+// XXX depreceated - old animation system <<<
+ for (chan=act->chanbase.first; chan; chan=chan->next) {
+ chan->ipo= newlibadr_us(fd, act->id.lib,
chan->ipo);
+ lib_link_constraint_channels(fd, &act->id,
&chan->constraintChannels);
+ }
+// >>> XXX depreceated - old animation system
+
+ lib_link_fcurves(fd, &act->id, &act->curves);
+ }
+ }
+}
+
+static void direct_link_action(FileData *fd, bAction *act)
+{
+ bActionChannel *achan; // XXX depreceated - old animation system
+ bActionGroup *agrp;
+
+ link_list(fd, &act->curves); // xxx - do we need to patch the data for
this?
+ link_list(fd, &act->chanbase);
+ link_list(fd, &act->groups);
+ link_list(fd, &act->markers);
+
+// XXX depreceated - old animation system <<<
+ for (achan = act->chanbase.first; achan; achan=achan->next) {
+ achan->grp= newdataadr(fd, achan->grp);
+
+ link_list(fd, &achan->constraintChannels);
+ }
+// >>> XXX depreceated - old animation system
+
+ direct_link_fcurves(fd, &act->curves);
+
+ for (agrp = act->groups.first; agrp; agrp= agrp->next) {
+ if (agrp->channels.first) {
+ agrp->channels.first= newdataadr(fd,
agrp->channels.first);
+ agrp->channels.last= newdataadr(fd,
agrp->channels.last);
+ }
+ }
+}
+
+/* ------- */
+
+static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
+{
+ if (adt == NULL)
+ return;
+
+ /* link action data */
+ adt->action= newlibadr_us(fd, id->lib, adt->action);
+
+ /* link drivers */
+ lib_link_fcurves(fd, id, &adt->drivers);
+
+ /* overrides don't have lib-link for now, so no need to do anything */
+
+ /* link NLA-data */
+ // TODO...
+}
+
+static void direct_link_animdata(FileData *fd, AnimData *adt)
+{
+ /* NOTE: must have called newdataadr already before doing this... */
+ if (adt == NULL)
+ return;
+
+ /* link drivers */
+ direct_link_fcurves(fd, &adt->drivers);
+
+ /* link overrides */
+ // TODO...
+
+ /* link NLA-data */
+ // TODO...
+}
+
+/* ************ READ ARMATURE ***************** */
+
static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
{
bConstraint *con;
@@ -1754,7 +1972,7 @@
con->type= CONSTRAINT_TYPE_NULL;
}
/* own ipo, all constraints have it */
- con->ipo= newlibadr_us(fd, id->lib, con->ipo);
+ con->ipo= newlibadr_us(fd, id->lib, con->ipo); // XXX
depreceated - old animation system
switch (con->type) {
case CONSTRAINT_TYPE_PYTHON:
@@ -1947,26 +2165,6 @@
}
}
-static void lib_link_action(FileData *fd, Main *main)
-{
- bAction *act;
- bActionChannel *chan;
-
- act= main->action.first;
- while(act) {
- if(act->id.flag & LIB_NEEDLINK) {
- act->id.flag -= LIB_NEEDLINK;
-
- for (chan=act->chanbase.first; chan; chan=chan->next) {
- chan->ipo= newlibadr_us(fd, act->id.lib,
chan->ipo);
- lib_link_constraint_channels(fd, &act->id,
&chan->constraintChannels);
- }
-
- }
- act= act->id.next;
- }
-}
-
static void direct_link_bones(FileData *fd, Bone* bone)
{
Bone *child;
@@ -1980,30 +2178,6 @@
}
}
-
-static void direct_link_action(FileData *fd, bAction *act)
-{
- bActionChannel *achan;
- bActionGroup *agrp;
-
- link_list(fd, &act->chanbase);
- link_list(fd, &act->groups);
- link_list(fd, &act->markers);
-
- for (achan = act->chanbase.first; achan; achan=achan->next) {
- achan->grp= newdataadr(fd, achan->grp);
-
- link_list(fd, &achan->constraintChannels);
- }
-
- for (agrp = act->groups.first; agrp; agrp= agrp->next) {
- if (agrp->channels.first) {
- agrp->channels.first= newdataadr(fd,
agrp->channels.first);
- agrp->channels.last= newdataadr(fd,
agrp->channels.last);
- }
- }
-}
-
static void direct_link_armature(FileData *fd, bArmature *arm)
{
Bone *bone;
@@ -2027,13 +2201,14 @@
ca= main->camera.first;
while(ca) {
if(ca->id.flag & LIB_NEEDLINK) {
-
- ca->ipo= newlibadr_us(fd, ca->id.lib, ca->ipo);
+ if (ca->adt) lib_link_animdata(fd, &ca->id, ca->adt);
+ ca->ipo= newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX
depreceated - old animation system
+
ca->dof_ob= newlibadr_us(fd, ca->id.lib, ca->dof_ob);
lib_link_scriptlink(fd, &ca->id, &ca->scriptlink);
-
+
ca->id.flag -= LIB_NEEDLINK;
}
ca= ca->id.next;
@@ -2042,6 +2217,9 @@
static void direct_link_camera(FileData *fd, Camera *ca)
{
+ ca->adt= newdataadr(fd, ca->adt);
+ direct_link_animdata(fd, ca->adt);
+
direct_link_scriptlink(fd, &ca->scriptlink);
}
@@ -2057,7 +2235,8 @@
la= main->lamp.first;
while(la) {
if(la->id.flag & LIB_NEEDLINK) {
-
+ if (la->adt) lib_link_animdata(fd, &la->id, la->adt);
+
for(a=0; a<MAX_MTEX; a++) {
mtex= la->mtex[a];
if(mtex) {
@@ -2065,11 +2244,11 @@
mtex->object= newlibadr(fd, la->id.lib,
mtex->object);
}
}
-
- la->ipo= newlibadr_us(fd, la->id.lib, la->ipo);
-
+
+ la->ipo= newlibadr_us(fd, la->id.lib, la->ipo); // XXX
depreceated - old animation system
+
lib_link_scriptlink(fd, &la->id, &la->scriptlink);
-
+
la->id.flag -= LIB_NEEDLINK;
}
la= la->id.next;
@@ -2079,7 +2258,10 @@
static void direct_link_lamp(FileData *fd, Lamp *la)
{
int a;
-
+
+ la->adt= newdataadr(fd, la->adt);
+ direct_link_animdata(fd, la->adt);
+
direct_link_scriptlink(fd, &la->scriptlink);
for(a=0; a<MAX_MTEX; a++) {
@@ -2103,7 +2285,7 @@
while(key) {
if(key->id.flag & LIB_NEEDLINK) {
- key->ipo= newlibadr_us(fd, key->id.lib, key->ipo);
+ key->ipo= newlibadr_us(fd, key->id.lib, key->ipo); //
XXX depreceated - old animation system
key->from= newlibadr(fd, key->id.lib, key->from);
key->id.flag -= LIB_NEEDLINK;
@@ -2152,6 +2334,9 @@
link_list(fd, &(key->block));
+ key->adt= newdataadr(fd, key->adt);
+ direct_link_animdata(fd, key->adt);
+
key->refkey= newdataadr(fd, key->refkey);
kb= key->block.first;
@@ -2179,7 +2364,7 @@
for(a=0; a<mb->totcol; a++) mb->mat[a]=
newlibadr_us(fd, mb->id.lib, mb->mat[a]);
- mb->ipo= newlibadr_us(fd, mb->id.lib, mb->ipo);
+ mb->ipo= newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX
depreceated - old animation system
mb->id.flag -= LIB_NEEDLINK;
}
@@ -2210,9 +2395,10 @@
wrld= main->world.first;
while(wrld) {
if(wrld->id.flag & LIB_NEEDLINK) {
-
- wrld->ipo= newlibadr_us(fd, wrld->id.lib, wrld->ipo);
-
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs