From 75919c9223431333d93b65f7dee4a39bc015832b Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 24 Apr 2019 10:45:08 +0200 Subject: GPencil: Add small offset to follow the drawing path for single points The offset added allows to generate a vector to determine direction. This direction will be used when rotate the object to rotate texture. The solution is not 100% perfect, but it's far better that having an unpredictable rotation. --- source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source') 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 ea33c004191..c1014bb5ca4 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c @@ -176,16 +176,20 @@ void DRW_gpencil_get_point_geom(GpencilBatchCacheElem *be, /* use previous point to determine stroke direction */ bGPDspoint *pt2 = NULL; + float fpt[3]; if (i == 0) { if (gps->totpoints > 1) { /* extrapolate a point before first point */ - float fpt[3]; pt2 = &gps->points[1]; interp_v3_v3v3(fpt, &pt2->x, &pt->x, 1.5f); GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt); } else { - GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, &pt->x); + /* add small offset to get a vector */ + copy_v3_v3(fpt, &pt->x); + fpt[0] += 0.00001f; + fpt[1] += 0.00001f; + GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt); } } else { -- cgit v1.2.3