Skip to content

Commit 9023d87

Browse files
committed
USDScene : Ignore attributes without authored values
This prevents us from having to later return a null attribute from `readAttribute()`, which in turn becomes a warning in Gaffer.
1 parent 5be2bd1 commit 9023d87

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,9 @@ bool USDScene::hasAttribute( const SceneInterface::Name &name ) const
762762
pxr::TfToken kind;
763763
return model.GetKind( &kind );
764764
}
765-
else if( AttributeAlgo::findUSDAttribute( m_location->prim, name.string() ) )
765+
else if( auto attribute = AttributeAlgo::findUSDAttribute( m_location->prim, name.string() ) )
766766
{
767-
return true;
767+
return attribute.HasAuthoredValue();
768768
}
769769
else
770770
{
@@ -813,6 +813,10 @@ void USDScene::attributeNames( SceneInterface::NameList &attrs ) const
813813
std::vector<pxr::UsdAttribute> attributes = m_location->prim.GetAuthoredAttributes();
814814
for( const auto &attribute : attributes )
815815
{
816+
if( !attribute.HasAuthoredValue() )
817+
{
818+
continue;
819+
}
816820
IECore::InternedString name = IECoreUSD::AttributeAlgo::cortexAttributeName( attribute );
817821
if( name.string().size() )
818822
{

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,7 @@ def assertExpectedAttributes( sphere ) :
23882388
"namespaced:test",
23892389
"nonexistent",
23902390
"radius",
2391+
"test:noAuthoredValue",
23912392
] :
23922393
self.assertFalse( sphere.hasAttribute( name ) )
23932394
self.assertIsNone( sphere.readAttribute( name, 0 ) )

contrib/IECoreUSD/test/IECoreUSD/data/customAttribute.usda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def Sphere "sphere"
2323
)
2424
float primvars:arnold:disp_height = 0.5
2525
int primvars:arnold:poly_mesh:subdiv_iterations = 3
26+
custom string[] test:noAuthoredValue
2627
}
2728
def Xform "a"
2829
{

0 commit comments

Comments
 (0)