[Bf-blender-cvs] [ec26260132b] blender-v2.83-release: GPencil: Fix unreported wrong Sculpt brushes initialization in Templates

Antonio Vazquez noreply at git.blender.org
Sat May 30 17:33:18 CEST 2020


Commit: ec26260132b49bf071facc3fbd728413ef2155d1
Author: Antonio Vazquez
Date:   Sat May 30 17:31:54 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBec26260132b49bf071facc3fbd728413ef2155d1

GPencil: Fix unreported wrong Sculpt brushes initialization in Templates

The Sculpt brushes were not properly initialized when use 2D template or other templates.

Also, using the default template (not factory settings) could be situations where the brushes were not updated.

This problem was introduced when some versioning code was removed in order to avoid duplicated brush creation.

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

M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/gpencil/gpencil_edit.c

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

diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 8a7fd80ea0e..993d50bf642 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -463,6 +463,9 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
     /* Reset all grease pencil brushes. */
     Scene *scene = bmain->scenes.first;
     BKE_brush_gpencil_paint_presets(bmain, scene->toolsettings, true);
+    BKE_brush_gpencil_sculpt_presets(bmain, scene->toolsettings, true);
+    BKE_brush_gpencil_vertex_presets(bmain, scene->toolsettings, true);
+    BKE_brush_gpencil_weight_presets(bmain, scene->toolsettings, true);
 
     /* Ensure new Paint modes. */
     BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 99700a870b9..e2bd1c4a4a9 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -353,7 +353,7 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
 
   if (mode == OB_MODE_PAINT_GPENCIL) {
     /* Be sure we have brushes and Paint settings.
-     * Need Draw and Vertex (used fro Tint). */
+     * Need Draw and Vertex (used for Tint). */
     BKE_paint_ensure(ts, (Paint **)&ts->gp_paint);
     BKE_paint_ensure(ts, (Paint **)&ts->gp_vertexpaint);
 
@@ -464,11 +464,13 @@ static int gpencil_sculptmode_toggle_exec(bContext *C, wmOperator *op)
   }
 
   if (mode == OB_MODE_SCULPT_GPENCIL) {
-    /* be sure we have brushes */
+    /* Be sure we have brushes. */
     BKE_paint_ensure(ts, (Paint **)&ts->gp_sculptpaint);
-    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_sculptpaint->paint);
 
-    BKE_brush_gpencil_sculpt_presets(bmain, ts, false);
+    const bool reset_mode = (ts->gp_sculptpaint->paint.brush == NULL);
+    BKE_brush_gpencil_sculpt_presets(bmain, ts, reset_mode);
+
+    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_sculptpaint->paint);
   }
 
   /* setup other modes */
@@ -565,11 +567,13 @@ static int gpencil_weightmode_toggle_exec(bContext *C, wmOperator *op)
   }
 
   if (mode == OB_MODE_WEIGHT_GPENCIL) {
-    /* be sure we have brushes */
+    /* Be sure we have brushes. */
     BKE_paint_ensure(ts, (Paint **)&ts->gp_weightpaint);
-    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_weightpaint->paint);
 
-    BKE_brush_gpencil_weight_presets(bmain, ts, false);
+    const bool reset_mode = (ts->gp_weightpaint->paint.brush == NULL);
+    BKE_brush_gpencil_weight_presets(bmain, ts, reset_mode);
+
+    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_weightpaint->paint);
   }
 
   /* setup other modes */
@@ -665,11 +669,13 @@ static int gpencil_vertexmode_toggle_exec(bContext *C, wmOperator *op)
   }
 
   if (mode == OB_MODE_VERTEX_GPENCIL) {
-    /* be sure we have brushes */
+    /* Be sure we have brushes. */
     BKE_paint_ensure(ts, (Paint **)&ts->gp_vertexpaint);
-    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_vertexpaint->paint);
 
-    BKE_brush_gpencil_vertex_presets(bmain, ts, false);
+    const bool reset_mode = (ts->gp_vertexpaint->paint.brush == NULL);
+    BKE_brush_gpencil_vertex_presets(bmain, ts, reset_mode);
+
+    BKE_paint_toolslots_brush_validate(bmain, &ts->gp_vertexpaint->paint);
 
     /* Ensure Palette by default. */
     BKE_gpencil_palette_ensure(bmain, CTX_data_scene(C));



More information about the Bf-blender-cvs mailing list