[Bf-blender-cvs] [585a3f3428b] usd-importer-T81257: USD importer: keep original UV map name.

Michael A. Kowalski noreply at git.blender.org
Mon Oct 19 00:12:21 CEST 2020


Commit: 585a3f3428b6890971ade26837ba5969a07efd94
Author: Michael A. Kowalski
Date:   Sun Oct 18 18:10:08 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rB585a3f3428b6890971ade26837ba5969a07efd94

USD importer:  keep original UV map name.

Now keeping the USD UV primvar name as the Blender
UV map name.  Currently, always using the default
name 'st', but this may be an arbitrary name in
the future.

===================================================================

M	source/blender/io/usd/import/usd_reader_mesh.cc

===================================================================

diff --git a/source/blender/io/usd/import/usd_reader_mesh.cc b/source/blender/io/usd/import/usd_reader_mesh.cc
index 948d46279c1..f6f321e3e94 100644
--- a/source/blender/io/usd/import/usd_reader_mesh.cc
+++ b/source/blender/io/usd/import/usd_reader_mesh.cc
@@ -44,6 +44,7 @@ struct MeshSampleData {
   pxr::VtArray<pxr::GfVec3f> points;
   pxr::VtArray<int> vertex_counts;
   pxr::VtArray<int> vertex_indices;
+  pxr::TfToken uv_primvar_name;
   pxr::VtVec2fArray uv_values;
   pxr::VtArray<int> uv_indices;
   pxr::TfToken uv_interpolation;
@@ -80,6 +81,7 @@ static void sample_uvs(const pxr::UsdGeomMesh &mesh,
                 << mesh.GetPath() << std::endl;
     }
 
+    mesh_data.uv_primvar_name = primvar_name;
     st_primvar.GetIndices(&mesh_data.uv_indices, time);
     mesh_data.uv_interpolation = st_primvar.GetInterpolation();
   }
@@ -139,10 +141,11 @@ static void read_mpolys(Mesh *mesh, const MeshSampleData &mesh_data)
 
   const bool do_uvs = (mesh_data.uv_interpolation == pxr::UsdGeomTokens->faceVarying ||
                        mesh_data.uv_interpolation == pxr::UsdGeomTokens->vertex) &&
-                      !(mesh_data.uv_indices.empty() && mesh_data.uv_values.empty());
+                      !(mesh_data.uv_indices.empty() && mesh_data.uv_values.empty()) &&
+                      !mesh_data.uv_primvar_name.IsEmpty();
 
   if (do_uvs) {
-    void *cd_ptr = add_customdata(mesh, "uvMap", CD_MLOOPUV);
+    void *cd_ptr = add_customdata(mesh, mesh_data.uv_primvar_name.GetString().c_str(), CD_MLOOPUV);
     mloopuvs = static_cast<MLoopUV *>(cd_ptr);
   }



More information about the Bf-blender-cvs mailing list