GPencil: New Simplify Tint option

This is useful to disable all layers tint in one step and it will be used for future operators.
This commit is contained in:
Antonio Vazquez 2019-09-10 17:37:27 +02:00
parent 8f55794c0e
commit 0174185e2f
5 changed files with 21 additions and 23 deletions

View File

@ -677,6 +677,7 @@ class RENDER_PT_simplify_greasepencil(RenderButtonsPanel, Panel):
col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
col.prop(rd, "simplify_gpencil_blend", text="Layers Blending")
col.prop(rd, "simplify_gpencil_tint", text="Layers Tinting")
col.prop(rd, "simplify_gpencil_view_fill")
sub = col.column()

View File

@ -58,6 +58,9 @@ struct MDeformVert;
#define GPENCIL_SIMPLIFY_BLEND(scene, playing) \
((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_BLEND)))
#define GPENCIL_SIMPLIFY_TINT(scene, playing) \
((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT)))
/* ------------ Grease-Pencil API ------------------ */

View File

@ -1922,6 +1922,7 @@ void gpencil_populate_multiedit(GPENCIL_e_data *e_data,
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
int cfra_eval = (int)DEG_get_ctime(draw_ctx->depsgraph);
GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra_eval);
@ -1937,39 +1938,23 @@ void gpencil_populate_multiedit(GPENCIL_e_data *e_data,
if (gpl->flag & GP_LAYER_HIDE) {
continue;
}
const float alpha = GPENCIL_SIMPLIFY_TINT(scene, playing) ? 0.0f : gpl->tintcolor[3];
const float tintcolor[4] = {gpl->tintcolor[0], gpl->tintcolor[1], gpl->tintcolor[2], alpha};
/* 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,
ob,
gpd,
gpl,
gpf,
gpl->opacity,
gpl->tintcolor,
false,
cache_ob);
gpencil_draw_strokes(
cache, e_data, vedata, ob, gpd, gpl, gpf, gpl->opacity, tintcolor, false, cache_ob);
}
}
}
else {
gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
if (gpf) {
gpencil_draw_strokes(cache,
e_data,
vedata,
ob,
gpd,
gpl,
gpf,
gpl->opacity,
gpl->tintcolor,
false,
cache_ob);
gpencil_draw_strokes(
cache, e_data, vedata, ob, gpd, gpl, gpf, gpl->opacity, tintcolor, false, cache_ob);
}
}
}
@ -2091,8 +2076,10 @@ void gpencil_populate_datablock(GPENCIL_e_data *e_data,
}
}
/* draw normal strokes */
const float alpha = GPENCIL_SIMPLIFY_TINT(scene, playing) ? 0.0f : gpl->tintcolor[3];
const float tintcolor[4] = {gpl->tintcolor[0], gpl->tintcolor[1], gpl->tintcolor[2], alpha};
gpencil_draw_strokes(
cache, e_data, vedata, ob, gpd, gpl, gpf_eval, opacity, gpl->tintcolor, false, cache_ob);
cache, e_data, vedata, ob, gpd, gpl, gpf_eval, opacity, tintcolor, false, cache_ob);
}
/* create batchs and shading groups */

View File

@ -2292,6 +2292,8 @@ typedef enum eGPencil_SimplifyFlags {
SIMPLIFY_GPENCIL_FX = (1 << 5),
/* Simplify layer blending */
SIMPLIFY_GPENCIL_BLEND = (1 << 6),
/* Simplify layer tint */
SIMPLIFY_GPENCIL_TINT = (1 << 7),
} eGPencil_SimplifyFlags;
/* ToolSettings.gpencil_*_align - Stroke Placement mode flags */

View File

@ -6341,6 +6341,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Layers Blending", "Do not display blend layers");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "simplify_gpencil_tint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_TINT);
RNA_def_property_ui_text(prop, "Layers Tinting", "Do not display layer tint");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* persistent data */
prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);