Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-11-03 19:11:38 +0300
committerAntonioya <blendergit@gmail.com>2018-11-03 19:11:38 +0300
commitd2b4eaa13711b346df98e432bfd806be91dbac05 (patch)
treebb23b7c6006e41b06a9c7dedc80244090104891c
parentec017861b6fe9ce15b5eec88536aa457a5c99984 (diff)
GP: New Time Offset custom frame range parameters
These parameters allow to define a frame range for the animation loop and make possible to loop a section while the scene is playing.
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py12
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c7
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c46
4 files changed, 65 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 329b8785aec..2633168e2fa 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1848,6 +1848,18 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
row.prop(md, "frame_scale")
row = layout.row()
+ row.separator()
+
+ row = layout.row()
+ row.enabled = md.mode != 'FIX'
+ row.prop(md, "use_custom_frame_range")
+
+ row = layout.row(align=True)
+ row.enabled = md.mode != 'FIX' and md.use_custom_frame_range is True
+ row.prop(md, "frame_start")
+ row.prop(md, "frame_end")
+
+ row = layout.row()
row.enabled = md.mode != 'FIX'
row.prop(md, "use_keep_loop")
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
index 0e66f639ce3..29f06a4017f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
@@ -57,6 +57,8 @@ static void initData(GpencilModifierData *md)
gpmd->offset = 1;
gpmd->frame_scale = 1.0f;
gpmd->flag |= GP_TIME_KEEP_LOOP;
+ gpmd->sfra = 1;
+ gpmd->efra = 250;
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
@@ -69,8 +71,9 @@ static int remapTime(
struct Scene *scene, struct Object *UNUSED(ob), struct bGPDlayer *gpl, int cfra)
{
TimeGpencilModifierData *mmd = (TimeGpencilModifierData *)md;
- const int sfra = scene->r.sfra;
- const int efra = scene->r.efra;
+ const bool custom = mmd->flag & GP_TIME_CUSTOM_RANGE;
+ const int sfra = custom ? mmd->sfra : scene->r.sfra;
+ const int efra = custom ? mmd->efra : scene->r.efra;
const bool invgpl = mmd->flag & GP_TIME_INVERT_LAYER;
const bool invpass = mmd->flag & GP_TIME_INVERT_LAYERPASS;
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 191588a9d36..af680b8fb9d 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -153,6 +153,7 @@ typedef struct TimeGpencilModifierData {
int offset;
float frame_scale; /* animation scale */
int mode;
+ int sfra, efra; /* start and end frame for custom range */
char pad_[4];
} TimeGpencilModifierData;
@@ -160,6 +161,7 @@ typedef enum eTimeGpencil_Flag {
GP_TIME_INVERT_LAYER = (1 << 0),
GP_TIME_KEEP_LOOP = (1 << 1),
GP_TIME_INVERT_LAYERPASS = (1 << 2),
+ GP_TIME_CUSTOM_RANGE = (1 << 3),
} eTimeGpencil_Flag;
typedef enum eTimeGpencil_Mode {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index bc7b145d55a..fc3a5917a66 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -273,6 +273,28 @@ static void rna_HookGpencilModifier_object_set(PointerRNA *ptr, PointerRNA value
BKE_object_modifier_gpencil_hook_reset(ob, hmd);
}
+static void rna_TimeModifier_start_frame_set(PointerRNA *ptr, int value)
+{
+ TimeGpencilModifierData *tmd = ptr->data;
+ CLAMP(value, MINFRAME, MAXFRAME);
+ tmd->sfra = value;
+
+ if (tmd->sfra >= tmd->efra) {
+ tmd->efra = MIN2(tmd->sfra, MAXFRAME);
+ }
+}
+
+static void rna_TimeModifier_end_frame_set(PointerRNA *ptr, int value)
+{
+ TimeGpencilModifierData *tmd = ptr->data;
+ CLAMP(value, MINFRAME, MAXFRAME);
+ tmd->efra = value;
+
+ if (tmd->sfra >= tmd->efra) {
+ tmd->sfra = MAX2(tmd->efra, MINFRAME);
+ }
+}
+
#else
static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
@@ -849,11 +871,35 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Frame Scale", "Evaluation time in seconds");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_int_sdna(prop, NULL, "sfra");
+ RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_start_frame_set", NULL);
+ RNA_def_property_range(prop, MINFRAME, MAXFRAME);
+ RNA_def_property_int_default(prop, 1);
+ RNA_def_property_ui_text(prop, "Start Frame", "First frame of the range");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_int_sdna(prop, NULL, "efra");
+ RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_end_frame_set", NULL);
+ RNA_def_property_range(prop, MINFRAME, MAXFRAME);
+ RNA_def_property_int_default(prop, 250);
+ RNA_def_property_ui_text(prop, "End Frame", "Final frame of the range");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "use_keep_loop", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_KEEP_LOOP);
RNA_def_property_ui_text(prop, "Keep Loop",
"Retiming end frames and move to start of animation to keep loop");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "use_custom_frame_range", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_CUSTOM_RANGE);
+ RNA_def_property_ui_text(prop, "Custom Range",
+ "Define a custom range of frames to use in modifier");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
}
static void rna_def_modifier_gpencilcolor(BlenderRNA *brna)