[Bf-blender-cvs] [bcca4e5] gooseberry: Mesh storage and reading in child objects for dupligroups.

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


Commit: bcca4e5676ae7cce7b26863b14d21f8e8d8659f3
Author: Lukas Tönne
Date:   Mon Mar 16 11:13:26 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBbcca4e5676ae7cce7b26863b14d21f8e8d8659f3

Mesh storage and reading in child objects for dupligroups.

The layout of the Alembic files resembles the DNA structure in Blender:
- On the top level (under the top/root node) there are Abc::Objects for
  Blender ID datablocks (currently Object and Group)
- Objects store final data (DerivedMesh) and later simulation results
  etc.
- Groups store their full duplilists for instancing. Currently there is
  no recursive nesting of groups, since this would limit duplis to
  dupligroups and exclude e.g. duplifaces.

On reading the duplilist gets reconstructed and stored in the DupliCache
for a duplicator empty (the group instance). DerivedMesh data is stored
in a hash table for each instanciated object and can later replace
finalDM in drawing and rendering.

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

M	source/blender/pointcache/alembic/abc_group.cpp
M	source/blender/pointcache/alembic/abc_group.h
M	source/blender/pointcache/alembic/abc_object.cpp
M	source/blender/pointcache/alembic/abc_object.h

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

diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index fead89e..406e4e9 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -229,8 +229,10 @@ void AbcDupligroupReader::init_abc()
 {
 }
 
-void AbcDupligroupReader::read_dupligroup_object(IObject object, const ISampleSelector &ss)
+void AbcDupligroupReader::read_dupligroup_object(IObject object, float frame)
 {
+	ISampleSelector ss = abc_archive()->get_frame_sample_selector(frame);
+	
 	if (GS(object.getName().c_str()) == ID_OB) {
 		/* instances are handled later, we create true object data here */
 		if (object.isInstanceDescendant())
@@ -240,10 +242,16 @@ void AbcDupligroupReader::read_dupligroup_object(IObject object, const ISampleSe
 		if (!b_ob)
 			return;
 		
-		/* TODO load DM, from subobjects for IPolyMesh etc. */
-		DerivedMesh *dm = NULL;
-		DupliObjectData *data = BKE_dupli_cache_add_mesh(dupli_cache, b_ob, dm);
-		insert_dupli_data(object.getPtr(), data);
+		AbcDerivedMeshReader dm_reader("mesh", b_ob);
+		dm_reader.init(abc_archive());
+		dm_reader.init_abc(object);
+		if (dm_reader.read_sample(frame) != PTC_READ_SAMPLE_INVALID) {
+			DerivedMesh *dm = dm_reader.acquire_result();
+			DupliObjectData *data = BKE_dupli_cache_add_mesh(dupli_cache, b_ob, dm);
+			insert_dupli_data(object.getPtr(), data);
+		}
+		else
+			dm_reader.discard_result();
 	}
 }
 
@@ -283,7 +291,7 @@ PTCReadSampleResult AbcDupligroupReader::read_sample(float frame)
 	
 	/* first create shared object data */
 	for (size_t i = 0; i < abc_top.getNumChildren(); ++i) {
-		read_dupligroup_object(abc_top.getChild(i), ss);
+		read_dupligroup_object(abc_top.getChild(i), frame);
 	}
 	
 	/* now generate dupli instances for the group */
diff --git a/source/blender/pointcache/alembic/abc_group.h b/source/blender/pointcache/alembic/abc_group.h
index d45a7d4..ca2b0f6 100644
--- a/source/blender/pointcache/alembic/abc_group.h
+++ b/source/blender/pointcache/alembic/abc_group.h
@@ -107,7 +107,7 @@ public:
 	PTCReadSampleResult read_sample(float frame);
 	
 protected:
-	void read_dupligroup_object(Abc::IObject object, const Abc::ISampleSelector &ss);
+	void read_dupligroup_object(Abc::IObject object, float frame);
 	void read_dupligroup_group(Abc::IObject abc_group, const Abc::ISampleSelector &ss);
 	
 	DupliObjectData *find_dupli_data(Abc::ObjectReaderPtr ptr) const;
diff --git a/source/blender/pointcache/alembic/abc_object.cpp b/source/blender/pointcache/alembic/abc_object.cpp
index 28bfb02..338c4c9 100644
--- a/source/blender/pointcache/alembic/abc_object.cpp
+++ b/source/blender/pointcache/alembic/abc_object.cpp
@@ -32,7 +32,8 @@ using namespace Abc;
 using namespace AbcGeom;
 
 AbcObjectWriter::AbcObjectWriter(const std::string &name, Object *ob) :
-    ObjectWriter(ob, name)
+    ObjectWriter(ob, name),
+    m_dm_writer("mesh", ob, &ob->derivedFinal)
 {
 }
 
@@ -42,6 +43,10 @@ void AbcObjectWriter::init_abc()
 		return;
 	
 	m_abc_object = abc_archive()->add_id_object<OObject>((ID *)m_ob);
+	
+	/* XXX not nice */
+	m_dm_writer.init(abc_archive());
+	m_dm_writer.init_abc(m_abc_object);
 }
 
 #if 0
@@ -60,7 +65,7 @@ void AbcObjectWriter::write_sample()
 	if (!m_abc_object)
 		return;
 	
-	// TODO mesh, modifiers, sims ...
+	m_dm_writer.write_sample();
 }
 
 
diff --git a/source/blender/pointcache/alembic/abc_object.h b/source/blender/pointcache/alembic/abc_object.h
index bc90033..cd2d15a 100644
--- a/source/blender/pointcache/alembic/abc_object.h
+++ b/source/blender/pointcache/alembic/abc_object.h
@@ -29,6 +29,7 @@
 #include "abc_reader.h"
 #include "abc_schema.h"
 #include "abc_writer.h"
+#include "abc_mesh.h"
 
 struct Object;
 
@@ -47,6 +48,8 @@ public:
 	
 private:
 	Abc::OObject m_abc_object;
+	
+	AbcDerivedMeshWriter m_dm_writer;
 };
 
 class AbcObjectReader : public ObjectReader, public AbcReader {




More information about the Bf-blender-cvs mailing list