[Bf-blender-cvs] [96e33c428e1] greasepencil-object: Add simplify level

Antonio Vazquez noreply at git.blender.org
Thu Jan 4 11:03:09 CET 2018


Commit: 96e33c428e1e8efada517083be96b1b6a4077b6d
Author: Antonio Vazquez
Date:   Thu Jan 4 11:03:03 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB96e33c428e1e8efada517083be96b1b6a4077b6d

Add simplify level

Added a new parameter to define the number of times the new fill stroke is simplified using fixed simplify algorithm.

This simplify reduces the number of points but also the precision of the filling shape for large values.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/makesdna/DNA_gpencil_types.h
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 857d4448975..ddd2cfb898f 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -386,6 +386,9 @@ class GreasePencilBrushPanel:
                 row = layout.row(align=True)
                 row.prop(brush, "fill_leak", text="Leak Size")
 
+                row = layout.row(align=True)
+                row.prop(brush, "fill_simplyfy_lvl", text="Simplify")
+
                 row = layout.row(align=True)
                 row.prop(brush, "fill_hide", text="Hide Transparent Lines")
                 row = layout.row(align=True)
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index cb856a3785e..7e2ca2656aa 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -754,6 +754,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
 	brush->draw_sensitivity = 1.0f;
 	brush->fill_leak = 3;
 	brush->fill_threshold = 0.1f;
+	brush->fill_simplylvl = 1;
 
 	brush->draw_strength = 1.0f;
 	copy_v3_v3(brush->curcolor, curcolor);
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index ca093ed9539..6b7e85ffab8 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -721,13 +721,15 @@ static void gpencil_stroke_from_stack(tGPDfill *tgpf)
 	}
 
 	/* if parented change position relative to parent object */
-	for (int i = 0; i < totpoints; i++) {
-		pt = &gps->points[i];
+	for (int a = 0; a < totpoints; a++) {
+		pt = &gps->points[a];
 		gp_apply_parent_point(tgpf->ob, tgpf->gpd, tgpf->gpl, pt);
 	}
 
 	/* simplify stroke */
-	BKE_gpencil_simplify_fixed(tgpf->gpl, gps);
+	for (int b = 0; b < tgpf->fill_simplylvl; b++) {
+		BKE_gpencil_simplify_fixed(tgpf->gpl, gps);
+	}
 }
 
 /* ----------------------- */
@@ -818,6 +820,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *op)
 	tgpf->flag = brush->flag;
 	tgpf->fill_leak = brush->fill_leak;
 	tgpf->fill_threshold = brush->fill_threshold;
+	tgpf->fill_simplylvl = brush->fill_simplylvl;
 
 	/* init undo */
 	gpencil_undo_init(tgpf->gpd);
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index e60a1e45cd8..8f8248148fc 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -156,6 +156,7 @@ typedef struct tGPDfill {
 
 	short fill_leak;                    /* number of pixel to consider the leak is too small (x 2) */
 	float fill_threshold;               /* factor for transparency */
+	int fill_simplylvl;                 /* number of simplify steps */
 
 	struct Image *ima;					/* temp image */
 	struct BLI_Stack *stack;			/* temp points data */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0f0249fc037..c628a57718d 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -126,6 +126,8 @@ typedef struct bGPDbrush {
 
 	short fill_leak;          /* number of pixel to consider the leak is too small (x 2) */
 	float fill_threshold;     /* factor for transparency */
+	int   fill_simplylvl;     /* number of simplify steps */
+	char pad[4];
 } bGPDbrush;
 
 /* bGPDbrush->flag */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 3cd54b11707..2acb532afcf 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2312,6 +2312,14 @@ static void rna_def_gpencil_brush(BlenderRNA *brna)
 		"Size in pixels to consider the leak closed");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+	/* fill simplify steps */
+	prop = RNA_def_property(srna, "fill_simplyfy_lvl", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "fill_simplylvl");
+	RNA_def_property_range(prop, 0, 10);
+	RNA_def_property_ui_text(prop, "Simplify",
+		"Number of simplify steps (large values reduce fill accuracy)");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
 	/* Flags */
 	prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE);



More information about the Bf-blender-cvs mailing list