Skip to content

Commit

Permalink
Fixes issue where UsdGeomPrimvar::IsIndexed() doesn't work
Browse files Browse the repository at this point in the history
for index attrs with only authored timeSamples.  We now have
UsdResolveInfo for answering "has value" questions without actually
needing to read in an attribute value (in theory, though actually
pulling off that optimization will require some SdfAbstractData API
work, to allow USD to query a value's type, which in crate and other
formats can be discovered without actually reading in the full value).

Fixes #238

(Internal change: 1767403)
  • Loading branch information
spiffmon authored and pixar-oss committed Jul 25, 2017
1 parent 9746195 commit 2746117
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pxr/usd/lib/usdGeom/primvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ UsdGeomPrimvar::GetIndices(VtIntArray *indices,
bool
UsdGeomPrimvar::IsIndexed() const
{
// XXX update this to api that can directly see if an attribute is blocked.
VtIntArray dummy;
return _GetIndicesAttr(/*create*/ false).Get(&dummy);
UsdResolveInfo valueSource = _GetIndicesAttr(/*create*/ false).
GetResolveInfo(UsdTimeCode::EarliestTime());

return (valueSource.HasAuthoredValueOpinion() &&
!valueSource.ValueIsBlocked());
}

bool
Expand Down
9 changes: 9 additions & 0 deletions pxr/usd/lib/usdGeom/testenv/testUsdGeomPrimvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ def test_PrimvarAPI(self):
self.assertTrue(len(u1.ComputeFlattened(2.0)) == 0)
self.assertNotEqual(u1.ComputeFlattened(2.0), u1.Get(2.0))

# Ensure that primvars with indices only authored at timeSamples
# (i.e. no default) are recognized as such. Manual name-munging
# necessitated by UsdGeomPrimvar's lack of API for accessing
# the indices attribute directly!
u1Indices = p.GetAttribute(u1.GetName() + ":indices")
self.assertTrue(u1Indices)
u1Indices.ClearDefault()
self.assertTrue(u1.IsIndexed())

# Finally, ensure the values returned by GetDeclarationInfo
# (on new Primvar objects, to test the GprimSchema API)
# is identical to the individual queries, and matches what we set above
Expand Down

0 comments on commit 2746117

Please sign in to comment.