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:
@@ -211,8 +211,9 @@ bool BKE_cachefile_filepath_get(
|
|||||||
|
|
||||||
float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
|
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);
|
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. */
|
/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */
|
||||||
|
@@ -4041,6 +4041,9 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
|
|||||||
uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
|
uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
|
||||||
uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE);
|
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);
|
row = uiLayoutRow(layout, false);
|
||||||
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
|
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
|
||||||
|
|
||||||
|
@@ -75,9 +75,12 @@ typedef struct CacheFile {
|
|||||||
|
|
||||||
float scale;
|
float scale;
|
||||||
float frame; /* The frame/time to lookup in the cache file. */
|
float frame; /* The frame/time to lookup in the cache file. */
|
||||||
|
float frame_offset; /* The frame offset to subtract. */
|
||||||
|
|
||||||
short flag; /* Animation flag. */
|
short flag; /* Animation flag. */
|
||||||
short draw_flag;
|
short draw_flag;
|
||||||
|
|
||||||
|
char padding[4];
|
||||||
} CacheFile;
|
} CacheFile;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -148,6 +148,15 @@ static void rna_def_cachefile(BlenderRNA *brna)
|
|||||||
" or to determine which file to use in a file sequence");
|
" or to determine which file to use in a file sequence");
|
||||||
RNA_def_property_update(prop, 0, "rna_CacheFile_update");
|
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 ----------------- */
|
/* ----------------- Axis Conversion ----------------- */
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);
|
||||||
|
@@ -109,7 +109,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
|||||||
Scene *scene = md->scene;
|
Scene *scene = md->scene;
|
||||||
const float frame = BKE_scene_frame_get(scene);
|
const float frame = BKE_scene_frame_get(scene);
|
||||||
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
|
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
|
||||||
|
|
||||||
const char *err_str = NULL;
|
const char *err_str = NULL;
|
||||||
|
|
||||||
CacheFile *cache_file = mcmd->cache_file;
|
CacheFile *cache_file = mcmd->cache_file;
|
||||||
|
Reference in New Issue
Block a user