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.
This commit is contained in:
parent
ec017861b6
commit
d2b4eaa137
|
@ -1847,6 +1847,18 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
|
|||
row.enabled = md.mode != 'FIX'
|
||||
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")
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue