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/io/alembic/intern/abc_reader_object.cc
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/io/alembic/intern/abc_reader_object.cc')
-rw-r--r--source/blender/io/alembic/intern/abc_reader_object.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc
index dac0890e7c5..a698eeca8f1 100644
--- a/source/blender/io/alembic/intern/abc_reader_object.cc
+++ b/source/blender/io/alembic/intern/abc_reader_object.cc
@@ -97,7 +97,9 @@ void AbcObjectReader::object(Object *ob)
m_object = ob;
}
-static Imath::M44d blend_matrices(const Imath::M44d &m0, const Imath::M44d &m1, const float weight)
+static Imath::M44d blend_matrices(const Imath::M44d &m0,
+ const Imath::M44d &m1,
+ const double weight)
{
float mat0[4][4], mat1[4][4], ret[4][4];
@@ -108,16 +110,16 @@ static Imath::M44d blend_matrices(const Imath::M44d &m0, const Imath::M44d &m1,
convert_matrix_datatype(m0, mat0);
convert_matrix_datatype(m1, mat1);
- interp_m4_m4m4(ret, mat0, mat1, weight);
+ interp_m4_m4m4(ret, mat0, mat1, static_cast<float>(weight));
return convert_matrix_datatype(ret);
}
-Imath::M44d get_matrix(const IXformSchema &schema, const float time)
+Imath::M44d get_matrix(const IXformSchema &schema, const chrono_t time)
{
Alembic::AbcGeom::index_t i0, i1;
Alembic::AbcGeom::XformSample s0, s1;
- const float weight = get_weight_and_index(
+ const double weight = get_weight_and_index(
time, schema.getTimeSampling(), schema.getNumSamples(), i0, i1);
schema.get(s0, Alembic::AbcGeom::ISampleSelector(i0));
@@ -148,7 +150,7 @@ bool AbcObjectReader::topology_changed(const Mesh * /*existing_mesh*/,
return false;
}
-void AbcObjectReader::setupObjectTransform(const float time)
+void AbcObjectReader::setupObjectTransform(const chrono_t time)
{
bool is_constant = false;
float transform_from_alembic[4][4];
@@ -214,7 +216,7 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform()
}
void AbcObjectReader::read_matrix(float r_mat[4][4] /* local matrix */,
- const float time,
+ const chrono_t time,
const float scale,
bool &is_constant)
{