Commit: c1518938d86ff6b162edd1d5e885811cdbbd2a28
Author: Antonio Vazquez
Date:   Tue Aug 29 11:46:05 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc1518938d86ff6b162edd1d5e885811cdbbd2a28

Draw several frames when multiedit is enabled

===================================================================

M       source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M       source/blender/draw/engines/gpencil/gpencil_engine.c
M       source/blender/draw/engines/gpencil/gpencil_engine.h

===================================================================

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 7fab3c5a347..3ab62fd5be8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -688,18 +688,19 @@ static void gpencil_draw_strokes(GpencilBatchCache 
*cache, GPENCIL_e_data *e_dat
        DRWShadingGroup *fillgrp;
        DRWShadingGroup *strokegrp;
        float viewmatrix[4][4];
+       bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
 
        /* get parent matrix and save as static data */
        ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
        copy_m4_m4(derived_gpf->viewmatrix, viewmatrix);
 
        /* initialization steps */
-       if ((cache->is_dirty) && (ob->modifiers.first)) {
+       if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
                BKE_gpencil_reset_modifiers(ob);
        }
 
        /* apply geometry modifiers */
-       if ((cache->is_dirty) && (ob->modifiers.first)) {
+       if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
                if (BKE_gpencil_has_geometry_modifiers(ob)) {
                        BKE_gpencil_geometry_modifiers(ob, gpl, derived_gpf);
                }
@@ -751,7 +752,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, 
GPENCIL_e_data *e_dat
                strokegrp = stl->shgroups[id].shgrps_stroke;
 
                /* apply modifiers (only modify geometry, but not create ) */
-               if ((cache->is_dirty) && (ob->modifiers.first)) {
+               if ((cache->is_dirty) && (ob->modifiers.first) && 
(!is_multiedit)) {
                        BKE_gpencil_stroke_modifiers(ob, gpl, derived_gpf, gps);
                }
                /* fill */
@@ -923,6 +924,47 @@ static void gpencil_draw_onionskins(GpencilBatchCache 
*cache, GPENCIL_e_data *e_
        }
 }
 
+/* populate a datablock for multiedit (no onions, no modifiers) */
+void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data, void *vedata, 
Scene *scene, Object *ob, ToolSettings *ts, bGPdata *gpd)
+{
+       ListBase tmp_frames = { NULL, NULL };
+       bGPDframe *gpf = NULL;
+
+       GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
+       GpencilBatchCache *cache = gpencil_batch_cache_get(ob, CFRA);
+       cache->cache_idx = 0;
+
+       /* check if playing animation */
+       bool playing = (bool)stl->storage->playing;
+
+       /* draw strokes */
+       for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+               /* don't draw layer if hidden */
+               if (gpl->flag & GP_LAYER_HIDE)
+                       continue;
+
+               /* list of frames to draw */
+               if (!playing) {
+                       for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+                               if ((gpf == gpl->actframe) || (gpf->flag & 
GP_FRAME_SELECT)) {
+                                       gpencil_draw_strokes(cache, e_data, 
vedata, ts, ob, gpd, gpl, gpf, gpf,
+                                               gpl->opacity, gpl->tintcolor, 
false);
+                               }
+                       }
+               }
+               else {
+                       gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
+                       if (gpf) {
+                               gpencil_draw_strokes(cache, e_data, vedata, ts, 
ob, gpd, gpl, gpf, gpf,
+                                       gpl->opacity, gpl->tintcolor, false);
+                       }
+               }
+
+       }
+
+       cache->is_dirty = false;
+}
+
 /* helper for populate a complete grease pencil datablock */
 void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, 
Scene *scene, Object *ob, ToolSettings *ts, bGPdata *gpd)
 {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index f4c04afca05..17fae17e9fb 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -37,6 +37,7 @@
 #include "gpencil_engine.h"
 
 #include "ED_screen.h"
+#include "ED_gpencil.h"
 
 extern char datatoc_gpencil_fill_vert_glsl[];
 extern char datatoc_gpencil_fill_frag_glsl[];
@@ -327,6 +328,7 @@ static void GPENCIL_cache_finish(void *vedata)
        Scene *scene = draw_ctx->scene;
        ToolSettings *ts = scene->toolsettings;
        tGPencilObjectCache *cache;
+       bool is_multiedit = false; 
 
        /* Draw all pending objects */
        if (stl->g_data->gp_cache_used > 0) {
@@ -336,7 +338,13 @@ static void GPENCIL_cache_finish(void *vedata)
                        stl->g_data->gp_object_cache[i].init_grp = 
stl->storage->shgroup_id;
 
                        /* fill shading groups */
-                       DRW_gpencil_populate_datablock(&e_data, vedata, scene, 
ob, ts, ob->gpd);
+                       is_multiedit = 
(bool)GPENCIL_MULTIEDIT_SESSIONS_ON(ob->gpd);
+                       if (!is_multiedit) {
+                               DRW_gpencil_populate_datablock(&e_data, vedata, 
scene, ob, ts, ob->gpd);
+                       }
+                       else {
+                               DRW_gpencil_populate_multiedit(&e_data, vedata, 
scene, ob, ts, ob->gpd);
+                       }
 
                        /* save end shading group */
                        stl->g_data->gp_object_cache[i].end_grp = 
stl->storage->shgroup_id - 1;
@@ -346,7 +354,7 @@ static void GPENCIL_cache_finish(void *vedata)
                        }
                        /* VFX pass */
                        cache = &stl->g_data->gp_object_cache[i];
-                       if (ob->modifiers.first) {
+                       if ((!is_multiedit) && (ob->modifiers.first)) {
                                DRW_gpencil_vfx_modifiers(i, &e_data, vedata, 
ob, cache);
                        }
                }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index b1a68d38198..3f60ba9f98c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -243,6 +243,7 @@ struct DRWShadingGroup 
*DRW_gpencil_shgroup_drawing_fill_create(struct DRWPass *
 
 void DRW_gpencil_populate_datablock(struct GPENCIL_e_data *e_data, void 
*vedata, struct Scene *scene, struct Object *ob, struct ToolSettings *ts, 
struct bGPdata *gpd);
 void DRW_gpencil_populate_buffer_strokes(void *vedata, struct ToolSettings 
*ts, struct bGPdata *gpd);
+void DRW_gpencil_populate_multiedit(struct GPENCIL_e_data *e_data, void 
*vedata, struct Scene *scene, struct Object *ob, struct ToolSettings *ts, 
struct bGPdata *gpd);
 
 struct Gwn_Batch *DRW_gpencil_get_point_geom(struct bGPDstroke *gps, short 
thickness, const float ink[4]);
 struct Gwn_Batch *DRW_gpencil_get_stroke_geom(struct bGPDframe *gpf, struct 
bGPDstroke *gps, short thickness, const float ink[4]);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to