Skip to content

Commit c40ce53

Browse files
USD CameraAlgo : Only write authored shutter values to USD
This avoids baking in our default [-0.5, 0.5] shutter when writing a camera with no shutter to USD.
1 parent 9cb99c2 commit c40ce53

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

Changes

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

4+
Fixes
5+
-----
46

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.
58

69
10.5.x.x (relative to 10.5.15.0)
710
========

contrib/IECoreUSD/src/IECoreUSD/CameraAlgo.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,17 @@ bool writeCamera( const IECoreScene::Camera *camera, const pxr::UsdStagePtr &sta
188188
usdCamera.GetFStopAttr().Set( camera->getFStop() );
189189
usdCamera.GetFocusDistanceAttr().Set( camera->getFocusDistance() );
190190

191-
/// \todo This is documented as being specified in UsdTimeCode units,
192-
/// in which case I think we should be converting from seconds using
193-
/// `stage->GetTimeCodesPerSecond()`. Having looked at both the Maya
194-
/// and Houdini plugin sources, I've been unable to find evidence for
195-
/// anyone else doing this though, so maybe it's one of those things
196-
/// everyone is just getting wrong?
197-
usdCamera.GetShutterOpenAttr().Set( (double)camera->getShutter()[0] );
198-
usdCamera.GetShutterCloseAttr().Set( (double)camera->getShutter()[1] );
191+
if( camera->hasShutter() )
192+
{
193+
/// \todo This is documented as being specified in UsdTimeCode units,
194+
/// in which case I think we should be converting from seconds using
195+
/// `stage->GetTimeCodesPerSecond()`. Having looked at both the Maya
196+
/// and Houdini plugin sources, I've been unable to find evidence for
197+
/// anyone else doing this though, so maybe it's one of those things
198+
/// everyone is just getting wrong?
199+
usdCamera.GetShutterOpenAttr().Set( (double)camera->getShutter()[0] );
200+
usdCamera.GetShutterCloseAttr().Set( (double)camera->getShutter()[1] );
201+
}
199202

200203
return true;
201204
}

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,13 @@ def formatCameraName( **kw ) :
12851285
name = formatCameraName( scale = scale )
12861286
testCameras[name] = c
12871287

1288+
for shutterOpen in [ 0, -0.25, -1.0 ] :
1289+
for shutterClose in [ 0, 0.25, 1.0 ] :
1290+
c = IECoreScene.Camera()
1291+
c.setShutter( imath.V2f( shutterOpen, shutterClose ) )
1292+
name = formatCameraName( shutterOpen = shutterOpen, shutterClose = shutterClose )
1293+
testCameras[name] = c
1294+
12881295
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
12891296

12901297
for name, c in testCameras.items() :
@@ -1321,8 +1328,12 @@ def formatCameraName( **kw ) :
13211328
self.assertEqual( c.clippingRange.max, cortexCam.getClippingPlanes()[1] )
13221329
self.assertEqual( c.fStop, cortexCam.getFStop() )
13231330
self.assertEqual( c.focusDistance, cortexCam.getFocusDistance() )
1324-
self.assertEqual( cG.GetShutterOpenAttr().Get(), cortexCam.getShutter()[0] )
1325-
self.assertEqual( cG.GetShutterCloseAttr().Get(), cortexCam.getShutter()[1] )
1331+
if cortexCam.hasShutter() :
1332+
self.assertEqual( cG.GetShutterOpenAttr().Get(), cortexCam.getShutter()[0] )
1333+
self.assertEqual( cG.GetShutterCloseAttr().Get(), cortexCam.getShutter()[1] )
1334+
else :
1335+
self.assertFalse( cG.GetShutterOpenAttr().HasAuthoredValue() )
1336+
self.assertFalse( cG.GetShutterCloseAttr().HasAuthoredValue() )
13261337

13271338
try :
13281339
from pxr import CameraUtil

0 commit comments

Comments
 (0)