44#include <pxr/base/gf/matrix4f.h>
45#include <pxr/base/vt/array.h>
46#include <pxr/base/vt/types.h>
47#include <pxr/usd/sdf/types.h>
48#include <pxr/usd/usdGeom/primvarsAPI.h>
49#include <pxr/usd/usdGeom/subset.h>
50#include <pxr/usd/usdShade/materialBindingAPI.h>
51#include <pxr/usd/usdShade/tokens.h>
52#include <pxr/usd/usdSkel/bindingAPI.h>
63static const pxr::TfToken
st(
"st", pxr::TfToken::Immortal);
74 const pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim);
80 pxr::UsdShadeMaterial mtl;
81 switch (mtl_purpose) {
83 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->full);
86 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
90 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
93 mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->allPurpose);
104 pxr::UsdStageRefPtr stage,
107 if (!(stage && bmain && ob)) {
117 for (
const auto item : mat_index_map.
items()) {
124 pxr::UsdPrim prim = stage->GetPrimAtPath(item.key);
125 pxr::UsdShadeMaterial usd_mat(prim);
129 &
LOG,
"Couldn't construct USD material from prim %s", item.key.GetAsString().c_str());
137 assigned_mat = mat_reader.
add_material(usd_mat, !have_import_hook);
141 "Couldn't create Blender material from USD material %s",
142 item.key.GetAsString().c_str());
153 if (have_import_hook) {
165 CLOG_WARN(&
LOG,
"Couldn't assign material %s", item.key.GetAsString().c_str());
187 is_initial_load_ =
true;
191 Mesh *read_mesh = this->read_mesh(mesh,
params,
nullptr);
193 is_initial_load_ =
false;
194 if (read_mesh != mesh) {
198 readFaceSetsSample(bmain, mesh, time);
200 if (mesh_prim_.GetPointsAttr().ValueMightBeTimeVarying() ||
201 mesh_prim_.GetNormalsAttr().ValueMightBeTimeVarying() ||
202 mesh_prim_.GetVelocitiesAttr().ValueMightBeTimeVarying() ||
203 mesh_prim_.GetCreaseSharpnessesAttr().ValueMightBeTimeVarying() ||
204 mesh_prim_.GetCreaseLengthsAttr().ValueMightBeTimeVarying() ||
205 mesh_prim_.GetCreaseIndicesAttr().ValueMightBeTimeVarying() ||
206 mesh_prim_.GetCornerSharpnessesAttr().ValueMightBeTimeVarying() ||
207 mesh_prim_.GetCornerIndicesAttr().ValueMightBeTimeVarying())
209 is_time_varying_ =
true;
212 if (is_time_varying_) {
217 pxr::TfToken subdivScheme;
218 mesh_prim_.GetSubdivisionSchemeAttr().Get(&subdivScheme, time);
220 if (subdivScheme == pxr::UsdGeomTokens->catmullClark) {
242 mesh_prim_.GetFaceVertexIndicesAttr().Get(&face_indices_, time);
243 mesh_prim_.GetFaceVertexCountsAttr().Get(&face_counts_, time);
244 mesh_prim_.GetPointsAttr().Get(&positions_, time);
246 const pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
253 if (primvar.HasValue()) {
254 primvar.ComputeFlattened(&normals_, time);
255 normal_interpolation_ = primvar.GetInterpolation();
258 mesh_prim_.GetNormalsAttr().Get(&normals_, time);
259 normal_interpolation_ = mesh_prim_.GetNormalsInterpolation();
262 return positions_.size() != existing_mesh->
verts_num ||
263 face_counts_.size() != existing_mesh->
faces_num ||
264 face_indices_.size() != existing_mesh->
corners_num;
267bool USDMeshReader::read_faces(
Mesh *mesh)
const
274 for (
int i = 0;
i < face_counts_.size();
i++) {
275 const int face_size = face_counts_[
i];
277 face_offsets[
i] = loop_index;
282 if (is_left_handed_) {
283 int loop_end_index = loop_index + (face_size - 1);
284 for (
int f = 0; f < face_size; ++f, ++loop_index) {
285 corner_verts[loop_index] = face_indices_[loop_end_index - f];
289 for (
int f = 0; f < face_size; ++f, ++loop_index) {
290 corner_verts[loop_index] = face_indices_[loop_index];
296 const OffsetIndices<int>
faces = mesh->faces();
301 [&](
const IndexRange part,
const bool ok_so_far) {
302 bool current_faces_ok = ok_so_far;
304 for (const int i : part) {
305 const IndexRange face_range = faces[i];
306 const Set<int, 32> used_verts(corner_verts.slice(face_range));
307 current_faces_ok = current_faces_ok && used_verts.size() == face_range.size();
310 return current_faces_ok;
312 std::logical_and<>());
319 if (is_initial_load_) {
320 const char *message =
N_(
321 "Invalid face data detected for mesh '%s'. Automatic correction will be used, but some "
322 "data will most likely be lost");
323 const std::string prim_path = this->prim_path().GetAsString();
336 mesh->tag_topology_changed();
341void USDMeshReader::read_uv_data_primvar(
Mesh *mesh,
342 const pxr::UsdGeomPrimvar &primvar,
343 const pxr::UsdTimeCode time)
345 const StringRef primvar_name(
346 pxr::UsdGeomPrimvar::StripPrimvarsName(primvar.GetName()).GetString());
348 const pxr::VtVec2fArray usd_uvs = get_primvar_array<pxr::GfVec2f>(primvar, time);
349 if (usd_uvs.empty()) {
353 const pxr::TfToken varying_type = primvar.GetInterpolation();
355 pxr::UsdGeomTokens->vertex,
356 pxr::UsdGeomTokens->faceVarying,
357 pxr::UsdGeomTokens->varying));
359 if ((varying_type == pxr::UsdGeomTokens->faceVarying && usd_uvs.size() != mesh->
corners_num) ||
360 (varying_type == pxr::UsdGeomTokens->vertex && usd_uvs.size() != mesh->
verts_num) ||
361 (varying_type == pxr::UsdGeomTokens->varying && usd_uvs.size() != mesh->
verts_num))
365 "USD Import: UV attribute value '%s' count inconsistent with interpolation type",
366 primvar.GetName().GetText());
370 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
371 bke::SpanAttributeWriter<float2> uv_data = attributes.lookup_or_add_for_write_only_span<
float2>(
377 "USD Import: couldn't add UV attribute '%s'",
378 primvar.GetBaseName().GetText());
382 if (varying_type == pxr::UsdGeomTokens->faceVarying) {
383 if (is_left_handed_) {
385 const OffsetIndices
faces = mesh->faces();
386 for (
const int i :
faces.index_range()) {
387 const IndexRange face =
faces[
i];
389 const int rev_index = face.
last(j);
390 uv_data.span[face.
start() + j] =
float2(usd_uvs[rev_index][0], usd_uvs[rev_index][1]);
395 for (
int i = 0;
i < uv_data.span.size(); ++
i) {
396 uv_data.span[
i] =
float2(usd_uvs[
i][0], usd_uvs[
i][1]);
402 const Span<int> corner_verts = mesh->corner_verts();
404 for (
int i = 0;
i < uv_data.span.size(); ++
i) {
406 int vi = corner_verts[
i];
407 uv_data.span[
i] =
float2(usd_uvs[vi][0], usd_uvs[vi][1]);
414void USDMeshReader::read_subdiv()
419 pxr::TfToken uv_smooth;
420 mesh_prim_.GetFaceVaryingLinearInterpolationAttr().Get(&uv_smooth);
422 if (uv_smooth == pxr::UsdGeomTokens->
all) {
425 else if (uv_smooth == pxr::UsdGeomTokens->cornersOnly) {
428 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus1) {
431 else if (uv_smooth == pxr::UsdGeomTokens->cornersPlus2) {
434 else if (uv_smooth == pxr::UsdGeomTokens->boundaries) {
437 else if (uv_smooth == pxr::UsdGeomTokens->none) {
441 pxr::TfToken boundary_smooth;
442 mesh_prim_.GetInterpolateBoundaryAttr().Get(&boundary_smooth);
444 if (boundary_smooth == pxr::UsdGeomTokens->edgeOnly) {
447 else if (boundary_smooth == pxr::UsdGeomTokens->edgeAndCorner) {
452void USDMeshReader::read_vertex_creases(
Mesh *mesh,
const pxr::UsdTimeCode time)
454 pxr::VtIntArray usd_corner_indices;
455 if (!mesh_prim_.GetCornerIndicesAttr().Get(&usd_corner_indices, time)) {
459 pxr::VtFloatArray usd_corner_sharpnesses;
460 if (!mesh_prim_.GetCornerSharpnessesAttr().Get(&usd_corner_sharpnesses, time)) {
465 if (usd_corner_indices.empty() || usd_corner_sharpnesses.empty()) {
470 if (usd_corner_indices.size() > mesh->
verts_num) {
472 &
LOG,
"Too many vertex creases for mesh %s", this->prim_path().GetAsString().c_str());
476 if (usd_corner_indices.size() != usd_corner_sharpnesses.size()) {
478 "Vertex crease and sharpness count mismatch for mesh %s",
479 this->prim_path().GetAsString().c_str());
483 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
484 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<
float>(
486 creases.span.fill(0.0f);
488 Span<int> corner_indices =
Span(usd_corner_indices.cdata(), usd_corner_indices.size());
489 Span<float> corner_sharpnesses =
Span(usd_corner_sharpnesses.cdata(),
490 usd_corner_sharpnesses.size());
492 for (
size_t i = 0;
i < corner_indices.
size();
i++) {
493 const float crease = settings_->blender_stage_version_prior_44 ?
494 corner_sharpnesses[
i] :
496 creases.span[corner_indices[
i]] = std::clamp(crease, 0.0f, 1.0f);
501void USDMeshReader::read_edge_creases(
Mesh *mesh,
const pxr::UsdTimeCode time)
503 pxr::VtArray<int> usd_crease_lengths;
504 pxr::VtArray<int> usd_crease_indices;
505 pxr::VtArray<float> usd_crease_sharpness;
506 mesh_prim_.GetCreaseLengthsAttr().Get(&usd_crease_lengths, time);
507 mesh_prim_.GetCreaseIndicesAttr().Get(&usd_crease_indices, time);
508 mesh_prim_.GetCreaseSharpnessesAttr().Get(&usd_crease_sharpness, time);
511 if (usd_crease_lengths.empty() || usd_crease_indices.empty() || usd_crease_sharpness.empty()) {
516 if (usd_crease_lengths.size() != usd_crease_sharpness.size()) {
518 "Edge crease and sharpness count mismatch for mesh %s",
519 this->prim_path().GetAsString().c_str());
524 using EdgeMap = VectorSet<OrderedEdge,
527 DefaultHash<OrderedEdge>,
528 DefaultEquality<OrderedEdge>,
529 SimpleVectorSetSlot<OrderedEdge, int>,
531 Span<int2> edges = mesh->edges();
533 edge_map.reserve(edges.
size());
536 edge_map.add(edges[
i]);
539 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
540 bke::SpanAttributeWriter creases = attributes.lookup_or_add_for_write_only_span<
float>(
542 creases.span.fill(0.0f);
544 Span<int> crease_lengths =
Span(usd_crease_lengths.cdata(), usd_crease_lengths.size());
545 Span<int> crease_indices =
Span(usd_crease_indices.cdata(), usd_crease_indices.size());
546 Span<float> crease_sharpness =
Span(usd_crease_sharpness.cdata(), usd_crease_sharpness.size());
548 size_t index_start = 0;
549 for (
size_t i = 0;
i < crease_lengths.
size();
i++) {
550 const int length = crease_lengths[
i];
555 "Edge crease length %d is invalid for mesh %s",
557 this->prim_path().GetAsString().c_str());
561 if (index_start +
length > crease_indices.
size()) {
563 "Edge crease lengths are out of bounds for mesh %s",
564 this->prim_path().GetAsString().c_str());
568 float crease = settings_->blender_stage_version_prior_44 ?
569 crease_sharpness[
i] :
571 crease = std::clamp(crease, 0.0f, 1.0f);
572 for (
size_t j = 0; j <
length - 1; j++) {
573 const int v1 = crease_indices[index_start + j];
574 const int v2 = crease_indices[index_start + j + 1];
575 const int edge_i = edge_map.index_of_try({v1,
v2});
580 creases.span[edge_i] = crease;
589void USDMeshReader::read_velocities(
Mesh *mesh,
const pxr::UsdTimeCode time)
591 pxr::VtVec3fArray velocities;
592 mesh_prim_.GetVelocitiesAttr().Get(&velocities, time);
594 if (!velocities.empty()) {
595 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
596 bke::SpanAttributeWriter<float3> velocity =
599 Span<pxr::GfVec3f> usd_data(velocities.cdata(), velocities.size());
600 velocity.span.copy_from(usd_data.cast<
float3>());
605void USDMeshReader::process_normals_vertex_varying(
Mesh *mesh)
607 if (normals_.empty()) {
611 if (normals_.size() != mesh->
verts_num) {
613 "Vertex varying normals count mismatch for mesh '%s'",
614 this->prim_path().GetAsString().c_str());
620 *mesh, {
reinterpret_cast<float3 *
>(normals_.data()),
int64_t(normals_.size())});
623void USDMeshReader::process_normals_face_varying(
Mesh *mesh)
const
625 if (normals_.empty()) {
632 &
LOG,
"Loop normal count mismatch for mesh '%s'", this->prim_path().GetAsString().c_str());
638 const OffsetIndices
faces = mesh->faces();
639 for (
const int i :
faces.index_range()) {
640 const IndexRange face =
faces[
i];
642 const int corner = face.
start() + j;
644 int usd_index = face.
start();
645 if (is_left_handed_) {
646 usd_index += face.
size() - 1 - j;
652 corner_normals[corner] = detail::convert_value<pxr::GfVec3f, float3>(normals_[usd_index]);
659void USDMeshReader::process_normals_uniform(
Mesh *mesh)
const
661 if (normals_.empty()) {
666 if (normals_.size() != mesh->
faces_num) {
668 "Uniform normal count mismatch for mesh '%s'",
669 this->prim_path().GetAsString().c_str());
675 const OffsetIndices
faces = mesh->faces();
676 for (
const int i :
faces.index_range()) {
677 for (
const int corner :
faces[
i]) {
678 corner_normals[corner] = detail::convert_value<pxr::GfVec3f, float3>(normals_[
i]);
685void USDMeshReader::read_mesh_sample(ImportSettings *settings,
687 const pxr::UsdTimeCode time,
695 MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
697 mesh->tag_positions_changed();
699 read_vertex_creases(mesh, time);
703 if (!read_faces(mesh)) {
706 read_edge_creases(mesh, time);
708 if (normal_interpolation_ == pxr::UsdGeomTokens->faceVarying) {
709 process_normals_face_varying(mesh);
711 else if (normal_interpolation_ == pxr::UsdGeomTokens->uniform) {
712 process_normals_uniform(mesh);
718 normal_interpolation_ == pxr::UsdGeomTokens->vertex)
720 process_normals_vertex_varying(mesh);
728 read_velocities(mesh, time);
733void USDMeshReader::read_custom_data(
const ImportSettings *settings,
735 const pxr::UsdTimeCode time,
742 pxr::UsdGeomPrimvarsAPI pv_api = pxr::UsdGeomPrimvarsAPI(mesh_prim_);
743 std::vector<pxr::UsdGeomPrimvar> primvars = pv_api.GetPrimvarsWithValues();
745 pxr::TfToken active_color_name;
746 pxr::TfToken active_uv_set_name;
749 for (
const pxr::UsdGeomPrimvar &pv : primvars) {
750 const pxr::SdfValueTypeName type = pv.GetTypeName();
751 if (!type.IsArray()) {
755 const pxr::TfToken varying_type = pv.GetInterpolation();
756 const pxr::TfToken
name = pxr::UsdGeomPrimvar::StripPrimvarsName(pv.GetPrimvarName());
760 if (!new_mesh && primvar_varying_map_.contains(
name) && !primvar_varying_map_.lookup(
name)) {
770 pxr::SdfValueTypeNames->StringArray,
771 pxr::SdfValueTypeNames->QuatdArray,
772 pxr::SdfValueTypeNames->QuathArray))
785 active_color_name =
name;
793 else if (
ELEM(varying_type,
794 pxr::UsdGeomTokens->vertex,
795 pxr::UsdGeomTokens->faceVarying,
796 pxr::UsdGeomTokens->varying) &&
804 active_uv_set_name =
name;
806 this->read_uv_data_primvar(mesh, pv, time);
818 if (!primvar_varying_map_.contains(
name)) {
819 bool might_be_time_varying = pv.ValueMightBeTimeVarying();
820 primvar_varying_map_.add(
name, might_be_time_varying);
821 if (might_be_time_varying) {
822 is_time_varying_ =
true;
827 if (!active_color_name.IsEmpty()) {
832 if (!active_uv_set_name.IsEmpty()) {
835 if (layer_index > -1) {
842void USDMeshReader::assign_facesets_to_material_indices(pxr::UsdTimeCode time,
843 MutableSpan<int> material_indices,
844 blender::Map<pxr::SdfPath, int> *r_mat_map)
846 if (r_mat_map ==
nullptr) {
856 const std::vector<pxr::UsdGeomSubset> subsets = pxr::UsdGeomSubset::GetAllGeomSubsets(
860 if (!subsets.empty()) {
861 for (
const pxr::UsdGeomSubset &subset : subsets) {
862 pxr::UsdPrim subset_prim = subset.GetPrim();
863 pxr::UsdShadeMaterial subset_mtl = utils::compute_bound_material(subset_prim,
864 import_params_.mtl_purpose);
869 pxr::SdfPath subset_mtl_path = subset_mtl.GetPath();
870 if (subset_mtl_path.IsEmpty()) {
874 pxr::TfToken element_type;
875 subset.GetElementTypeAttr().Get(&element_type, time);
876 if (element_type != pxr::UsdGeomTokens->face) {
878 "UsdGeomSubset '%s' uses unsupported elementType: %s",
879 subset_prim.GetName().GetText(),
880 element_type.GetText());
884 const int mat_idx = r_mat_map->
lookup_or_add(subset_mtl_path, 1 + current_mat++);
885 const int max_element_idx = std::max(0,
int(material_indices.
size() - 1));
888 subset.GetIndicesAttr().Get(&
indices, time);
890 int bad_element_count = 0;
891 for (
const int element_idx :
indices.AsConst()) {
892 const int safe_element_idx = std::clamp(element_idx, 0, max_element_idx);
893 bad_element_count += (safe_element_idx != element_idx) ? 1 : 0;
894 material_indices[safe_element_idx] = mat_idx - 1;
897 if (bad_element_count > 0) {
899 "UsdGeomSubset '%s' contains invalid indices; material assignment may be "
900 "incorrect (%d were out of range)",
901 subset_prim.GetName().GetText(),
908 pxr::UsdShadeMaterial mtl = utils::compute_bound_material(prim_, import_params_.mtl_purpose);
910 pxr::SdfPath mtl_path = mtl.GetPath();
912 if (!mtl_path.IsEmpty()) {
913 r_mat_map->
add(mtl.GetPath(), 1);
919void USDMeshReader::readFaceSetsSample(Main *bmain,
Mesh *mesh,
const pxr::UsdTimeCode time)
921 if (!import_params_.import_materials) {
925 blender::Map<pxr::SdfPath, int> mat_map;
927 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
928 bke::SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<
int>(
930 this->assign_facesets_to_material_indices(time, material_indices.span, &mat_map);
931 material_indices.finish();
933 if (this->settings_->mat_name_to_mat.is_empty()) {
936 utils::assign_materials(
937 bmain, object_, mat_map, this->import_params_, this->prim_.GetStage(), *this->settings_);
940Mesh *USDMeshReader::read_mesh(
Mesh *existing_mesh,
941 const USDMeshReadParams
params,
944 mesh_prim_.GetOrientationAttr().Get(&orientation_);
945 if (orientation_ == pxr::UsdGeomTokens->leftHanded) {
946 is_left_handed_ =
true;
949 Mesh *active_mesh = existing_mesh;
950 bool new_mesh =
false;
955 ImportSettings settings;
956 settings.read_flag |=
params.read_flags;
958 if (topology_changed(existing_mesh,
params.motion_sample_time)) {
961 existing_mesh, positions_.size(), 0, face_counts_.size(), face_indices_.size());
965 &settings, active_mesh,
params.motion_sample_time, new_mesh || is_initial_load_);
971 if (active_mesh->
faces_num != 0 && import_params_.import_materials) {
972 blender::Map<pxr::SdfPath, int> mat_map;
973 bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
974 bke::SpanAttributeWriter<int> material_indices =
976 assign_facesets_to_material_indices(
977 params.motion_sample_time, material_indices.span, &mat_map);
978 material_indices.finish();
982 if (import_params_.validate_meshes) {
984 BKE_reportf(reports(),
RPT_INFO,
"Fixed mesh for prim: %s", mesh_prim_.GetPath().GetText());
993 const char **r_err_str)
996 Mesh *new_mesh = read_mesh(existing_mesh,
params, r_err_str);
998 if (new_mesh != existing_mesh) {
1012 pxr::UsdSkelBindingAPI skel_api(
prim_);
1014 if (pxr::UsdSkelSkeleton skel = skel_api.GetInheritedSkeleton()) {
1015 return skel.GetPath();
1021std::optional<XformResult> USDMeshReader::get_local_usd_xform(
const pxr::UsdTimeCode time)
const
1023 if (!import_params_.import_skeletons || prim_.IsInstanceProxy()) {
1030 pxr::UsdSkelBindingAPI skel_api = pxr::UsdSkelBindingAPI(prim_);
1031 if (pxr::UsdAttribute xf_attr = skel_api.GetGeomBindTransformAttr()) {
1032 if (xf_attr.HasAuthoredValue()) {
1033 pxr::GfMatrix4d bind_xf;
1034 if (skel_api.GetGeomBindTransformAttr().Get(&bind_xf)) {
1039 return XformResult(pxr::GfMatrix4f(bind_xf),
true);
1044 "%s: Couldn't compute geom bind transform for %s",
1046 prim_.GetPath().GetAsString().c_str());
1050 return USDXformReader::get_local_usd_xform(time);
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
CustomData interface, see also DNA_customdata_types.h.
void CustomData_set_layer_render_index(CustomData *data, eCustomDataType type, int n)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, blender::StringRef name)
void CustomData_set_layer_active_index(CustomData *data, eCustomDataType type, int n)
General operations, lookup, etc. for materials.
void BKE_object_material_assign_single_obdata(Main *bmain, Object *ob, Material *ma, short act)
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
bool BKE_mesh_validate(Mesh *mesh, bool do_verbose, bool cddata_check_mask)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys=true)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_STATIC_ASSERT(a, msg)
#define CLOG_WARN(clg_ref,...)
@ SUBSURF_BOUNDARY_SMOOTH_ALL
@ SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS
struct ModifierData ModifierData
@ MOD_MESHSEQ_READ_ATTRIBUTES
struct SubsurfModifierData SubsurfModifierData
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS
@ SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES
@ SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE
Object is a sort of wrapper for general info.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr int64_t start() const
constexpr IndexRange index_range() const
void add_new(const Key &key, const Value &value)
constexpr int64_t size() const
constexpr void copy_from(Span< T > values) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
bool add(const Key &key, const Value &value)
ItemIterator items() const &
Value & lookup_or_add(const Key &key, const Value &value)
bool contains(const Key &key) 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 USDImportParams & import_params_
ReportList * reports() const
bool all(VecOp< bool, D >) RET
VectorSet< OrderedEdge, 16, DefaultProbingStrategy, DefaultHash< OrderedEdge >, DefaultEquality< OrderedEdge >, SimpleVectorSetSlot< OrderedEdge, int >, GuardedAllocator > EdgeMap
BLI_INLINE float sharpness_to_crease(float sharpness)
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)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
void read_custom_data(const std::string &iobject_full_name, const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim, eUSDMtlPurpose mtl_purpose)
static void assign_materials(Main *bmain, Object *ob, const blender::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)
void build_material_map(const Main *bmain, blender::Map< std::string, Material * > &r_mat_map)
Material * find_existing_material(const pxr::SdfPath &usd_mat_path, const USDImportParams ¶ms, const blender::Map< std::string, Material * > &mat_map, const blender::Map< pxr::SdfPath, Material * > &usd_path_to_mat)
USDMeshReadParams create_mesh_read_params(const double motion_sample_time, const int read_flags)
@ USD_MTL_PURPOSE_PREVIEW
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)
@ USD_MTL_NAME_COLLISION_MAKE_UNIQUE
void read_generic_mesh_primvar(Mesh *mesh, const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time, const bool is_left_handed)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
VecBase< float, 2 > float2
PythonProbingStrategy<> DefaultProbingStrategy
VecBase< float, 3 > float3
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
static const pxr::TfToken normalsPrimvar("normals", pxr::TfToken::Immortal)
const pxr::TfToken displayColor("displayColor", pxr::TfToken::Immortal)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Mesh * get_mesh_for_write()
blender::Map< std::string, Material * > mat_name_to_mat
blender::Set< pxr::SdfPath > mat_import_hook_sources
blender::Map< pxr::SdfPath, Material * > usd_path_to_mat_for_hook
blender::Map< pxr::SdfPath, Material * > usd_path_to_mat