diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-02-23 07:45:55 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-02-23 08:06:50 +0300 |
commit | 87ef03745971e1c860894ddc18172a183f42ed26 (patch) | |
tree | 0fd59f0156b1157c70b9759fbd4dcf21e7caed57 /intern/cycles/render/alembic.cpp | |
parent | 3d5e290ee0fd0c2dcda21f66b9e1c4f276f0a39a (diff) |
Alembic procedural: cleanup, demultiply Object and Geometry Node
creation
Diffstat (limited to 'intern/cycles/render/alembic.cpp')
-rw-r--r-- | intern/cycles/render/alembic.cpp | 103 |
1 files changed, 34 insertions, 69 deletions
diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp index 2f69cc99638..13144f46314 100644 --- a/intern/cycles/render/alembic.cpp +++ b/intern/cycles/render/alembic.cpp @@ -1466,38 +1466,47 @@ void AlembicProcedural::load_objects(Progress &progress) for (size_t i = 0; i < root.getNumChildren(); ++i) { walk_hierarchy(root, root.getChildHeader(i), nullptr, object_map, progress); } -} -void AlembicProcedural::read_mesh(Scene *scene, - AlembicObject *abc_object, - Abc::chrono_t frame_time, - Progress &progress) -{ - IPolyMesh polymesh(abc_object->iobject, Alembic::Abc::kWrapExisting); + /* Create nodes in the scene. */ + for (std::pair<string, AlembicObject *> pair : object_map) { + AlembicObject *abc_object = pair.second; - Mesh *mesh = nullptr; + Geometry *geometry = nullptr; - /* create a mesh node in the scene if not already done */ - if (!abc_object->get_object()) { - mesh = scene->create_node<Mesh>(); - mesh->set_owner(this); - mesh->name = abc_object->iobject.getName(); + if (abc_object->schema_type == AlembicObject::CURVES) { + geometry = scene_->create_node<Hair>(); + } + else if (abc_object->schema_type == AlembicObject::POLY_MESH || + abc_object->schema_type == AlembicObject::SUBD) { + geometry = scene_->create_node<Mesh>(); + } + else { + continue; + } + + geometry->set_owner(this); + geometry->name = abc_object->iobject.getName(); array<Node *> used_shaders = abc_object->get_used_shaders(); - mesh->set_used_shaders(used_shaders); + geometry->set_used_shaders(used_shaders); - /* create object*/ - Object *object = scene->create_node<Object>(); + Object *object = scene_->create_node<Object>(); object->set_owner(this); - object->set_geometry(mesh); - object->set_tfm(abc_object->xform); + object->set_geometry(geometry); object->name = abc_object->iobject.getName(); abc_object->set_object(object); } - else { - mesh = static_cast<Mesh *>(abc_object->get_object()->get_geometry()); - } +} + +void AlembicProcedural::read_mesh(Scene *scene, + AlembicObject *abc_object, + Abc::chrono_t frame_time, + Progress &progress) +{ + IPolyMesh polymesh(abc_object->iobject, Alembic::Abc::kWrapExisting); + + Mesh *mesh = static_cast<Mesh *>(abc_object->get_object()->get_geometry()); CachedData &cached_data = abc_object->get_cached_data(); IPolyMeshSchema schema = polymesh.getSchema(); @@ -1570,32 +1579,10 @@ void AlembicProcedural::read_subd(Scene *scene, ISubD subd_mesh(abc_object->iobject, Alembic::Abc::kWrapExisting); ISubDSchema schema = subd_mesh.getSchema(); - Mesh *mesh = nullptr; - - /* create a mesh node in the scene if not already done */ - if (!abc_object->get_object()) { - mesh = scene->create_node<Mesh>(); - mesh->set_owner(this); - mesh->name = abc_object->iobject.getName(); - - array<Node *> used_shaders = abc_object->get_used_shaders(); - mesh->set_used_shaders(used_shaders); - - /* Alembic is OpenSubDiv compliant, there is no option to set another subdivision type. */ - mesh->set_subdivision_type(Mesh::SubdivisionType::SUBDIVISION_CATMULL_CLARK); - - /* create object*/ - Object *object = scene->create_node<Object>(); - object->set_owner(this); - object->set_geometry(mesh); - object->set_tfm(abc_object->xform); - object->name = abc_object->iobject.getName(); + Mesh *mesh = static_cast<Mesh *>(abc_object->get_object()->get_geometry()); - abc_object->set_object(object); - } - else { - mesh = static_cast<Mesh *>(abc_object->get_object()->get_geometry()); - } + /* Alembic is OpenSubDiv compliant, there is no option to set another subdivision type. */ + mesh->set_subdivision_type(Mesh::SubdivisionType::SUBDIVISION_CATMULL_CLARK); if (!abc_object->has_data_loaded()) { abc_object->load_all_data(this, schema, scale, progress); @@ -1696,29 +1683,7 @@ void AlembicProcedural::read_curves(Scene *scene, Progress &progress) { ICurves curves(abc_object->iobject, Alembic::Abc::kWrapExisting); - Hair *hair; - - /* create a hair node in the scene if not already done */ - if (!abc_object->get_object()) { - hair = scene->create_node<Hair>(); - hair->set_owner(this); - hair->name = abc_object->iobject.getName(); - - array<Node *> used_shaders = abc_object->get_used_shaders(); - hair->set_used_shaders(used_shaders); - - /* create object*/ - Object *object = scene->create_node<Object>(); - object->set_owner(this); - object->set_geometry(hair); - object->set_tfm(abc_object->xform); - object->name = abc_object->iobject.getName(); - - abc_object->set_object(object); - } - else { - hair = static_cast<Hair *>(abc_object->get_object()->get_geometry()); - } + Hair *hair = static_cast<Hair *>(abc_object->get_object()->get_geometry()); ICurvesSchema schema = curves.getSchema(); |