Alembic: added frame offset property

The offset is subtracted, so that it's intuitive (dragging slider pushes
the animation further that way on the timeline).
This commit is contained in:
Sybren A. Stüvel 2017-10-29 17:23:50 +01:00
parent bbc7eb8ae5
commit 6099b2620d
5 changed files with 17 additions and 2 deletions

View File

@ -211,8 +211,9 @@ bool BKE_cachefile_filepath_get(
float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
{
const float time_offset = cache_file->frame_offset / fps;
const float frame = (cache_file->override_frame ? cache_file->frame : time);
return cache_file->is_sequence ? frame : frame / fps;
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */

View File

@ -4041,6 +4041,9 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemR(row, &fileptr, "frame_offset", 0, "Frame Offset", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);

View File

@ -75,9 +75,12 @@ typedef struct CacheFile {
float scale;
float frame; /* The frame/time to lookup in the cache file. */
float frame_offset; /* The frame offset to subtract. */
short flag; /* Animation flag. */
short draw_flag;
char padding[4];
} CacheFile;
#ifdef __cplusplus

View File

@ -148,6 +148,15 @@ static void rna_def_cachefile(BlenderRNA *brna)
" or to determine which file to use in a file sequence");
RNA_def_property_update(prop, 0, "rna_CacheFile_update");
prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "frame_offset");
RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Frame Offset",
"Subtracted from the current frame to use for "
"looking up the data in the cache file, or to "
"determine which file to use in a file sequence");
RNA_def_property_update(prop, 0, "rna_CacheFile_update");
/* ----------------- Axis Conversion ----------------- */
prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);

View File

@ -109,7 +109,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
Scene *scene = md->scene;
const float frame = BKE_scene_frame_get(scene);
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
const char *err_str = NULL;
CacheFile *cache_file = mcmd->cache_file;