[Bf-blender-cvs] [bdb4e2b1c4f] greasepencil-refactor: GPencil: Fix old files using Stencil Mask

Antonio Vazquez noreply at git.blender.org
Thu Dec 12 15:52:55 CET 2019


Commit: bdb4e2b1c4f3b9fc00365f8c8f8494e572747db2
Author: Antonio Vazquez
Date:   Thu Dec 12 15:39:21 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBbdb4e2b1c4f3b9fc00365f8c8f8494e572747db2

GPencil: Fix old files using Stencil Mask

===================================================================

M	source/blender/blenloader/intern/versioning_280.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 15956a7c9b5..4aa58df2ac0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4320,12 +4320,30 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
 
-    /* Set Checker material as Solid for Grease Pencil. This fill mode has been removed
-     * and replaced by textures. */
+    /* Update Grease Pencil Materials */
     {
       for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
-        if ((mat->gp_style) && (mat->gp_style->fill_style == GP_STYLE_FILL_STYLE_CHECKER)) {
-          mat->gp_style->fill_style = GP_STYLE_FILL_STYLE_SOLID;
+        MaterialGPencilStyle *gp_style = mat->gp_style;
+        if (gp_style == NULL) {
+          continue;
+        }
+        /* Set Checker material as Solid. This fill mode has been removed and replaced
+         * by textures. */
+        if (gp_style->fill_style == GP_STYLE_FILL_STYLE_CHECKER) {
+          gp_style->fill_style = GP_STYLE_FILL_STYLE_SOLID;
+        }
+        /* Update Alpha channel for texture opacity. */
+        if (gp_style->fill_style == GP_STYLE_FILL_STYLE_TEXTURE) {
+          gp_style->fill_rgba[3] *= gp_style->texture_opacity;
+        }
+        /* Stroke stencil mask to mix = 1. */
+        if (gp_style->flag & GP_STYLE_STROKE_PATTERN) {
+          gp_style->mix_stroke_factor = 1.0f;
+          gp_style->flag &= ~GP_STYLE_STROKE_PATTERN;
+        }
+        /* Mix disabled, set mix factor to 0. */
+        else if ((gp_style->flag & GP_STYLE_STROKE_TEX_MIX) == 0) {
+          gp_style->mix_stroke_factor = 0.0f;
         }
       }
     }



More information about the Bf-blender-cvs mailing list