[Bf-blender-cvs] [13fedec4abf] greasepencil-object: GP: Allow different cap shape in each extrem of the stroke
Antonioya
noreply at git.blender.org
Sat Jan 5 16:38:13 CET 2019
Commit: 13fedec4abff3e90eae7051d1489c0fbbdd9293f
Author: Antonioya
Date: Sat Jan 5 16:38:04 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB13fedec4abff3e90eae7051d1489c0fbbdd9293f
GP: Allow different cap shape in each extrem of the stroke
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_gpencil.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 0ec865683ac..1229a7cf09c 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -191,7 +191,7 @@ class GreasePencilStrokeEditPanel:
col.operator("gpencil.duplicate_move", text="Duplicate")
if is_3d_view:
col.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
- col.operator("gpencil.stroke_caps_set", text="Toggle Caps").type = 'TOGGLE'
+ col.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 1c15983e58e..b0fe98e4ff8 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3955,7 +3955,7 @@ class VIEW3D_MT_edit_gpencil(Menu):
layout.menu("VIEW3D_MT_edit_gpencil_delete")
layout.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
- layout.operator("gpencil.stroke_caps_set", text="Toggle Caps").type = 'TOGGLE'
+ layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type")
layout.separator()
@@ -5564,7 +5564,7 @@ class VIEW3D_MT_gpencil_edit_specials(Menu):
layout.operator("gpencil.stroke_join", text="Join").type = 'JOIN'
layout.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY'
layout.operator("gpencil.stroke_flip", text="Flip Direction")
- layout.operator("gpencil.stroke_caps_set", text="Toggle Caps").type = 'TOGGLE'
+ layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type")
layout.separator()
layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame")
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index f9e0fea223c..08e1b458127 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -387,8 +387,9 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
DRW_shgroup_uniform_int(grp, "color_type", &stl->shgroups[id].color_type, 1);
DRW_shgroup_uniform_float(grp, "pixfactor", &gpd->pixfactor, 1);
- stl->shgroups[id].caps_mode = ((gps) && (gps->flag & GP_STROKE_FLATCAPS)) ? 1 : 0;
- DRW_shgroup_uniform_int(grp, "caps_mode", &stl->shgroups[id].caps_mode, 1);
+ stl->shgroups[id].caps_mode[0] = ((gps) && (gps->flag & GP_STROKE_FLATCAPS_START)) ? 1 : 0;
+ stl->shgroups[id].caps_mode[1] = ((gps) && (gps->flag & GP_STROKE_FLATCAPS_END)) ? 1 : 0;
+ DRW_shgroup_uniform_int(grp, "caps_mode", &stl->shgroups[id].caps_mode[0], 2);
}
else {
stl->storage->obj_scale = 1.0f;
@@ -403,8 +404,8 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
else {
DRW_shgroup_uniform_float(grp, "pixfactor", &stl->storage->pixfactor, 1);
}
- const int zero = 0;
- DRW_shgroup_uniform_int(grp, "caps_mode", &zero, 1);
+ const int zero[2] = { 0, 0 };
+ DRW_shgroup_uniform_int(grp, "caps_mode", &zero[0], 2);
}
if ((gpd) && (id > -1)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 0235ee06f9c..c560321df9f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -114,7 +114,7 @@ typedef struct GPENCIL_shgroup {
int texture_clamp;
int fill_style;
int keep_size;
- int caps_mode;
+ int caps_mode[2];
float obj_scale;
} GPENCIL_shgroup;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index 471b6d96f1d..48c37303082 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -2,7 +2,7 @@ uniform mat4 ModelViewProjectionMatrix;
uniform vec2 Viewport;
uniform int xraymode;
uniform int color_type;
-uniform int caps_mode;
+uniform int caps_mode[2];
layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 13) out;
@@ -162,7 +162,7 @@ void main(void)
}
/* generate the start endcap (alpha < 0 used as endcap flag)*/
- if ((caps_mode != GPENCIL_FLATCAP) && is_equal(P0,P2) &&
+ if ((caps_mode[0] != GPENCIL_FLATCAP) && is_equal(P0,P2) &&
(color_type == GPENCIL_COLOR_SOLID))
{
mTexCoord = vec2(2, 1);
@@ -204,7 +204,7 @@ void main(void)
EmitVertex();
/* generate the end endcap (alpha < 0 used as endcap flag)*/
- if ((caps_mode != GPENCIL_FLATCAP) && is_equal(P1,P3) &&
+ if ((caps_mode[1] != GPENCIL_FLATCAP) && is_equal(P1,P3) &&
(color_type == GPENCIL_COLOR_SOLID) && (finaluvdata[2].x > 0))
{
mTexCoord = vec2(finaluvdata[2].x, 2);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index e7acfbbd7cc..1fcf6a1248d 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2518,9 +2518,10 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot)
/* ******************* Flat Stroke Caps ************************** */
enum {
- GP_STROKE_CAPS_ROUND = 0,
- GP_STROKE_CAPS_FLAT = 1,
- GP_STROKE_CAPS_TOGGLE = 2
+ GP_STROKE_CAPS_TOGGLE_BOTH = 0,
+ GP_STROKE_CAPS_TOGGLE_START = 1,
+ GP_STROKE_CAPS_TOGGLE_END = 2,
+ GP_STROKE_CAPS_TOGGLE_DEFAULT = 3
};
static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
@@ -2551,17 +2552,19 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
continue;
switch (type) {
- case GP_STROKE_CAPS_ROUND:
- /* Disable */
- gps->flag &= ~GP_STROKE_FLATCAPS;
+ case GP_STROKE_CAPS_TOGGLE_BOTH:
+ gps->flag ^= GP_STROKE_FLATCAPS_START;
+ gps->flag ^= GP_STROKE_FLATCAPS_END;
break;
- case GP_STROKE_CAPS_FLAT:
- /* Enable */
- gps->flag |= GP_STROKE_FLATCAPS;
+ case GP_STROKE_CAPS_TOGGLE_START:
+ gps->flag ^= GP_STROKE_FLATCAPS_START;
break;
- case GP_STROKE_CAPS_TOGGLE:
- /* Just toggle flag... */
- gps->flag ^= GP_STROKE_FLATCAPS;
+ case GP_STROKE_CAPS_TOGGLE_END:
+ gps->flag ^= GP_STROKE_FLATCAPS_END;
+ break;
+ case GP_STROKE_CAPS_TOGGLE_DEFAULT:
+ gps->flag &= ~GP_STROKE_FLATCAPS_START;
+ gps->flag &= ~GP_STROKE_FLATCAPS_END;
break;
default:
BLI_assert(0);
@@ -2583,10 +2586,11 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
*/
void GPENCIL_OT_stroke_caps_set(wmOperatorType *ot)
{
- static const EnumPropertyItem cyclic_type[] = {
- {GP_STROKE_CAPS_ROUND, "ROUND", 0, "Rounded caps", ""},
- {GP_STROKE_CAPS_FLAT, "FLAT", 0, "Flat caps", ""},
- {GP_STROKE_CAPS_TOGGLE, "TOGGLE", 0, "Toggle", ""},
+ static const EnumPropertyItem toggle_type[] = {
+ {GP_STROKE_CAPS_TOGGLE_BOTH, "TOGGLE", 0, "Both", ""},
+ {GP_STROKE_CAPS_TOGGLE_START, "START", 0, "Start", ""},
+ {GP_STROKE_CAPS_TOGGLE_END, "END", 0, "End", ""},
+ {GP_STROKE_CAPS_TOGGLE_DEFAULT, "TOGGLE", 0, "Default", "Set as default rounded"},
{0, NULL, 0, NULL, NULL}
};
@@ -2603,7 +2607,7 @@ void GPENCIL_OT_stroke_caps_set(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", cyclic_type, GP_STROKE_CAPS_TOGGLE, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", toggle_type, GP_STROKE_CAPS_TOGGLE_BOTH, "Type", "");
}
/* ******************* Stroke join ************************** */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index a297662706c..78db7466575 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -203,7 +203,8 @@ typedef enum eGPDstroke_Flag {
/* Flag used to indicate that stroke is used for fill close and must use fill color for stroke and no fill area */
GP_STROKE_NOFILL = (1 << 8),
/* Flag used to indicate if the stroke has flat caps (by default rounded) */
- GP_STROKE_FLATCAPS = (1 << 9),
+ GP_STROKE_FLATCAPS_START = (1 << 9),
+ GP_STROKE_FLATCAPS_END = (1 << 10),
/* only for use with stroke-buffer (while drawing eraser) */
GP_STROKE_ERASER = (1 << 15)
} eGPDstroke_Flag;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 12fa320ae9c..615a4fedf1c 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -969,8 +969,13 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_GPencil_update");
/* Enable Flat Caps mode */
- prop = RNA_def_property(srna, "is_flat_caps", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_FLATCAPS);
+ prop = RNA_def_property(srna, "is_start_flat_caps", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_FLATCAPS_START);
+ RNA_def_property_ui_text(prop, "Flat", "Stroke caps are flat (rounded by default)");
+ RNA_def_property_update(prop, 0, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "is_end_flat_caps", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_FLATCAPS_END);
RNA_def_property_ui_text(prop, "Flat", "Stroke caps are flat (rounded by default)");
RNA_def_property_update(prop, 0, "rna_GPencil_update");
More information about the Bf-blender-cvs
mailing list