Commit: 8d3e2af8775e8a778f923583e455f412897fa204 Author: Dalai Felinto Date: Tue Jun 13 15:58:48 2017 +0200 Branches: greasepencil-object https://developer.blender.org/rB8d3e2af8775e8a778f923583e455f412897fa204
Grease Pencil: Fix problems linking object with Pallete This should at the very least use a hash system. But it could even do a local pointer lookup. (Way) More often than not multiple strokes will point to the same pallete color. =================================================================== M source/blender/blenloader/intern/readfile.c =================================================================== diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5fb651490fc..dadb8001b58 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6496,6 +6496,24 @@ static void lib_link_gpencil(FileData *fd, Main *main) { for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { if (gpd->id.tag & LIB_TAG_NEED_LINK) { + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + gps->palette = newlibadr(fd, NULL, gps->palette); + /* Relink color + * The Pallete colors are pointers to a listbase inside the Pallete datablock. + * So the pointers have to be re-assigned on file open + */ + gps->palcolor = BKE_palette_color_getbyname(gps->palette, gps->colorname); + if (gps->palcolor == NULL) { + gps->palcolor = BKE_palette_color_add_name(gps->palette, gps->colorname); + /* Set to a different color. */ + ARRAY_SET_ITEMS(gps->palcolor->rgb, 1.0f, 0.0f, 1.0f, 1.0f); + } + } + } + } + IDP_LibLinkProperty(gpd->id.properties, fd); lib_link_animdata(fd, &gpd->id, gpd->adt); @@ -6550,18 +6568,6 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) gps->triangles = NULL; gps->tot_triangles = 0; gps->flag |= GP_STROKE_RECALC_CACHES; - /* palette */ - gps->palette = newlibadr(fd, gpd->id.lib, gps->palette); - if (gps->palette == NULL) { - gps->palette = BKE_palette_add(G.main, "GP Palette"); - } - /* relink color */ - gps->palcolor = BKE_palette_color_getbyname(gps->palette, gps->colorname); - if (gps->palcolor == NULL) { - gps->palcolor = BKE_palette_color_add_name(gps->palette, gps->colorname); - /* set to a different color */ - ARRAY_SET_ITEMS(gps->palcolor->rgb, 1.0f, 0.0f, 1.0f, 1.0f); - } } } } @@ -10012,8 +10018,17 @@ static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *li static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd) { - if (gpd->adt) + if (gpd->adt) { expand_animdata(fd, mainvar, gpd->adt); + } + + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + expand_doit(fd, mainvar, gps->palette); + } + } + } } static void expand_palette(FileData *fd, Main *mainvar, Palette *palette) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs