Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-17 16:50:47 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-17 16:51:04 +0300
commit0a08ac2528eee972c4dc23554ffd088305e6ae92 (patch)
tree2ef9014dc16053ce6d249d877110766b0972a2ac /intern
parent9d3f35a0bf1bf5776363bfd61d53a7c85b5827a4 (diff)
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override data from other archives, provided that the hierarchies match. This is useful for modifying a UV map, updating an animation, or even creating some sort of LOD system where low resolution meshes are swapped by high resolution versions. It is possible to add UV maps and vertex colors using this system, however, they will only appear in the spreadsheet editor when viewing evaluated data, as the UV map and Vertex color UI only show data present on the original mesh. Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile` DNA, as well as some operators and UI to present and manage the layers. For both the Alembic importer and the Cycles procedural, the main change is creating an archive from a list of filepaths, instead of a single one. After importing the base file through the regular import operator, layers can be added to or removed from the `CacheFile` via the UI list under the `Override Layers` panel located in the Mesh Sequence Cache modifier. Layers can also be moved around or hidden. See differential page for tests files and demos. Reviewed by: brecht, sybren Differential Revision: https://developer.blender.org/D13603
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/object.cpp11
-rw-r--r--intern/cycles/scene/alembic.cpp17
-rw-r--r--intern/cycles/scene/alembic.h4
3 files changed, 30 insertions, 2 deletions
diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp
index 86314d3b196..65a04a39660 100644
--- a/intern/cycles/blender/object.cpp
+++ b/intern/cycles/blender/object.cpp
@@ -529,6 +529,17 @@ void BlenderSync::sync_procedural(BL::Object &b_ob,
string absolute_path = blender_absolute_path(b_data, b_ob, b_mesh_cache.cache_file().filepath());
procedural->set_filepath(ustring(absolute_path));
+ array<ustring> layers;
+ for (BL::CacheFileLayer &layer : cache_file.layers) {
+ if (layer.hide_layer()) {
+ continue;
+ }
+
+ absolute_path = blender_absolute_path(b_data, b_ob, layer.filepath());
+ layers.push_back_slow(ustring(absolute_path));
+ }
+ procedural->set_layers(layers);
+
procedural->set_scale(cache_file.scale());
procedural->set_use_prefetch(cache_file.use_prefetch());
diff --git a/intern/cycles/scene/alembic.cpp b/intern/cycles/scene/alembic.cpp
index 71fa1863b8b..7780b13eecb 100644
--- a/intern/cycles/scene/alembic.cpp
+++ b/intern/cycles/scene/alembic.cpp
@@ -742,6 +742,7 @@ NODE_DEFINE(AlembicProcedural)
NodeType *type = NodeType::add("alembic", create);
SOCKET_STRING(filepath, "Filename", ustring());
+ SOCKET_STRING_ARRAY(layers, "Layers", array<ustring>());
SOCKET_FLOAT(frame, "Frame", 1.0f);
SOCKET_FLOAT(start_frame, "Start Frame", 1.0f);
SOCKET_FLOAT(end_frame, "End Frame", 1.0f);
@@ -839,14 +840,26 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
return;
}
- if (!archive.valid()) {
+ if (!archive.valid() || filepath_is_modified() || layers_is_modified()) {
Alembic::AbcCoreFactory::IFactory factory;
factory.setPolicy(Alembic::Abc::ErrorHandler::kQuietNoopPolicy);
- archive = factory.getArchive(filepath.c_str());
+
+ std::vector<std::string> filenames;
+ filenames.push_back(filepath.c_str());
+
+ for (const ustring &layer : layers) {
+ filenames.push_back(layer.c_str());
+ }
+
+ /* We need to reverse the order as overriding archives should come first. */
+ std::reverse(filenames.begin(), filenames.end());
+
+ archive = factory.getArchive(filenames);
if (!archive.valid()) {
/* avoid potential infinite update loops in viewport synchronization */
filepath.clear();
+ layers.clear();
clear_modified();
return;
}
diff --git a/intern/cycles/scene/alembic.h b/intern/cycles/scene/alembic.h
index 3a4d37da3ff..6068ea3ef03 100644
--- a/intern/cycles/scene/alembic.h
+++ b/intern/cycles/scene/alembic.h
@@ -479,6 +479,10 @@ class AlembicProcedural : public Procedural {
/* The file path to the Alembic archive */
NODE_SOCKET_API(ustring, filepath)
+ /* Layers for the Alembic archive. Layers are in the order in which they override data, with the
+ * latter elements overriding the former ones. */
+ NODE_SOCKET_API_ARRAY(array<ustring>, layers)
+
/* The current frame to render. */
NODE_SOCKET_API(float, frame)