[Bf-blender-cvs] [3e9405e26df] blender2.8: GP: Add new frame scale parameter to Time modifier

Antonioya noreply at git.blender.org
Tue Oct 23 16:50:24 CEST 2018


Commit: 3e9405e26dfb02f1aa05c530cce3ca6f9d1c84c7
Author: Antonioya
Date:   Tue Oct 23 16:44:31 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3e9405e26dfb02f1aa05c530cce3ca6f9d1c84c7

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.

===================================================================

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index b58438a7678..a576d91a42c 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -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:")
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
index 521a398ee29..c72a20cc0e9 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
@@ -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) {
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index fd1a4d2a2b7..5d743350827 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index e9ca90e1300..bc0db0ddaea 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -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",



More information about the Bf-blender-cvs mailing list