GP: Enable Object Onion Skin by default

Now, the main switchis on, and the layer onion skin is off.
This commit is contained in:
Antonio Vazquez 2018-12-10 10:41:47 +01:00
parent 9def295d57
commit bcb5293b9b
4 changed files with 22 additions and 7 deletions

View File

@ -381,8 +381,6 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
/* thickness parameter represents "thickness change", not absolute thickness */
gpl->thickness = 0;
gpl->opacity = 1.0f;
/* onion-skinning settings */
gpl->onion_flag |= GP_LAYER_ONIONSKIN;
}
/* auto-name */
@ -415,7 +413,8 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
/* general flags */
gpd->flag |= GP_DATA_VIEWALIGN;
gpd->flag |= GP_DATA_STROKE_FORCE_RECALC;
/* always enable object onion skin swith */
gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
/* GP object specific settings */
ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);

View File

@ -186,7 +186,7 @@ static bool gpencil_batch_cache_valid(GpencilBatchCache *cache, bGPdata *gpd, in
else if (gpd->flag & GP_DATA_CACHE_IS_DIRTY) {
valid = false;
}
else if (gpd->flag & GP_DATA_SHOW_ONIONSKINS) {
else if (DRW_gpencil_onion_active(gpd)) {
/* if onion, set as dirty always
* This reduces performance, but avoid any crash in the multiple
* overlay and multiwindow options and keep all windows working

View File

@ -366,6 +366,20 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
return grp;
}
/* check if some onion is enabled */
bool DRW_gpencil_onion_active(bGPdata *gpd)
{
if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) == 0) {
return false;
}
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
return true;
}
}
return false;
}
/* create shading group for strokes */
DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob,
@ -1499,7 +1513,8 @@ void DRW_gpencil_populate_datablock(
bGPDframe *derived_gpf = NULL;
const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true;
const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion;
const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) &&
main_onion && DRW_gpencil_onion_active(gpd);
const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) : true;
const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
@ -1585,8 +1600,7 @@ void DRW_gpencil_populate_datablock(
/* draw onion skins */
if (!ID_IS_LINKED(&gpd->id)) {
if ((gpd->flag & GP_DATA_SHOW_ONIONSKINS) &&
(do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
if ((do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
((!playing) || (gpd->onion_flag & GP_ONION_GHOST_ALWAYS)) &&
(!cache_ob->is_dup_ob) && (gpd->id.us <= 1))
{

View File

@ -385,6 +385,8 @@ struct tGPencilObjectCache *gpencil_object_cache_add(
struct tGPencilObjectCache *cache_array, struct Object *ob,
int *gp_cache_size, int *gp_cache_used);
bool DRW_gpencil_onion_active(struct bGPdata *gpd);
/* shading groups cache functions */
struct GpencilBatchGroup *gpencil_group_cache_add(
struct GpencilBatchGroup *cache_array,