Skip to content

Commit 86d7e66

Browse files
committed
USDScene : Use extentsHint to load bounds when prim.IsModel()
Even if the UsdGeomModelAPI that provides that attribute has not been applied. This allows us to load the bounds from certain assets exported from certain DCCs. It also follows the behaviour of UsdGeomBBoxCache, where `_UseExtentsHintForPrim()` checks `prim.IsModel()` but doesn't check the for the application of the API.
1 parent 0d816e8 commit 86d7e66

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)