[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55092] trunk/blender/source/blender/ blenloader/intern/writefile.c: Speedup for Grease Pencil animators.

Ton Roosendaal ton at blender.org
Thu Mar 7 17:57:53 CET 2013


Revision: 55092
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55092
Author:   ton
Date:     2013-03-07 16:57:53 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
Speedup for Grease Pencil animators.

Saving and loading gpencil was using different order for the individual list items.
On a 120 Mb gpencil project (yes, animators!) loading time went down from 1 minute 
to a second or two.

Note that this to have effect, you need to save once.

Developer note: check this commit, it uses a new writelist function. You can 
speedup stuff tremendously with keeping saved and read data in sync.

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	2013-03-07 16:12:36 UTC (rev 55091)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2013-03-07 16:57:53 UTC (rev 55092)
@@ -380,6 +380,17 @@
 	if (len) mywrite(wd, adr, len);
 }
 
+/* use this to force writing of lists in same order as reading (using link_list) */
+static void writelist(WriteData *wd, int filecode, const char *structname, ListBase *lb)
+{
+	Link *link = lb->first;
+	
+	while (link) {
+		writestruct(wd, filecode, structname, 1, link);
+		link = link->next;
+	}
+}
+
 /* *************** writing some direct data structs used in more code parts **************** */
 /*These functions are used by blender's .blend system for file saving/loading.*/
 void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd);
@@ -2335,16 +2346,16 @@
 			writestruct(wd, ID_GD, "bGPdata", 1, gpd);
 			
 			/* write grease-pencil layers to file */
+			writelist(wd, DATA, "bGPDlayer", &gpd->layers);
 			for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
-				writestruct(wd, DATA, "bGPDlayer", 1, gpl);
 				
 				/* write this layer's frames to file */
+				writelist(wd, DATA, "bGPDframe", &gpl->frames);
 				for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
-					writestruct(wd, DATA, "bGPDframe", 1, gpf);
 					
 					/* write strokes */
+					writelist(wd, DATA, "bGPDstroke", &gpf->strokes);
 					for (gps= gpf->strokes.first; gps; gps= gps->next) {
-						writestruct(wd, DATA, "bGPDstroke", 1, gps);
 						writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);
 					}
 				}




More information about the Bf-blender-cvs mailing list