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>2016-09-20 15:15:02 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2016-09-20 15:17:05 +0300
commitf3b94a54bc9dc2c93c350e67f4cf1bb048d32afa (patch)
tree8d5f69006a233563408036c8743f149bf5ffa7a1 /source/blender/alembic/intern/abc_util.cc
parent386da0cc77cbd16a8b5a196dd1b44e517198dbda (diff)
Alembic: add support to interpolate transform matrices in-between
frames.
Diffstat (limited to 'source/blender/alembic/intern/abc_util.cc')
-rw-r--r--source/blender/alembic/intern/abc_util.cc45
1 files changed, 36 insertions, 9 deletions
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index fbab0bcdf34..60c66bca1c8 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -201,16 +201,9 @@ void create_transform_matrix(float r_mat[4][4])
copy_m4_m4(r_mat, transform_mat);
}
-void create_input_transform(const Alembic::AbcGeom::ISampleSelector &sample_sel,
- const Alembic::AbcGeom::IXform &ixform, Object *ob,
- float r_mat[4][4], float scale, bool has_alembic_parent)
+void convert_matrix(const Imath::M44d &xform, Object *ob,
+ float r_mat[4][4], float scale, bool has_alembic_parent)
{
-
- const Alembic::AbcGeom::IXformSchema &ixform_schema = ixform.getSchema();
- Alembic::AbcGeom::XformSample xs;
- ixform_schema.get(xs, sample_sel);
- const Imath::M44d &xform = xs.getMatrix();
-
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
r_mat[i][j] = xform[i][j];
@@ -435,3 +428,37 @@ bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string
return prop.getPropertyHeader(name) != NULL;
}
+
+typedef std::pair<Alembic::AbcCoreAbstract::index_t, float> index_time_pair_t;
+
+float get_weight_and_index(float time,
+ const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
+ int samples_number,
+ Alembic::AbcGeom::index_t &i0,
+ Alembic::AbcGeom::index_t &i1)
+{
+ samples_number = std::max(samples_number, 1);
+
+ index_time_pair_t t0 = time_sampling->getFloorIndex(time, samples_number);
+ i0 = i1 = t0.first;
+
+ if (samples_number == 1 || (fabs(time - t0.second) < 0.0001f)) {
+ return 0.0f;
+ }
+
+ index_time_pair_t t1 = time_sampling->getCeilIndex(time, samples_number);
+ i1 = t1.first;
+
+ if (i0 == i1) {
+ return 0.0f;
+ }
+
+ const float bias = (time - t0.second) / (t1.second - t0.second);
+
+ if (fabs(1.0f - bias) < 0.0001f) {
+ i0 = i1;
+ return 0.0f;
+ }
+
+ return bias;
+}