[Bf-blender-cvs] [fe143aa] gooseberry: Simplification of the archive init functions in writers and readers.

Lukas Tönne noreply at git.blender.org
Mon Mar 23 13:03:39 CET 2015


Commit: fe143aaeb34163d1cb59e88f949519a399ea7826
Author: Lukas Tönne
Date:   Mon Mar 16 09:43:27 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBfe143aaeb34163d1cb59e88f949519a399ea7826

Simplification of the archive init functions in writers and readers.

Now the base types for readers/writers are not nominally forming the
interface any more (they may be removed entirely later). This makes
possible a cleaner init method directly in the Abc Writer/Reader
classes.

Further work may be required in this area.

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

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/editors/io/io_cache_library.c
M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h
M	source/blender/pointcache/alembic/abc_cloth.cpp
M	source/blender/pointcache/alembic/abc_cloth.h
M	source/blender/pointcache/alembic/abc_group.cpp
M	source/blender/pointcache/alembic/abc_group.h
M	source/blender/pointcache/alembic/abc_mesh.cpp
M	source/blender/pointcache/alembic/abc_mesh.h
M	source/blender/pointcache/alembic/abc_object.cpp
M	source/blender/pointcache/alembic/abc_object.h
M	source/blender/pointcache/alembic/abc_particles.cpp
M	source/blender/pointcache/alembic/abc_particles.h
M	source/blender/pointcache/alembic/abc_reader.cpp
M	source/blender/pointcache/alembic/abc_reader.h
M	source/blender/pointcache/alembic/abc_writer.h
M	source/blender/pointcache/intern/ptc_types.h
M	source/blender/pointcache/intern/reader.cpp
M	source/blender/pointcache/intern/reader.h
M	source/blender/pointcache/intern/writer.cpp
M	source/blender/pointcache/intern/writer.h

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

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 0b63ad5..3ae8f8c 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -846,7 +846,7 @@ struct PTCWriterArchive *BKE_cache_library_writers_open_archive(Scene *scene, Ca
 	archive = PTC_open_writer_archive(scene, filename);
 	
 	for (link = writers->first; link; link = link->next) {
-		PTC_writer_set_archive(link->writer, archive);
+		PTC_writer_init(link->writer, archive);
 	}
 	
 	for (link = writers->first; link; link = link->next) {
@@ -991,7 +991,7 @@ eCacheReadSampleResult BKE_cache_library_read_derived_mesh(Scene *scene, float f
 		
 		BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
 		archive = PTC_open_reader_archive(scene, filename);
-		PTC_reader_set_archive(reader, archive);
+		PTC_reader_init(reader, archive);
 		
 		result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 		item->read_result = result;
@@ -1021,7 +1021,7 @@ eCacheReadSampleResult BKE_cache_library_read_hair_dynamics(Scene *scene, float
 		
 		BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
 		archive = PTC_open_reader_archive(scene, filename);
-		PTC_reader_set_archive(reader, archive);
+		PTC_reader_init(reader, archive);
 		
 		result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 		item->read_result = result;
@@ -1049,7 +1049,7 @@ eCacheReadSampleResult BKE_cache_library_read_particles(Scene *scene, float fram
 		
 		BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
 		archive = PTC_open_reader_archive(scene, filename);
-		PTC_reader_set_archive(reader, archive);
+		PTC_reader_init(reader, archive);
 		
 		result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 		item->read_result = result;
@@ -1077,7 +1077,7 @@ eCacheReadSampleResult BKE_cache_library_read_particles_pathcache_parents(Scene
 		
 		BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
 		archive = PTC_open_reader_archive(scene, filename);
-		PTC_reader_set_archive(reader, archive);
+		PTC_reader_init(reader, archive);
 		
 		result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 		item->read_result = result;
@@ -1105,7 +1105,7 @@ eCacheReadSampleResult BKE_cache_library_read_particles_pathcache_children(Scene
 		
 		BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
 		archive = PTC_open_reader_archive(scene, filename);
-		PTC_reader_set_archive(reader, archive);
+		PTC_reader_init(reader, archive);
 		
 		result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 		item->read_result = result;
@@ -1236,7 +1236,7 @@ bool BKE_cache_read_dupligroup(Main *bmain, Scene *scene, float frame, eCacheLib
 			archive = PTC_open_reader_archive(scene, filename);
 			
 			reader = PTC_reader_dupligroup(dupgroup->id.name, dupgroup, dupcache);
-			PTC_reader_set_archive(reader, archive);
+			PTC_reader_init(reader, archive);
 			
 			result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 			
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 5a535b0..094f9b1 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -282,7 +282,7 @@ static void cache_library_bake_startjob(void *customdata, short *stop, short *do
 	data->archive = PTC_open_writer_archive(scene, filename);
 	
 	data->writer = PTC_writer_dupligroup(data->cachelib->group->id.name, &data->eval_ctx, scene, data->cachelib->group);
-	PTC_writer_set_archive(data->writer, data->archive);
+	PTC_writer_init(data->writer, data->archive);
 	
 	G.is_break = false;
 	
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index b2a9a56..a37709d 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -117,11 +117,11 @@ void PTC_close_reader_archive(PTCReaderArchive *_archive)
 	delete archive;
 }
 
-void PTC_writer_set_archive(PTCWriter *_writer, PTCWriterArchive *_archive)
+void PTC_writer_init(PTCWriter *_writer, PTCWriterArchive *_archive)
 {
 	PTC::Writer *writer = (PTC::Writer *)_writer;
 	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
-	writer->set_archive(archive);
+	writer->init(archive);
 }
 
 void PTC_writer_create_refs(PTCWriter *_writer)
@@ -130,11 +130,11 @@ void PTC_writer_create_refs(PTCWriter *_writer)
 	writer->create_refs();
 }
 
-void PTC_reader_set_archive(PTCReader *_reader, PTCReaderArchive *_archive)
+void PTC_reader_init(PTCReader *_reader, PTCReaderArchive *_archive)
 {
 	PTC::Reader *reader = (PTC::Reader *)_reader;
 	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
-	reader->set_archive(archive);
+	reader->init(archive);
 }
 
 /* ========================================================================= */
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 105dabb..48d4a94 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -69,9 +69,9 @@ void PTC_close_writer_archive(struct PTCWriterArchive *archive);
 struct PTCReaderArchive *PTC_open_reader_archive(struct Scene *scene, const char *path);
 void PTC_close_reader_archive(struct PTCReaderArchive *archive);
 
-void PTC_writer_set_archive(struct PTCWriter *writer, struct PTCWriterArchive *archive);
+void PTC_writer_init(struct PTCWriter *writer, struct PTCWriterArchive *archive);
 void PTC_writer_create_refs(struct PTCWriter *writer);
-void PTC_reader_set_archive(struct PTCReader *reader, struct PTCReaderArchive *archive);
+void PTC_reader_init(struct PTCReader *reader, struct PTCReaderArchive *archive);
 
 /*** Reader/Writer Interface ***/
 
diff --git a/source/blender/pointcache/alembic/abc_cloth.cpp b/source/blender/pointcache/alembic/abc_cloth.cpp
index 594bb4d..1e6621b 100644
--- a/source/blender/pointcache/alembic/abc_cloth.cpp
+++ b/source/blender/pointcache/alembic/abc_cloth.cpp
@@ -45,23 +45,18 @@ AbcClothWriter::~AbcClothWriter()
 {
 }
 
-void AbcClothWriter::open_archive(WriterArchive *archive)
+void AbcClothWriter::init_abc(OObject parent)
 {
-	BLI_assert(dynamic_cast<AbcWriterArchive*>(archive));
-	AbcWriter::abc_archive(static_cast<AbcWriterArchive*>(archive));
-	
-	if (abc_archive()->archive) {
-		OObject parent = abc_archive()->get_id_object((ID *)m_ob);
-		if (parent) {
-			m_points = OPoints(parent, m_name, abc_archive()->frame_sampling_index());
-			
-			OPointsSchema &schema = m_points.getSchema();
-			OCompoundProperty geom_params = schema.getArbGeomParams();
-			
-			m_param_velocities = OV3fGeomParam(geom_params, "velocities", false, kVaryingScope, 1, 0);
-			m_param_goal_positions = OP3fGeomParam(geom_params, "goal_positions", false, kVaryingScope, 1, 0);
-		}
-	}
+	if (m_points)
+		return;
+	
+	m_points = OPoints(parent, m_name, abc_archive()->frame_sampling_index());
+	
+	OPointsSchema &schema = m_points.getSchema();
+	OCompoundProperty geom_params = schema.getArbGeomParams();
+	
+	m_param_velocities = OV3fGeomParam(geom_params, "velocities", false, kVaryingScope, 1, 0);
+	m_param_goal_positions = OP3fGeomParam(geom_params, "goal_positions", false, kVaryingScope, 1, 0);
 }
 
 static V3fArraySample create_sample_velocities(Cloth *cloth, std::vector<V3f> &data)
@@ -143,22 +138,19 @@ AbcClothReader::~AbcClothReader()
 {
 }
 
-void AbcClothReader::open_archive(ReaderArchive *archive)
+void AbcClothReader::init_abc(IObject parent)
 {
-	BLI_assert(dynamic_cast<AbcReaderArchive*>(archive));
-	AbcReader::abc_archive(static_cast<AbcReaderArchive*>(archive));
-	
-	if (abc_archive()->archive) {
-		IObject parent = abc_archive()->get_id_object((ID *)m_ob);
-		if (parent && parent.getChild(m_name)) {
-			m_points = IPoints(parent, m_name);
-			
-			IPointsSchema &schema = m_points.getSchema();
-			ICompoundProperty geom_params = schema.getArbGeomParams();
-			
-			m_param_velocities = IV3fGeomParam(geom_params, "velocities", 0);
-			m_param_goal_positions= IP3fGeomParam(geom_params, "goal_positions", 0);
-		}
+	if (m_points)
+		return;
+	
+	if (parent.getChild(m_name)) {
+		m_points = IPoints(parent, m_name);
+		
+		IPointsSchema &schema = m_points.getSchema();
+		ICompoundProperty geom_params = schema.getArbGeomParams();
+		
+		m_param_velocities = IV3fGeomParam(geom_params, "velocities", 0);
+		m_param_goal_positions= IP3fGeomParam(geom_params, "goal_positions", 0);
 	}
 }
 
diff --git a/source/blender/pointcache/alembic/abc_cloth.h b/source/blender/pointcache/alembic/abc_cloth.h
index 947f49a..42460d1 100644
--- a/source/blender/pointcache/alembic/abc_cloth.h
+++ b/source/blender/pointcache/alembic/abc_cloth.h
@@ -38,7 +38,7 @@ public:
 	AbcClothWriter(const std::string &name, Object *ob, ClothModifierData *clmd);
 	~AbcClothWriter();
 	
-	void open_archive(WriterArchive *archive);
+	void init_abc(Abc::OObject parent);
 	
 	void write_sample();
 	
@@ -53,7 +53,7 @@ public:
 	AbcClothReader(const std::string &name, Object *ob, ClothModifierData *clmd);
 	~AbcClothReader();
 	
-	void open_archive(ReaderArchive *archive);
+	void init_abc(Abc::IObject parent);
 	
 	PTCReadSampleResult read_sample(float frame);
 	
diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index b2be672..fead89e 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -49,14 +49,12 @@ AbcGroupWriter::AbcGroupWriter(const std::string &name, Group *group) :
 {
 }
 
-void AbcGroupWriter::open_archive(WriterArchive *archive)
+void AbcGroupWriter::init_abc()
 {
-	BLI_assert(dynamic_cast<AbcWriterArchive*>(archive));
-	AbcWriter::abc_archive(static_cast<AbcWriterArchive*>(archive));
+	if (m_abc_object)
+		return;
 	
-	if (abc_archive()->archive) {
-		m_abc_object = abc_archive()->add_id_object<OObject>((ID *)m_group);
-	}
+	m_abc_object = abc_archive()->add_id_object<OObject>((ID *)m_gro

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list