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>
61static const pxr::TfToken
st(
"st", pxr::TfToken::Immortal);
72 const pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim);
78 pxr::UsdShadeMaterial mtl;
79 switch (mtl_purpose) {
81 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->full);
84 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
88 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
91 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->allPurpose);
102 pxr::UsdStageRefPtr stage,
105 if (!(stage && bmain && ob)) {
115 for (
const auto item : mat_index_map.
items()) {
122 pxr::UsdPrim prim = stage->GetPrimAtPath(item.key);
123 pxr::UsdShadeMaterial usd_mat(prim);
127 &
LOG,
"Couldn't construct USD material from prim %s", item.key.GetAsString().c_str());
135 assigned_mat = mat_reader.
add_material(usd_mat, !have_import_hook);
139 "Couldn't create Blender material from USD material %s",
140 item.key.GetAsString().c_str());
144 settings.
mat_name_to_mat.add_new(assigned_mat->id.name + 2, assigned_mat);
151 if (have_import_hook) {
163 CLOG_WARN(&
LOG,
"Couldn't assign material %s", item.key.GetAsString().c_str());
175 mesh_prim.GetPointsAttr().Get(&positions_, time);
176 mesh_prim.GetFaceVertexIndicesAttr().Get(&face_indices_, time);
177 mesh_prim.GetFaceVertexCountsAttr().Get(&face_counts_, time);
180 const pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim);
182 if (primvar.HasValue()) {
183 primvar.ComputeFlattened(&normals_, time);
187 mesh_prim.GetNormalsAttr().Get(&normals_, time);
192 if (face_counts_.empty()) {
193 face_indices_.clear();
196 mesh_prim.GetOrientationAttr().Get(&
orientation, time);
211 is_initial_load_ =
true;
215 Mesh *read_mesh = this->read_mesh(
mesh, params,
nullptr);
217 is_initial_load_ =
false;
218 if (read_mesh !=
mesh) {
222 readFaceSetsSample(bmain,
mesh, time);
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())
233 is_time_varying_ =
true;
237 if (!is_time_varying_) {
238 const pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
240 if (primvar.HasValue() && primvar.ValueMightBeTimeVarying()) {
241 is_time_varying_ =
true;
245 if (is_time_varying_) {
250 pxr::TfToken subdivScheme;
251 mesh_prim_.GetSubdivisionSchemeAttr().Get(&subdivScheme, time);
253 if (subdivScheme == pxr::UsdGeomTokens->catmullClark) {
289 bool all_faces_ok =
true;
295 int face_size = face_counts[i];
297 face_offsets[i] = int(loop_index);
299 if (face_size < 3 || face_size > corners_num - loop_index) {
301 all_faces_ok =
false;
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];
313 all_faces_ok =
false;
315 corner_verts[loop_index] = vidx;
319 for (
int64_t f = 0; f < face_size; ++f, ++loop_index) {
320 int vidx = face_indices[loop_index];
323 all_faces_ok =
false;
325 corner_verts[loop_index] = vidx;
331 IndexMaskMemory memory;
333 if (!bad_faces.is_empty()) {
334 all_faces_ok =
false;
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");
359 mesh->tag_topology_changed();
364void USDMeshReader::read_uv_data_primvar(Mesh *mesh,
365 const pxr::UsdGeomPrimvar &primvar,
366 const pxr::UsdTimeCode time)
368 const StringRef primvar_name(
369 pxr::UsdGeomPrimvar::StripPrimvarsName(primvar.GetName()).GetString());
372 if (usd_uvs.empty()) {
376 const pxr::TfToken varying_type = primvar.GetInterpolation();
378 pxr::UsdGeomTokens->
vertex,
379 pxr::UsdGeomTokens->faceVarying,
380 pxr::UsdGeomTokens->varying));
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))
388 "USD Import: UV attribute value '%s' count inconsistent with interpolation type",
389 primvar.GetName().GetText());
393 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
394 bke::SpanAttributeWriter<float2> uv_data = attributes.lookup_or_add_for_write_only_span<
float2>(
400 "USD Import: couldn't add UV attribute '%s'",
401 primvar.GetBaseName().GetText());
405 if (varying_type == pxr::UsdGeomTokens->faceVarying) {
406 if (is_left_handed_) {
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);
414 float2(usd_uvs[rev_index][0],
415 usd_uvs[rev_index][1]) :
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]);
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) {
432 const int vi = corner_verts[i];
434 float2(usd_uvs[vi][0], usd_uvs[vi][1]) :
442void USDMeshReader::read_subdiv()
445 SubsurfModifierData *subdiv_data =
reinterpret_cast<SubsurfModifierData *
>(md);
447 pxr::TfToken uv_smooth;
448 mesh_prim_.GetFaceVaryingLinearInterpolationAttr().Get(&uv_smooth);
450 if (uv_smooth == pxr::UsdGeomTokens->
all) {
453 else if (uv_smooth == pxr::UsdGeomTokens->cornersOnly) {
456 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus1) {
459 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus2) {
462 else if (uv_smooth == pxr::UsdGeomTokens->boundaries) {
465 else if (uv_smooth == pxr::UsdGeomTokens->none) {
469 pxr::TfToken boundary_smooth;
470 mesh_prim_.GetInterpolateBoundaryAttr().Get(&boundary_smooth);
472 if (boundary_smooth == pxr::UsdGeomTokens->edgeOnly) {
475 else if (boundary_smooth == pxr::UsdGeomTokens->edgeAndCorner) {
480void USDMeshReader::read_vertex_creases(Mesh *mesh,
const pxr::UsdTimeCode time)
482 pxr::VtIntArray usd_corner_indices;
483 if (!mesh_prim_.GetCornerIndicesAttr().Get(&usd_corner_indices, time)) {
487 pxr::VtFloatArray usd_corner_sharpnesses;
488 if (!mesh_prim_.GetCornerSharpnessesAttr().Get(&usd_corner_sharpnesses, time)) {
493 if (usd_corner_indices.empty() || usd_corner_sharpnesses.empty()) {
498 if (usd_corner_indices.size() > mesh->verts_num) {
500 &
LOG,
"Too many vertex creases for mesh %s", this->
prim_path().GetAsString().c_str());
504 if (usd_corner_indices.size() != usd_corner_sharpnesses.size()) {
506 "Vertex crease and sharpness count mismatch for mesh %s",
507 this->
prim_path().GetAsString().c_str());
511 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
512 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<
float>(
514 creases.span.fill(0.0f);
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());
521 const int idx = corner_indices[i];
526 corner_sharpnesses[i] :
528 creases.span[idx] = std::clamp(crease, 0.0f, 1.0f);
533void USDMeshReader::read_edge_creases(Mesh *mesh,
const pxr::UsdTimeCode time)
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);
543 if (usd_crease_lengths.empty() || usd_crease_indices.empty() || usd_crease_sharpness.empty()) {
548 if (usd_crease_lengths.size() != usd_crease_sharpness.size()) {
550 "Edge crease and sharpness count mismatch for mesh %s",
551 this->
prim_path().GetAsString().c_str());
556 using EdgeMap = VectorSet<OrderedEdge,
559 DefaultHash<OrderedEdge>,
560 DefaultEquality<OrderedEdge>,
561 SimpleVectorSetSlot<OrderedEdge, int>,
563 Span<int2> edges = mesh->edges();
565 edge_map.reserve(edges.
size());
568 edge_map.add(edges[i]);
571 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
572 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<
float>(
574 creases.span.fill(0.0f);
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());
582 const int length = crease_lengths[i];
587 "Edge crease length %d is invalid for mesh %s",
589 this->
prim_path().GetAsString().c_str());
593 if (index_start +
length > crease_indices.
size()) {
595 "Edge crease lengths are out of bounds for mesh %s",
596 this->
prim_path().GetAsString().c_str());
601 crease_sharpness[i] :
603 crease = std::clamp(crease, 0.0f, 1.0f);
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});
612 creases.span[edge_i] = crease;
621void USDMeshReader::read_velocities(Mesh *mesh,
const pxr::UsdTimeCode time)
623 pxr::VtVec3fArray velocities;
624 mesh_prim_.GetVelocitiesAttr().Get(&velocities, time);
626 if (!velocities.empty()) {
627 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
628 bke::SpanAttributeWriter<float3>
velocity =
631 Span<pxr::GfVec3f> usd_data(velocities.cdata(), velocities.size());
637void USDMeshReader::process_normals_vertex_varying(Mesh *mesh,
638 const MutableSpan<float3> usd_normals)
const
640 if (usd_normals.is_empty()) {
644 if (usd_normals.size() != mesh->verts_num) {
646 "Vertex varying normals count mismatch for mesh '%s'",
647 this->
prim_path().GetAsString().c_str());
654void USDMeshReader::process_normals_face_varying(Mesh *mesh,
const Span<float3> usd_normals)
const
661 if (usd_normals.
size() != mesh->corners_num) {
663 &
LOG,
"Loop normal count mismatch for mesh '%s'", this->
prim_path().GetAsString().c_str());
667 Array<float3> corner_normals(mesh->corners_num);
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;
675 int usd_index = face.start();
676 if (is_left_handed_) {
677 usd_index += face.size() - 1 - j;
683 corner_normals[corner] = usd_normals[usd_index];
690void USDMeshReader::process_normals_uniform(Mesh *mesh,
const Span<float3> usd_normals)
const
697 if (usd_normals.
size() != mesh->faces_num) {
699 "Uniform normal count mismatch for mesh '%s'",
700 this->
prim_path().GetAsString().c_str());
704 Array<float3> corner_normals(mesh->corners_num);
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];
719 const pxr::UsdTimeCode time,
727 MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
728 vert_positions.copy_from(usd_data.positions());
729 mesh->tag_positions_changed();
731 read_vertex_creases(mesh, time);
735 if (!read_faces(mesh, usd_data)) {
738 read_edge_creases(mesh, time);
740 if (usd_data.normal_interpolation == pxr::UsdGeomTokens->faceVarying) {
741 process_normals_face_varying(mesh, usd_data.normals());
743 else if (usd_data.normal_interpolation == pxr::UsdGeomTokens->uniform) {
744 process_normals_uniform(mesh, usd_data.normals());
750 ELEM(usd_data.normal_interpolation, pxr::UsdGeomTokens->vertex, pxr::UsdGeomTokens->varying))
752 process_normals_vertex_varying(mesh, usd_data.normals_for_write());
760 read_velocities(mesh, time);
761 read_custom_data(settings, mesh, time, new_mesh);
765void USDMeshReader::read_custom_data(
const ImportSettings *settings,
767 const pxr::UsdTimeCode time,
770 if (!(mesh && mesh->corners_num > 0)) {
774 pxr::UsdGeomPrimvarsAPI pv_api = pxr::UsdGeomPrimvarsAPI(mesh_prim_);
775 std::vector<pxr::UsdGeomPrimvar> primvars = pv_api.GetPrimvarsWithValues();
777 pxr::TfToken active_color_name;
778 pxr::TfToken active_uv_set_name;
781 for (
const pxr::UsdGeomPrimvar &pv : primvars) {
782 const pxr::SdfValueTypeName type = pv.GetTypeName();
783 if (!type.IsArray()) {
787 const pxr::TfToken varying_type = pv.GetInterpolation();
788 const pxr::TfToken
name = pxr::UsdGeomPrimvar::StripPrimvarsName(pv.GetPrimvarName());
792 if (!new_mesh && primvar_varying_map_.contains(
name) && !primvar_varying_map_.lookup(
name)) {
797 if (
ELEM(
name,
"velocity",
"normals")) {
802 pxr::SdfValueTypeNames->StringArray,
803 pxr::SdfValueTypeNames->QuatdArray,
804 pxr::SdfValueTypeNames->QuathArray))
817 active_color_name =
name;
825 else if (
ELEM(varying_type,
826 pxr::UsdGeomTokens->
vertex,
827 pxr::UsdGeomTokens->faceVarying,
828 pxr::UsdGeomTokens->varying) &&
836 active_uv_set_name =
name;
838 this->read_uv_data_primvar(mesh, pv, time);
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;
859 if (!active_color_name.IsEmpty()) {
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());
870void USDMeshReader::assign_facesets_to_material_indices(pxr::UsdTimeCode time,
871 MutableSpan<int> material_indices,
872 Map<pxr::SdfPath, int> *r_mat_map)
874 if (r_mat_map ==
nullptr) {
884 const std::vector<pxr::UsdGeomSubset> subsets = pxr::UsdGeomSubset::GetAllGeomSubsets(
888 if (!subsets.empty()) {
889 for (
const pxr::UsdGeomSubset &subset : subsets) {
890 pxr::UsdPrim subset_prim = subset.GetPrim();
897 pxr::SdfPath subset_mtl_path = subset_mtl.GetPath();
898 if (subset_mtl_path.IsEmpty()) {
902 pxr::TfToken element_type;
903 subset.GetElementTypeAttr().Get(&element_type, time);
904 if (element_type != pxr::UsdGeomTokens->face) {
906 "UsdGeomSubset '%s' uses unsupported elementType: %s",
907 subset_prim.GetName().GetText(),
908 element_type.GetText());
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));
915 pxr::VtIntArray indices;
916 subset.GetIndicesAttr().Get(&indices, time);
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;
925 if (bad_element_count > 0) {
927 "UsdGeomSubset '%s' contains invalid indices; material assignment may be "
928 "incorrect (%d were out of range)",
929 subset_prim.GetName().GetText(),
935 if (r_mat_map->is_empty()) {
938 pxr::SdfPath mtl_path = mtl.GetPath();
940 if (!mtl_path.IsEmpty()) {
941 r_mat_map->add(mtl.GetPath(), 1);
947void USDMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh,
const pxr::UsdTimeCode time)
953 Map<pxr::SdfPath, int> mat_map;
955 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
956 bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<
int>(
958 this->assign_facesets_to_material_indices(time, material_indices.span, &mat_map);
959 material_indices.finish();
968Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
972 USDMeshReadData usd_data(mesh_prim_, params.motion_sample_time);
973 if (usd_data.orientation == pxr::UsdGeomTokens->leftHanded) {
974 is_left_handed_ =
true;
982 "Mesh '%s' too large to import, exceeds max int size",
983 this->
prim_path().GetAsString().c_str());
984 return existing_mesh;
987 Mesh *active_mesh = existing_mesh;
988 bool new_mesh =
false;
993 ImportSettings settings;
994 settings.read_flag |= params.read_flags;
999 usd_data.positions().size(),
1001 usd_data.face_counts().size(),
1002 usd_data.face_indices().size());
1006 &settings, active_mesh, usd_data, params.motion_sample_time, new_mesh || is_initial_load_);
1013 Map<pxr::SdfPath, int> mat_map;
1014 bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
1015 bke::SpanAttributeWriter<int> material_indices =
1017 assign_facesets_to_material_indices(
1018 params.motion_sample_time, material_indices.span, &mat_map);
1019 material_indices.finish();
1034 const char **r_err_str)
1037 Mesh *new_mesh = read_mesh(existing_mesh, params, r_err_str);
1039 if (new_mesh != existing_mesh) {
1053 pxr::UsdSkelBindingAPI skel_api(
prim_);
1055 if (pxr::UsdSkelSkeleton skel = skel_api.GetInheritedSkeleton()) {
1056 return skel.GetPath();
1062std::optional<XformResult> USDMeshReader::get_local_usd_xform(
const pxr::UsdTimeCode time)
const
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)) {
1080 return XformResult(pxr::GfMatrix4f(bind_xf),
true);
1085 "%s: Couldn't compute geom bind transform for %s",
1087 prim_.GetPath().GetAsString().c_str());
Generic geometry attributes built on CustomData.
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define CLOG_WARN(clg_ref,...)
Object is a sort of wrapper for general info.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
ItemIterator items() const &
bool contains(const Key &key) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr const char * c_str() const
void add_cache_modifier()
void add_subdiv_modifier()
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_
StringRefNull name() const
pxr::SdfPath prim_path() const
const USDImportParams & import_params_
ReportList * reports() const
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 ¶ms, 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 ¶ms, 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)
constexpr StringRefNull velocity
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)
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
@ MOD_MESHSEQ_READ_ATTRIBUTES
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
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)
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
Mesh * BKE_mesh_add(Main *bmain, const char *name)
ListBaseT< ModifierData > modifiers
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Mesh * get_mesh_for_write()
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
bool blender_stage_version_prior_44
MtlNameCollisionMode mtl_name_collision_mode
MeshSeqCacheModifierReadFlag mesh_read_flag
Span< int > face_indices() const
pxr::TfToken normal_interpolation
Span< float3 > positions() const
Span< int > face_counts() const
USDMeshReadData(const pxr::UsdGeomMesh &mesh_prim, pxr::UsdTimeCode time)