[Bf-blender-cvs] [f24153b] alembic: Apply sim debug data from caches back to the global hash table.

Lukas Tönne noreply at git.blender.org
Sun Apr 5 17:11:41 CEST 2015


Commit: f24153bcbce32b14af499a8616cf897f560b37f8
Author: Lukas Tönne
Date:   Sun Apr 5 17:10:14 2015 +0200
Branches: alembic
https://developer.blender.org/rBf24153bcbce32b14af499a8616cf897f560b37f8

Apply sim debug data from caches back to the global hash table.

Note that this is quite messy atm, it will override debug data if
different caches are used, and does not discriminate when writing to
caches either.

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

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h
M	source/blender/pointcache/alembic/abc_group.cpp
M	source/blender/pointcache/alembic/abc_group.h
M	source/blender/pointcache/alembic/alembic.cpp
M	source/blender/pointcache/intern/ptc_types.h

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

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 5d57d45..3f29c24 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -350,7 +350,7 @@ bool BKE_cache_read_dupli_cache(CacheLibrary *cachelib, DupliCache *dupcache,
 		return false;
 	
 	// TODO duplicache reader should only overwrite data that is not sequentially generated by modifiers (simulations) ...
-	reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache);
+	reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache, G.debug & G_DEBUG_SIMDATA);
 	PTC_reader_init(reader, archive);
 	
 	dupcache->result = BKE_cache_read_result(PTC_read_sample(reader, frame));
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 592fc57..27b192f 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -71,7 +71,7 @@ class StubFactory : public Factory {
 	Writer *create_writer_derived_final_render(const std::string &/*name*/, Scene */*scene*/, Object */*ob*/, DerivedMesh **/*render_dm_ptr*/) { return NULL; }
 	Writer *create_writer_dupligroup(const std::string &/*name*/, EvaluationContext */*eval_ctx*/, Scene */*scene*/, Group */*group*/, CacheLibrary */*cachelib*/) { return NULL; }
 	Writer *create_writer_duplicache(const std::string &/*name*/, Group */*group*/, DupliCache */*dupcache*/, int /*datatypes*/, bool /*do_sim_debug*/) { return NULL; }
-	Reader *create_reader_duplicache(const std::string &/*name*/, Group */*group*/, DupliCache */*dupcache*/) { return NULL; }
+	Reader *create_reader_duplicache(const std::string &/*name*/, Group */*group*/, DupliCache */*dupcache*/, bool /*do_sim_debug*/) { return NULL; }
 	Reader *create_reader_duplicache_object(const std::string &/*name*/, Object */*ob*/, DupliObjectData */*data*/) { return NULL; }
 };
 
@@ -254,9 +254,9 @@ PTCWriter *PTC_writer_duplicache(const char *name, struct Group *group, struct D
 	return (PTCWriter *)PTC::Factory::alembic->create_writer_duplicache(name, group, dupcache, datatypes, do_sim_debug);
 }
 
-PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache)
+PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache, bool do_sim_debug)
 {
-	return (PTCReader *)PTC::Factory::alembic->create_reader_duplicache(name, group, dupcache);
+	return (PTCReader *)PTC::Factory::alembic->create_reader_duplicache(name, group, dupcache, do_sim_debug);
 }
 
 PTCReader *PTC_reader_duplicache_object(const char *name, struct Object *ob, struct DupliObjectData *data)
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 51963f7..b9b92a6 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -85,7 +85,7 @@ char *PTC_get_archive_info(struct PTCReaderArchive *archive);
 struct PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group, struct CacheLibrary *cachelib);
 struct PTCWriter *PTC_writer_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache, int datatypes, bool do_sim_debug);
 
-struct PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache);
+struct PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache, bool do_sim_debug);
 struct PTCReader *PTC_reader_duplicache_object(const char *name, struct Object *ob, struct DupliObjectData *data);
 
 /* get writer/reader from RNA type */
diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index b64792a..48131af 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -340,19 +340,28 @@ AbcWriter *AbcDupliCacheWriter::find_id_writer(ID *id) const
 
 /* ------------------------------------------------------------------------- */
 
-AbcDupliCacheReader::AbcDupliCacheReader(const std::string &name, Group *group, DupliCache *dupli_cache) :
+AbcDupliCacheReader::AbcDupliCacheReader(const std::string &name, Group *group, DupliCache *dupli_cache, bool do_sim_debug) :
     GroupReader(group, name),
-    dupli_cache(dupli_cache)
+    dupli_cache(dupli_cache),
+    m_simdebug_reader(NULL)
 {
 	/* XXX this mapping allows fast lookup of existing objects in Blender data
 	 * to associate with duplis. Later i may be possible to create instances of
 	 * non-DNA data, but for the time being this is a requirement due to other code parts (drawing, rendering)
 	 */
 	build_object_map(G.main, group);
+	
+	if (do_sim_debug) {
+		BKE_sim_debug_data_set_enabled(true);
+		if (_sim_debug_data)
+			m_simdebug_reader = new AbcSimDebugReader(_sim_debug_data);
+	}
 }
 
 AbcDupliCacheReader::~AbcDupliCacheReader()
 {
+	if (m_simdebug_reader)
+		delete m_simdebug_reader;
 }
 
 void AbcDupliCacheReader::init_abc(IObject object)
@@ -463,6 +472,16 @@ PTCReadSampleResult AbcDupliCacheReader::read_sample(float frame)
 	/* now generate dupli instances for the group */
 	read_dupligroup_group(abc_group, ss);
 	
+	// XXX reader init is a mess ...
+	if (m_simdebug_reader) {
+		if (abc_top.getChildHeader("sim_debug")) {
+			m_simdebug_reader->init(abc_archive());
+			m_simdebug_reader->init_abc(abc_top.getChild("sim_debug"));
+			
+			m_simdebug_reader->read_sample(frame);
+		}
+	}
+	
 	return PTC_READ_SAMPLE_EXACT;
 }
 
diff --git a/source/blender/pointcache/alembic/abc_group.h b/source/blender/pointcache/alembic/abc_group.h
index a4cee8a5..1bdc910 100644
--- a/source/blender/pointcache/alembic/abc_group.h
+++ b/source/blender/pointcache/alembic/abc_group.h
@@ -38,6 +38,7 @@ namespace PTC {
 class AbcDerivedMeshWriter;
 class AbcStrandsWriter;
 class AbcSimDebugWriter;
+class AbcSimDebugReader;
 
 class AbcGroupWriter : public GroupWriter, public AbcWriter {
 public:
@@ -135,7 +136,7 @@ public:
 	typedef std::pair<std::string, Object*> ObjectPair;
 	
 public:
-	AbcDupliCacheReader(const std::string &name, Group *group, DupliCache *dupcache);
+	AbcDupliCacheReader(const std::string &name, Group *group, DupliCache *dupcache, bool do_sim_debug);
 	~AbcDupliCacheReader();
 	
 	void init_abc(Abc::IObject object);
@@ -158,6 +159,7 @@ private:
 	DupliCache *dupli_cache;
 	
 	ObjectMap object_map;
+	AbcSimDebugReader *m_simdebug_reader;
 };
 
 
diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp
index 99d2376..c62a838 100644
--- a/source/blender/pointcache/alembic/alembic.cpp
+++ b/source/blender/pointcache/alembic/alembic.cpp
@@ -152,9 +152,9 @@ class AbcFactory : public Factory {
 		return new AbcDupliCacheWriter(name, group, dupcache, datatypes, do_sim_debug);
 	}
 	
-	Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache)
+	Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache, bool do_sim_debug)
 	{
-		return new AbcDupliCacheReader(name, group, dupcache);
+		return new AbcDupliCacheReader(name, group, dupcache, do_sim_debug);
 	}
 	
 	Reader *create_reader_duplicache_object(const std::string &name, Object *ob, DupliObjectData *data)
diff --git a/source/blender/pointcache/intern/ptc_types.h b/source/blender/pointcache/intern/ptc_types.h
index bc0b4d6..25628a6 100644
--- a/source/blender/pointcache/intern/ptc_types.h
+++ b/source/blender/pointcache/intern/ptc_types.h
@@ -230,7 +230,7 @@ struct Factory {
 	
 	virtual Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib) = 0;
 	virtual Writer *create_writer_duplicache(const std::string &name, Group *group, DupliCache *dupcache, int datatypes, bool do_sim_debug) = 0;
-	virtual Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache) = 0;
+	virtual Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache, bool do_sim_debug) = 0;
 	virtual Reader *create_reader_duplicache_object(const std::string &name, Object *ob, DupliObjectData *data) = 0;
 	
 	static Factory *alembic;




More information about the Bf-blender-cvs mailing list