[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33628] trunk/blender/source/blender/ blenloader/intern/writefile.c: Reshuffled AnimData reading functions in writefile.c as per an old

Joshua Leung aligorith at gmail.com
Mon Dec 13 09:08:09 CET 2010


Revision: 33628
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33628
Author:   aligorith
Date:     2010-12-13 09:08:09 +0100 (Mon, 13 Dec 2010)

Log Message:
-----------
Reshuffled AnimData reading functions in writefile.c as per an old
comment I'd left in there before this code had been merged back from
NLA-SoC branch

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/writefile.c

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2010-12-13 07:54:35 UTC (rev 33627)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2010-12-13 08:08:09 UTC (rev 33628)
@@ -362,7 +362,6 @@
 /*These functions are used by blender's .blend system for file saving/loading.*/
 void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd);
 void IDP_WriteProperty(IDProperty *prop, void *wd);
-static void write_animdata(WriteData *wd, AnimData *adt); // XXX code needs reshuffling, but not before NLA SoC is merged back into 2.5
 
 static void IDP_WriteArray(IDProperty *prop, void *wd)
 {
@@ -434,6 +433,200 @@
 	IDP_WriteProperty_OnlyData(prop, wd);
 }
 
+static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
+{
+	FModifier *fcm;
+	
+	/* Modifiers */
+	for (fcm= fmodifiers->first; fcm; fcm= fcm->next) {
+		FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
+		
+		/* Write the specific data */
+		if (fmi && fcm->data) {
+			/* firstly, just write the plain fmi->data struct */
+			writestruct(wd, DATA, fmi->structName, 1, fcm->data);
+			
+			/* do any modifier specific stuff */
+			switch (fcm->type) {
+				case FMODIFIER_TYPE_GENERATOR:
+				{
+					FMod_Generator *data= (FMod_Generator *)fcm->data;
+					
+					/* write coefficients array */
+					if (data->coefficients)
+						writedata(wd, DATA, sizeof(float)*(data->arraysize), data->coefficients);
+				}
+					break;
+				case FMODIFIER_TYPE_ENVELOPE:
+				{
+					FMod_Envelope *data= (FMod_Envelope *)fcm->data;
+					
+					/* write envelope data */
+					if (data->data)
+						writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data);
+				}
+					break;
+				case FMODIFIER_TYPE_PYTHON:
+				{
+					FMod_Python *data = (FMod_Python *)fcm->data;
+					
+					/* Write ID Properties -- and copy this comment EXACTLY for easy finding
+					 of library blocks that implement this.*/
+					IDP_WriteProperty(data->prop, wd);
+				}
+					break;
+			}
+		}
+		
+		/* Write the modifier */
+		writestruct(wd, DATA, "FModifier", 1, fcm);
+	}
+}
+
+static void write_fcurves(WriteData *wd, ListBase *fcurves)
+{
+	FCurve *fcu;
+	
+	for (fcu=fcurves->first; fcu; fcu=fcu->next) {
+		/* F-Curve */
+		writestruct(wd, DATA, "FCurve", 1, fcu);
+		
+		/* curve data */
+		if (fcu->bezt)  	
+			writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt);
+		if (fcu->fpt)
+			writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt);
+			
+		if (fcu->rna_path)
+			writedata(wd, DATA, strlen(fcu->rna_path)+1, fcu->rna_path);
+		
+		/* driver data */
+		if (fcu->driver) {
+			ChannelDriver *driver= fcu->driver;
+			DriverVar *dvar;
+			
+			writestruct(wd, DATA, "ChannelDriver", 1, driver);
+			
+			/* variables */
+			for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
+				writestruct(wd, DATA, "DriverVar", 1, dvar);
+				
+				DRIVER_TARGETS_USED_LOOPER(dvar)
+				{
+					if (dtar->rna_path)
+						writedata(wd, DATA, strlen(dtar->rna_path)+1, dtar->rna_path);
+				}
+				DRIVER_TARGETS_LOOPER_END
+			}
+		}
+		
+		/* write F-Modifiers */
+		write_fmodifiers(wd, &fcu->modifiers);
+	}
+}
+
+static void write_actions(WriteData *wd, ListBase *idbase)
+{
+	bAction	*act;
+	bActionGroup *grp;
+	TimeMarker *marker;
+	
+	for(act=idbase->first; act; act= act->id.next) {
+		if (act->id.us>0 || wd->current) {
+			writestruct(wd, ID_AC, "bAction", 1, act);
+			if (act->id.properties) IDP_WriteProperty(act->id.properties, wd);
+			
+			write_fcurves(wd, &act->curves);
+			
+			for (grp=act->groups.first; grp; grp=grp->next) {
+				writestruct(wd, DATA, "bActionGroup", 1, grp);
+			}
+			
+			for (marker=act->markers.first; marker; marker=marker->next) {
+				writestruct(wd, DATA, "TimeMarker", 1, marker);
+			}
+		}
+	}
+	
+	/* flush helps the compression for undo-save */
+	mywrite(wd, MYWRITE_FLUSH, 0);
+}
+
+static void write_keyingsets(WriteData *wd, ListBase *list)
+{
+	KeyingSet *ks;
+	KS_Path *ksp;
+	
+	for (ks= list->first; ks; ks= ks->next) {
+		/* KeyingSet */
+		writestruct(wd, DATA, "KeyingSet", 1, ks);
+		
+		/* Paths */
+		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+			/* Path */
+			writestruct(wd, DATA, "KS_Path", 1, ksp);
+			
+			if (ksp->rna_path)
+				writedata(wd, DATA, strlen(ksp->rna_path)+1, ksp->rna_path);
+		}
+	}
+}
+
+static void write_nlastrips(WriteData *wd, ListBase *strips)
+{
+	NlaStrip *strip;
+	
+	for (strip= strips->first; strip; strip= strip->next) {
+		/* write the strip first */
+		writestruct(wd, DATA, "NlaStrip", 1, strip);
+		
+		/* write the strip's F-Curves and modifiers */
+		write_fcurves(wd, &strip->fcurves);
+		write_fmodifiers(wd, &strip->modifiers);
+		
+		/* write the strip's children */
+		write_nlastrips(wd, &strip->strips);
+	}
+}
+
+static void write_nladata(WriteData *wd, ListBase *nlabase)
+{
+	NlaTrack *nlt;
+	
+	/* write all the tracks */
+	for (nlt= nlabase->first; nlt; nlt= nlt->next) {
+		/* write the track first */
+		writestruct(wd, DATA, "NlaTrack", 1, nlt);
+		
+		/* write the track's strips */
+		write_nlastrips(wd, &nlt->strips);
+	}
+}
+
+static void write_animdata(WriteData *wd, AnimData *adt)
+{
+	AnimOverride *aor;
+	
+	/* firstly, just write the AnimData block */
+	writestruct(wd, DATA, "AnimData", 1, adt);
+	
+	/* write drivers */
+	write_fcurves(wd, &adt->drivers);
+	
+	/* write overrides */
+	// FIXME: are these needed?
+	for (aor= adt->overrides.first; aor; aor= aor->next) {
+		/* overrides consist of base data + rna_path */
+		writestruct(wd, DATA, "AnimOverride", 1, aor);
+		writedata(wd, DATA, strlen(aor->rna_path)+1, aor->rna_path);
+	}
+	
+	// TODO write the remaps (if they are needed)
+	
+	/* write NLA data */
+	write_nladata(wd, &adt->nla_tracks);
+}
+
 static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
 {
 	int a;
@@ -846,200 +1039,6 @@
 	}
 }
 
-static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
-{
-	FModifier *fcm;
-	
-	/* Modifiers */
-	for (fcm= fmodifiers->first; fcm; fcm= fcm->next) {
-		FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
-		
-		/* Write the specific data */
-		if (fmi && fcm->data) {
-			/* firstly, just write the plain fmi->data struct */
-			writestruct(wd, DATA, fmi->structName, 1, fcm->data);
-			
-			/* do any modifier specific stuff */
-			switch (fcm->type) {
-				case FMODIFIER_TYPE_GENERATOR:
-				{
-					FMod_Generator *data= (FMod_Generator *)fcm->data;
-					
-					/* write coefficients array */
-					if (data->coefficients)
-						writedata(wd, DATA, sizeof(float)*(data->arraysize), data->coefficients);
-				}
-					break;
-				case FMODIFIER_TYPE_ENVELOPE:
-				{
-					FMod_Envelope *data= (FMod_Envelope *)fcm->data;
-					
-					/* write envelope data */
-					if (data->data)
-						writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data);
-				}
-					break;
-				case FMODIFIER_TYPE_PYTHON:
-				{
-					FMod_Python *data = (FMod_Python *)fcm->data;
-					
-					/* Write ID Properties -- and copy this comment EXACTLY for easy finding
-					 of library blocks that implement this.*/
-					IDP_WriteProperty(data->prop, wd);
-				}
-					break;
-			}
-		}
-		
-		/* Write the modifier */
-		writestruct(wd, DATA, "FModifier", 1, fcm);
-	}
-}
-
-static void write_fcurves(WriteData *wd, ListBase *fcurves)
-{
-	FCurve *fcu;
-	
-	for (fcu=fcurves->first; fcu; fcu=fcu->next) {
-		/* F-Curve */
-		writestruct(wd, DATA, "FCurve", 1, fcu);
-		
-		/* curve data */
-		if (fcu->bezt)  	
-			writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt);
-		if (fcu->fpt)
-			writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt);
-			
-		if (fcu->rna_path)
-			writedata(wd, DATA, strlen(fcu->rna_path)+1, fcu->rna_path);
-		
-		/* driver data */
-		if (fcu->driver) {
-			ChannelDriver *driver= fcu->driver;
-			DriverVar *dvar;
-			
-			writestruct(wd, DATA, "ChannelDriver", 1, driver);
-			
-			/* variables */
-			for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
-				writestruct(wd, DATA, "DriverVar", 1, dvar);
-				
-				DRIVER_TARGETS_USED_LOOPER(dvar)
-				{
-					if (dtar->rna_path)
-						writedata(wd, DATA, strlen(dtar->rna_path)+1, dtar->rna_path);
-				}
-				DRIVER_TARGETS_LOOPER_END
-			}
-		}
-		
-		/* write F-Modifiers */
-		write_fmodifiers(wd, &fcu->modifiers);
-	}
-}
-
-static void write_actions(WriteData *wd, ListBase *idbase)
-{
-	bAction	*act;
-	bActionGroup *grp;
-	TimeMarker *marker;
-	
-	for(act=idbase->first; act; act= act->id.next) {
-		if (act->id.us>0 || wd->current) {
-			writestruct(wd, ID_AC, "bAction", 1, act);
-			if (act->id.properties) IDP_WriteProperty(act->id.properties, wd);
-			
-			write_fcurves(wd, &act->curves);
-			
-			for (grp=act->groups.first; grp; grp=grp->next) {
-				writestruct(wd, DATA, "bActionGroup", 1, grp);
-			}
-			
-			for (marker=act->markers.first; marker; marker=marker->next) {
-				writestruct(wd, DATA, "TimeMarker", 1, marker);
-			}
-		}
-	}
-	
-	/* flush helps the compression for undo-save */
-	mywrite(wd, MYWRITE_FLUSH, 0);
-}
-
-static void write_keyingsets(WriteData *wd, ListBase *list)
-{
-	KeyingSet *ks;
-	KS_Path *ksp;
-	
-	for (ks= list->first; ks; ks= ks->next) {
-		/* KeyingSet */
-		writestruct(wd, DATA, "KeyingSet", 1, ks);
-		
-		/* Paths */
-		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
-			/* Path */
-			writestruct(wd, DATA, "KS_Path", 1, ksp);
-			
-			if (ksp->rna_path)
-				writedata(wd, DATA, strlen(ksp->rna_path)+1, ksp->rna_path);
-		}
-	}
-}
-
-static void write_nlastrips(WriteData *wd, ListBase *strips)
-{
-	NlaStrip *strip;
-	
-	for (strip= strips->first; strip; strip= strip->next) {
-		/* write the strip first */
-		writestruct(wd, DATA, "NlaStrip", 1, strip);
-		
-		/* write the strip's F-Curves and modifiers */
-		write_fcurves(wd, &strip->fcurves);
-		write_fmodifiers(wd, &strip->modifiers);
-		
-		/* write the strip's children */
-		write_nlastrips(wd, &strip->strips);
-	}
-}
-
-static void write_nladata(WriteData *wd, ListBase *nlabase)
-{
-	NlaTrack *nlt;
-	
-	/* write all the tracks */
-	for (nlt= nlabase->first; nlt; nlt= nlt->next) {
-		/* write the track first */
-		writestruct(wd, DATA, "NlaTrack", 1, nlt);
-		
-		/* write the track's strips */
-		write_nlastrips(wd, &nlt->strips);
-	}
-}
-
-static void write_animdata(WriteData *wd, AnimData *adt)
-{
-	AnimOverride *aor;
-	
-	/* firstly, just write the AnimData block */
-	writestruct(wd, DATA, "AnimData", 1, adt);
-	
-	/* write drivers */
-	write_fcurves(wd, &adt->drivers);
-	
-	/* write overrides */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list