Skip to content

Commit 494496c

Browse files
USD CameraAlgo : Only read authored shutter values from USD
This avoids cameras read from USD files ending up with USD's default [0, 0] shutter when the USD camera has no shutter values.
1 parent c40ce53 commit 494496c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Changes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
Fixes
55
-----
66

7-
- USDScene : Fixed writing of shutter values from cameras without a `shutter` parameter. The `shutter:open` and `shutter:close` attributes are now omitted instead of being written with Cortex's default -0.5, 0.5 shutter values.
7+
- USDScene :
8+
- Fixed writing of shutter values from cameras without a `shutter` parameter. The `shutter:open` and `shutter:close` attributes are now omitted instead of being written with Cortex's default -0.5, 0.5 shutter values.
9+
- Fixed reading of shutter values from cameras without `shutter:open` and `shutter:close` attributes. The `shutter` parameter is now omitted instead of being created with USD's default 0, 0 shutter values.
810

911
10.5.x.x (relative to 10.5.15.0)
1012
========

contrib/IECoreUSD/src/IECoreUSD/CameraAlgo.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ IECore::ObjectPtr readCamera( pxr::UsdGeomCamera &camera, pxr::UsdTimeCode time,
111111
result->setFocusDistance( focusDistance );
112112

113113
Imath::V2d shutter;
114-
camera.GetShutterOpenAttr().Get( &shutter[0], time );
115-
camera.GetShutterCloseAttr().Get( &shutter[1], time );
116-
result->setShutter( shutter );
114+
auto shutterOpenAttr = camera.GetShutterOpenAttr();
115+
auto shutterCloseAttr = camera.GetShutterCloseAttr();
116+
if( shutterOpenAttr.HasAuthoredValue() || shutterCloseAttr.HasAuthoredValue() )
117+
{
118+
shutterOpenAttr.Get( &shutter[0], time );
119+
shutterCloseAttr.Get( &shutter[1], time );
120+
result->setShutter( shutter );
121+
}
117122

118123
return result;
119124
}

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ def assertVectorsAlmostEqual( a, b,**kw ) :
14001400
self.assertEqual( c2.getClippingPlanes(), c.getClippingPlanes() )
14011401
self.assertEqual( c2.getFStop(), c.getFStop() )
14021402
self.assertEqual( c2.getFocusDistance(), c.getFocusDistance() )
1403+
self.assertEqual( c2.hasShutter(), c.hasShutter() )
14031404
self.assertEqual( c2.getShutter(), c.getShutter() )
14041405

14051406
assertVectorsAlmostEqual( c2.frustum().min(), c.frustum().min(), places = 6 )

0 commit comments

Comments
 (0)