Add DNA_struct_elem_find check
Other devs can now safely add own stuff to 2.77.3 version patch. Also minor whitespace cleanup.
This commit is contained in:
@@ -1227,74 +1227,76 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(main, 277, 3)) {
|
||||
/* ------- init of grease pencil initialization --------------- */
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
/* initialize use position for sculpt brushes */
|
||||
ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
|
||||
/* initialize selected vertices alpha factor */
|
||||
ts->gp_sculpt.alpha = 1.0f;
|
||||
|
||||
/* new strength sculpt brush */
|
||||
if (ts->gp_sculpt.brush[0].size >= 11) {
|
||||
GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
|
||||
GP_EditBrush_Data *brush;
|
||||
|
||||
brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
|
||||
brush->size = 25;
|
||||
brush->strength = 0.5f;
|
||||
brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
|
||||
}
|
||||
}
|
||||
/* create a default grease pencil drawing brushes set */
|
||||
if (!BLI_listbase_is_empty(&main->gpencil)) {
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "palcolor")) {
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
if (BLI_listbase_is_empty(&ts->gp_brushes)) {
|
||||
gpencil_brush_init_presets(ts);
|
||||
/* initialize use position for sculpt brushes */
|
||||
ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
|
||||
/* initialize selected vertices alpha factor */
|
||||
ts->gp_sculpt.alpha = 1.0f;
|
||||
|
||||
/* new strength sculpt brush */
|
||||
if (ts->gp_sculpt.brush[0].size >= 11) {
|
||||
GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
|
||||
GP_EditBrush_Data *brush;
|
||||
|
||||
brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
|
||||
brush->size = 25;
|
||||
brush->strength = 0.5f;
|
||||
brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Convert Grease Pencil to new palettes/brushes
|
||||
Loop all strokes and create the palette and all colors
|
||||
*/
|
||||
for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
|
||||
if (BLI_listbase_is_empty(&gpd->palettes)) {
|
||||
/* create palette */
|
||||
bGPDpalette *palette = gpencil_palette_addnew(gpd, "GP_Palette", true);
|
||||
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
/* create color using layer name */
|
||||
bGPDpalettecolor *palcolor = gpencil_palettecolor_addnew(palette, gpl->info, true);
|
||||
if (palcolor != NULL) {
|
||||
/* set color attributes */
|
||||
copy_v4_v4(palcolor->color, gpl->color);
|
||||
copy_v4_v4(palcolor->fill, gpl->fill);
|
||||
palcolor->flag = gpl->flag;
|
||||
/* set layer opacity to 1 */
|
||||
gpl->opacity = 1.0f;
|
||||
/* set tint color */
|
||||
ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
/* create a default grease pencil drawing brushes set */
|
||||
if (!BLI_listbase_is_empty(&main->gpencil)) {
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
if (BLI_listbase_is_empty(&ts->gp_brushes)) {
|
||||
gpencil_brush_init_presets(ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Convert Grease Pencil to new palettes/brushes
|
||||
* Loop all strokes and create the palette and all colors
|
||||
*/
|
||||
for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
|
||||
if (BLI_listbase_is_empty(&gpd->palettes)) {
|
||||
/* create palette */
|
||||
bGPDpalette *palette = gpencil_palette_addnew(gpd, "GP_Palette", true);
|
||||
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
/* create color using layer name */
|
||||
bGPDpalettecolor *palcolor = gpencil_palettecolor_addnew(palette, gpl->info, true);
|
||||
if (palcolor != NULL) {
|
||||
/* set color attributes */
|
||||
copy_v4_v4(palcolor->color, gpl->color);
|
||||
copy_v4_v4(palcolor->fill, gpl->fill);
|
||||
palcolor->flag = gpl->flag;
|
||||
/* set layer opacity to 1 */
|
||||
gpl->opacity = 1.0f;
|
||||
/* set tint color */
|
||||
ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
|
||||
/* set stroke to palette and force recalculation */
|
||||
strcpy(gps->colorname, gpl->info);
|
||||
gps->palcolor = NULL;
|
||||
gps->flag |= GP_STROKE_RECALC_COLOR;
|
||||
gps->thickness = gpl->thickness;
|
||||
/* set alpha strength to 1 */
|
||||
for (int i = 0; i < gps->totpoints; i++) {
|
||||
gps->points[i].strength = 1.0f;
|
||||
}
|
||||
|
||||
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
|
||||
/* set stroke to palette and force recalculation */
|
||||
strcpy(gps->colorname, gpl->info);
|
||||
gps->palcolor = NULL;
|
||||
gps->flag |= GP_STROKE_RECALC_COLOR;
|
||||
gps->thickness = gpl->thickness;
|
||||
/* set alpha strength to 1 */
|
||||
for (int i = 0; i < gps->totpoints; i++) {
|
||||
gps->points[i].strength = 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* set thickness to 0 (now it is a factor to override stroke thickness) */
|
||||
gpl->thickness = 0.0f;
|
||||
}
|
||||
/* set thickness to 0 (now it is a factor to override stroke thickness) */
|
||||
gpl->thickness = 0.0f;
|
||||
/* set first color as active */
|
||||
if (palette->colors.first)
|
||||
gpencil_palettecolor_setactive(palette, palette->colors.first);
|
||||
}
|
||||
/* set first color as active */
|
||||
if (palette->colors.first)
|
||||
gpencil_palettecolor_setactive(palette, palette->colors.first);
|
||||
}
|
||||
}
|
||||
/* ------- end of grease pencil initialization --------------- */
|
||||
|
@@ -1436,9 +1436,9 @@ static int gp_brush_remove_exec(bContext *C, wmOperator *op)
|
||||
|
||||
|
||||
/* make the brush before this the new active brush
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only brush, this naturally becomes NULL
|
||||
*/
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only brush, this naturally becomes NULL
|
||||
*/
|
||||
if (brush->prev)
|
||||
gpencil_brush_setactive(ts, brush->prev);
|
||||
else
|
||||
@@ -1791,9 +1791,9 @@ static int gp_palette_remove_exec(bContext *C, wmOperator *op)
|
||||
|
||||
|
||||
/* make the palette before this the new active palette
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only palette, this naturally becomes NULL
|
||||
*/
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only palette, this naturally becomes NULL
|
||||
*/
|
||||
if (palette->prev)
|
||||
gpencil_palette_setactive(gpd, palette->prev);
|
||||
else
|
||||
@@ -2003,9 +2003,9 @@ static int gp_palettecolor_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* make the palette color before this the new active color
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only color, this naturally becomes NULL
|
||||
*/
|
||||
* - use the one after if this is the first
|
||||
* - if this is the only color, this naturally becomes NULL
|
||||
*/
|
||||
if (color->prev)
|
||||
gpencil_palettecolor_setactive(palette, color->prev);
|
||||
else
|
||||
|
Reference in New Issue
Block a user