[Bf-blender-cvs] [dd4e908] alembic_basic_io: Modify the way time offset and scaling works.
Kévin Dietrich
noreply at git.blender.org
Thu Jun 30 03:12:20 CEST 2016
Commit: dd4e90852bedfcba822d382077504c36d61297d2
Author: Kévin Dietrich
Date: Thu Jun 30 02:44:42 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBdd4e90852bedfcba822d382077504c36d61297d2
Modify the way time offset and scaling works.
Now rather than having two separate properties to override or offset the
current frame or time to lookup inside an archive, a single property is
used to simply override the current scene frame.
===================================================================
M source/blender/blenkernel/BKE_cachefile.h
M source/blender/blenkernel/intern/cachefile.c
M source/blender/blenkernel/intern/constraint.c
M source/blender/blenkernel/intern/scene.c
M source/blender/editors/interface/interface_templates.c
M source/blender/makesdna/DNA_cachefile_types.h
M source/blender/makesrna/intern/rna_cachefile.c
M source/blender/modifiers/intern/MOD_meshsequencecache.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index 487c6d9..c4c131f 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -45,12 +45,12 @@ struct CacheFile *BKE_cachefile_copy(struct Main *bmain, struct CacheFile *cache
void BKE_cachefile_load(struct CacheFile *cache_file, const char *relabase);
-void BKE_cachefile_update_frame(struct Main *bmain, float ctime);
+void BKE_cachefile_update_frame(struct Main *bmain, float ctime, const float fps);
bool BKE_cachefile_filepath_get(struct CacheFile *cache_file, float frame,
char *r_filename);
-float BKE_cachefile_time_offset(struct CacheFile *cache_file, float time);
+float BKE_cachefile_time_offset(struct CacheFile *cache_file, const float time, const float fps);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index adf3837..78a4f64 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -61,8 +61,8 @@ void *BKE_cachefile_add(Main *bmain, const char *name)
cache_file->handle = NULL;
cache_file->filepath[0] = '\0';
- cache_file->frame_start = 0.0f;
- cache_file->frame_scale = 1.0f;
+ cache_file->override_frame = false;
+ cache_file->frame = 0.0f;
cache_file->is_sequence = false;
cache_file->scale = 1.0f;
@@ -85,8 +85,8 @@ CacheFile *BKE_cachefile_copy(Main *bmain, CacheFile *cache_file)
BLI_strncpy(new_cache_file->filepath, cache_file->filepath, FILE_MAX);
- new_cache_file->frame_start = cache_file->frame_start;
- new_cache_file->frame_scale = cache_file->frame_scale;
+ new_cache_file->frame = cache_file->frame;
+ new_cache_file->override_frame = cache_file->override_frame;
new_cache_file->is_sequence = cache_file->is_sequence;
new_cache_file->scale = cache_file->scale;
@@ -115,7 +115,7 @@ void BKE_cachefile_load(CacheFile *cache_file, const char *relabase)
#endif
}
-void BKE_cachefile_update_frame(Main *bmain, float ctime)
+void BKE_cachefile_update_frame(Main *bmain, const float ctime, const float fps)
{
CacheFile *cache_file;
char filename[FILE_MAX];
@@ -125,7 +125,7 @@ void BKE_cachefile_update_frame(Main *bmain, float ctime)
continue;
}
- const float time = BKE_cachefile_time_offset(cache_file, ctime);
+ const float time = BKE_cachefile_time_offset(cache_file, ctime, fps);
if (BKE_cachefile_filepath_get(cache_file, time, filename)) {
#ifdef WITH_ALEMBIC
@@ -156,7 +156,8 @@ bool BKE_cachefile_filepath_get(CacheFile *cache_file, float frame, char *r_file
return true;
}
-float BKE_cachefile_time_offset(CacheFile *cache_file, float time)
+float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
{
- return (cache_file->frame_scale * time) - cache_file->frame_start;
+ const float frame = (cache_file->override_frame ? cache_file->frame : time);
+ return cache_file->is_sequence ? frame : frame / fps;
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 51856f4..72110b1 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4353,7 +4353,7 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
Scene *scene = cob->scene;
const float frame = BKE_scene_frame_get(scene);
- const float time = BKE_cachefile_time_offset(data->cache_file, frame / FPS);
+ const float time = BKE_cachefile_time_offset(data->cache_file, frame, FPS);
ABC_get_transform(data->cache_file->handle, cob->ob, data->abc_object_path,
cob->matrix, time, data->cache_file->scale);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 8c37402..5b1d56f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1906,7 +1906,7 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
BKE_mask_evaluate_all_masks(bmain, ctime, true);
/* Update animated cache files for modifiers. */
- BKE_cachefile_update_frame(bmain, ctime);
+ BKE_cachefile_update_frame(bmain, ctime, (((double)sce->r.frs_sec) / (double)sce->r.frs_sec_base));
#ifdef POSE_ANIMATION_WORKAROUND
scene_armature_depsgraph_workaround(bmain);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 02d88a5..170ac0a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3886,10 +3886,11 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiItemR(row, &fileptr, "filepath", 0, "", ICON_NONE);
row = uiLayoutRow(layout, false);
- uiItemR(row, &fileptr, "frame_start", 0, "Frame Start", ICON_NONE);
+ uiItemR(row, &fileptr, "override_frame", 0, "Override Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
- uiItemR(row, &fileptr, "frame_scale", 0, "Frame Scale", ICON_NONE);
+ uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
+ uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h
index 1156a9b..f8dcade 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/makesdna/DNA_cachefile_types.h
@@ -53,15 +53,13 @@ typedef struct CacheFile {
char is_sequence;
char forward_axis;
char up_axis;
- char pad;
+ char override_frame;
float scale;
-
- float frame_start;
- float frame_scale;
+ float frame; /* The frame/time to lookup in the cache file. */
short flag; /* Animation flag. */
- short pad2[3];
+ short pad;
} CacheFile;
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index b7dc256..6ddfa22 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -68,16 +68,17 @@ static void rna_def_cachefile(BlenderRNA *brna)
/* ----------------- For Scene time ------------------- */
- prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "frame_start");
- RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
- RNA_def_property_ui_text(prop, "Frame Start", "Add this to the start frame");
+ prop = RNA_def_property(srna, "override_frame", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Override Frame",
+ "Whether to use a custom frame for looking up data in the cache file,"
+ " instead of using the current scene frame");
RNA_def_property_update(prop, 0, NULL);
- 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.0f, 100.0f);
- RNA_def_property_ui_text(prop, "Frame Scale", "Evaluation time in seconds");
+ prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "frame");
+ RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
+ RNA_def_property_ui_text(prop, "Frame", "The time 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, NULL);
/* ----------------- Axis Conversion ----------------- */
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index e2d40c4..58ac064 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -89,7 +89,7 @@ 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 float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
DerivedMesh *result = ABC_read_mesh(mcmd->cache_file->handle,
dm,
More information about the Bf-blender-cvs
mailing list