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
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-09-08 12:33:35 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-08 12:33:35 +0300
commit63dc72c35215d38c437a5d20a8dc8f6e25e1fc8c (patch)
tree228683e5201e83ad39913f3d277a49a634d6b360 /source/blender/io/usd/intern/usd_writer_mesh.cc
parentb8d4a2aff8069dd7d6fb91ad0d9427eed489b68f (diff)
Cleanup: USD export, refactor mesh instancing
Extract the mesh instancing code from the mesh writing function into a generic 'mark as instance' function on the abstract USD writer. This will help in supporting non-mesh instances. No functional changes.
Diffstat (limited to 'source/blender/io/usd/intern/usd_writer_mesh.cc')
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc23
1 files changed, 6 insertions, 17 deletions
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 7d3ea911a65..2073d4cbe87 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -160,29 +160,18 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
get_geometry_data(mesh, usd_mesh_data);
if (usd_export_context_.export_params.use_instancing && context.is_instance()) {
- // This object data is instanced, just reference the original instead of writing a copy.
- if (context.export_path == context.original_export_path) {
- printf("USD ref error: export path is reference path: %s\n", context.export_path.c_str());
- BLI_assert(!"USD reference error");
- return;
- }
- pxr::SdfPath ref_path(context.original_export_path);
- if (!usd_mesh.GetPrim().GetReferences().AddInternalReference(ref_path)) {
- /* See this URL for a description fo why referencing may fail"
- * https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References
- */
- printf("USD Export warning: unable to add reference from %s to %s, not instancing object\n",
- context.export_path.c_str(),
- context.original_export_path.c_str());
+ if (!mark_as_instance(context, usd_mesh.GetPrim())) {
return;
}
+
/* The material path will be of the form </_materials/{material name}>, which is outside the
- sub-tree pointed to by ref_path. As a result, the referenced data is not allowed to point out
- of its own sub-tree. It does work when we override the material with exactly the same path,
- though.*/
+ * sub-tree pointed to by ref_path. As a result, the referenced data is not allowed to point
+ * out of its own sub-tree. It does work when we override the material with exactly the same
+ * path, though.*/
if (usd_export_context_.export_params.export_materials) {
assign_materials(context, usd_mesh, usd_mesh_data.face_groups);
}
+
return;
}