diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-05-11 13:57:22 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-05-11 13:57:22 +0300 |
commit | a1593fa05baf72653b3f086e795b47c79b2af7fd (patch) | |
tree | 2996fc722feae8b26e1938235cf6cd6d189a0f30 /source | |
parent | e82d8c60f03a5e41aa48d99d5012f56c68968b32 (diff) |
GPencil: New Percentage parameter in Build modifier
Add a factor to determine the percentage affected.
This parameter is used to hide part of the stroke and to have a full control of how the points are displayed and not linked to current scene frame.
{F8526502}
{F8526511}
Reviewed By: mendio, pepeland
Differential Revision: https://developer.blender.org/D7682
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_modifier_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil_modifier.c | 14 |
3 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index c31f73df25d..71a051629d8 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -406,6 +406,7 @@ static void generate_geometry(GpencilModifierData *md, { BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); + const bool is_percentage = (mmd->flag & GP_BUILD_PERCENTAGE); const float ctime = DEG_get_ctime(depsgraph); @@ -500,7 +501,8 @@ static void generate_geometry(GpencilModifierData *md, } /* Determine how far along we are between the keyframes */ - float fac = (ctime - start_frame) / (end_frame - start_frame); + float fac = is_percentage ? mmd->percentage_fac : + (ctime - start_frame) / (end_frame - start_frame); /* Time management mode */ switch (mmd->mode) { diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index deb955f5551..dc4b0997b00 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -370,6 +370,9 @@ typedef struct BuildGpencilModifierData { * For the "Concurrent" mode, when should "shorter" strips start/end. */ short time_alignment; + /** Factor of the stroke (used instead of frame evaluation. */ + float percentage_fac; + char _pad[4]; } BuildGpencilModifierData; typedef enum eBuildGpencil_Mode { @@ -405,6 +408,9 @@ typedef enum eBuildGpencil_Flag { /* Restrict modifier to only operating between the nominated frames */ GP_BUILD_RESTRICT_TIME = (1 << 2), GP_BUILD_INVERT_LAYERPASS = (1 << 3), + + /* Use a percentage instead of frame number to evaluate strokes. */ + GP_BUILD_PERCENTAGE = (1 << 4), } eBuildGpencil_Flag; typedef struct LatticeGpencilModifierData { diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 1906c663c54..e6cc14da667 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -1671,6 +1671,20 @@ static void rna_def_modifier_gpencilbuild(BlenderRNA *brna) prop, "Restrict Frame Range", "Only modify strokes during the specified frame range"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + /* Use percentage */ + prop = RNA_def_property(srna, "use_percentage", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_PERCENTAGE); + RNA_def_property_ui_text( + prop, "Restrict Visible Points", "Use a percentage factor to determine the visible points"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + /* Percentage factor. */ + prop = RNA_def_property(srna, "percentage_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "percentage_fac"); + RNA_def_property_ui_text(prop, "Factor", "Defines how much of the stroke is visible"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "start_frame"); RNA_def_property_ui_text( |