GPencil: Fix unreported UV error when use subdivide modifier
authorAntonioya <blendergit@gmail.com>
Mon, 11 Mar 2019 09:42:39 +0000 (10:42 +0100)
committerAntonioya <blendergit@gmail.com>
Mon, 11 Mar 2019 09:42:39 +0000 (10:42 +0100)
When the subdivide modifier was used, the UV was not recalculated and the texture of the stroke was wrong.

source/blender/blenkernel/intern/gpencil_modifier.c
source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
source/blender/draw/engines/gpencil/gpencil_draw_utils.c

index bd83e93..5af0bd9 100644 (file)
@@ -425,9 +425,12 @@ void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer *g
 
                        if (mti && mti->deformStroke) {
                                mti->deformStroke(md, depsgraph, ob, gpl, gps);
-
+                               /* subdivide allways requires update */
+                               if (md->type == eGpencilModifierType_Subdiv) {
+                                       gps->flag |= GP_STROKE_RECALC_GEOMETRY;
+                               }
                                /* some modifiers could require a recalc of fill triangulation data */
-                               if (gpd->flag & GP_DATA_STROKE_FORCE_RECALC) {
+                               else if (gpd->flag & GP_DATA_STROKE_FORCE_RECALC) {
                                        if (ELEM(md->type,
                                                 eGpencilModifierType_Armature,
                                                 eGpencilModifierType_Hook,
index 4c69965..70e679d 100644 (file)
@@ -202,7 +202,6 @@ void DRW_gpencil_get_fill_geom(struct GpencilBatchCacheElem *be, Object *ob, bGP
        /* Calculate triangles cache for filling area (must be done only after changes) */
        if ((gps->flag & GP_STROKE_RECALC_GEOMETRY) || (gps->tot_triangles == 0) || (gps->triangles == NULL)) {
                DRW_gpencil_triangulate_stroke_fill(ob, gps);
-               ED_gpencil_calc_stroke_uv(ob, gps);
        }
 
        BLI_assert(gps->tot_triangles >= 1);
index a96d293..4875273 100644 (file)
@@ -1005,6 +1005,11 @@ static void gpencil_draw_strokes(
                                    ((gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
                                     (gpl->blend_mode == eGplBlendMode_Normal)))
                                {
+                                       /* recalc strokes uv (geometry be changed by modifiers) */
+                                       if (gps->flag & GP_STROKE_RECALC_GEOMETRY) {
+                                               ED_gpencil_calc_stroke_uv(ob, gps);
+                                       }
+
                                        gpencil_add_stroke_vertexdata(
                                                cache, ob, gpl, derived_gpf, gps,
                                                opacity, tintcolor, false, custonion);