Skip to content

Commit

Permalink
USDScene : Fix hash of bounds from UsdGeomModelAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Aug 27, 2024
1 parent 1cca931 commit 5957180
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
Fixes
-----

- USDScene : Fixed round-tripping of colons in set names.
- USDScene :
- Fixed round-tripping of colons in set names.
- Fixed `hash()` to consider animation on ModelAPI extents when hashing the bound.

10.5.9.1 (relative to 10.5.9.0)
========
Expand Down
4 changes: 2 additions & 2 deletions contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,11 +1590,11 @@ void USDScene::hash( SceneInterface::HashType hashType, double time, MurmurHash

void USDScene::boundHash( double time, IECore::MurmurHash &h ) const
{
if( pxr::UsdGeomBoundable boundable = pxr::UsdGeomBoundable( m_location->prim ) )
if( auto attribute = boundAttribute( m_location->prim ) )
{
h.append( m_root->uniqueId() );
appendPrimOrMasterPath( m_location->prim, h );
if( boundable.GetExtentAttr().ValueMightBeTimeVarying() )
if( attribute.ValueMightBeTimeVarying() )
{
h.append( time );
}
Expand Down
25 changes: 25 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4235,6 +4235,31 @@ def testModelBound( self ) :
self.assertTrue( root.child( "withModelAPIAndExtent" ).hasBound() )
self.assertEqual( root.child( "withModelAPIAndExtent" ).readBound( 0 ), imath.Box3d( imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ) ) )

def testAnimatedModelBound( self ) :

fileName = os.path.join( self.temporaryDirectory(), "modelBound.usda" )

stage = pxr.Usd.Stage.CreateNew( fileName )
pxr.UsdGeom.Xform.Define( stage, "/model" )

pxr.UsdGeom.ModelAPI.Apply( stage.GetPrimAtPath( "/model" ) )
modelAPI = pxr.UsdGeom.ModelAPI.Apply( stage.GetPrimAtPath( "/model" ) )
modelAPI.SetExtentsHint( [ ( 1, 2, 3 ), ( 4, 5, 6 ) ], 0 )
modelAPI.SetExtentsHint( [ ( 2, 3, 4 ), ( 5, 6, 7 ) ], 24 )

stage.GetRootLayer().Save()
del stage

root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
self.assertTrue( root.child( "model" ).hasBound() )
self.assertEqual( root.child( "model" ).readBound( 0 ), imath.Box3d( imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ) ) )
self.assertEqual( root.child( "model" ).readBound( 1 ), imath.Box3d( imath.V3d( 2, 3, 4 ), imath.V3d( 5, 6, 7 ) ) )

self.assertNotEqual(
root.child( "model" ).hash( root.HashType.BoundHash, 0 ),
root.child( "model" ).hash( root.HashType.BoundHash, 1 )
)

def testPerPurposeModelBound( self ) :

fileName = os.path.join( self.temporaryDirectory(), "testPerPurposeModelBound.usda" )
Expand Down

0 comments on commit 5957180

Please sign in to comment.