Fix T49081: Alembic sampling times are not taking start frame into
authorKévin Dietrich <kevin.dietrich@mailoo.org>
Wed, 17 Aug 2016 20:06:05 +0000 (22:06 +0200)
committerKévin Dietrich <kevin.dietrich@mailoo.org>
Wed, 17 Aug 2016 20:26:50 +0000 (22:26 +0200)
account.

This resulted in animations always starting at frame 0.

source/blender/alembic/intern/abc_exporter.cc

index 127e8853789fafccbed04448ecc8e12189cb57eb..f71d78bd60e5459464f27d2b812a7572cb72d2e4 100644 (file)
@@ -175,7 +175,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative,
        /* sample all frame */
        if (shutter_open == 0.0 && shutter_close == 1.0) {
                for (double t = 0; t < 1.0; t += step) {
-                       samples.push_back(t / time_factor);
+                       samples.push_back((t + m_settings.frame_start) / time_factor);
                }
        }
        else {
@@ -184,7 +184,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative,
                const double time_inc = (shutter_close - shutter_open) / nsamples;
 
                for (double t = shutter_open; t <= shutter_close; t += time_inc) {
-                       samples.push_back(t / time_factor);
+                       samples.push_back((t + m_settings.frame_start) / time_factor);
                }
        }
 }
@@ -325,16 +325,18 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
                        break;
                }
 
-               double f = *begin;
-               setCurrentFrame(bmain, f);
+               const double frame = *begin;
 
-               if (shape_frames.count(f) != 0) {
+               /* 'frame' is offset by start frame, so need to cancel the offset. */
+               setCurrentFrame(bmain, frame - m_settings.frame_start);
+
+               if (shape_frames.count(frame) != 0) {
                        for (int i = 0, e = m_shapes.size(); i != e; ++i) {
                                m_shapes[i]->write();
                        }
                }
 
-               if (xform_frames.count(f) == 0) {
+               if (xform_frames.count(frame) == 0) {
                        continue;
                }