[Bf-blender-cvs] [2121b0a0dde] : Don't bother re-reading constant properties.
Sybren A. Stüvel
noreply at git.blender.org
Thu Dec 7 10:36:40 CET 2017
Commit: 2121b0a0ddec4cf7200f2c64661b82adb2b5de31
Author: Sybren A. Stüvel
Date: Tue Nov 14 00:33:20 2017 +0100
Branches:
https://developer.blender.org/rB2121b0a0ddec4cf7200f2c64661b82adb2b5de31
Don't bother re-reading constant properties.
Without this, all properties would be re-read and recreated for every
frame, even when they are constant. Still needs testing, requires an
animated object or custom property (so that a constraint is added that
reads Alembic for every frame) together with constant properties.
Writing is broken at the moment, though...
===================================================================
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 17dec94d0b0..981f6ac4f27 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1378,10 +1378,10 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
/* ******* Custom properties support **************************************** */
-void AbcMeshReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+void AbcMeshReader::do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
bool &r_is_constant)
{
- AbcObjectReader::read_custom_properties(sample_sel, r_is_constant);
+ AbcObjectReader::do_read_custom_properties(sample_sel, r_is_constant);
read_custom_properties_into(static_cast<ID *>(m_object->data),
m_schema.getArbGeomParams(),
@@ -1389,10 +1389,10 @@ void AbcMeshReader::read_custom_properties(const Alembic::Abc::ISampleSelector &
r_is_constant);
}
-void AbcSubDReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+void AbcSubDReader::do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
bool &r_is_constant)
{
- AbcObjectReader::read_custom_properties(sample_sel, r_is_constant);
+ AbcObjectReader::do_read_custom_properties(sample_sel, r_is_constant);
read_custom_properties_into(static_cast<ID *>(m_object->data),
m_schema.getArbGeomParams(),
@@ -1411,11 +1411,14 @@ void AbcMeshWriter::create_custom_properties()
if (group == NULL) return;
m_custom_int_props[std::string("primes")] = OInt32ArrayProperty(m_custom_props, "primes");
+ m_custom_int_props[std::string("static")] = OInt32ArrayProperty(m_custom_props, "static");
}
void AbcMeshWriter::write_custom_properties()
{
OInt32ArrayProperty primes = m_custom_int_props.find(std::string("primes"))->second;
+ // TODO: move to prop creation
+ primes.setTimeSampling(m_time_sampling);
Scene *scene = (Scene *)G.main->scene.first;
std::vector<Alembic::Util::int32_t> vals(4);
@@ -1424,11 +1427,20 @@ void AbcMeshWriter::write_custom_properties()
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";
+
+
+ OInt32ArrayProperty staticprop = m_custom_int_props.find(std::string("primes"))->second;
+ // TODO: move to prop creation
+ staticprop.setTimeSampling(m_time_sampling);
+
+ std::vector<Alembic::Util::int32_t> staticval(1);
+ staticval[0] = 13;
+ staticprop.set(staticval);
+ std::cerr << "Set property " << staticprop.getName() << " to "
+ << staticval[0] << " (" << staticval.size() << " items)\n";
}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 83e3be2390a..afc8833db94 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -114,7 +114,7 @@ public:
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
- virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+ virtual void do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
bool &r_is_constant) override;
private:
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
@@ -145,7 +145,7 @@ public:
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
- virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+ virtual void do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
bool &r_is_constant) override;
};
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 8a43ec31f52..7b1ed4efea3 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -117,6 +117,7 @@ AbcObjectReader::AbcObjectReader(const IObject &object, ImportSettings &settings
, m_max_time(std::numeric_limits<chrono_t>::min())
, m_refcount(0)
, parent_reader(NULL)
+ , m_custom_props_read(false)
{
m_name = object.getFullName();
std::vector<std::string> parts;
@@ -497,10 +498,12 @@ void AbcObjectReader::read_custom_properties_into(ID *id,
std::cerr << " - POD: " << header.getDataType().getPod() << "\n";
IArrayProperty ap(params, header.getName());
r_is_const &= ap.isConstant();
+ std::cerr << " - array is constant: " << ap.isConstant() << "\n";
+ /* Don't bother re-reading constant properties. */
+ if (ap.isConstant() && m_custom_props_read) continue;
ArraySamplePtr val;
ap.get(val, sample_sel);
- std::cerr << " - array is constant: " << ap.isConstant() << "\n";
Dimensions dim;
ap.getDimensions(dim, sample_sel);
@@ -598,6 +601,9 @@ void AbcObjectReader::read_custom_properties_into(ID *id,
else {
/* There are only three types (Composite, Array, and Scalar), so this must be true. */
BLI_assert(header.isScalar());
+ IScalarProperty baseprop(params, header.getName());
+ /* Don't bother re-reading constant properties. */
+ if (baseprop.isConstant() && m_custom_props_read) continue;
switch (header.getDataType().getPod()) {
case kBooleanPOD:
@@ -662,6 +668,13 @@ void AbcObjectReader::read_custom_properties_into(ID *id,
void AbcObjectReader::read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
bool &r_is_constant)
+{
+ do_read_custom_properties(sample_sel, r_is_constant);
+ m_custom_props_read = true;
+}
+
+void AbcObjectReader::do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+ bool &r_is_constant)
{
IXform my_xform = xform();
if (!my_xform.valid()) return;
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 4a1135e612f..63044335c55 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -150,7 +150,7 @@ protected:
int m_refcount;
bool m_inherits_xform;
-
+ bool m_custom_props_read;
public:
AbcObjectReader *parent_reader;
@@ -206,18 +206,20 @@ public:
void read_matrix(float r_mat[4][4], const float time,
const float scale, bool &r_is_constant);
- virtual void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
- bool &r_is_constant);
+ void read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+ bool &r_is_constant);
protected:
void determine_inherits_xform();
+ virtual void do_read_custom_properties(const Alembic::Abc::ISampleSelector &sample_sel,
+ bool &r_is_constant);
/* Reads custom properties from an Alembic ICustomProperty into ID
* Properties of the given ID block. At this moment does NOT support
* Alembic's 64-bit numerical types, wide strings, or arrays of strings. */
- static void read_custom_properties_into(ID *id,
- Alembic::Abc::ICompoundProperty params,
- const Alembic::Abc::ISampleSelector &sample_sel,
- bool &r_is_constant);
+ void read_custom_properties_into(ID *id,
+ Alembic::Abc::ICompoundProperty params,
+ const Alembic::Abc::ISampleSelector &sample_sel,
+ bool &r_is_constant);
};
Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);
More information about the Bf-blender-cvs
mailing list