From a8731718a1c476ed0d7a95c2c25cb9da7e90e6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 24 Oct 2022 12:55:24 +0200 Subject: GPencil: Fix regressions introduced in rB0ee9282b5c51 Batching was broken / disabled and starting indices were wrong. --- source/blender/draw/engines/gpencil/gpencil_engine.c | 8 ++++---- source/blender/draw/intern/draw_cache_impl_gpencil.cc | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 956830e6b4c..14a3c5a8e7e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -346,7 +346,7 @@ typedef struct gpIterPopulateData { int vfirst, vcount; } gpIterPopulateData; -#define DISABLE_BATCHING 1 +#define DISABLE_BATCHING 0 static void gpencil_drawcall_flush(gpIterPopulateData *iter) { @@ -382,7 +382,7 @@ static void gpencil_drawcall_add( int last = iter->vfirst + iter->vcount; /* Interrupt draw-call grouping if the sequence is not consecutive. */ - if ((geom != iter->geom) || (v_first - last > 3)) { + if ((geom != iter->geom) || (v_first - last > 0)) { gpencil_drawcall_flush(iter); } iter->geom = geom; @@ -540,8 +540,8 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, if (show_stroke) { int vfirst = gps->runtime.stroke_start * 3; - /* Include "potential" cyclic vertex (see shader). */ - int vcount = (gps->totpoints + 1) * 2 * 3; + bool is_cyclic = ((gps->flag & GP_STROKE_CYCLIC) != 0) && (gps->totpoints > 2); + int vcount = (gps->totpoints + (int)is_cyclic) * 2 * 3; gpencil_drawcall_add(iter, geom, false, vfirst, vcount); } diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.cc b/source/blender/draw/intern/draw_cache_impl_gpencil.cc index 1a77793bb5b..bc01ab24947 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.cc @@ -653,6 +653,9 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_stroke, bool do_ MEM_freeN(tpoints2d); } + gps->runtime.stroke_start = do_fill ? gps->tot_triangles : 0; + gps->runtime.fill_start = 0; + gps->runtime.vertex_start = 0; /* Fill buffers with data. */ gpencil_buffer_add_stroke(&ibo_builder, verts, cols, gps); -- cgit v1.2.3