Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-04-08 18:57:35 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-04-08 18:57:35 +0300
commitf3a475a76721a8333396ce1801124a15278b4d1f (patch)
tree94e78d60f2bc631ada663c3afc2fef0e01280733 /source/blender/blenkernel
parent8b7cd1ed2a17e40661101eea4adae99e8e3d02e9 (diff)
Cleanup: CacheFile, use double precision for time
Both the Alembic and USD libraries use double precision floating point numbers internally to store time. However the Alembic I/O code defaulted to floats even though Blender's Scene FPS, which is generally used for look ups, is stored using a double type. Such downcasts could lead to imprecise lookups, and would cause compilation warnings (at least on MSVC). This modifies the Alembic exporter and importer to make use of doubles for the current scene time, and only downcasting to float at the very last steps (e.g. for vertex interpolation). For the importer, doubles are also used for computing interpolation weights, as it is based on a time offset. Although the USD code already used doubles internally, floats were used at the C API level. Those were replaced as well. Differential Revision: https://developer.blender.org/D13855
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h2
-rw-r--r--source/blender/blenkernel/intern/cachefile.c10
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
3 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index 41a0ad3f763..fd559abf7f2 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -35,7 +35,7 @@ bool BKE_cachefile_filepath_get(const struct Main *bmain,
const struct CacheFile *cache_file,
char r_filename[1024]);
-float BKE_cachefile_time_offset(const struct CacheFile *cache_file, float time, float fps);
+double BKE_cachefile_time_offset(const struct CacheFile *cache_file, double time, double fps);
/* Modifiers and constraints open and free readers through these. */
void BKE_cachefile_reader_open(struct CacheFile *cache_file,
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 338c74d550c..6b6b7223a0b 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -395,8 +395,8 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
Scene *scene = DEG_get_evaluated_scene(depsgraph);
const float ctime = BKE_scene_ctime_get(scene);
- const float fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
- const float frame = BKE_cachefile_time_offset(cache_file, ctime, fps);
+ const double fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
+ const int frame = (int)BKE_cachefile_time_offset(cache_file, (double)ctime, fps);
char ext[32];
BLI_path_frame_strip(r_filepath, ext);
@@ -410,10 +410,10 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
return true;
}
-float BKE_cachefile_time_offset(const CacheFile *cache_file, const float time, const float fps)
+double BKE_cachefile_time_offset(const CacheFile *cache_file, const double time, const double fps)
{
- const float time_offset = cache_file->frame_offset / fps;
- const float frame = (cache_file->override_frame ? cache_file->frame : time);
+ const double time_offset = (double)cache_file->frame_offset / fps;
+ const double frame = (cache_file->override_frame ? (double)cache_file->frame : time);
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index fc3f84778f8..0bab3d826fd 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -5417,7 +5417,7 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
}
const float frame = DEG_get_ctime(cob->depsgraph);
- const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
+ const double time = BKE_cachefile_time_offset(cache_file, (double)frame, FPS);
if (!data->reader || !STREQ(data->reader_object_path, data->object_path)) {
STRNCPY(data->reader_object_path, data->object_path);