[Bf-blender-cvs] [5fa7283] alembic_pointcache: Fixed start frame mapping in Alembic archives.

Lukas Tönne noreply at git.blender.org
Thu Feb 26 15:26:02 CET 2015


Commit: 5fa7283f861c4cdfb6a1aa92f53c6d0454d30eba
Author: Lukas Tönne
Date:   Thu Feb 26 15:24:29 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB5fa7283f861c4cdfb6a1aa92f53c6d0454d30eba

Fixed start frame mapping in Alembic archives.

Writers were always starting at time 0.0, which means that for start
frames > 1 the readers would always be off. Now match the writer start
frame to the actual Blender start frame.

===================================================================

M	source/blender/pointcache/alembic/abc_frame_mapper.cpp
M	source/blender/pointcache/alembic/abc_frame_mapper.h
M	source/blender/pointcache/alembic/abc_writer.cpp

===================================================================

diff --git a/source/blender/pointcache/alembic/abc_frame_mapper.cpp b/source/blender/pointcache/alembic/abc_frame_mapper.cpp
index 097e271..3788861 100644
--- a/source/blender/pointcache/alembic/abc_frame_mapper.cpp
+++ b/source/blender/pointcache/alembic/abc_frame_mapper.cpp
@@ -29,16 +29,20 @@ namespace PTC {
 using namespace Abc;
 using namespace AbcCoreAbstract;
 
-FrameMapper::FrameMapper(double fps)
+FrameMapper::FrameMapper(double fps, double start_time)
 {
 	m_frames_per_sec = fps;
 	m_sec_per_frame = (fps == 0.0 ? 0.0 : 1.0/fps);
+	m_start_frame = start_time * fps;
+	m_start_time = start_time;
 }
 
 FrameMapper::FrameMapper(Scene *scene)
 {
 	m_frames_per_sec = (scene->r.frs_sec_base == 0.0f ? 0.0 : (double)scene->r.frs_sec / (double)scene->r.frs_sec_base);
 	m_sec_per_frame = (scene->r.frs_sec == 0.0f ? 0.0 : (double)scene->r.frs_sec_base / (double)scene->r.frs_sec);
+	m_start_frame = ((double)scene->r.sfra);
+	m_start_time = m_start_frame * m_sec_per_frame;
 }
 
 chrono_t FrameMapper::frame_to_time(float frame) const
diff --git a/source/blender/pointcache/alembic/abc_frame_mapper.h b/source/blender/pointcache/alembic/abc_frame_mapper.h
index f9a0e73..fcceb8f 100644
--- a/source/blender/pointcache/alembic/abc_frame_mapper.h
+++ b/source/blender/pointcache/alembic/abc_frame_mapper.h
@@ -35,17 +35,20 @@ using Alembic::AbcCoreAbstract::chrono_t;
 
 class FrameMapper {
 public:
-	FrameMapper(double fps);
+	FrameMapper(double fps, double start_time);
 	FrameMapper(Scene *scene);
 	
 	double frames_per_second() const { return m_frames_per_sec; }
 	double seconds_per_frame() const { return m_sec_per_frame; }
+	double start_frame() const { return m_start_frame; }
+	double start_time() const { return m_start_time; }
 	
 	chrono_t frame_to_time(float frame) const;
 	float time_to_frame(chrono_t time) const;
 	
 private:
 	double m_frames_per_sec, m_sec_per_frame;
+	double m_start_frame, m_start_time;
 };
 
 #endif /* WITH_ALEMBIC */
diff --git a/source/blender/pointcache/alembic/abc_writer.cpp b/source/blender/pointcache/alembic/abc_writer.cpp
index e94a72b..2754557 100644
--- a/source/blender/pointcache/alembic/abc_writer.cpp
+++ b/source/blender/pointcache/alembic/abc_writer.cpp
@@ -51,8 +51,8 @@ AbcWriterArchive::AbcWriterArchive(Scene *scene, const std::string &filename, Er
 	PTC_SAFE_CALL_BEGIN
 	archive = OArchive(AbcCoreHDF5::WriteArchive(), filename, Abc::ErrorHandler::kThrowPolicy);
 	
-	chrono_t cycle_time = seconds_per_frame();
-	chrono_t start_time = 0.0f;
+	chrono_t cycle_time = this->seconds_per_frame();
+	chrono_t start_time = this->start_time();
 	m_frame_sampling = archive.addTimeSampling(TimeSampling(cycle_time, start_time));
 	
 	PTC_SAFE_CALL_END_HANDLER(m_error_handler)




More information about the Bf-blender-cvs mailing list