GP: Add new frame scale parameter to Time modifier

This new parameter allows to increase or decrease the animation speed to break animation patterns when reuse data blocks.
This commit is contained in:
Antonioya
2018-10-23 16:44:31 +02:00
parent ca003d0f5c
commit 3e9405e26d
4 changed files with 17 additions and 0 deletions

View File

@@ -1795,6 +1795,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
row = layout.row()
row.prop(md, "offset")
row = layout.row()
row.prop(md, "frame_scale")
row = layout.row()
row.label(text="Layer:")

View File

@@ -55,6 +55,7 @@ static void initData(GpencilModifierData *md)
TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)md;
gpmd->layername[0] = '\0';
gpmd->offset = 1;
gpmd->frame_scale = 1.0f;
gpmd->flag |= GP_TIME_KEEP_LOOP;
}
@@ -88,6 +89,12 @@ static int remapTime(
}
}
/* apply frame scale */
cfra *= mmd->frame_scale;
if (cfra > efra) {
cfra = sfra + (cfra - ((cfra / efra) * efra));
}
if (mmd->flag & GP_TIME_KEEP_LOOP) {
/* if the sum of the cfra is out scene frame range, recalc */
if (cfra + mmd->offset < sfra) {

View File

@@ -145,6 +145,8 @@ typedef struct TimeGpencilModifierData {
char layername[64]; /* layer name */
int flag; /* flags */
int offset;
float frame_scale; /* animation scale */
char pad[4];
} TimeGpencilModifierData;
typedef enum eTimeGpencil_Flag {

View File

@@ -749,6 +749,12 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
"Number of frames to offset original keyframe number");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "frame_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "frame_scale");
RNA_def_property_range(prop, 0.001f, 100.0f);
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, "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",