From edef141d0bf4a9fef986f57fdd7dec43ca6949bd Mon Sep 17 00:00:00 2001 From: Antonioya Date: Thu, 30 Aug 2018 10:17:29 +0200 Subject: [PATCH] GP: Add small offset to stroke over surface. This small offset helps to keep the stroke over the surface and avoid the stoke is "inside" the face of the surface. We could add this as a parameter in the UI, but after doing a lot of test, the valid values are very limited and don't worth the change, so a hardcoded value works fine. --- source/blender/editors/gpencil/gpencil_paint.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 4bd8c28a85c..ef70608d99c 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -369,6 +369,15 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { + + /* add small offset to keep stroke over the surface. + * This could be a UI parameter, but the value is too sensitive for + * the user to use it and don't improve the result. + */ + if (depth) { + *depth *= 0.99998f; + } + if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it