[Bf-blender-cvs] [82fe7b1cec2] : Very hackish WIP writing of custom properties

Sybren A. Stüvel noreply at git.blender.org
Thu Dec 7 10:36:38 CET 2017


Commit: 82fe7b1cec2497c72044236a427a081edff95a3a
Author: Sybren A. Stüvel
Date:   Mon Nov 13 17:27:18 2017 +0100
Branches: 
https://developer.blender.org/rB82fe7b1cec2497c72044236a427a081edff95a3a

Very hackish WIP writing of custom properties

For now just one hard-coded "property" to get a feel for how this works.

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

M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/abc_mesh.h
M	source/blender/alembic/intern/abc_object.cc
M	source/blender/alembic/intern/abc_object.h

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

diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 2c57af25c1b..17dec94d0b0 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -39,12 +39,16 @@ extern "C" {
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_depsgraph.h"
+#include "BKE_idprop.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 
+#include "BKE_global.h"
+#include "DNA_scene_types.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -282,6 +286,8 @@ AbcMeshWriter::AbcMeshWriter(Scene *scene,
 		OBoolProperty type(typeContainer, "meshtype");
 		type.set(m_is_subd);
 	}
+
+	create_custom_properties();
 }
 
 AbcMeshWriter::~AbcMeshWriter()
@@ -1393,4 +1399,36 @@ void AbcSubDReader::read_custom_properties(const Alembic::Abc::ISampleSelector &
 	                            sample_sel,
 	                            r_is_constant);
 }
+
+void AbcMeshWriter::create_custom_properties()
+{
+	if (m_settings.use_subdiv_schema && m_is_subd)
+		m_custom_props = m_subdiv_schema.getArbGeomParams();
+	else
+		m_custom_props = m_mesh_schema.getArbGeomParams();
+
+	IDProperty *group = IDP_GetProperties((ID *)m_object->data, false);
+	if (group == NULL) return;
+
+	m_custom_int_props[std::string("primes")] = OInt32ArrayProperty(m_custom_props, "primes");
+}
+
+void AbcMeshWriter::write_custom_properties()
+{
+	OInt32ArrayProperty primes = m_custom_int_props.find(std::string("primes"))->second;
+
+	Scene *scene = (Scene *)G.main->scene.first;
+	std::vector<Alembic::Util::int32_t> vals(4);
+	vals[0] = 13 + CFRA;
+	vals[1] = 17 + CFRA;
+	vals[2] = 19 + CFRA;
+	vals[3] = 23 + CFRA;
+	primes.set(vals);
+
+	primes.setTimeSampling(m_time_sampling);
+	std::cerr << "Set property " << primes.getName() << " to "
+	          << vals[0] << ", "
+	          << vals[1] << ", "
+	          << vals[2] << ", "
+	          << vals[3] << " (" << vals.size() << " items)\n";
 }
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index fa2444e9279..83e3be2390a 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -41,6 +41,9 @@ class AbcMeshWriter : public AbcObjectWriter {
 
 	Alembic::Abc::OArrayProperty m_mat_indices;
 
+	Alembic::Abc::OCompoundProperty m_custom_props;
+	std::map<std::string, Alembic::Abc::OInt32ArrayProperty> m_custom_int_props;
+
 	bool m_is_animated;
 	ModifierData *m_subsurf_mod;
 
@@ -58,6 +61,8 @@ public:
 
 	~AbcMeshWriter();
 	void setIsAnimated(bool is_animated);
+	virtual void write_custom_properties() override;
+	virtual void create_custom_properties();
 
 private:
 	virtual void do_write();
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 9b5d568016b..8a43ec31f52 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -100,6 +100,7 @@ Imath::Box3d AbcObjectWriter::bounds()
 void AbcObjectWriter::write()
 {
 	do_write();
+	write_custom_properties();
 	m_first_frame = false;
 }
 
@@ -669,4 +670,12 @@ void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector
 	read_custom_properties_into(&m_object->id, schema.getArbGeomParams(), sample_sel,
 	                            r_is_constant);
 }
+
+void AbcObjectWriter::write_custom_properties()
+{
+}
+
+void AbcObjectWriter::write_custom_properties_into(Alembic::Abc::OCompoundProperty params,
+                                                   const ID *id)
+{
 }
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 10af94cd143..4a1135e612f 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -67,9 +67,17 @@ public:
 	virtual Imath::Box3d bounds();
 
 	void write();
+	virtual void write_custom_properties();
 
 private:
 	virtual void do_write() = 0;
+protected:
+
+	/* Reads ID properties from the given ID block, and writes them to an
+	 * Alembic OCustomProperty. At this moment does NOT support
+	 * Alembic's 64-bit numerical types, wide strings, or arrays of strings. */
+	static void write_custom_properties_into(Alembic::Abc::OCompoundProperty params,
+	                                         const ID *id);
 };
 
 /* ************************************************************************** */



More information about the Bf-blender-cvs mailing list