Skip to content

Commit f1e9aa6

Browse files
Merge pull request #1474 from johnhaddon/extentsWithoutModelAPI
USDScene : Use `extentsHint` to load bounds when `prim.IsModel()`
2 parents 0d816e8 + 86d7e66 commit f1e9aa6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
10.5.x.x (relative to 10.5.15.0)
22
========
33

4+
Fixes
5+
-----
46

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

69
10.5.15.0 (relative to 10.5.14.1)
710
=========

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ pxr::UsdAttribute boundAttribute( const pxr::UsdPrim &prim )
627627

628628
if( g_useModelAPIBounds )
629629
{
630-
if( auto modelAPI = pxr::UsdGeomModelAPI( prim ) )
630+
pxr::UsdGeomModelAPI modelAPI( prim );
631+
if( modelAPI || prim.IsModel() )
631632
{
632633
return modelAPI.GetExtentsHintAttr();
633634
}

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,11 +4413,18 @@ def testModelBound( self ) :
44134413
pxr.UsdGeom.Xform.Define( stage, "/withoutModelAPI" )
44144414
pxr.UsdGeom.Xform.Define( stage, "/withModelAPI" )
44154415
pxr.UsdGeom.Xform.Define( stage, "/withModelAPIAndExtent" )
4416+
pxr.UsdGeom.Xform.Define( stage, "/withKind" )
4417+
pxr.UsdGeom.Xform.Define( stage, "/withKindAndExtent" )
44164418

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

4423+
stage.GetPrimAtPath( "/withKind" ).SetKind( "group" )
4424+
stage.GetPrimAtPath( "/withKindAndExtent" ).SetKind( "group" )
4425+
modelAPI = pxr.UsdGeom.ModelAPI( stage.GetPrimAtPath( "/withKindAndExtent" ) )
4426+
modelAPI.SetExtentsHint( [ ( 1, 2, 3 ), ( 4, 5, 6 ) ] )
4427+
44214428
stage.GetRootLayer().Save()
44224429
del stage
44234430

@@ -4428,6 +4435,9 @@ def testModelBound( self ) :
44284435
self.assertFalse( root.child( "withModelAPI" ).hasBound() )
44294436
self.assertTrue( root.child( "withModelAPIAndExtent" ).hasBound() )
44304437
self.assertEqual( root.child( "withModelAPIAndExtent" ).readBound( 0 ), imath.Box3d( imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ) ) )
4438+
self.assertFalse( root.child( "withKind" ).hasBound() )
4439+
self.assertTrue( root.child( "withKindAndExtent" ).hasBound() )
4440+
self.assertEqual( root.child( "withKindAndExtent" ).readBound( 0 ), imath.Box3d( imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ) ) )
44314441

44324442
def testAnimatedModelBound( self ) :
44334443

0 commit comments

Comments
 (0)