[Bf-blender-cvs] [dfc42af] alembic_pointcache: Utility function PTC::Reader for getting the stored frame range.

Lukas Tönne noreply at git.blender.org
Thu Oct 16 16:53:41 CEST 2014


Commit: dfc42af50b96beb6da49240025261f25cf10c18e
Author: Lukas Tönne
Date:   Thu Nov 28 13:37:35 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBdfc42af50b96beb6da49240025261f25cf10c18e

Utility function PTC::Reader for getting the stored frame range.

The way this works is currently not ideal, it takes the start/end times
used by Alembic and then multiplies by the scene fps to convert into
frames. It might be better to use the sample numbers directly, but
we cannot associate these directly to frames so far.

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

M	source/blender/pointcache/intern/reader.cpp
M	source/blender/pointcache/intern/reader.h

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

diff --git a/source/blender/pointcache/intern/reader.cpp b/source/blender/pointcache/intern/reader.cpp
index e94da3b..951deb5 100644
--- a/source/blender/pointcache/intern/reader.cpp
+++ b/source/blender/pointcache/intern/reader.cpp
@@ -17,9 +17,14 @@
  */
 
 #include <Alembic/AbcCoreHDF5/ReadWrite.h>
+#include <Alembic/Abc/ArchiveInfo.h>
 
 #include "reader.h"
 
+extern "C" {
+#include "DNA_scene_types.h"
+}
+
 namespace PTC {
 
 using namespace Abc;
@@ -33,4 +38,22 @@ Reader::~Reader()
 {
 }
 
+void Reader::get_frame_range(Scene *scene, int &start_frame, int &end_frame)
+{
+	if (scene->r.frs_sec_base == 0.0f) {
+		/* Should never happen, just to be safe */
+		start_frame = end_frame = 1;
+		return;
+	}
+	
+	double start_time, end_time;
+	GetArchiveStartAndEndTime(m_archive, start_time, end_time);
+	
+	double fps = (double)scene->r.frs_sec / (double)scene->r.frs_sec_base;
+	start_frame = start_time * fps;
+	end_frame = end_time * fps;
+}
+
+//AbcA::TimeSamplingPtr ts = iArchive.getTimeSampling( i )
+
 } /* namespace PTC */
diff --git a/source/blender/pointcache/intern/reader.h b/source/blender/pointcache/intern/reader.h
index 926fea2..56d85cd 100644
--- a/source/blender/pointcache/intern/reader.h
+++ b/source/blender/pointcache/intern/reader.h
@@ -23,6 +23,8 @@
 
 #include <Alembic/Abc/IArchive.h>
 
+struct Scene;
+
 namespace PTC {
 
 using namespace Alembic;
@@ -32,6 +34,8 @@ public:
 	Reader(const std::string &filename);
 	virtual ~Reader();
 	
+	void get_frame_range(Scene *scene, int &start_frame, int &end_frame);
+	
 	virtual void read_sample() = 0;
 	
 protected:




More information about the Bf-blender-cvs mailing list