GP: Fix duplication when draw strokes in multiple windows
authorAntonioya <blendergit@gmail.com>
Sat, 20 Oct 2018 17:40:29 +0000 (19:40 +0200)
committerAntonioya <blendergit@gmail.com>
Sat, 20 Oct 2018 17:40:29 +0000 (19:40 +0200)
The stroke must be visible only in the current region and only visible when the stroke is completed.

source/blender/draw/engines/gpencil/gpencil_engine.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/makesdna/DNA_gpencil_types.h

index f371de066a93d9ec9ec3b1f580ebc3fd515cf710..71e3c6a22efe992d067323ee3096129c9a29452d 100644 (file)
@@ -579,8 +579,12 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
                        gpencil_add_draw_data(vedata, ob);
                }
 
-               /* draw current painting strokes */
-               if (draw_ctx->obact == ob) {
+               /* draw current painting strokes
+               * (only if region is equal to originated paint region)
+               */
+               if ((draw_ctx->obact == ob) &&
+                       ((gpd->runtime.ar == NULL) || (gpd->runtime.ar == draw_ctx->ar)))
+               {
                        DRW_gpencil_populate_buffer_strokes(&e_data, vedata, ts, ob);
                }
 
index 3650ae644fba648ed8a214ce038d9154797a5368..711f77c5890d025bda8676e40f7bd9fd513be341 100644 (file)
@@ -1875,6 +1875,9 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
        /* lock axis */
        p->lock_axis = ts->gp_sculpt.lock_axis;
 
+       /* region where paint was originated */
+       p->gpd->runtime.ar = CTX_wm_region(C);
+
        return 1;
 }
 
index b420c595c6e8708e950e21bdd3a97f49d73362c6..858008afd9102e7b7023228a8caac75f243ad8f7 100644 (file)
@@ -34,6 +34,7 @@
 #include "DNA_ID.h"
 #include "DNA_brush_types.h"
 
+struct ARegion;
 struct AnimData;
 struct CurveMapping;
 struct GHash;
@@ -306,6 +307,7 @@ typedef enum eGPDlayer_OnionFlag {
 
 /* Runtime temp data for bGPdata */
 typedef struct bGPdata_Runtime {
+       struct ARegion *ar;         /* last region where drawing was originated */
        void *sbuffer;                          /* stroke buffer (can hold GP_STROKE_BUFFER_MAX) */
 
        /* GP Object drawing */