@@ -1793,7 +1793,8 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
17931793 m_session( nullptr ),
17941794 m_scene( nullptr ),
17951795 m_renderCallback( nullptr ),
1796- m_rendering( false )
1796+ m_rendering( false ),
1797+ m_deviceDirty( false )
17971798 {
17981799 // Set path to find shaders
17991800 ccl::path_init ( getenv (" GAFFERCYCLES" ) );
@@ -1967,20 +1968,21 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
19671968 }
19681969 else if ( name == g_deviceOptionName )
19691970 {
1970- if ( const StringData *data = reportedCast< const StringData>( value, " option " , name ) )
1971+ if ( value == nullptr )
19711972 {
1972- auto device_name = data->readable ();
1973- m_deviceName = device_name;
1973+ m_deviceName = " CPU" ;
19741974 }
1975- else if ( value == nullptr )
1975+ else if ( const StringData *data = reportedCast< const StringData>( value, " option " , name ) )
19761976 {
1977- m_deviceName = " CPU" ;
1977+ auto device_name = data->readable ();
1978+ m_deviceName = device_name;
19781979 }
19791980 else
19801981 {
19811982 m_deviceName = " CPU" ;
19821983 IECore::msg ( IECore::Msg::Warning, " CyclesRenderer::option" , boost::format ( " Unknown value \" %s\" for option \" %s\" ." ) % m_deviceName % name.string () );
19831984 }
1985+ m_deviceDirty = true ;
19841986 return ;
19851987 }
19861988 else if ( name == g_shadingsystemOptionName )
@@ -2396,6 +2398,10 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
23962398
23972399 ObjectInterfacePtr object ( const std::string &name, const IECore::Object *object, const AttributesInterface *attributes ) override
23982400 {
2401+ if ( object->typeId () == IECoreScene::Camera::staticTypeId () )
2402+ {
2403+ return nullptr ;
2404+ }
23992405 Instance instance = m_instanceCache->get ( object, name );
24002406
24012407 ObjectInterfacePtr result = new CyclesObject ( instance );
@@ -2405,6 +2411,10 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
24052411
24062412 ObjectInterfacePtr object ( const std::string &name, const std::vector<const IECore::Object *> &samples, const std::vector<float > ×, const AttributesInterface *attributes ) override
24072413 {
2414+ if ( samples.front ()->typeId () == IECoreScene::Camera::staticTypeId () )
2415+ {
2416+ return nullptr ;
2417+ }
24082418 Instance instance = m_instanceCache->get ( samples, times, name );
24092419
24102420 ObjectInterfacePtr result = new CyclesObject ( instance );
@@ -2571,8 +2581,10 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
25712581 m_sessionParams.denoising = m_denoiseParams;
25722582 // If anything changes in scene or session, we reset.
25732583 if ( m_scene->params .modified ( m_sceneParams ) ||
2574- m_session->params .modified ( m_sessionParams ) )
2584+ m_session->params .modified ( m_sessionParams ) ||
2585+ m_deviceDirty )
25752586 {
2587+ m_deviceDirty = false ;
25762588 reset ();
25772589 }
25782590
@@ -2785,6 +2797,7 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
27852797 int m_frame;
27862798 string m_camera;
27872799 bool m_rendering;
2800+ bool m_deviceDirty;
27882801
27892802 // Caches.
27902803 CameraCachePtr m_cameraCache;
0 commit comments