Skip to content

USDScene : Use extentsHint to load bounds when prim.IsModel() #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
10.5.x.x (relative to 10.5.15.0)
========

Fixes
-----

- USDScene : Fixed reading of bounds from prims with `extentsHint` and model `kind` but without UsdGeomModelAPI applied.

10.5.15.0 (relative to 10.5.14.1)
=========
Expand Down
3 changes: 2 additions & 1 deletion contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ pxr::UsdAttribute boundAttribute( const pxr::UsdPrim &prim )

if( g_useModelAPIBounds )
{
if( auto modelAPI = pxr::UsdGeomModelAPI( prim ) )
pxr::UsdGeomModelAPI modelAPI( prim );
if( modelAPI || prim.IsModel() )
{
return modelAPI.GetExtentsHintAttr();
}
Expand Down
10 changes: 10 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4413,11 +4413,18 @@ def testModelBound( self ) :
pxr.UsdGeom.Xform.Define( stage, "/withoutModelAPI" )
pxr.UsdGeom.Xform.Define( stage, "/withModelAPI" )
pxr.UsdGeom.Xform.Define( stage, "/withModelAPIAndExtent" )
pxr.UsdGeom.Xform.Define( stage, "/withKind" )
pxr.UsdGeom.Xform.Define( stage, "/withKindAndExtent" )

pxr.UsdGeom.ModelAPI.Apply( stage.GetPrimAtPath( "/withModelAPI" ) )
modelAPI = pxr.UsdGeom.ModelAPI.Apply( stage.GetPrimAtPath( "/withModelAPIAndExtent" ) )
modelAPI.SetExtentsHint( [ ( 1, 2, 3 ), ( 4, 5, 6 ) ] )

stage.GetPrimAtPath( "/withKind" ).SetKind( "group" )
stage.GetPrimAtPath( "/withKindAndExtent" ).SetKind( "group" )
modelAPI = pxr.UsdGeom.ModelAPI( stage.GetPrimAtPath( "/withKindAndExtent" ) )
modelAPI.SetExtentsHint( [ ( 1, 2, 3 ), ( 4, 5, 6 ) ] )

stage.GetRootLayer().Save()
del stage

Expand All @@ -4428,6 +4435,9 @@ def testModelBound( self ) :
self.assertFalse( root.child( "withModelAPI" ).hasBound() )
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 ) ) )
self.assertFalse( root.child( "withKind" ).hasBound() )
self.assertTrue( root.child( "withKindAndExtent" ).hasBound() )
self.assertEqual( root.child( "withKindAndExtent" ).readBound( 0 ), imath.Box3d( imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ) ) )

def testAnimatedModelBound( self ) :

Expand Down