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.
This commit is contained in:
Ton Roosendaal
2013-03-07 16:57:53 +00:00
parent e93068ad78
commit a134d9ed51

View File

@@ -380,6 +380,17 @@ static void writedata(WriteData *wd, int filecode, int len, const void *adr) /*
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 @@ static void write_gpencils(WriteData *wd, ListBase *lb)
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);
}
}