[Bf-blender-cvs] [a47ce4b] gooseberry: Refactoring of archive handling in readers/writers.

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


Commit: a47ce4b04da9747ac48148c4a9ea66e178aad26b
Author: Lukas Tönne
Date:   Tue Feb 24 18:25:15 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBa47ce4b04da9747ac48148c4a9ea66e178aad26b

Refactoring of archive handling in readers/writers.

Now instead of each reader/writer creating its own archive, the archive
is created by the caller in advance and passed as a constructor
argument. This means that multiple items can be stored together in the
same archive.

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

M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/modifiers/intern/MOD_pointcache.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_dynamicpaint.cpp
M	source/blender/pointcache/alembic/abc_dynamicpaint.h
M	source/blender/pointcache/alembic/abc_mesh.cpp
M	source/blender/pointcache/alembic/abc_mesh.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_rigidbody.cpp
M	source/blender/pointcache/alembic/abc_rigidbody.h
M	source/blender/pointcache/alembic/abc_smoke.cpp
M	source/blender/pointcache/alembic/abc_smoke.h
M	source/blender/pointcache/alembic/abc_softbody.cpp
M	source/blender/pointcache/alembic/abc_softbody.h
M	source/blender/pointcache/alembic/abc_writer.cpp
M	source/blender/pointcache/alembic/abc_writer.h
M	source/blender/pointcache/intern/alembic.h

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

diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index dba34e0..bfc5280 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -54,6 +54,10 @@ typedef struct CacheItem {
 	
 	int flag;
 	int pad;
+	
+	/* runtime */
+	struct PTCReader *reader;
+	struct PTCWriter *writer;
 } CacheItem;
 
 typedef enum eCacheItem_Flag {
@@ -68,6 +72,10 @@ typedef struct CacheLibrary {
 	
 	ListBase items;				/* cached items */
 	struct GHash *items_hash;	/* runtime: cached items hash for fast lookup */
+	
+	/* runtime */
+	struct PTCReaderArchive *reader_archive;
+	struct PTCWriterArchive *writer_archive;
 } CacheLibrary;
 
 #endif
diff --git a/source/blender/modifiers/intern/MOD_pointcache.c b/source/blender/modifiers/intern/MOD_pointcache.c
index 8e8d648..51eadf7 100644
--- a/source/blender/modifiers/intern/MOD_pointcache.c
+++ b/source/blender/modifiers/intern/MOD_pointcache.c
@@ -95,6 +95,7 @@ static DerivedMesh *pointcache_do(PointCacheModifierData *pcmd, Object *ob, Deri
 	
 	DerivedMesh *finaldm = dm;
 	
+#if 0
 	if (mode == MOD_POINTCACHE_MODE_NONE) {
 		mode = PTC_mod_point_cache_set_mode(scene, ob, pcmd, MOD_POINTCACHE_MODE_READ);
 	}
@@ -114,6 +115,7 @@ static DerivedMesh *pointcache_do(PointCacheModifierData *pcmd, Object *ob, Deri
 				finaldm = result;
 		}
 	}
+#endif
 	
 	return finaldm;
 }
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 6e3eda4..645a865 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -86,6 +86,29 @@ void PTC_error_handler_modifier(struct ModifierData *md)
 }
 
 
+PTCWriterArchive *PTC_open_writer_archive(Scene *scene, const char *path)
+{
+	return (PTCWriterArchive *)abc_writer_archive(scene, path, NULL);
+}
+
+void PTC_close_writer_archive(PTCWriterArchive *_archive)
+{
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	delete archive;
+}
+
+PTCReaderArchive *PTC_open_reader_archive(Scene *scene, const char *path)
+{
+	return (PTCReaderArchive *)abc_reader_archive(scene, path, NULL);
+}
+
+void PTC_close_reader_archive(PTCReaderArchive *_archive)
+{
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	delete archive;
+}
+
+
 void PTC_writer_free(PTCWriter *_writer)
 {
 	PTC::Writer *writer = (PTC::Writer *)_writer;
@@ -142,11 +165,14 @@ PTCReadSampleResult PTC_test_sample(PTCReader *_reader, float frame)
 /* get writer/reader from RNA type */
 PTCWriter *PTC_writer_from_rna(Scene *scene, PointerRNA *ptr)
 {
+#if 0
+#if 0
 	if (RNA_struct_is_a(ptr->type, &RNA_ParticleSystem)) {
 		Object *ob = (Object *)ptr->id.data;
 		ParticleSystem *psys = (ParticleSystem *)ptr->data;
 		return PTC_writer_particles_combined(scene, ob, psys);
 	}
+#endif
 	if (RNA_struct_is_a(ptr->type, &RNA_ClothModifier)) {
 		Object *ob = (Object *)ptr->id.data;
 		ClothModifierData *clmd = (ClothModifierData *)ptr->data;
@@ -179,11 +205,13 @@ PTCWriter *PTC_writer_from_rna(Scene *scene, PointerRNA *ptr)
 		return PTC_writer_point_cache(scene, ob, pcmd);
 	}
 #endif
+#endif
 	return NULL;
 }
 
 PTCReader *PTC_reader_from_rna(Scene *scene, PointerRNA *ptr)
 {
+#if 0
 	if (RNA_struct_is_a(ptr->type, &RNA_ParticleSystem)) {
 		Object *ob = (Object *)ptr->id.data;
 		ParticleSystem *psys = (ParticleSystem *)ptr->data;
@@ -227,46 +255,53 @@ PTCReader *PTC_reader_from_rna(Scene *scene, PointerRNA *ptr)
 		PointCacheModifierData *pcmd = (PointCacheModifierData *)ptr->data;
 		return PTC_reader_point_cache(scene, ob, pcmd);
 	}
+#endif
 	return NULL;
 }
 
 
 /* ==== CLOTH ==== */
 
-PTCWriter *PTC_writer_cloth(Scene *scene, Object *ob, ClothModifierData *clmd)
+PTCWriter *PTC_writer_cloth(PTCWriterArchive *_archive, Object *ob, ClothModifierData *clmd)
 {
-	return (PTCWriter *)abc_writer_cloth(scene, ob, clmd);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_cloth(archive, ob, clmd);
 }
 
-PTCReader *PTC_reader_cloth(Scene *scene, Object *ob, ClothModifierData *clmd)
+PTCReader *PTC_reader_cloth(PTCReaderArchive *_archive, Object *ob, ClothModifierData *clmd)
 {
-	return (PTCReader *)abc_reader_cloth(scene, ob, clmd);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_cloth(archive, ob, clmd);
 }
 
 
 /* ==== DYNAMIC PAINT ==== */
 
-PTCWriter *PTC_writer_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface)
+PTCWriter *PTC_writer_dynamicpaint(PTCWriterArchive *_archive, Object *ob, DynamicPaintSurface *surface)
 {
-	return (PTCWriter *)abc_writer_dynamicpaint(scene, ob, surface);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_dynamicpaint(archive, ob, surface);
 }
 
-PTCReader *PTC_reader_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface)
+PTCReader *PTC_reader_dynamicpaint(PTCReaderArchive *_archive, Object *ob, DynamicPaintSurface *surface)
 {
-	return (PTCReader *)abc_reader_dynamicpaint(scene, ob, surface);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_dynamicpaint(archive, ob, surface);
 }
 
 
 /* ==== MESH ==== */
 
-PTCWriter *PTC_writer_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd)
+PTCWriter *PTC_writer_point_cache(PTCWriterArchive *_archive, Object *ob, PointCacheModifierData *pcmd)
 {
-	return (PTCWriter *)abc_writer_point_cache(scene, ob, pcmd);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_point_cache(archive, ob, pcmd);
 }
 
-PTCReader *PTC_reader_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd)
+PTCReader *PTC_reader_point_cache(PTCReaderArchive *_archive, Object *ob, PointCacheModifierData *pcmd)
 {
-	return (PTCReader *)abc_reader_point_cache(scene, ob, pcmd);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_point_cache(archive, ob, pcmd);
 }
 
 struct DerivedMesh *PTC_reader_point_cache_acquire_result(PTCReader *_reader)
@@ -294,6 +329,7 @@ ePointCacheModifierMode PTC_mod_point_cache_get_mode(PointCacheModifierData *pcm
 		return MOD_POINTCACHE_MODE_NONE;
 }
 
+#if 0
 ePointCacheModifierMode PTC_mod_point_cache_set_mode(Scene *scene, Object *ob, PointCacheModifierData *pcmd, ePointCacheModifierMode mode)
 {
 	switch (mode) {
@@ -329,18 +365,21 @@ ePointCacheModifierMode PTC_mod_point_cache_set_mode(Scene *scene, Object *ob, P
 			return MOD_POINTCACHE_MODE_NONE;
 	}
 }
+#endif
 
 
 /* ==== PARTICLES ==== */
 
-PTCWriter *PTC_writer_particles(Scene *scene, Object *ob, ParticleSystem *psys)
+PTCWriter *PTC_writer_particles(PTCWriterArchive *_archive, Object *ob, ParticleSystem *psys)
 {
-	return (PTCWriter *)abc_writer_particles(scene, ob, psys);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_particles(archive, ob, psys);
 }
 
-PTCReader *PTC_reader_particles(Scene *scene, Object *ob, ParticleSystem *psys)
+PTCReader *PTC_reader_particles(PTCReaderArchive *_archive, Object *ob, ParticleSystem *psys)
 {
-	return (PTCReader *)abc_reader_particles(scene, ob, psys);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_particles(archive, ob, psys);
 }
 
 int PTC_reader_particles_totpoint(PTCReader *_reader)
@@ -348,56 +387,59 @@ int PTC_reader_particles_totpoint(PTCReader *_reader)
 	return ((PTC::ParticlesReader *)_reader)->totpoint();
 }
 
-//PTCWriter *PTC_writer_particle_paths(Scene *scene, Object *ob, ParticleSystem *psys)
-//{
-//	return (PTCWriter *)abc_writer_particle_paths(scene, ob, psys);
-//}
-
-PTCReader *PTC_reader_particle_paths(Scene *scene, Object *ob, ParticleSystem *psys, eParticlePathsMode mode)
+PTCWriter *PTC_writer_particle_paths(PTCWriterArchive *_archive, Object *ob, ParticleSystem *psys)
 {
-	return (PTCReader *)abc_reader_particle_paths(scene, ob, psys, mode);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_particle_paths(archive, ob, psys);
 }
 
-PTCWriter *PTC_writer_particles_combined(Scene *scene, Object *ob, ParticleSystem *psys)
+PTCReader *PTC_reader_particle_paths(PTCReaderArchive *_archive, Object *ob, ParticleSystem *psys, eParticlePathsMode mode)
 {
-	return (PTCWriter *)abc_writer_particle_combined(scene, ob, psys);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_particle_paths(archive, ob, psys, mode);
 }
 
 
 /* ==== RIGID BODY ==== */
 
-PTCWriter *PTC_writer_rigidbody(Scene *scene, RigidBodyWorld *rbw)
+PTCWriter *PTC_writer_rigidbody(PTCWriterArchive *_archive, Scene *scene, RigidBodyWorld *rbw)
 {
-	return (PTCWriter *)abc_writer_rigidbody(scene, rbw);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_rigidbody(archive, scene, rbw);
 }
 
-PTCReader *PTC_reader_rigidbody(Scene *scene, RigidBodyWorld *rbw)
+PTCReader *PTC_reader_rigidbody(PTCReaderArchive *_archive, Scene *scene, RigidBodyWorld *rbw)
 {
-	return (PTCReader *)abc_reader_rigidbody(scene, rbw);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_rigidbody(archive, scene, rbw);
 }
 
 
 /* ==== SMOKE ==== */
 
-PTCWriter *PTC_writer_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain)
+PTCWriter *PTC_writer_smoke(PTCWriterArchive *_archive, Object *ob, SmokeDomainSettings *domain)
 {
-	return (PTCWriter *)abc_writer_smoke(scene, ob, domain);
+	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+	return (PTCWriter *)abc_writer_smoke(archive, ob, domain);
 }
 
-PTCReader *PTC_reader_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain)
+PTCReader *PTC_reader_smoke(PTCReaderArchive *_archive, Object *ob, SmokeDomainSettings *domain)
 {
-	return (PTCReader *)abc_reader_smoke(scene, ob, domain);
+	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+	return (PTCReader *)abc_reader_smoke(archive, ob, domain);
 }
 
 
 /* ==== SOFT BODY ==== */
 
-PTCWriter *PTC_writer_softbody(Scene *scene, Object *ob, SoftBody *softbody)
+PTCW

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list