Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-03-17 21:47:31 +0300
committerAntonioya <blendergit@gmail.com>2019-03-17 21:47:56 +0300
commit6577618d5bb93792c805e0c22e4de1a015ee25d5 (patch)
tree05d5056646b3aefd8be21bb1ff314e4373865683 /source/blender/editors/gpencil/drawgpencil.c
parent887d052e56a515145f4dd7433e49c91c5d149169 (diff)
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
Diffstat (limited to 'source/blender/editors/gpencil/drawgpencil.c')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c24
1 files changed, 15 insertions, 9 deletions
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.0f));
@@ -733,23 +736,22 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
/* first point for adjacency (not drawn) */
if (i == 0) {
gp_set_point_varying_color(points, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+
if ((cyclic) && (totpoints > 2)) {
+ immAttr1f(attr_id.thickness, max_ff((points + totpoints - 1)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 1)->x);
}
else {
+ immAttr1f(attr_id.thickness, max_ff((points + 1)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
}
- mul_v3_fl(fpt, -1.0f);
immVertex3fv(attr_id.pos, fpt);
}
/* set point */
gp_set_point_varying_color(pt, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+ immAttr1f(attr_id.thickness, max_ff(pt->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
immVertex3fv(attr_id.pos, fpt);
-
- curpressure = pt->pressure;
}
if (cyclic && totpoints > 2) {
@@ -765,10 +767,9 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
}
/* last adjacency point (not drawn) */
else {
- gp_set_point_varying_color(points + totpoints - 1, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+ gp_set_point_varying_color(points + totpoints - 2, ink, attr_id.color);
+ immAttr1f(attr_id.thickness, max_ff((points + totpoints - 2)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
- mul_v3_fl(fpt, -1.0f);
immVertex3fv(attr_id.pos, fpt);
}
@@ -1029,6 +1030,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* calculate thickness */
sthickness = gps->thickness + tgpw->lthick;
+ if (tgpw->is_fill_stroke) {
+ sthickness = (short)max_ii(1, sthickness / 2);
+ }
+
if (sthickness <= 0) {
continue;
}
@@ -1427,6 +1432,7 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
tgpw.winx = winx;
tgpw.winy = winy;
tgpw.dflag = dflag;
+ tgpw.is_fill_stroke = false;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* calculate parent position */