[Bf-blender-cvs] [8696000] gooseberry: Use explicit name strings for all readers/writers in the cache instead of constructing names internally.

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


Commit: 8696000dd18faabb66a90808751f5cb9aa3a800e
Author: Lukas Tönne
Date:   Wed Feb 25 10:31:20 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB8696000dd18faabb66a90808751f5cb9aa3a800e

Use explicit name strings for all readers/writers in the cache instead
of constructing names internally.

This helps prevent name collisions and guarantees a consistent naming
scheme for putting multiple items in the same cache.

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

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_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/intern/alembic.h

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

diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index d77a297..e8fee2a 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -38,6 +38,7 @@ extern "C" {
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
 
+#include "BKE_cache_library.h"
 #include "BKE_modifier.h"
 #include "BKE_report.h"
 
@@ -274,9 +275,13 @@ PTCWriterArchive *PTC_cachlib_writers(Scene *scene, CacheLibrary *cachelib, List
 	BLI_listbase_clear(writers);
 	
 	for (CacheItem *item = (CacheItem *)cachelib->items.first; item; item = item->next) {
+		char name[2*MAX_NAME];
+		
 		if (!(item->flag & CACHE_ITEM_ENABLED))
 			continue;
 		
+		BKE_cache_item_name(item->ob, item->type, item->index, name);
+		
 		PTCWriter *writer = NULL;
 		switch (item->type) {
 			case CACHE_TYPE_DERIVED_MESH:
@@ -285,7 +290,7 @@ PTCWriterArchive *PTC_cachlib_writers(Scene *scene, CacheLibrary *cachelib, List
 			case CACHE_TYPE_HAIR: {
 				ParticleSystem *psys = (ParticleSystem *)BLI_findlink(&item->ob->particlesystem, item->index);
 				if (psys && psys->part && psys->part->type == PART_HAIR && psys->clmd) {
-					writer = PTC_writer_cloth(archive, item->ob, psys->clmd);
+					writer = PTC_writer_cloth(archive, name, item->ob, psys->clmd);
 				}
 				break;
 			};
@@ -317,16 +322,16 @@ void PTC_cachlib_writers_free(PTCWriterArchive *archive, ListBase *writers)
 
 /* ==== CLOTH ==== */
 
-PTCWriter *PTC_writer_cloth(PTCWriterArchive *_archive, Object *ob, ClothModifierData *clmd)
+PTCWriter *PTC_writer_cloth(PTCWriterArchive *_archive, const char *name, Object *ob, ClothModifierData *clmd)
 {
 	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
-	return (PTCWriter *)abc_writer_cloth(archive, ob, clmd);
+	return (PTCWriter *)abc_writer_cloth(archive, name, ob, clmd);
 }
 
-PTCReader *PTC_reader_cloth(PTCReaderArchive *_archive, Object *ob, ClothModifierData *clmd)
+PTCReader *PTC_reader_cloth(PTCReaderArchive *_archive, const char *name, Object *ob, ClothModifierData *clmd)
 {
 	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
-	return (PTCReader *)abc_reader_cloth(archive, ob, clmd);
+	return (PTCReader *)abc_reader_cloth(archive, name, ob, clmd);
 }
 
 
@@ -357,16 +362,16 @@ void PTC_reader_derived_mesh_discard_result(PTCReader *_reader)
 }
 
 
-PTCWriter *PTC_writer_point_cache(PTCWriterArchive *_archive, Object *ob, PointCacheModifierData *pcmd)
+PTCWriter *PTC_writer_point_cache(PTCWriterArchive *_archive, const char *name, Object *ob, PointCacheModifierData *pcmd)
 {
 	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
-	return (PTCWriter *)abc_writer_point_cache(archive, ob, pcmd);
+	return (PTCWriter *)abc_writer_point_cache(archive, name, ob, pcmd);
 }
 
-PTCReader *PTC_reader_point_cache(PTCReaderArchive *_archive, Object *ob, PointCacheModifierData *pcmd)
+PTCReader *PTC_reader_point_cache(PTCReaderArchive *_archive, const char *name, Object *ob, PointCacheModifierData *pcmd)
 {
 	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
-	return (PTCReader *)abc_reader_point_cache(archive, ob, pcmd);
+	return (PTCReader *)abc_reader_point_cache(archive, name, ob, pcmd);
 }
 
 ePointCacheModifierMode PTC_mod_point_cache_get_mode(PointCacheModifierData *pcmd)
@@ -425,16 +430,16 @@ ePointCacheModifierMode PTC_mod_point_cache_set_mode(Scene *scene, Object *ob, P
 
 /* ==== PARTICLES ==== */
 
-PTCWriter *PTC_writer_particles(PTCWriterArchive *_archive, Object *ob, ParticleSystem *psys)
+PTCWriter *PTC_writer_particles(PTCWriterArchive *_archive, const char *name, Object *ob, ParticleSystem *psys)
 {
 	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
-	return (PTCWriter *)abc_writer_particles(archive, ob, psys);
+	return (PTCWriter *)abc_writer_particles(archive, name, ob, psys);
 }
 
-PTCReader *PTC_reader_particles(PTCReaderArchive *_archive, Object *ob, ParticleSystem *psys)
+PTCReader *PTC_reader_particles(PTCReaderArchive *_archive, const char *name, Object *ob, ParticleSystem *psys)
 {
 	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
-	return (PTCReader *)abc_reader_particles(archive, ob, psys);
+	return (PTCReader *)abc_reader_particles(archive, name, ob, psys);
 }
 
 int PTC_reader_particles_totpoint(PTCReader *_reader)
@@ -442,14 +447,14 @@ int PTC_reader_particles_totpoint(PTCReader *_reader)
 	return ((PTC::ParticlesReader *)_reader)->totpoint();
 }
 
-PTCWriter *PTC_writer_particle_paths(PTCWriterArchive *_archive, Object *ob, ParticleSystem *psys)
+PTCWriter *PTC_writer_particle_paths(PTCWriterArchive *_archive, const char *name, Object *ob, ParticleSystem *psys)
 {
 	PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
-	return (PTCWriter *)abc_writer_particle_paths(archive, ob, psys);
+	return (PTCWriter *)abc_writer_particle_paths(archive, name, ob, psys);
 }
 
-PTCReader *PTC_reader_particle_paths(PTCReaderArchive *_archive, Object *ob, ParticleSystem *psys, eParticlePathsMode mode)
+PTCReader *PTC_reader_particle_paths(PTCReaderArchive *_archive, const char *name, Object *ob, ParticleSystem *psys, eParticlePathsMode mode)
 {
 	PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
-	return (PTCReader *)abc_reader_particle_paths(archive, ob, psys, mode);
+	return (PTCReader *)abc_reader_particle_paths(archive, name, ob, psys, mode);
 }
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index a65775d..467e674 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -86,8 +86,8 @@ struct PTCWriterArchive *PTC_cachlib_writers(struct Scene *scene, struct CacheLi
 void PTC_cachlib_writers_free(struct PTCWriterArchive *archive, struct ListBase *writers);
 
 /* Particles */
-struct PTCWriter *PTC_writer_particles(struct PTCWriterArchive *archive, struct Object *ob, struct ParticleSystem *psys);
-struct PTCReader *PTC_reader_particles(struct PTCReaderArchive *archive, struct Object *ob, struct ParticleSystem *psys);
+struct PTCWriter *PTC_writer_particles(struct PTCWriterArchive *archive, const char *name, struct Object *ob, struct ParticleSystem *psys);
+struct PTCReader *PTC_reader_particles(struct PTCReaderArchive *archive, const char *name, struct Object *ob, struct ParticleSystem *psys);
 int PTC_reader_particles_totpoint(struct PTCReader *reader);
 
 typedef enum eParticlePathsMode {
@@ -95,12 +95,12 @@ typedef enum eParticlePathsMode {
 	PTC_PARTICLE_PATHS_CHILDREN = 1,
 } eParticlePathsMode;
 
-struct PTCWriter *PTC_writer_particle_paths(struct PTCWriterArchive *archive, struct Object *ob, struct ParticleSystem *psys);
-struct PTCReader *PTC_reader_particle_paths(struct PTCReaderArchive *archive, struct Object *ob, struct ParticleSystem *psys, eParticlePathsMode mode);
+struct PTCWriter *PTC_writer_particle_paths(struct PTCWriterArchive *archive, const char *name, struct Object *ob, struct ParticleSystem *psys);
+struct PTCReader *PTC_reader_particle_paths(struct PTCReaderArchive *archive, const char *name, struct Object *ob, struct ParticleSystem *psys, eParticlePathsMode mode);
 
 /* Cloth */
-struct PTCWriter *PTC_writer_cloth(struct PTCWriterArchive *archive, struct Object *ob, struct ClothModifierData *clmd);
-struct PTCReader *PTC_reader_cloth(struct PTCReaderArchive *archive, struct Object *ob, struct ClothModifierData *clmd);
+struct PTCWriter *PTC_writer_cloth(struct PTCWriterArchive *archive, const char *name, struct Object *ob, struct ClothModifierData *clmd);
+struct PTCReader *PTC_reader_cloth(struct PTCReaderArchive *archive, const char *name, struct Object *ob, struct ClothModifierData *clmd);
 
 /* Modifier Stack */
 typedef enum ePointCacheModifierMode {
@@ -114,8 +114,8 @@ struct PTCReader *PTC_reader_derived_mesh(struct PTCReaderArchive *archive, cons
 struct DerivedMesh *PTC_reader_derived_mesh_acquire_result(struct PTCReader *reader);
 void PTC_reader_derived_mesh_discard_result(struct PTCReader *reader);
 
-struct PTCWriter *PTC_writer_point_cache(struct PTCWriterArchive *archive, struct Object *ob, struct PointCacheModifierData *pcmd);
-struct PTCReader *PTC_reader_point_cache(struct PTCReaderArchive *archive, struct Object *ob, struct PointCacheModifierData *pcmd);
+struct PTCWriter *PTC_writer_point_cache(struct PTCWriterArchive *archive, const char *name, struct Object *ob, struct PointCacheModifierData *pcmd);
+struct PTCReader *PTC_reader_point_cache(struct PTCReaderArchive *archive, const char *name, struct Object *ob, struct PointCacheModifierData *pcmd);
 ePointCacheModifierMode PTC_mod_point_cache_get_mode(struct PointCacheModifierData *pcmd);
 /* returns the actual new mode, in case a change didn't succeed */
 ePointCacheModifierMode PTC_mod_point_cache_set_mode(struct Scene *scene, struct Object *ob, struct PointCacheModifierData *pcmd, ePointCacheModifierMode mode);
diff --git a/source/blender/pointcache/alembic/abc_cloth.cpp b/source/blender/pointcache/alembic/abc_cloth.cpp
index 9244176..082e7d0 100644
--- a/source/blender/pointcache/alembic/abc_cloth.cpp
+++ b/source/blender/pointcache/alembic/abc_cloth.cpp
@@ -37,7 +37,7 @@ namespace PTC {
 using namespace Abc;
 using namespace AbcGeom;
 
-AbcClothWriter::AbcClothWriter(AbcWriterArchive *archive, Object *ob, ClothModifierData *clmd) :
+AbcClothWriter::AbcClothWriter(AbcWriterArchive *archive, const std::string &name, Object *ob, ClothModifierData *clmd) :
     ClothWriter(ob, clmd, archive),
     AbcWriter(archive)
 {
@@ -45,7 +45,7 @@ AbcClothWriter::AbcClothWriter(AbcWriterArchive *archive, Object *ob, ClothModif
 	
 	if (archive->archive) {
 		OObject root = archive->archive.getTop();
-		m_points = OPoints(root, m_clmd->modifier.name, archive->frame_sampling_index());
+		m_points = OPoints(root, name, archive->frame_sampling_index());
 		
 		OPointsSchema &schema = m_points.getSchema();
 		OCompoundProperty geom_params = schema.getArbGeomParams();
@@ -128,7 +128,7 @@ void AbcClothWriter::write_sample()
 }
 
 
-AbcClothReader::AbcClothReader(AbcReaderArchive *archive, Object *ob, ClothModifierData *clmd) :
+AbcClothReader::AbcClothReader(AbcReaderArchive *archive, const std::string &name, Object *ob, ClothModifierData *clmd) :
     ClothR

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list