[Bf-blender-cvs] [6577618d5bb] master: GPencil: Changes in Fill and new 3D Cursor View Plane

Antonioya noreply at git.blender.org
Sun Mar 17 19:48:00 CET 2019


Commit: 6577618d5bb93792c805e0c22e4de1a015ee25d5
Author: Antonioya
Date:   Sun Mar 17 19:47:31 2019 +0100
Branches: master
https://developer.blender.org/rB6577618d5bb93792c805e0c22e4de1a015ee25d5

GPencil: Changes in Fill and new 3D Cursor View Plane

This commit groups several options that were tested in grease pencil branch:

- Changes to fill algorithms and improves, specially in small areas and stroke corners.
  New options has been added in order to define how the fill is working and internally there are optimizations in detect the small areas in the extremes.

  Kudos to @charlie for coding this fill improvements.

- New 3D cursor view plane option.

  Now it's possible to lock the drawing plane to the 3D cursor and use the 3D cursor orientation. This allows more flexibility when you are drawing and reduce the need to create geometry to draw over surfaces.

- Canvas Grid now can be locked to 3D cursor.
- New option to reproject stroke using 3D cursor.
- Small tweaks and fixes.

Changes reviewed by @pepeland and @mendio

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
M	source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 1a1f0fa3fb7..ac63948d18a 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -393,7 +393,7 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
     layout.row().prop(brush, "direction", expand=True, **({"text": ""} if compact else {}))
 
 
-def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False):
+def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=True):
     gp_settings = brush.gpencil_settings
 
     # Brush details
@@ -412,24 +412,15 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
             row = layout.row(align=True)
             row.prop(gp_settings, "eraser_thickness_factor")
     elif brush.gpencil_tool == 'FILL':
-        row = layout.column(align=True)
+        row = layout.row(align=True)
         row.prop(gp_settings, "fill_leak", text="Leak Size")
-        row.separator()
-        row = layout.column(align=True)
+        row = layout.row(align=True)
         row.prop(brush, "size", text="Thickness")
-        row = layout.column(align=True)
+        row = layout.row(align=True)
         row.prop(gp_settings, "fill_simplify_level", text="Simplify")
-
         row = layout.row(align=True)
-        row.prop(gp_settings, "fill_draw_mode", text="Boundary Draw Mode")
+        row.prop(gp_settings, "fill_draw_mode", text="Boundary")
         row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
-
-        row = layout.column(align=True)
-        row.enabled = gp_settings.fill_draw_mode != 'STROKE'
-        row.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
-        sub = layout.row(align=True)
-        sub.enabled = not gp_settings.show_fill
-        sub.prop(gp_settings, "fill_threshold", text="Threshold")
     else:  # brush.gpencil_tool == 'DRAW':
         row = layout.row(align=True)
         row.prop(brush, "size", text="Radius")
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 4cda2678e33..73aa59a2693 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -362,6 +362,15 @@ class _draw_left_context_mode:
                     panel="TOPBAR_PT_gpencil_primitive",
                     text="Thickness Profile"
                 )
+                
+            if brush.gpencil_tool == 'FILL':
+                settings = context.tool_settings.gpencil_sculpt
+                row = layout.row(align=True)
+                sub = row.row(align=True)
+                sub.popover(
+                    panel="TOPBAR_PT_gpencil_fill",
+                    text="Fill Options"
+                )
 
         @staticmethod
         def SCULPT_GPENCIL(context, layout, tool):
@@ -1036,6 +1045,28 @@ class TOPBAR_PT_gpencil_primitive(Panel):
         # Curve
         layout.template_curve_mapping(settings, "thickness_primitive_curve", brush=True)
 
+# Grease Pencil Fill
+class TOPBAR_PT_gpencil_fill(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'HEADER'
+    bl_label = "Advanced"
+
+    @staticmethod
+    def draw(self, context):
+        paint = context.tool_settings.gpencil_paint
+        brush = paint.brush
+        gp_settings = brush.gpencil_settings
+
+        layout = self.layout
+        # Fill
+        row = layout.row(align=True)
+        row.prop(gp_settings, "fill_factor", text="Resolution")
+        if gp_settings.fill_draw_mode != 'STROKE':
+            row = layout.row(align=True)
+            row.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
+            row = layout.row(align=True)
+            row.prop(gp_settings, "fill_threshold", text="Threshold")
+
 
 classes = (
     TOPBAR_HT_upper_bar,
@@ -1058,6 +1089,7 @@ classes = (
     TOPBAR_PT_active_tool,
     TOPBAR_PT_gpencil_layers,
     TOPBAR_PT_gpencil_primitive,
+    TOPBAR_PT_gpencil_fill,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 2e68c88c5f7..c959504f84f 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -480,6 +480,7 @@ void BKE_brush_gpencil_presets(bContext *C)
 	brush->gpencil_settings->fill_leak = 3;
 	brush->gpencil_settings->fill_threshold = 0.1f;
 	brush->gpencil_settings->fill_simplylvl = 1;
+	brush->gpencil_settings->fill_factor = 1;
 	brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL;
 	brush->gpencil_tool = GPAINT_TOOL_FILL;
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 1f3874e70ba..b72a6ebebbd 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -270,7 +270,7 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
 
 	for (int i = 0; i < totpoints; i++, tpt++) {
 		ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
-		ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
+		ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
 
 		/* first point for adjacency (not drawn) */
 		if (i == 0) {
@@ -361,7 +361,7 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
 
 	for (int i = 0; i < totpoints; i++, tpt++) {
 		ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
-		ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
+		ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
 
 		/* set point */
 		gpencil_set_stroke_point(
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index a50b4fac15c..2710ecc5e5b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -506,7 +506,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
 	DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
 
 	/* avoid wrong values */
-	if ((gpd) && (gpd->pixfactor == 0)) {
+	if ((gpd) && (gpd->pixfactor == 0.0f)) {
 		gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
 	}
 
@@ -627,7 +627,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
 	DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
 
 	/* avoid wrong values */
-	if ((gpd) && (gpd->pixfactor == 0)) {
+	if ((gpd) && (gpd->pixfactor == 0.0f)) {
 		gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
 	}
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 5f2652b0bfb..7fbae5e98ea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -582,6 +582,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
 	Scene *scene = draw_ctx->scene;
 	ToolSettings *ts = scene->toolsettings;
 	View3D *v3d = draw_ctx->v3d;
+	const View3DCursor *cursor = &scene->cursor;
 
 	if (ob->type == OB_GPENCIL && ob->data) {
 		bGPdata *gpd = (bGPdata *)ob->data;
@@ -626,7 +627,9 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
 		if ((v3d) &&
 		    ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) &&
 		    (v3d->gp_flag & V3D_GP_SHOW_GRID) &&
-		    (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact))
+		    (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact) &&
+			((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0) &&
+			((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) == 0))
 		{
 			GPU_BATCH_DISCARD_SAFE(e_data.batch_grid);
 			MEM_SAFE_FREE(e_data.batch_grid);
@@ -634,13 +637,36 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
 			e_data.batch_grid = DRW_gpencil_get_grid(ob);
 
 			/* define grid orientation */
-			if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_VIEW) {
-				copy_m4_m4(stl->storage->grid_matrix, ob->obmat);
+			switch (ts->gp_sculpt.lock_axis) {
+				case GP_LOCKAXIS_VIEW:
+				{
+					/* align always to view */
+					invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat);
+					/* copy ob location */
+					copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]);
+					break;
+				}
+				case GP_LOCKAXIS_CURSOR:
+				{
+					float scale[3] = { 1.0f, 1.0f, 1.0f };
+					loc_eul_size_to_mat4(stl->storage->grid_matrix,
+										cursor->location,
+										cursor->rotation_euler,
+										scale);
+					break;
+				}
+				default:
+				{
+					copy_m4_m4(stl->storage->grid_matrix, ob->obmat);
+					break;
+				}
+			}
+
+			/* Move the origin to Object or Cursor */
+			if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+				copy_v3_v3(stl->storage->grid_matrix[3], cursor->location);
 			}
 			else {
-				/* align always to view */
-				invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat);
-				/* copy ob location */
 				copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]);
 			}
 
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 1ae3176d393..ebe0fa61b21 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -720,9 +720,12 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
 	immUniform1f("objscale", obj_scale);
 	int keep_size = (int)((tgpw->gpd) && (tgpw->gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));
 	immUniform1i("keep_size", keep_size);
-	immUniform1i("pixfactor", tgpw->gpd->pixfactor);
+	immUniform1f("pixfactor", tgpw->gpd->pixfactor);
 	/* xray mode always to 3D space to avoid wrong zdepth calculation (T60051) */
 	immUniform1i("xraymode", GP_XRAY_3DSPACE);
+	immUniform1i("caps_start", (int)tgpw->gps->caps[0]);
+	immUniform1i("caps_end", (int)tgpw->gps->caps[1]);
+	immUniform1i("fill_stroke", (int)tgpw->is_fill_stroke);
 
 	/* draw stroke curve */
 	GPU_line_width(max_ff(curpressure * thickness, 1.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list