From e1a66201da2595b8d5afd7072a1f3730ca34d04a Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 24 Oct 2018 11:02:52 +0200 Subject: GP: Add layer pass index to time modifier --- .../blender/gpencil_modifiers/intern/MOD_gpenciltime.c | 16 +++++++++++++++- source/blender/makesdna/DNA_gpencil_modifier_types.h | 3 +++ source/blender/makesdna/DNA_gpencil_types.h | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 6 ++++++ source/blender/makesrna/intern/rna_gpencil_modifier.c | 11 +++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c index 0096c6c00d5..cb7e508e3db 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c @@ -71,7 +71,8 @@ static int remapTime( TimeGpencilModifierData *mmd = (TimeGpencilModifierData *)md; const int sfra = scene->r.sfra; const int efra = scene->r.efra; - const bool invgpl = mmd->flag & GP_SIMPLIFY_INVERT_LAYER; + const bool invgpl = mmd->flag & GP_TIME_INVERT_LAYER; + const bool invpass = mmd->flag & GP_TIME_INVERT_PASS; /* omit if filter by layer */ if (mmd->layername[0] != '\0') { @@ -86,6 +87,19 @@ static int remapTime( } } } + /* verify pass */ + if (mmd->pass_index > 0) { + if (invpass == false) { + if (gpl->pass_index != mmd->pass_index) { + return cfra; + } + } + else { + if (gpl->pass_index == mmd->pass_index) { + return cfra; + } + } + } /* if fix mode, return predefined frame number */ if (mmd->mode == GP_TIME_MODE_FIX) { diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 9d543ddbc78..17ec1073c1d 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -143,15 +143,18 @@ typedef enum eThickGpencil_Flag { typedef struct TimeGpencilModifierData { GpencilModifierData modifier; char layername[64]; /* layer name */ + int pass_index; /* custom index for passes */ int flag; /* flags */ int offset; float frame_scale; /* animation scale */ int mode; + char pad_[4]; } TimeGpencilModifierData; typedef enum eTimeGpencil_Flag { GP_TIME_INVERT_LAYER = (1 << 0), GP_TIME_KEEP_LOOP = (1 << 1), + GP_TIME_INVERT_PASS = (1 << 2), } eTimeGpencil_Flag; typedef enum eTimeGpencil_Mode { diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 858008afd91..54559ce89f7 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -260,7 +260,7 @@ typedef struct bGPDlayer { * needs to be kept unique, as it's used as the layer identifier */ short thickness; /* thickness to apply to strokes (Annotations) */ - char pad_1[2]; + short pass_index; /* used to filter groups of layers in modifiers */ struct Object *parent; /* parent object */ float inverse[4][4]; /* inverse matrix (only used if parented) */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index a02868622e4..de31c884b6b 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1094,6 +1094,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Onion Skinning", "Display onion skins before and after the current frame"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* pass index for compositing and modifiers */ + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Layer Index\" pass"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE); diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 0ef07b46309..1230c9862ed 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -750,11 +750,22 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layer", "Layer name"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_INVERT_LAYER); RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "invert_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "offset"); RNA_def_property_range(prop, -INT_MAX, INT_MAX); -- cgit v1.2.3