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
diff options
context:
space:
mode:
authormakowalski <makowalski@nvidia.com>2021-02-08 20:59:18 +0300
committermakowalski <makowalski@nvidia.com>2021-02-08 20:59:18 +0300
commita9b77cb74f870f6cd5d14cd60b3a55f00498dd25 (patch)
treeb7193c063f55e1989aaaaffe9241920ea7fab3e6 /source/blender
parent17cd9adbde9df63d2fa700a303d7ea1fef4ff332 (diff)
USD import: handle primvars:normals if specified.
Per Pixar UsdGeomPointBased documentation: If 'normals' and 'primvars:normals' are both specified, the latter has precedence.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/io/usd/intern/usd_reader_mesh.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 8afd8378386..0bc21145e5b 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -72,6 +72,7 @@ static const pxr::TfToken st("st", pxr::TfToken::Immortal);
static const pxr::TfToken UVMap("UVMap", pxr::TfToken::Immortal);
static const pxr::TfToken Cd("Cd", pxr::TfToken::Immortal);
static const pxr::TfToken displayColor("displayColor", pxr::TfToken::Immortal);
+static const pxr::TfToken normalsPrimvar("normals", pxr::TfToken::Immortal);
} // namespace usdtokens
namespace utils {
@@ -239,7 +240,16 @@ bool USDMeshReader::topology_changed(Mesh *existing_mesh, double motionSampleTim
faceVertCountsAttr.Get(&m_face_counts, motionSampleTime);
pointsAttr.Get(&m_positions, motionSampleTime);
- normalsAttr.Get(&m_normals, motionSampleTime);
+ // If 'normals' and 'primvars:normals' are both specified, the latter has precedence.
+ pxr::UsdGeomPrimvar primvar = mesh_prim.GetPrimvar(usdtokens::normalsPrimvar);
+ if (primvar.HasValue()) {
+ primvar.ComputeFlattened(&m_normals, motionSampleTime);
+ m_normalInterpolation = primvar.GetInterpolation();
+ }
+ else {
+ mesh_prim.GetNormalsAttr().Get(&m_normals, motionSampleTime);
+ m_normalInterpolation = mesh_prim.GetNormalsInterpolation();
+ }
if (m_lastNumPositions != m_positions.size()) {
m_lastNumPositions = m_positions.size();
@@ -655,8 +665,6 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
// pxr::UsdAttribute faceVertCountsAttr = mesh_prim.GetFaceVertexCountsAttr();
// pxr::UsdAttribute faceVertIndicesAttr = mesh_prim.GetFaceVertexIndicesAttr();
- m_normalInterpolation = mesh_prim.GetNormalsInterpolation();
-
mesh_prim.GetOrientationAttr().Get(&m_orientation);
if (m_orientation == pxr::UsdGeomTokens->leftHanded)
m_isLeftHanded = true;