diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-02-23 07:31:34 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-02-23 07:31:34 +0300 |
commit | 3d5e290ee0fd0c2dcda21f66b9e1c4f276f0a39a (patch) | |
tree | d9e2dad3bc893ec22d1d01371c14223da4c01118 /intern | |
parent | d9abcee47eb5540f6f5fd60b83cc7d45ad7bc56f (diff) |
Alembic procedural: use an enumeration to discriminate IObjects
Using the various IObject::matches() to do so was expensive and would
show up in profiles as requires creating std::strings for each call.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/render/alembic.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/render/alembic.h | 12 |
2 files changed, 19 insertions, 3 deletions
diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp index 0f11a9368da..2f69cc99638 100644 --- a/intern/cycles/render/alembic.cpp +++ b/intern/cycles/render/alembic.cpp @@ -609,6 +609,7 @@ NODE_DEFINE(AlembicObject) AlembicObject::AlembicObject() : Node(node_type) { + schema_type = INVALID; } AlembicObject::~AlembicObject() @@ -1402,13 +1403,13 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress) continue; } - if (IPolyMesh::matches(object->iobject.getHeader())) { + if (object->schema_type == AlembicObject::POLY_MESH) { read_mesh(scene, object, frame_time, progress); } - else if (ICurves::matches(object->iobject.getHeader())) { + else if (object->schema_type == AlembicObject::CURVES) { read_curves(scene, object, frame_time, progress); } - else if (ISubD::matches(object->iobject.getHeader())) { + else if (object->schema_type == AlembicObject::SUBD) { read_subd(scene, object, frame_time, progress); } @@ -1823,6 +1824,7 @@ void AlembicProcedural::walk_hierarchy( if (iter != object_map.end()) { AlembicObject *abc_object = iter->second; abc_object->iobject = subd; + abc_object->schema_type = AlembicObject::SUBD; if (xform_samples) { abc_object->xform_samples = *xform_samples; @@ -1840,6 +1842,7 @@ void AlembicProcedural::walk_hierarchy( if (iter != object_map.end()) { AlembicObject *abc_object = iter->second; abc_object->iobject = mesh; + abc_object->schema_type = AlembicObject::POLY_MESH; if (xform_samples) { abc_object->xform_samples = *xform_samples; @@ -1857,6 +1860,7 @@ void AlembicProcedural::walk_hierarchy( if (iter != object_map.end()) { AlembicObject *abc_object = iter->second; abc_object->iobject = curves; + abc_object->schema_type = AlembicObject::CURVES; if (xform_samples) { abc_object->xform_samples = *xform_samples; diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h index 6b0d32fb3ab..1bfdc9e6757 100644 --- a/intern/cycles/render/alembic.h +++ b/intern/cycles/render/alembic.h @@ -263,12 +263,24 @@ class AlembicObject : public Node { bool has_data_loaded() const; + /* Enumeration used to speed up the discrimination of an IObject as IObject::matches() methods + * are too expensive and show up in profiles. */ + enum AbcSchemaType { + INVALID, + POLY_MESH, + SUBD, + CURVES, + }; + bool need_shader_update = true; MatrixSampleMap xform_samples; Alembic::AbcGeom::IObject iobject; Transform xform; + /* Set if the path points to a valid IObject whose type is supported. */ + AbcSchemaType schema_type; + CachedData &get_cached_data() { return cached_data; |