[Bf-blender-cvs] [a085b4c] alembic: Use fps and start frame settings for cache archives internally, rather than relying on values from Scene.

Lukas Tönne noreply at git.blender.org
Mon May 18 20:36:03 CEST 2015


Commit: a085b4c9f6533b1dc0d22b774f715945f41e64d4
Author: Lukas Tönne
Date:   Mon May 18 19:59:30 2015 +0200
Branches: alembic
https://developer.blender.org/rBa085b4c9f6533b1dc0d22b774f715945f41e64d4

Use fps and start frame settings for cache archives internally, rather
than relying on values from Scene.

This gives more flexibility when creating archives. A default variant
for opening archives using the scene settings is still available.

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

M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h
M	source/blender/pointcache/alembic/abc_frame_mapper.cpp
M	source/blender/pointcache/alembic/abc_frame_mapper.h
M	source/blender/pointcache/alembic/abc_reader.cpp
M	source/blender/pointcache/alembic/abc_reader.h
M	source/blender/pointcache/alembic/abc_writer.cpp
M	source/blender/pointcache/alembic/abc_writer.h
M	source/blender/pointcache/alembic/alembic.cpp
M	source/blender/pointcache/intern/ptc_types.h

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

diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 69e3d21..2cb1f6e 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -37,10 +37,12 @@ extern "C" {
 
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_modifier.h"
 #include "BKE_report.h"
+#include "BKE_scene.h"
 
 #include "RNA_access.h"
 }
@@ -136,7 +138,14 @@ const char *PTC_get_default_archive_extension(void)
 
 PTCWriterArchive *PTC_open_writer_archive(Scene *scene, const char *path)
 {
-	return (PTCWriterArchive *)PTC::Factory::alembic->open_writer_archive(scene, path, NULL);
+	double fps = FPS;
+	float start_frame = scene->r.sfra;
+	return PTC_open_writer_archive_ex(fps, start_frame, path);
+}
+
+PTCWriterArchive *PTC_open_writer_archive_ex(double fps, float start_frame, const char *path)
+{
+	return (PTCWriterArchive *)PTC::Factory::alembic->open_writer_archive(fps, start_frame, path, NULL);
 }
 
 void PTC_close_writer_archive(PTCWriterArchive *_archive)
@@ -153,7 +162,14 @@ void PTC_writer_archive_use_render(PTCWriterArchive *_archive, bool enable)
 
 PTCReaderArchive *PTC_open_reader_archive(Scene *scene, const char *path)
 {
-	return (PTCReaderArchive *)PTC::Factory::alembic->open_reader_archive(scene, path, NULL);
+	double fps = FPS;
+	float start_frame = scene->r.sfra;
+	return PTC_open_reader_archive_ex(fps, start_frame, path);
+}
+
+PTCReaderArchive *PTC_open_reader_archive_ex(double fps, float start_frame, const char *path)
+{
+	return (PTCReaderArchive *)PTC::Factory::alembic->open_reader_archive(fps, start_frame, path, NULL);
 }
 
 void PTC_close_reader_archive(PTCReaderArchive *_archive)
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 6c531c9..16cfb33 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -60,10 +60,12 @@ void PTC_error_handler_modifier(struct ModifierData *md);
 const char *PTC_get_default_archive_extension(void);
 
 struct PTCWriterArchive *PTC_open_writer_archive(struct Scene *scene, const char *path);
+struct PTCWriterArchive *PTC_open_writer_archive_ex(double fps, float start_frame, const char *path);
 void PTC_close_writer_archive(struct PTCWriterArchive *archive);
 void PTC_writer_archive_use_render(struct PTCWriterArchive *archive, bool enable);
 
 struct PTCReaderArchive *PTC_open_reader_archive(struct Scene *scene, const char *path);
+struct PTCReaderArchive *PTC_open_reader_archive_ex(double fps, float start_frame, const char *path);
 void PTC_close_reader_archive(struct PTCReaderArchive *archive);
 void PTC_reader_archive_use_render(struct PTCReaderArchive *archive, bool enable);
 
diff --git a/source/blender/pointcache/alembic/abc_frame_mapper.cpp b/source/blender/pointcache/alembic/abc_frame_mapper.cpp
index fc1a223..ba5ded1 100644
--- a/source/blender/pointcache/alembic/abc_frame_mapper.cpp
+++ b/source/blender/pointcache/alembic/abc_frame_mapper.cpp
@@ -29,20 +29,12 @@ namespace PTC {
 using namespace Abc;
 using namespace AbcCoreAbstract;
 
-FrameMapper::FrameMapper(double fps, double start_time)
+FrameMapper::FrameMapper(double fps, float start_frame)
 {
 	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;
+	m_start_frame = start_frame;
+	m_start_time = 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 fcceb8f..b61baee 100644
--- a/source/blender/pointcache/alembic/abc_frame_mapper.h
+++ b/source/blender/pointcache/alembic/abc_frame_mapper.h
@@ -35,8 +35,7 @@ using Alembic::AbcCoreAbstract::chrono_t;
 
 class FrameMapper {
 public:
-	FrameMapper(double fps, double start_time);
-	FrameMapper(Scene *scene);
+	FrameMapper(double fps, float start_frame);
 	
 	double frames_per_second() const { return m_frames_per_sec; }
 	double seconds_per_frame() const { return m_sec_per_frame; }
diff --git a/source/blender/pointcache/alembic/abc_reader.cpp b/source/blender/pointcache/alembic/abc_reader.cpp
index 7f19087..aad2a02 100644
--- a/source/blender/pointcache/alembic/abc_reader.cpp
+++ b/source/blender/pointcache/alembic/abc_reader.cpp
@@ -28,14 +28,14 @@
 #include "util_error_handler.h"
 
 extern "C" {
-#include "DNA_scene_types.h"
+#include "DNA_ID.h"
 }
 
 namespace PTC {
 
 using namespace Abc;
 
-AbcReaderArchive *AbcReaderArchive::open(Scene *scene, const std::string &filename, ErrorHandler *error_handler)
+AbcReaderArchive *AbcReaderArchive::open(double fps, float start_frame, const std::string &filename, ErrorHandler *error_handler)
 {
 	IArchive abc_archive;
 	PTC_SAFE_CALL_BEGIN
@@ -44,13 +44,13 @@ AbcReaderArchive *AbcReaderArchive::open(Scene *scene, const std::string &filena
 	PTC_SAFE_CALL_END_HANDLER(error_handler)
 	
 	if (abc_archive)
-		return new AbcReaderArchive(scene, error_handler, abc_archive);
+		return new AbcReaderArchive(fps, start_frame, error_handler, abc_archive);
 	else
 		return NULL;
 }
 
-AbcReaderArchive::AbcReaderArchive(Scene *scene, ErrorHandler *error_handler, IArchive abc_archive) :
-    FrameMapper(scene),
+AbcReaderArchive::AbcReaderArchive(double fps, float start_frame, ErrorHandler *error_handler, IArchive abc_archive) :
+    FrameMapper(fps, start_frame),
     m_error_handler(error_handler),
     m_use_render(false),
     m_abc_archive(abc_archive)
diff --git a/source/blender/pointcache/alembic/abc_reader.h b/source/blender/pointcache/alembic/abc_reader.h
index 72554f7..222e670 100644
--- a/source/blender/pointcache/alembic/abc_reader.h
+++ b/source/blender/pointcache/alembic/abc_reader.h
@@ -32,8 +32,6 @@
 #include "util_error_handler.h"
 #include "util_types.h"
 
-struct Scene;
-
 namespace PTC {
 
 using namespace Alembic;
@@ -42,7 +40,7 @@ class AbcReaderArchive : public ReaderArchive, public FrameMapper {
 public:
 	virtual ~AbcReaderArchive();
 	
-	static AbcReaderArchive *open(Scene *scene, const std::string &filename, ErrorHandler *error_handler);
+	static AbcReaderArchive *open(double fps, float start_frame, const std::string &filename, ErrorHandler *error_handler);
 	
 	bool use_render() const { return m_use_render; }
 	void use_render(bool enable) { m_use_render = enable; }
@@ -60,7 +58,7 @@ public:
 	void get_info_nodes(CacheArchiveInfo *info, bool calc_bytes_size);
 	
 protected:
-	AbcReaderArchive(Scene *scene, ErrorHandler *error_handler, Abc::IArchive abc_archive);
+	AbcReaderArchive(double fps, float start_frame, ErrorHandler *error_handler, Abc::IArchive abc_archive);
 	
 protected:
 	ErrorHandler *m_error_handler;
diff --git a/source/blender/pointcache/alembic/abc_writer.cpp b/source/blender/pointcache/alembic/abc_writer.cpp
index 6daba44..34a83dd 100644
--- a/source/blender/pointcache/alembic/abc_writer.cpp
+++ b/source/blender/pointcache/alembic/abc_writer.cpp
@@ -27,8 +27,6 @@
 extern "C" {
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
-
-#include "DNA_scene_types.h"
 }
 
 namespace PTC {
@@ -43,7 +41,7 @@ static void ensure_directory(const char *filename)
 	BLI_dir_create_recursive(dir);
 }
 
-AbcWriterArchive *AbcWriterArchive::open(Scene *scene, const std::string &filename, ErrorHandler *error_handler)
+AbcWriterArchive *AbcWriterArchive::open(double fps, float start_frame, const std::string &filename, ErrorHandler *error_handler)
 {
 	ensure_directory(filename.c_str());
 	
@@ -54,13 +52,13 @@ AbcWriterArchive *AbcWriterArchive::open(Scene *scene, const std::string &filena
 	PTC_SAFE_CALL_END_HANDLER(error_handler)
 	
 	if (abc_archive)
-		return new AbcWriterArchive(scene, error_handler, abc_archive);
+		return new AbcWriterArchive(fps, start_frame, error_handler, abc_archive);
 	else
 		return NULL;
 }
 
-AbcWriterArchive::AbcWriterArchive(Scene *scene, ErrorHandler *error_handler, OArchive abc_archive) :
-    FrameMapper(scene),
+AbcWriterArchive::AbcWriterArchive(double fps, float start_frame, ErrorHandler *error_handler, OArchive abc_archive) :
+    FrameMapper(fps, start_frame),
     m_error_handler(error_handler),
     m_use_render(false),
     m_abc_archive(abc_archive)
diff --git a/source/blender/pointcache/alembic/abc_writer.h b/source/blender/pointcache/alembic/abc_writer.h
index ff7bb5f..af5de32 100644
--- a/source/blender/pointcache/alembic/abc_writer.h
+++ b/source/blender/pointcache/alembic/abc_writer.h
@@ -36,8 +36,6 @@ extern "C" {
 #include "DNA_ID.h"
 }
 
-struct Scene;
-
 namespace PTC {
 
 using namespace Alembic;
@@ -46,7 +44,7 @@ class AbcWriterArchive : public WriterArchive, public FrameMapper {
 public:
 	virtual ~AbcWriterArchive();
 	
-	static AbcWriterArchive *open(Scene *scene, const std::string &filename, ErrorHandler *error_handler);
+	static AbcWriterArchive *open(double fps, float start_frame, const std::string &filename, ErrorHandler *error_handler);
 	
 	bool use_render() const { return m_use_render; }
 	void use_render(bool enable) { m_use_render = enable; }
@@ -64,7 +62,7 @@ public:
 	Abc::TimeSamplingPtr frame_sampling();
 	
 protected:
-	AbcWriterArchive(Scene *scene, ErrorHandler *error_handler, Abc::OArchive abc_archive);
+	AbcWriterArchive(double fps, float start_frame, ErrorHandler *error_handler, Abc::OArchive abc_archive);
 	
 protected:
 	ErrorHandler *m_error_handler;
diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp
index 8716384..284a960 100644
--- a/source/blender/pointcache/alembic/alembic.cpp
+++ b/source/blender/pointcache/alembic/alembic.cpp
@@ -39,14 +39,14 @@ class AbcFactory : public Factory {
 		return ext;
 	}
 	
-	WriterArchive *open_writer_archive(Scene *scene, const std::string &n

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list