[Bf-blender-cvs] [2245dc80daa] greasepencil-object: Fix error with fill and modifiers
Antonio Vazquez
noreply at git.blender.org
Mon Jul 17 13:40:58 CEST 2017
Commit: 2245dc80daa80b303704a9da6a4d99ad986881c3
Author: Antonio Vazquez
Date: Mon Jul 17 13:08:15 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB2245dc80daa80b303704a9da6a4d99ad986881c3
Fix error with fill and modifiers
The modifiers must be evaluated before to affect stroke and fill
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
===================================================================
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 20999e09271..a4ad83bc5df 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -500,7 +500,6 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
float tcolor[4];
float ink[4];
short sthickness;
- bool is_edit = (bool)(gpd->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE));
/* set color using palette, tint color and opacity */
if (!onion) {
@@ -518,35 +517,14 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
}
}
- if (cache->is_dirty) {
- /* apply modifiers */
- bGPDstroke *gps_mod;
- if ((ob->modifiers.first) && (!is_edit)) {
- gps_mod = MEM_dupallocN(gps);
- gps_mod->points = MEM_dupallocN(gps->points);
- gps_mod->triangles = MEM_dupallocN(gps->triangles);
- gps_mod->palcolor = MEM_dupallocN(gps->palcolor);
- ED_gpencil_stroke_modifiers(ob, gpl, gps_mod);
- }
- else {
- gps_mod = gps;
- }
- sthickness = gps_mod->thickness + gpl->thickness;
- CLAMP_MIN(sthickness, 1);
- gpencil_batch_cache_check_free_slots(gpd);
- if ((gps_mod->totpoints > 1) && (gps_mod->palcolor->stroke_style != STROKE_STYLE_VOLUMETRIC)) {
- cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_stroke_geom(gpf, gps_mod, sthickness, ink);
- }
- else {
- cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_point_geom(gps_mod, sthickness, ink);
- }
- /* free modifier temp data */
- if ((ob->modifiers.first) && (!is_edit)) {
- MEM_SAFE_FREE(gps_mod->triangles);
- MEM_SAFE_FREE(gps_mod->points);
- MEM_SAFE_FREE(gps_mod->palcolor);
- MEM_SAFE_FREE(gps_mod);
- }
+ sthickness = gps->thickness + gpl->thickness;
+ CLAMP_MIN(sthickness, 1);
+ gpencil_batch_cache_check_free_slots(gpd);
+ if ((gps->totpoints > 1) && (gps->palcolor->stroke_style != STROKE_STYLE_VOLUMETRIC)) {
+ cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink);
+ }
+ else {
+ cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_point_geom(gps, sthickness, ink);
}
DRW_shgroup_call_add(strokegrp, cache->batch_stroke[cache->cache_idx], gpf->viewmatrix);
}
@@ -584,7 +562,10 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
DRWShadingGroup *fillgrp;
DRWShadingGroup *strokegrp;
+ bGPDstroke *gps_mod;
float viewmatrix[4][4];
+ bool is_edit = (bool)(gpd->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE));
+ bool is_mod = false;
/* get parent matrix and save as static data */
ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
@@ -614,7 +595,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
if (gps->totpoints > 2) {
stl->shgroups[id].shgrps_fill = DRW_gpencil_shgroup_fill_create(e_data, vedata, psl->stroke_pass, e_data->gpencil_fill_sh, gpd, gps->palcolor, id);
}
- else {
+ else {
stl->shgroups[id].shgrps_fill = NULL;
}
stl->shgroups[id].shgrps_stroke = DRW_gpencil_shgroup_stroke_create(e_data, vedata, psl->stroke_pass, e_data->gpencil_stroke_sh, ob, gpd, gps->palcolor, id);
@@ -627,17 +608,38 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
fillgrp = stl->shgroups[id].shgrps_fill;
strokegrp = stl->shgroups[id].shgrps_stroke;
+
+ /* apply modifiers */
+ if ((cache->is_dirty) && (ob->modifiers.first) && (!is_edit)) {
+ gps_mod = MEM_dupallocN(gps);
+ gps_mod->points = MEM_dupallocN(gps->points);
+ gps_mod->triangles = MEM_dupallocN(gps->triangles);
+ gps_mod->palcolor = MEM_dupallocN(gps->palcolor);
+ ED_gpencil_stroke_modifiers(ob, gpl, gps_mod);
+ is_mod = true;
+ }
+ else {
+ gps_mod = gps;
+ is_mod = false;
+ }
/* fill */
if (fillgrp) {
- gpencil_add_fill_shgroup(cache, fillgrp, gpd, gpl, gpf, gps, tintcolor, onion, custonion);
+ gpencil_add_fill_shgroup(cache, fillgrp, gpd, gpl, gpf, gps_mod, tintcolor, onion, custonion);
}
/* stroke */
- gpencil_add_stroke_shgroup(cache, strokegrp, ob, gpd, gpl, gpf, gps, opacity, tintcolor, onion, custonion);
+ gpencil_add_stroke_shgroup(cache, strokegrp, ob, gpd, gpl, gpf, gps_mod, opacity, tintcolor, onion, custonion);
/* edit points (only in edit mode) */
if (!onion) {
gpencil_add_editpoints_shgroup(stl, cache, ts, ob, gpd, gpl, gpf, gps);
}
+ /* free modifier temp data */
+ if (is_mod) {
+ MEM_SAFE_FREE(gps_mod->triangles);
+ MEM_SAFE_FREE(gps_mod->points);
+ MEM_SAFE_FREE(gps_mod->palcolor);
+ MEM_SAFE_FREE(gps_mod);
+ }
++cache->cache_idx;
}
More information about the Bf-blender-cvs
mailing list