Blender V5.3
usd_reader_mesh.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 * Adapted from the Blender Alembic importer implementation.
5 * Modifications Copyright 2021 Tangent Animation and
6 * NVIDIA Corporation. All rights reserved. */
7
8#include "usd_reader_mesh.hh"
9#include "usd.hh"
11#include "usd_mesh_utils.hh"
13#include "usd_skel_convert.hh"
14
15#include "BKE_attribute.h"
16#include "BKE_attribute.hh"
17#include "BKE_geometry_set.hh"
18#include "BKE_main.hh"
19#include "BKE_material.hh"
20#include "BKE_mesh.hh"
21#include "BKE_object.hh"
22#include "BKE_report.hh"
23#include "BKE_subdiv.hh"
24
25#include "BLI_array.hh"
26#include "BLI_map.hh"
28#include "BLI_ordered_edge.hh"
29#include "BLI_set.hh"
30#include "BLI_span.hh"
31#include "BLI_vector_set.hh"
32
33#include "BLT_translation.hh"
34
35#include "DNA_material_types.h"
36#include "DNA_modifier_types.h"
37#include "DNA_object_types.h"
38
39#include "IO_validate.hh"
40
41#include <pxr/base/gf/matrix4f.h>
42#include <pxr/base/vt/array.h>
43#include <pxr/base/vt/types.h>
44#include <pxr/usd/sdf/types.h>
45#include <pxr/usd/usdGeom/primvarsAPI.h>
46#include <pxr/usd/usdGeom/subset.h>
47#include <pxr/usd/usdShade/materialBindingAPI.h>
48#include <pxr/usd/usdShade/tokens.h>
49#include <pxr/usd/usdSkel/bindingAPI.h>
50
51#include <algorithm>
52
53#include "CLG_log.h"
54
55namespace blender {
56
57static CLG_LogRef LOG = {"io.usd"};
58
59namespace usdtokens {
60/* Materials */
61static const pxr::TfToken st("st", pxr::TfToken::Immortal);
62static const pxr::TfToken normalsPrimvar("normals", pxr::TfToken::Immortal);
63} // namespace usdtokens
64
65namespace io::usd {
66
67namespace utils {
68
69static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim,
70 MtlPurpose mtl_purpose)
71{
72 const pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim);
73
74 /* See the following documentation for material resolution behavior:
75 * https://openusd.org/release/api/class_usd_shade_material_binding_a_p_i.html#UsdShadeMaterialBindingAPI_MaterialResolution
76 */
77
78 pxr::UsdShadeMaterial mtl;
79 switch (mtl_purpose) {
81 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->full);
82 if (!mtl) {
83 /* Add an additional Blender-specific fallback to help with oddly authored USD files. */
84 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
85 }
86 break;
88 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
89 break;
90 case MtlPurpose::All:
91 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->allPurpose);
92 break;
93 }
94
95 return mtl;
96}
97
98static void assign_materials(Main *bmain,
99 Object *ob,
100 const Map<pxr::SdfPath, int> &mat_index_map,
101 const USDImportParams &params,
102 pxr::UsdStageRefPtr stage,
103 const ImportSettings &settings)
104{
105 if (!(stage && bmain && ob)) {
106 return;
107 }
108
109 if (mat_index_map.size() > MAXMAT) {
110 return;
111 }
112
113 USDMaterialReader mat_reader(params, *bmain);
114
115 for (const auto item : mat_index_map.items()) {
116 Material *assigned_mat = find_existing_material(
117 item.key, params, settings.mat_name_to_mat, settings.usd_path_to_mat);
118 if (!assigned_mat) {
119 /* Blender material doesn't exist, so create it now. */
120
121 /* Look up the USD material. */
122 pxr::UsdPrim prim = stage->GetPrimAtPath(item.key);
123 pxr::UsdShadeMaterial usd_mat(prim);
124
125 if (!usd_mat) {
126 CLOG_WARN(
127 &LOG, "Couldn't construct USD material from prim %s", item.key.GetAsString().c_str());
128 continue;
129 }
130
131 const bool have_import_hook = settings.mat_import_hook_sources.contains(item.key);
132
133 /* Add the Blender material. If we have an import hook which can handle this material
134 * we don't import USD Preview Surface shaders. */
135 assigned_mat = mat_reader.add_material(usd_mat, !have_import_hook);
136
137 if (!assigned_mat) {
138 CLOG_WARN(&LOG,
139 "Couldn't create Blender material from USD material %s",
140 item.key.GetAsString().c_str());
141 continue;
142 }
143
144 settings.mat_name_to_mat.add_new(assigned_mat->id.name + 2, assigned_mat);
145
147 /* Record the Blender material we created for the USD material with the given path. */
148 settings.usd_path_to_mat.add_new(item.key, assigned_mat);
149 }
150
151 if (have_import_hook) {
152 /* Defer invoking the hook to convert the material till we can do so from
153 * the main thread. */
154 settings.usd_path_to_mat_for_hook.add_new(item.key, assigned_mat);
155 }
156 }
157
158 if (assigned_mat) {
159 BKE_object_material_assign_single_obdata(bmain, ob, assigned_mat, item.value);
160 }
161 else {
162 /* This shouldn't happen. */
163 CLOG_WARN(&LOG, "Couldn't assign material %s", item.key.GetAsString().c_str());
164 }
165 }
166 if (ob->totcol > 0) {
167 ob->actcol = 1;
168 }
169}
170
171} // namespace utils
172
173USDMeshReadData::USDMeshReadData(const pxr::UsdGeomMesh &mesh_prim, const pxr::UsdTimeCode time)
174{
175 mesh_prim.GetPointsAttr().Get(&positions_, time);
176 mesh_prim.GetFaceVertexIndicesAttr().Get(&face_indices_, time);
177 mesh_prim.GetFaceVertexCountsAttr().Get(&face_counts_, time);
178
179 /* If 'normals' and 'primvars:normals' are both specified, the latter has precedence. */
180 const pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim);
181 const pxr::UsdGeomPrimvar primvar = primvarsAPI.GetPrimvar(usdtokens::normalsPrimvar);
182 if (primvar.HasValue()) {
183 primvar.ComputeFlattened(&normals_, time);
184 normal_interpolation = primvar.GetInterpolation();
185 }
186 else {
187 mesh_prim.GetNormalsAttr().Get(&normals_, time);
188 normal_interpolation = mesh_prim.GetNormalsInterpolation();
189 }
190
191 /* Drop dangling face_indices when there are no faces. */
192 if (face_counts_.empty()) {
193 face_indices_.clear();
194 }
195
196 mesh_prim.GetOrientationAttr().Get(&orientation, time);
197}
198
200{
201 Mesh *mesh = BKE_mesh_add(bmain, name_.c_str());
202
204 object_->data = id_cast<ID *>(mesh);
205}
206
207void USDMeshReader::read_object_data(Main *bmain, const pxr::UsdTimeCode time)
208{
209 Mesh *mesh = id_cast<Mesh *>(object_->data);
210
211 is_initial_load_ = true;
212 const USDMeshReadParams params = create_mesh_read_params(time.GetValue(),
214
215 Mesh *read_mesh = this->read_mesh(mesh, params, nullptr);
216
217 is_initial_load_ = false;
218 if (read_mesh != mesh) {
220 }
221
222 readFaceSetsSample(bmain, mesh, time);
223
224 if (mesh_prim_.GetPointsAttr().ValueMightBeTimeVarying() ||
225 mesh_prim_.GetNormalsAttr().ValueMightBeTimeVarying() ||
226 mesh_prim_.GetVelocitiesAttr().ValueMightBeTimeVarying() ||
227 mesh_prim_.GetCreaseSharpnessesAttr().ValueMightBeTimeVarying() ||
228 mesh_prim_.GetCreaseLengthsAttr().ValueMightBeTimeVarying() ||
229 mesh_prim_.GetCreaseIndicesAttr().ValueMightBeTimeVarying() ||
230 mesh_prim_.GetCornerSharpnessesAttr().ValueMightBeTimeVarying() ||
231 mesh_prim_.GetCornerIndicesAttr().ValueMightBeTimeVarying())
232 {
233 is_time_varying_ = true;
234 }
235
236 /* Make one final check against the special primvars:normals in case that was set. */
237 if (!is_time_varying_) {
238 const pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
239 const pxr::UsdGeomPrimvar primvar = primvarsAPI.GetPrimvar(usdtokens::normalsPrimvar);
240 if (primvar.HasValue() && primvar.ValueMightBeTimeVarying()) {
241 is_time_varying_ = true;
242 }
243 }
244
245 if (is_time_varying_) {
247 }
248
250 pxr::TfToken subdivScheme;
251 mesh_prim_.GetSubdivisionSchemeAttr().Get(&subdivScheme, time);
252
253 if (subdivScheme == pxr::UsdGeomTokens->catmullClark) {
255 read_subdiv();
256 }
257 }
258
261 }
262
265 }
266
268}
269
270bool USDMeshReader::topology_changed(const Mesh *existing_mesh, const pxr::UsdTimeCode time)
271{
272 USDMeshReadData usd_data(mesh_prim_, time);
273 return topology_changed(existing_mesh, usd_data);
274}
275
276bool USDMeshReader::topology_changed(const Mesh *existing_mesh,
277 const USDMeshReadData &usd_data) const
278{
279 return usd_data.positions().size() != existing_mesh->verts_num ||
280 usd_data.face_counts().size() != existing_mesh->faces_num ||
281 usd_data.face_indices().size() != existing_mesh->corners_num;
282}
283bool USDMeshReader::read_faces(Mesh *mesh, const USDMeshReadData &usd_data) const
284{
285 MutableSpan<int> face_offsets = mesh->face_offsets_for_write();
286 MutableSpan<int> corner_verts = mesh->corner_verts_for_write();
287
288 int64_t loop_index = 0;
289 bool all_faces_ok = true;
290
291 const Span<int> face_counts = usd_data.face_counts();
292 const Span<int> face_indices = usd_data.face_indices();
293 const int64_t corners_num = face_indices.size();
294 for (const int64_t i : face_counts.index_range()) {
295 int face_size = face_counts[i];
296
297 face_offsets[i] = int(loop_index);
298
299 if (face_size < 3 || face_size > corners_num - loop_index) {
300 face_size = 0;
301 all_faces_ok = false;
302 }
303
304 /* Polygons are always assumed to be smooth-shaded. If the mesh should be flat-shaded,
305 * this is encoded in custom loop normals. */
306
307 if (is_left_handed_) {
308 int64_t loop_end_index = loop_index + (face_size - 1);
309 for (int64_t f = 0; f < face_size; ++f, ++loop_index) {
310 int vidx = face_indices[loop_end_index - f];
311 if (!validate::index_in_range(vidx, mesh->verts_num)) {
312 vidx = 0;
313 all_faces_ok = false;
314 }
315 corner_verts[loop_index] = vidx;
316 }
317 }
318 else {
319 for (int64_t f = 0; f < face_size; ++f, ++loop_index) {
320 int vidx = face_indices[loop_index];
321 if (!validate::index_in_range(vidx, mesh->verts_num)) {
322 vidx = 0;
323 all_faces_ok = false;
324 }
325 corner_verts[loop_index] = vidx;
326 }
327 }
328 }
329
330 /* Check for faces with duplicate vertex indices. These will require a mesh validate to fix. */
331 IndexMaskMemory memory;
332 const IndexMask bad_faces = bke::mesh_find_faces_duplicate_verts(*mesh, memory);
333 if (!bad_faces.is_empty()) {
334 all_faces_ok = false;
335 }
336
337 /* If we detect bad faces it would be unsafe to continue beyond this point without first
338 * performing a destructive validate. Any operation requiring mesh connectivity information can
339 * assert or crash if the problem isn't addressed. Performing the check here, before most of the
340 * data has been loaded, unfortunately means any remaining data will be lost. */
341 if (!all_faces_ok) {
342 if (is_initial_load_) {
343 const char *message = N_(
344 "Invalid face data detected for mesh '%s'. Automatic correction will be used, but some "
345 "data will most likely be lost");
346 const std::string prim_path = this->prim_path().GetAsString();
347 BKE_reportf(this->reports(), RPT_WARNING, message, prim_path.c_str());
348 CLOG_WARN(&LOG, message, prim_path.c_str());
349 }
350 bke::mesh_validate(*mesh, false);
351 }
352
353 bke::mesh_calc_edges(*mesh, false, false);
354
355 /* It's possible that the number of faces, indices, and verts remain the same but the topology
356 * itself is different. Until finer-grained topology detection can be implemented, always tag the
357 * mesh as needing updated topology mappings. Without this, a time varying mesh could trigger
358 * undefined behavior. */
359 mesh->tag_topology_changed();
360
361 return all_faces_ok;
362}
363
364void USDMeshReader::read_uv_data_primvar(Mesh *mesh,
365 const pxr::UsdGeomPrimvar &primvar,
366 const pxr::UsdTimeCode time)
367{
368 const StringRef primvar_name(
369 pxr::UsdGeomPrimvar::StripPrimvarsName(primvar.GetName()).GetString());
370
371 const pxr::VtVec2fArray usd_uvs = get_primvar_array<pxr::GfVec2f>(primvar, time);
372 if (usd_uvs.empty()) {
373 return;
374 }
375
376 const pxr::TfToken varying_type = primvar.GetInterpolation();
377 BLI_assert(ELEM(varying_type,
378 pxr::UsdGeomTokens->vertex,
379 pxr::UsdGeomTokens->faceVarying,
380 pxr::UsdGeomTokens->varying));
381
382 if ((varying_type == pxr::UsdGeomTokens->faceVarying && usd_uvs.size() != mesh->corners_num) ||
383 (varying_type == pxr::UsdGeomTokens->vertex && usd_uvs.size() != mesh->verts_num) ||
384 (varying_type == pxr::UsdGeomTokens->varying && usd_uvs.size() != mesh->verts_num))
385 {
388 "USD Import: UV attribute value '%s' count inconsistent with interpolation type",
389 primvar.GetName().GetText());
390 return;
391 }
392
393 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
394 bke::SpanAttributeWriter<float2> uv_data = attributes.lookup_or_add_for_write_only_span<float2>(
395 primvar_name, bke::AttrDomain::Corner);
396
397 if (!uv_data) {
400 "USD Import: couldn't add UV attribute '%s'",
401 primvar.GetBaseName().GetText());
402 return;
403 }
404
405 if (varying_type == pxr::UsdGeomTokens->faceVarying) {
406 if (is_left_handed_) {
407 /* Reverse the index order. */
408 const OffsetIndices faces = mesh->faces();
409 for (const int i : faces.index_range()) {
410 const IndexRange face = faces[i];
411 for (int j : face.index_range()) {
412 const int rev_index = face.last(j);
413 uv_data.span[face.start() + j] = validate::index_in_range(rev_index, usd_uvs.size()) ?
414 float2(usd_uvs[rev_index][0],
415 usd_uvs[rev_index][1]) :
416 float2(0.0f);
417 }
418 }
419 }
420 else {
421 for (const int64_t i : uv_data.span.index_range()) {
422 uv_data.span[i] = float2(usd_uvs[i][0], usd_uvs[i][1]);
423 }
424 }
425 }
426 else {
427 /* Handle vertex interpolation. */
428 const Span<int> corner_verts = mesh->corner_verts();
429 BLI_assert(mesh->verts_num == usd_uvs.size());
430 for (int i = 0; i < uv_data.span.size(); ++i) {
431 /* Get the vertex index for this corner. */
432 const int vi = corner_verts[i];
433 uv_data.span[i] = validate::index_in_range(vi, usd_uvs.size()) ?
434 float2(usd_uvs[vi][0], usd_uvs[vi][1]) :
435 float2(0.0f);
436 }
437 }
438
439 uv_data.finish();
440}
441
442void USDMeshReader::read_subdiv()
443{
444 ModifierData *md = object_->modifiers.last();
445 SubsurfModifierData *subdiv_data = reinterpret_cast<SubsurfModifierData *>(md);
446
447 pxr::TfToken uv_smooth;
448 mesh_prim_.GetFaceVaryingLinearInterpolationAttr().Get(&uv_smooth);
449
450 if (uv_smooth == pxr::UsdGeomTokens->all) {
451 subdiv_data->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
452 }
453 else if (uv_smooth == pxr::UsdGeomTokens->cornersOnly) {
454 subdiv_data->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
455 }
456 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus1) {
458 }
459 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus2) {
461 }
462 else if (uv_smooth == pxr::UsdGeomTokens->boundaries) {
463 subdiv_data->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES;
464 }
465 else if (uv_smooth == pxr::UsdGeomTokens->none) {
466 subdiv_data->uv_smooth = SUBSURF_UV_SMOOTH_ALL;
467 }
468
469 pxr::TfToken boundary_smooth;
470 mesh_prim_.GetInterpolateBoundaryAttr().Get(&boundary_smooth);
471
472 if (boundary_smooth == pxr::UsdGeomTokens->edgeOnly) {
473 subdiv_data->boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL;
474 }
475 else if (boundary_smooth == pxr::UsdGeomTokens->edgeAndCorner) {
476 subdiv_data->boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS;
477 }
478}
479
480void USDMeshReader::read_vertex_creases(Mesh *mesh, const pxr::UsdTimeCode time)
481{
482 pxr::VtIntArray usd_corner_indices;
483 if (!mesh_prim_.GetCornerIndicesAttr().Get(&usd_corner_indices, time)) {
484 return;
485 }
486
487 pxr::VtFloatArray usd_corner_sharpnesses;
488 if (!mesh_prim_.GetCornerSharpnessesAttr().Get(&usd_corner_sharpnesses, time)) {
489 return;
490 }
491
492 /* Prevent the creation of the `crease_vert` attribute if we have no data. */
493 if (usd_corner_indices.empty() || usd_corner_sharpnesses.empty()) {
494 return;
495 }
496
497 /* It is fine to have fewer indices than vertices, but never the other way other. */
498 if (usd_corner_indices.size() > mesh->verts_num) {
499 CLOG_WARN(
500 &LOG, "Too many vertex creases for mesh %s", this->prim_path().GetAsString().c_str());
501 return;
502 }
503
504 if (usd_corner_indices.size() != usd_corner_sharpnesses.size()) {
505 CLOG_WARN(&LOG,
506 "Vertex crease and sharpness count mismatch for mesh %s",
507 this->prim_path().GetAsString().c_str());
508 return;
509 }
510
511 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
512 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<float>(
513 "crease_vert", bke::AttrDomain::Point);
514 creases.span.fill(0.0f);
515
516 Span<int> corner_indices = Span(usd_corner_indices.cdata(), usd_corner_indices.size());
517 Span<float> corner_sharpnesses = Span(usd_corner_sharpnesses.cdata(),
518 usd_corner_sharpnesses.size());
519
520 for (const int64_t i : corner_indices.index_range()) {
521 const int idx = corner_indices[i];
522 if (!validate::index_in_range(idx, mesh->verts_num)) {
523 continue;
524 }
525 const float crease = settings_->blender_stage_version_prior_44 ?
526 corner_sharpnesses[i] :
527 bke::subdiv::sharpness_to_crease(corner_sharpnesses[i]);
528 creases.span[idx] = std::clamp(crease, 0.0f, 1.0f);
529 }
530 creases.finish();
531}
532
533void USDMeshReader::read_edge_creases(Mesh *mesh, const pxr::UsdTimeCode time)
534{
535 pxr::VtArray<int> usd_crease_lengths;
536 pxr::VtArray<int> usd_crease_indices;
537 pxr::VtArray<float> usd_crease_sharpness;
538 mesh_prim_.GetCreaseLengthsAttr().Get(&usd_crease_lengths, time);
539 mesh_prim_.GetCreaseIndicesAttr().Get(&usd_crease_indices, time);
540 mesh_prim_.GetCreaseSharpnessesAttr().Get(&usd_crease_sharpness, time);
541
542 /* Prevent the creation of the `crease_edge` attribute if we have no data. */
543 if (usd_crease_lengths.empty() || usd_crease_indices.empty() || usd_crease_sharpness.empty()) {
544 return;
545 }
546
547 /* There should be as many sharpness values as lengths. */
548 if (usd_crease_lengths.size() != usd_crease_sharpness.size()) {
549 CLOG_WARN(&LOG,
550 "Edge crease and sharpness count mismatch for mesh %s",
551 this->prim_path().GetAsString().c_str());
552 return;
553 }
554
555 /* Build mapping from vert pairs to edge index. */
556 using EdgeMap = VectorSet<OrderedEdge,
557 16,
559 DefaultHash<OrderedEdge>,
560 DefaultEquality<OrderedEdge>,
561 SimpleVectorSetSlot<OrderedEdge, int>,
562 GuardedAllocator>;
563 Span<int2> edges = mesh->edges();
564 EdgeMap edge_map;
565 edge_map.reserve(edges.size());
566
567 for (const int i : edges.index_range()) {
568 edge_map.add(edges[i]);
569 }
570
571 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
572 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<float>(
573 "crease_edge", bke::AttrDomain::Edge);
574 creases.span.fill(0.0f);
575
576 Span<int> crease_lengths = Span(usd_crease_lengths.cdata(), usd_crease_lengths.size());
577 Span<int> crease_indices = Span(usd_crease_indices.cdata(), usd_crease_indices.size());
578 Span<float> crease_sharpness = Span(usd_crease_sharpness.cdata(), usd_crease_sharpness.size());
579
580 int64_t index_start = 0;
581 for (const int64_t i : crease_lengths.index_range()) {
582 const int length = crease_lengths[i];
583 if (length < 2) {
584 /* Since each crease must be at least one edge long, each element of this array must be at
585 * least two. If this is not the case it would not be safe to continue. */
586 CLOG_WARN(&LOG,
587 "Edge crease length %d is invalid for mesh %s",
588 length,
589 this->prim_path().GetAsString().c_str());
590 break;
591 }
592
593 if (index_start + length > crease_indices.size()) {
594 CLOG_WARN(&LOG,
595 "Edge crease lengths are out of bounds for mesh %s",
596 this->prim_path().GetAsString().c_str());
597 break;
598 }
599
601 crease_sharpness[i] :
602 bke::subdiv::sharpness_to_crease(crease_sharpness[i]);
603 crease = std::clamp(crease, 0.0f, 1.0f);
604 for (int64_t j = 0; j < length - 1; j++) {
605 const int v1 = crease_indices[index_start + j];
606 const int v2 = crease_indices[index_start + j + 1];
607 const int edge_i = edge_map.index_of_try({v1, v2});
608 if (edge_i < 0) {
609 continue;
610 }
611
612 creases.span[edge_i] = crease;
613 }
614
615 index_start += length;
616 }
617
618 creases.finish();
619}
620
621void USDMeshReader::read_velocities(Mesh *mesh, const pxr::UsdTimeCode time)
622{
623 pxr::VtVec3fArray velocities;
624 mesh_prim_.GetVelocitiesAttr().Get(&velocities, time);
625
626 if (!velocities.empty()) {
627 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
628 bke::SpanAttributeWriter<float3> velocity =
629 attributes.lookup_or_add_for_write_only_span<float3>("velocity", bke::AttrDomain::Point);
630
631 Span<pxr::GfVec3f> usd_data(velocities.cdata(), velocities.size());
632 velocity.span.copy_from(usd_data.cast<float3>());
633 velocity.finish();
634 }
635}
636
637void USDMeshReader::process_normals_vertex_varying(Mesh *mesh,
638 const MutableSpan<float3> usd_normals) const
639{
640 if (usd_normals.is_empty()) {
641 return;
642 }
643
644 if (usd_normals.size() != mesh->verts_num) {
645 CLOG_WARN(&LOG,
646 "Vertex varying normals count mismatch for mesh '%s'",
647 this->prim_path().GetAsString().c_str());
648 return;
649 }
650
651 bke::mesh_set_custom_normals_from_verts(*mesh, usd_normals);
652}
653
654void USDMeshReader::process_normals_face_varying(Mesh *mesh, const Span<float3> usd_normals) const
655{
656 if (usd_normals.is_empty()) {
657 return;
658 }
659
660 /* Check for normals count mismatches to prevent crashes. */
661 if (usd_normals.size() != mesh->corners_num) {
662 CLOG_WARN(
663 &LOG, "Loop normal count mismatch for mesh '%s'", this->prim_path().GetAsString().c_str());
664 return;
665 }
666
667 Array<float3> corner_normals(mesh->corners_num);
668
669 const OffsetIndices faces = mesh->faces();
670 for (const int i : faces.index_range()) {
671 const IndexRange face = faces[i];
672 for (int j : face.index_range()) {
673 const int corner = face.start() + j;
674
675 int usd_index = face.start();
676 if (is_left_handed_) {
677 usd_index += face.size() - 1 - j;
678 }
679 else {
680 usd_index += j;
681 }
682
683 corner_normals[corner] = usd_normals[usd_index];
684 }
685 }
686
687 bke::mesh_set_custom_normals(*mesh, corner_normals);
688}
689
690void USDMeshReader::process_normals_uniform(Mesh *mesh, const Span<float3> usd_normals) const
691{
692 if (usd_normals.is_empty()) {
693 return;
694 }
695
696 /* Check for normals count mismatches to prevent crashes. */
697 if (usd_normals.size() != mesh->faces_num) {
698 CLOG_WARN(&LOG,
699 "Uniform normal count mismatch for mesh '%s'",
700 this->prim_path().GetAsString().c_str());
701 return;
702 }
703
704 Array<float3> corner_normals(mesh->corners_num);
705
706 const OffsetIndices faces = mesh->faces();
707 for (const int i : faces.index_range()) {
708 for (const int corner : faces[i]) {
709 corner_normals[corner] = usd_normals[i];
710 }
711 }
712
713 bke::mesh_set_custom_normals(*mesh, corner_normals);
714}
715
716void USDMeshReader::read_mesh_sample(ImportSettings *settings,
717 Mesh *mesh,
718 USDMeshReadData &usd_data,
719 const pxr::UsdTimeCode time,
720 const bool new_mesh)
721{
722 /* Note that for new meshes we always want to read verts and faces,
723 * regardless of the value of the read_flag, to avoid a crash downstream
724 * in code that expect this data to be there. */
725
726 if (new_mesh || (settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) {
727 MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
728 vert_positions.copy_from(usd_data.positions());
729 mesh->tag_positions_changed();
730
731 read_vertex_creases(mesh, time);
732 }
733
734 if (new_mesh || (settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) {
735 if (!read_faces(mesh, usd_data)) {
736 return;
737 }
738 read_edge_creases(mesh, time);
739
740 if (usd_data.normal_interpolation == pxr::UsdGeomTokens->faceVarying) {
741 process_normals_face_varying(mesh, usd_data.normals());
742 }
743 else if (usd_data.normal_interpolation == pxr::UsdGeomTokens->uniform) {
744 process_normals_uniform(mesh, usd_data.normals());
745 }
746 }
747
748 /* Process point normals after reading faces. */
749 if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0 &&
750 ELEM(usd_data.normal_interpolation, pxr::UsdGeomTokens->vertex, pxr::UsdGeomTokens->varying))
751 {
752 process_normals_vertex_varying(mesh, usd_data.normals_for_write());
753 }
754
755 /* Custom Data layers. */
756 if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) ||
757 (settings->read_flag & MOD_MESHSEQ_READ_COLOR) ||
758 (settings->read_flag & MOD_MESHSEQ_READ_ATTRIBUTES))
759 {
760 read_velocities(mesh, time);
761 read_custom_data(settings, mesh, time, new_mesh);
762 }
763}
764
765void USDMeshReader::read_custom_data(const ImportSettings *settings,
766 Mesh *mesh,
767 const pxr::UsdTimeCode time,
768 const bool new_mesh)
769{
770 if (!(mesh && mesh->corners_num > 0)) {
771 return;
772 }
773
774 pxr::UsdGeomPrimvarsAPI pv_api = pxr::UsdGeomPrimvarsAPI(mesh_prim_);
775 std::vector<pxr::UsdGeomPrimvar> primvars = pv_api.GetPrimvarsWithValues();
776
777 pxr::TfToken active_color_name;
778 pxr::TfToken active_uv_set_name;
779
780 /* Convert primvars to custom layer data. */
781 for (const pxr::UsdGeomPrimvar &pv : primvars) {
782 const pxr::SdfValueTypeName type = pv.GetTypeName();
783 if (!type.IsArray()) {
784 continue; /* Skip non-array primvar attributes. */
785 }
786
787 const pxr::TfToken varying_type = pv.GetInterpolation();
788 const pxr::TfToken name = pxr::UsdGeomPrimvar::StripPrimvarsName(pv.GetPrimvarName());
789
790 /* To avoid unnecessarily reloading static primvars during animation,
791 * early out if not first load and this primvar isn't animated. */
792 if (!new_mesh && primvar_varying_map_.contains(name) && !primvar_varying_map_.lookup(name)) {
793 continue;
794 }
795
796 /* We handle certain primvars elsewhere. */
797 if (ELEM(name, "velocity", "normals")) {
798 continue;
799 }
800
801 if (ELEM(type,
802 pxr::SdfValueTypeNames->StringArray,
803 pxr::SdfValueTypeNames->QuatdArray,
804 pxr::SdfValueTypeNames->QuathArray))
805 {
806 /* Skip creating known unsupported types, and avoid noisy error prints. */
807 continue;
808 }
809
810 /* Read Color primvars. */
812 if ((settings->read_flag & MOD_MESHSEQ_READ_COLOR) != 0) {
813 /* Set the active color name to 'displayColor', if a color primvar
814 * with this name exists. Otherwise, use the name of the first
815 * color primvar we find for the active color. */
816 if (active_color_name.IsEmpty() || name == usdtokens::displayColor) {
817 active_color_name = name;
818 }
819
820 read_generic_mesh_primvar(mesh, pv, time, is_left_handed_);
821 }
822 }
823
824 /* Read UV primvars. */
825 else if (ELEM(varying_type,
826 pxr::UsdGeomTokens->vertex,
827 pxr::UsdGeomTokens->faceVarying,
828 pxr::UsdGeomTokens->varying) &&
830 {
831 if ((settings->read_flag & MOD_MESHSEQ_READ_UV) != 0) {
832 /* Set the active uv set name to 'st', if a uv set primvar
833 * with this name exists. Otherwise, use the name of the first
834 * uv set primvar we find for the active uv set. */
835 if (active_uv_set_name.IsEmpty() || name == usdtokens::st) {
836 active_uv_set_name = name;
837 }
838 this->read_uv_data_primvar(mesh, pv, time);
839 }
840 }
841
842 /* Read all other primvars. */
843 else {
844 if ((settings->read_flag & MOD_MESHSEQ_READ_ATTRIBUTES) != 0) {
845 read_generic_mesh_primvar(mesh, pv, time, is_left_handed_);
846 }
847 }
848
849 /* Record whether the primvar attribute might be time varying. */
850 if (!primvar_varying_map_.contains(name)) {
851 bool might_be_time_varying = pv.ValueMightBeTimeVarying();
852 primvar_varying_map_.add(name, might_be_time_varying);
853 if (might_be_time_varying) {
854 is_time_varying_ = true;
855 }
856 }
857 } /* End primvar attribute loop. */
858
859 if (!active_color_name.IsEmpty()) {
860 BKE_id_attributes_default_color_set(&mesh->id, active_color_name.GetText());
861 BKE_id_attributes_active_color_set(&mesh->id, active_color_name.GetText());
862 }
863
864 if (!active_uv_set_name.IsEmpty()) {
865 mesh->uv_maps_active_set(active_uv_set_name.GetText());
866 mesh->uv_maps_default_set(active_uv_set_name.GetText());
867 }
868}
869
870void USDMeshReader::assign_facesets_to_material_indices(pxr::UsdTimeCode time,
871 MutableSpan<int> material_indices,
872 Map<pxr::SdfPath, int> *r_mat_map)
873{
874 if (r_mat_map == nullptr) {
875 return;
876 }
877
878 /* Find the geom subsets that have bound materials.
879 * We don't call #pxr::UsdShadeMaterialBindingAPI::GetMaterialBindSubsets()
880 * because this function returns only those subsets that are in the 'materialBind'
881 * family, but, in practice, applications (like Houdini) might export subsets
882 * in different families that are bound to materials.
883 * TODO(makowalski): Reassess if the above is the best approach. */
884 const std::vector<pxr::UsdGeomSubset> subsets = pxr::UsdGeomSubset::GetAllGeomSubsets(
885 mesh_prim_);
886
887 int current_mat = 0;
888 if (!subsets.empty()) {
889 for (const pxr::UsdGeomSubset &subset : subsets) {
890 pxr::UsdPrim subset_prim = subset.GetPrim();
891 pxr::UsdShadeMaterial subset_mtl = utils::compute_bound_material(subset_prim,
893 if (!subset_mtl) {
894 continue;
895 }
896
897 pxr::SdfPath subset_mtl_path = subset_mtl.GetPath();
898 if (subset_mtl_path.IsEmpty()) {
899 continue;
900 }
901
902 pxr::TfToken element_type;
903 subset.GetElementTypeAttr().Get(&element_type, time);
904 if (element_type != pxr::UsdGeomTokens->face) {
905 CLOG_WARN(&LOG,
906 "UsdGeomSubset '%s' uses unsupported elementType: %s",
907 subset_prim.GetName().GetText(),
908 element_type.GetText());
909 continue;
910 }
911
912 const int mat_idx = r_mat_map->lookup_or_add(subset_mtl_path, 1 + current_mat++);
913 const int max_element_idx = std::max(0, int(material_indices.size() - 1));
914
915 pxr::VtIntArray indices;
916 subset.GetIndicesAttr().Get(&indices, time);
917
918 int bad_element_count = 0;
919 for (const int element_idx : indices.AsConst()) {
920 const int safe_element_idx = std::clamp(element_idx, 0, max_element_idx);
921 bad_element_count += (safe_element_idx != element_idx) ? 1 : 0;
922 material_indices[safe_element_idx] = mat_idx - 1;
923 }
924
925 if (bad_element_count > 0) {
926 CLOG_WARN(&LOG,
927 "UsdGeomSubset '%s' contains invalid indices; material assignment may be "
928 "incorrect (%d were out of range)",
929 subset_prim.GetName().GetText(),
930 bad_element_count);
931 }
932 }
933 }
934
935 if (r_mat_map->is_empty()) {
937 if (mtl) {
938 pxr::SdfPath mtl_path = mtl.GetPath();
939
940 if (!mtl_path.IsEmpty()) {
941 r_mat_map->add(mtl.GetPath(), 1);
942 }
943 }
944 }
945}
946
947void USDMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const pxr::UsdTimeCode time)
948{
950 return;
951 }
952
953 Map<pxr::SdfPath, int> mat_map;
954
955 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
956 bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<int>(
957 "material_index", bke::AttrDomain::Face);
958 this->assign_facesets_to_material_indices(time, material_indices.span, &mat_map);
959 material_indices.finish();
960 /* Build material name map if it's not built yet. */
961 if (this->settings_->mat_name_to_mat.is_empty()) {
963 }
965 bmain, object_, mat_map, this->import_params_, this->prim_.GetStage(), *this->settings_);
966}
967
968Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
969 const USDMeshReadParams params,
970 const char ** /*r_err_str*/)
971{
972 USDMeshReadData usd_data(mesh_prim_, params.motion_sample_time);
973 if (usd_data.orientation == pxr::UsdGeomTokens->leftHanded) {
974 is_left_handed_ = true;
975 }
976
977 if (!validate::size_fits_in_int(usd_data.positions().size()) ||
978 !validate::size_fits_in_int(usd_data.face_counts().size()) ||
979 !validate::size_fits_in_int(usd_data.face_indices().size()))
980 {
981 CLOG_WARN(&LOG,
982 "Mesh '%s' too large to import, exceeds max int size",
983 this->prim_path().GetAsString().c_str());
984 return existing_mesh;
985 }
986
987 Mesh *active_mesh = existing_mesh;
988 bool new_mesh = false;
989
990 /* TODO(makowalski): implement the optimization of only updating the mesh points when
991 * the topology is consistent, as in the Alembic importer. */
992
993 ImportSettings settings;
994 settings.read_flag |= params.read_flags;
995
996 if (topology_changed(existing_mesh, usd_data)) {
997 new_mesh = true;
998 active_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
999 usd_data.positions().size(),
1000 0,
1001 usd_data.face_counts().size(),
1002 usd_data.face_indices().size());
1003 }
1004
1005 read_mesh_sample(
1006 &settings, active_mesh, usd_data, params.motion_sample_time, new_mesh || is_initial_load_);
1007
1008 if (new_mesh) {
1009 /* Here we assume that the number of materials doesn't change, i.e. that
1010 * the material slots that were created when the object was loaded from
1011 * USD are still valid now. */
1012 if (active_mesh->faces_num != 0 && import_params_.import_materials) {
1013 Map<pxr::SdfPath, int> mat_map;
1014 bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
1015 bke::SpanAttributeWriter<int> material_indices =
1016 attributes.lookup_or_add_for_write_span<int>("material_index", bke::AttrDomain::Face);
1017 assign_facesets_to_material_indices(
1018 params.motion_sample_time, material_indices.span, &mat_map);
1019 material_indices.finish();
1020 }
1021 }
1022
1024 if (bke::mesh_validate(*active_mesh, false)) {
1025 BKE_reportf(reports(), RPT_INFO, "Fixed mesh for prim: %s", mesh_prim_.GetPath().GetText());
1026 }
1027 }
1028
1029 return active_mesh;
1030}
1031
1033 const USDMeshReadParams params,
1034 const char **r_err_str)
1035{
1036 Mesh *existing_mesh = geometry_set.get_mesh_for_write();
1037 Mesh *new_mesh = read_mesh(existing_mesh, params, r_err_str);
1038
1039 if (new_mesh != existing_mesh) {
1040 geometry_set.replace_mesh(new_mesh);
1041 }
1042}
1043
1045{
1046 /* Make sure we can apply UsdSkelBindingAPI to the prim.
1047 * Attempting to apply the API to instance proxies generates
1048 * a USD error. */
1049 if (!prim_ || prim_.IsInstanceProxy()) {
1050 return {};
1051 }
1052
1053 pxr::UsdSkelBindingAPI skel_api(prim_);
1054
1055 if (pxr::UsdSkelSkeleton skel = skel_api.GetInheritedSkeleton()) {
1056 return skel.GetPath();
1057 }
1058
1059 return {};
1060}
1061
1062std::optional<XformResult> USDMeshReader::get_local_usd_xform(const pxr::UsdTimeCode time) const
1063{
1064 if (!import_params_.import_skeletons || prim_.IsInstanceProxy()) {
1065 /* Use the standard transform computation, since we are ignoring
1066 * skinning data. Note that applying the UsdSkelBinding API to an
1067 * instance proxy generates a USD error. */
1069 }
1070
1071 pxr::UsdSkelBindingAPI skel_api = pxr::UsdSkelBindingAPI(prim_);
1072 if (pxr::UsdAttribute xf_attr = skel_api.GetGeomBindTransformAttr()) {
1073 if (xf_attr.HasAuthoredValue()) {
1074 pxr::GfMatrix4d bind_xf;
1075 if (skel_api.GetGeomBindTransformAttr().Get(&bind_xf)) {
1076 /* The USD bind transform is a matrix of doubles,
1077 * but we cast it to GfMatrix4f because Blender expects
1078 * a matrix of floats. Also, we assume the transform
1079 * is constant over time. */
1080 return XformResult(pxr::GfMatrix4f(bind_xf), true);
1081 }
1082
1085 "%s: Couldn't compute geom bind transform for %s",
1086 __func__,
1087 prim_.GetPath().GetAsString().c_str());
1088 }
1089 }
1090
1091 if (!get_skeleton_path().IsEmpty()) {
1092 /* The mesh is bound to a skeleton but has no usable geomBindTransform. Per the UsdSkel
1093 * spec the skinned mesh's own xformOps must be ignored (the skinned result is positioned by
1094 * the bound Skeleton), so use the identity rather than the prim's own transform. The mesh is
1095 * re-parented to the armature in USDStageReader::process_armature_modifiers(), giving a final
1096 * world transform of (skeleton world * identity). */
1097 return XformResult(pxr::GfMatrix4f(1.0), true);
1098 }
1099
1101}
1102
1104{
1106 /* Skinned meshes are re-parented to the bound armature during import, so they are never
1107 * the root of the transform hierarchy. */
1108 return false;
1109 }
1110
1112}
1113
1114} // namespace io::usd
1115} // namespace blender
Generic geometry attributes built on CustomData.
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
#define MAXMAT
Object is a sort of wrapper for general info.
#define BLI_assert(a)
#define ELEM(...)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
Definition btVector3.h:257
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr bool is_empty() const
Definition BLI_span.hh:264
int64_t size() const
Definition BLI_map.hh:976
ItemIterator items() const &
Definition BLI_map.hh:902
bool contains(const Key &key) const
Definition BLI_set.hh:310
constexpr Span()=default
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr const char * c_str() const
Material * add_material(const pxr::UsdShadeMaterial &usd_material, bool read_usd_preview=true) const
bool topology_changed(const Mesh *existing_mesh, pxr::UsdTimeCode time) override
pxr::SdfPath get_skeleton_path() const
void read_geometry(bke::GeometrySet &geometry_set, USDMeshReadParams params, const char **r_err_str) override
void create_object(Main *bmain) override
void read_object_data(Main *bmain, pxr::UsdTimeCode time) override
const ImportSettings * settings_
const USDImportParams & import_params_
void read_object_data(Main *bmain, pxr::UsdTimeCode time) override
virtual std::optional< XformResult > get_local_usd_xform(pxr::UsdTimeCode time) const
virtual bool is_root_xform_prim() const
#define vertex
bool all(VecOp< bool, D >) RET
BLI_INLINE float sharpness_to_crease(float sharpness)
IndexMask mesh_find_faces_duplicate_verts(const Mesh &mesh, IndexMaskMemory &memory)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void mesh_set_custom_normals_from_verts(Mesh &mesh, MutableSpan< float3 > vert_normals)
bool mesh_validate(Mesh &mesh, bool verbose=false, bool allow_missing_edges=false)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
VectorSet< OrderedEdge, 32, DefaultProbingStrategy, DefaultHash< OrderedEdge >, DefaultEquality< OrderedEdge >, SimpleVectorSetSlot< OrderedEdge, int >, GuardedAllocator > EdgeMap
static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim, MtlPurpose mtl_purpose)
static void assign_materials(Main *bmain, Object *ob, const Map< pxr::SdfPath, int > &mat_index_map, const USDImportParams &params, pxr::UsdStageRefPtr stage, const ImportSettings &settings)
void import_mesh_skel_bindings(Object *mesh_obj, const pxr::UsdPrim &prim, ReportList *reports)
pxr::VtArray< T > get_primvar_array(const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time)
USDMeshReadParams create_mesh_read_params(const double motion_sample_time, const int read_flags)
std::tuple< pxr::GfMatrix4f, bool > XformResult
void import_blendshapes(Main *bmain, Object *mesh_obj, const pxr::UsdPrim &prim, ReportList *reports, const bool import_anim)
std::optional< bke::AttrType > convert_usd_type_to_blender(const pxr::SdfValueTypeName usd_type)
Material * find_existing_material(const pxr::SdfPath &usd_mat_path, const USDImportParams &params, const Map< std::string, Material * > &mat_map, const Map< pxr::SdfPath, Material * > &usd_path_to_mat)
void read_generic_mesh_primvar(Mesh *mesh, const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time, const bool is_left_handed)
void build_material_map(const Main *bmain, Map< std::string, Material * > &r_mat_map)
bool size_fits_in_int(const int64_t size)
bool index_in_range(const int64_t index, const int64_t size)
const pxr::TfToken displayColor("displayColor", pxr::TfToken::Immortal)
static const pxr::TfToken normalsPrimvar("normals", pxr::TfToken::Immortal)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
BMesh Iterators.
__int64 int64_t
Definition BKE_text.h:90
@ RPT_WARNING
Definition BKE_report.hh:40
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS
@ SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys=true)
VecBase< float, 2 > float2
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
ATTR_WARN_UNUSED_RESULT const BMVert * v2
PythonProbingStrategy<> DefaultProbingStrategy
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
@ SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS
@ SUBSURF_BOUNDARY_SMOOTH_ALL
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
static CLG_LogRef LOG
Definition logging.cpp:12
void BKE_object_material_assign_single_obdata(Main *bmain, Object *ob, Material *ma, short act)
VecBase< float, 3 > float3
Object * BKE_object_add_only_object(Main *bmain, ObjectType type, const char *name) ATTR_RETURNS_NONNULL
Definition object.cc:2265
Mesh * BKE_mesh_add(Main *bmain, const char *name)
ListBaseT< ModifierData > modifiers
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Set< pxr::SdfPath > mat_import_hook_sources
Map< pxr::SdfPath, Material * > usd_path_to_mat_for_hook
Map< std::string, Material * > mat_name_to_mat
Map< pxr::SdfPath, Material * > usd_path_to_mat
MtlNameCollisionMode mtl_name_collision_mode
Definition usd.hh:230
MeshSeqCacheModifierReadFlag mesh_read_flag
Definition usd.hh:192
USDMeshReadData(const pxr::UsdGeomMesh &mesh_prim, pxr::UsdTimeCode time)
#define N_(msgid)