[Bf-blender-cvs] [aa8b7f4368b] greasepencil-object: RNA/DNA changes to further decouple Grease Pencil and Annotation settings where clashes occurred

Joshua Leung noreply at git.blender.org
Fri Jul 27 06:41:16 CEST 2018


Commit: aa8b7f4368b02ac35dc7305bf2a970972eef685a
Author: Joshua Leung
Date:   Fri Jul 27 16:13:56 2018 +1200
Branches: greasepencil-object
https://developer.blender.org/rBaa8b7f4368b02ac35dc7305bf2a970972eef685a

RNA/DNA changes to further decouple Grease Pencil and Annotation settings where clashes occurred

* Decouple stroke placement settings for 3D view
* Ensure that proper thickness controls are used in the topbar

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_gpencil.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 1bc8426b61a..1c9e4ab9a6a 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -25,13 +25,13 @@ from bpy.app.translations import pgettext_iface as iface_
 
 def gpencil_stroke_placement_settings(context, layout):
     if context.space_data.type == 'VIEW_3D':
-        propname = "gpencil_stroke_placement_view3d"
+        propname = "annotation_stroke_placement_view3d"
     elif context.space_data.type == 'SEQUENCE_EDITOR':
-        propname = "gpencil_stroke_placement_sequencer_preview"
+        propname = "annotation_stroke_placement_sequencer_preview"
     elif context.space_data.type == 'IMAGE_EDITOR':
-        propname = "gpencil_stroke_placement_image_editor"
+        propname = "annotation_stroke_placement_image_editor"
     else:
-        propname = "gpencil_stroke_placement_view2d"
+        propname = "annotation_stroke_placement_view2d"
 
     ts = context.tool_settings
 
@@ -131,7 +131,7 @@ class GreasePencilDrawingToolsPanel:
         #col.separator()
         #col.separator()
 
-        #gpencil_stroke_placement_settings(context, col)
+        gpencil_stroke_placement_settings(context, col)
 
         gpd = context.gpencil_data
 
@@ -789,8 +789,8 @@ class GreasePencilDataPanel:
                 sub.operator("gpencil.layer_move", icon='TRIA_DOWN', text="").type = 'DOWN'
 
         if gpl:
-            row = layout.row(align=True)
-            row.prop(gpl, "opacity", text="Opacity", slider=True)
+            layout.prop(gpl, "opacity", text="Opacity", slider=True)
+            layout.prop(gpl, "thickness", text="Thickness")
 
             layout.separator()
 
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index d7ab5e3bd33..ecf641b394e 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -200,10 +200,10 @@ class _defs_annotate:
 
         if gpd and gpl:
             layout.prop(gpd.layers, "active_note", text="")
-            layout.prop(gpl, "line_change", text="Thickness")  # XXX: Replace with proper thickness control
+            layout.prop(gpl, "thickness", text="Thickness")
         else:
             layout.prop(user_prefs.edit, "grease_pencil_default_color", text="Color")
-            layout.label("Thickness: [...]")
+            layout.prop(ts, "annotation_thickness", text="Thickness")
 
         # For 3D view, show the stroke placement settings
         # XXX: How to tell what editor the active tool comes from?
@@ -212,7 +212,7 @@ class _defs_annotate:
             layout.separator()
 
             row = layout.row(align=True)
-            row.prop(ts, "gpencil_stroke_placement_view3d", text="Orientation")
+            row.prop(ts, "annotation_stroke_placement_view3d", text="Orientation")
             if ts.gpencil_stroke_placement_view3d == 'CURSOR':
                 row.prop(ts.gpencil_sculpt, "lockaxis")
             elif ts.gpencil_stroke_placement_view3d in {'SURFACE', 'STROKE'}:
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b58a7f50d27..4d4e041cf8c 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -843,6 +843,10 @@ void BKE_scene_init(Scene *sce)
 	sce->toolsettings->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
 	sce->toolsettings->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
 
+	/* Annotations */
+	sce->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+	sce->toolsettings->annotate_thickness = 3;
+
 	sce->orientation_index_custom = -1;
 
 	/* Master Collection */
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 6e79a7baa36..fadf332c850 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1457,9 +1457,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
 								}
 							}
 						}
-
-						/* set thickness to 0 (now it is a factor to override stroke thickness) */
-						gpl->thickness = 0.0f;
 					}
 				}
 			}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index c8f023aced7..ae75657a0f6 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1731,4 +1731,23 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
 	}
 
+	if (!MAIN_VERSION_ATLEAST(bmain, 280, 22)) {
+		if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
+			for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+				scene->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+				scene->toolsettings->annotate_thickness = 3;
+			}
+		}
+		if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "short", "line_change")) {
+			for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+				for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+					gpl->line_change = gpl->thickness;
+					if ((gpl->thickness < 1) || (gpl->thickness > 10)) {
+						gpl->thickness = 3;
+					}
+				}
+			}
+		}
+	}
+
 }
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index a8480039943..a86986e2e09 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -248,6 +248,9 @@ void BLO_update_defaults_startup_blend(Main *bmain)
 			ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
 			ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
 
+			ts->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+			ts->annotate_thickness = 3;
+
 			ParticleEditSettings *pset = &ts->particle;
 			for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
 				pset->brush[a].strength = 0.5f;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 5c3cadd6e91..76cb1405a71 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -616,7 +616,7 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
 		}
 	}
 
-	sthickness = gps->thickness + gpl->thickness;
+	sthickness = gps->thickness + gpl->line_change;
 	CLAMP_MIN(sthickness, 1);
 	if (cache->is_dirty) {
 		gpencil_batch_cache_check_free_slots(ob);
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 4acc6dd985e..a1c57f7a8c8 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -493,7 +493,7 @@ static short gp_stroke_addpoint(
 
 				view3d_region_operator_needs_opengl(p->win, p->ar);
 				ED_view3d_autodist_init(
-				        p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+				        p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
 			}
 
 			/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -610,7 +610,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 
 	int i, totelem;
 	/* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
-	int depth_margin = (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
+	int depth_margin = (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
 
 	/* get total number of points to allocate space for
 	 *	- drawing straight-lines only requires the endpoints
@@ -743,7 +743,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 					depth_arr[i] = 0.9999f;
 			}
 			else {
-				if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
+				if (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
 					/* remove all info between the valid endpoints */
 					int first_valid = 0;
 					int last_valid = 0;
@@ -1055,7 +1055,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
 			/* CAUTION: If this is the "toolbar", then this will change on the first stroke */
 			p->sa = curarea;
 			p->ar = ar;
-			p->align_flag = &ts->gpencil_v3d_align;
+			p->align_flag = &ts->annotate_v3d_align;
 
 			if (ar->regiondata == NULL) {
 				p->status = GP_STATUS_ERROR;
@@ -1439,7 +1439,7 @@ static void gp_paint_strokeend(tGPsdata *p)
 
 		/* need to restore the original projection settings before packing up */
 		view3d_region_operator_needs_opengl(p->win, p->ar);
-		ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+		ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
 	}
 
 	/* check if doing eraser or not */
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 5f44cefc9aa..ce71a4f610f 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1399,7 +1399,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
 			tgpw.gpf = tgpil->interFrame;
 			tgpw.t_gpf = tgpil->interFrame;
 
-			tgpw.lthick = tgpil->gpl->thickness;
+			tgpw.lthick = tgpil->gpl->line_change;
 			tgpw.opacity = 1.0;
 			copy_v4_v4(tgpw.tintcolor, color);
 			tgpw.onion = true;
@@ -1456,7 +1456,7 @@ void ED_gp_draw_primitives(const bContext *C, tGPDprimitive *tgpi, const int typ
 			tgpw.gpf = tgpi->gpf;
 			tgpw.t_gpf = tgpi->gpf;
 
-			tgpw.lthick = tgpi->gpl->thickness;
+			tgpw.lthick = tgpi->gpl->line_change;
 			tgpw.opacity = 1.0;
 			copy_v4_v4(tgpw.tintcolor, color);
 			tgpw.onion = true;
@@ -1499,7 +1499,7 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
 		/* calculate parent position */


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list