Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authormakowalski <makowalski@nvidia.com>2021-07-22 22:40:58 +0300
committermakowalski <makowalski@nvidia.com>2021-07-22 22:40:58 +0300
commite02d956dd27b06ee09b208e9565e8f5a24b094fd (patch)
tree5245d7b8c42fb68828e1a120fe4fe7a0db53d373 /source
parent17719d4616114cf386356e3bbe6ec98b1c551ed0 (diff)
USD Import: only create UV data if needed.
Fixed bug where UV custom data was being created even if reading mesh UVs is disabled.
Diffstat (limited to 'source')
-rw-r--r--source/blender/io/usd/intern/usd_reader_mesh.cc60
1 files changed, 32 insertions, 28 deletions
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 4ac9a01f5d5..00122ac2b66 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -763,43 +763,47 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
std::vector<pxr::TfToken> uv_tokens;
- std::vector<pxr::UsdGeomPrimvar> primvars = mesh_prim_.GetPrimvars();
+ /* Currently we only handle UV primvars. */
+ if (read_flag & MOD_MESHSEQ_READ_UV) {
- for (pxr::UsdGeomPrimvar p : primvars) {
+ std::vector<pxr::UsdGeomPrimvar> primvars = mesh_prim_.GetPrimvars();
- pxr::TfToken name = p.GetPrimvarName();
- pxr::SdfValueTypeName type = p.GetTypeName();
+ for (pxr::UsdGeomPrimvar p : primvars) {
- bool is_uv = false;
+ pxr::TfToken name = p.GetPrimvarName();
+ pxr::SdfValueTypeName type = p.GetTypeName();
- /* Assume all uvs are stored in one of these primvar types */
- if (type == pxr::SdfValueTypeNames->TexCoord2hArray ||
- type == pxr::SdfValueTypeNames->TexCoord2fArray ||
- type == pxr::SdfValueTypeNames->TexCoord2dArray) {
- is_uv = true;
- }
- /* In some cases, the st primvar is stored as float2 values. */
- else if (name == usdtokens::st && type == pxr::SdfValueTypeNames->Float2Array) {
- is_uv = true;
- }
+ bool is_uv = false;
- if (is_uv) {
+ /* Assume all uvs are stored in one of these primvar types */
+ if (type == pxr::SdfValueTypeNames->TexCoord2hArray ||
+ type == pxr::SdfValueTypeNames->TexCoord2fArray ||
+ type == pxr::SdfValueTypeNames->TexCoord2dArray) {
+ is_uv = true;
+ }
+ /* In some cases, the st primvar is stored as float2 values. */
+ else if (name == usdtokens::st && type == pxr::SdfValueTypeNames->Float2Array) {
+ is_uv = true;
+ }
- pxr::TfToken interp = p.GetInterpolation();
+ if (is_uv) {
- if (!(interp == pxr::UsdGeomTokens->faceVarying || interp == pxr::UsdGeomTokens->vertex)) {
- continue;
- }
+ pxr::TfToken interp = p.GetInterpolation();
+
+ if (!(interp == pxr::UsdGeomTokens->faceVarying || interp == pxr::UsdGeomTokens->vertex)) {
+ continue;
+ }
- uv_tokens.push_back(p.GetBaseName());
- has_uvs_ = true;
+ uv_tokens.push_back(p.GetBaseName());
+ has_uvs_ = true;
- /* Record whether the UVs might be time varying. */
- if (primvar_varying_map_.find(name) == primvar_varying_map_.end()) {
- bool might_be_time_varying = p.ValueMightBeTimeVarying();
- primvar_varying_map_.insert(std::make_pair(name, might_be_time_varying));
- if (might_be_time_varying) {
- is_time_varying_ = true;
+ /* Record whether the UVs might be time varying. */
+ if (primvar_varying_map_.find(name) == primvar_varying_map_.end()) {
+ bool might_be_time_varying = p.ValueMightBeTimeVarying();
+ primvar_varying_map_.insert(std::make_pair(name, might_be_time_varying));
+ if (might_be_time_varying) {
+ is_time_varying_ = true;
+ }
}
}
}