[Bf-blender-cvs] [c541a589281] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object
Antonio Vazquez
noreply at git.blender.org
Tue Oct 24 13:47:52 CEST 2017
Commit: c541a5892816e6d0a21f53ee8e48f5d13d84a6ab
Author: Antonio Vazquez
Date: Tue Oct 24 13:35:51 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc541a5892816e6d0a21f53ee8e48f5d13d84a6ab
Merge branch 'blender2.8' into greasepencil-object
===================================================================
===================================================================
diff --cc source/blender/blenloader/intern/versioning_280.c
index 407d1990f32,da1562d3a64..e265a09adac
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@@ -442,141 -439,7 +444,140 @@@ void blo_do_versions_280(FileData *fd,
}
}
}
- }
+ if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
+ /* Convert grease pencil datablock to GP object */
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (scene->gpd) {
+ Object *ob;
+ SceneLayer *sl = scene->render_layers.first;
+
+ ob = BKE_object_add(main, scene, sl, OB_GPENCIL, "GP_Scene");
+ zero_v3(ob->loc);
+ ob->gpd = scene->gpd;
+ scene->gpd = NULL;
+
+ /* set cache as dirty */
+ BKE_gpencil_batch_cache_dirty(ob->gpd);
+ }
+ /* set default mode as object */
+ scene->toolsettings->gpencil_src = GP_TOOL_SOURCE_OBJECT;
+ }
+
+ /* Convert grease pencil palettes to blender palettes */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "Palette", "*palette")) {
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ /* first create all palettes and colors */
+ Palette *first = NULL;
+ for (bGPDpalette *oldpalette = gpd->palettes.first; oldpalette; oldpalette = oldpalette->next) {
+ /* create palette */
+ bGPDpaletteref *palslot = BKE_gpencil_paletteslot_addnew(main, gpd, oldpalette->info);
+ Palette *newpalette = palslot->palette;
+
+ /* save first to use later */
+ if (first == NULL) {
+ first = newpalette;
+ }
+
+ for (bGPDpalettecolor *oldcolor = oldpalette->colors.first; oldcolor; oldcolor = oldcolor->next) {
+ PaletteColor *newcolor = BKE_palette_color_add_name(newpalette, oldcolor->info);
+ /* set color attributes */
+ copy_v4_v4(newcolor->rgb, oldcolor->color);
+ copy_v4_v4(newcolor->fill, oldcolor->fill);
+ newcolor->flag = oldcolor->flag;
+ }
+ /* set first color active by default */
+ if (!BLI_listbase_is_empty(&newpalette->colors)) {
+ newpalette->active_color = 0;
+ }
+ }
+ /* second, assign the palette and the color (always to first palette) */
+ 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) {
+ Palette *palette = first;
+ PaletteColor *palcolor = BKE_palette_color_getbyname(first, gps->colorname);
+
+ gps->palette = palette;
+ gps->palcolor = palcolor;
+ }
+ }
+ }
+ gpd->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
+
+ /* Grease pencil sculpt and paint cursors */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "weighttype")) {
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->alpha = 1.0f;
+ gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDbrush", "float", "curcolor[3]")) {
+ float curcolor[3], curcolor_add[3], curcolor_sub[3];
+ ARRAY_SET_ITEMS(curcolor, 1.0f, 1.0f, 1.0f);
+ ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
+ ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
+ GP_EditBrush_Data *gp_brush;
+
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ /* drawing brushes */
+ ToolSettings *ts = scene->toolsettings;
+ for (bGPDbrush *brush = ts->gp_brushes.first; brush; brush = brush->next) {
+ brush->flag |= GP_BRUSH_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor, curcolor);
+ }
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
+ for (int i = 0; i < TOT_GP_EDITBRUSH_TYPES; ++i) {
+ gp_brush = &gset->brush[i];
+ gp_brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+ copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+ }
+ }
+ }
+
+ /* Init grease pencil vertex groups */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDweight", "int", "index")) {
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ 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) {
+ for (int i = 0; i < gps->totpoints; ++i) {
+ bGPDspoint *pt = &gps->points[i];
+ pt->totweight = 0;
+ pt->weights = NULL;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* Init grease pencil edit line color */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.3f);
+ }
+ }
+
+ /* Init grease pencil pixel size factor */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDdata", "int", "pixfactor")) {
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
+ }
+ }
+
+ }
+
+ {
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) {
for (Lamp *la = main->lamp.first; la; la = la->id.next) {
la->cascade_max_dist = 1000.0f;
More information about the Bf-blender-cvs
mailing list