virtual void *operator()( void *item ) { SceneGraph *s = (SceneGraph*)item; ScenePlug::ScenePath path; s->path( path ); try { ContextPtr context = new Context( *m_context, Context::Borrowed ); context->set( ScenePlug::scenePathContextName, path ); Context::Scope scopedContext( context.get() ); if( m_update ) { // we're re-traversing this location, so lets only recompute attributes where // their hashes change: IECore::MurmurHash attributesHash = m_scene->attributesPlug()->hash(); if( attributesHash != s->m_attributesHash ) { s->m_attributes = m_scene->attributesPlug()->getValue( &attributesHash ); s->m_attributesHash = attributesHash; } } else { // First traversal: attributes and attribute hash should have been computed // by the SceneGraphBuildTasks, so we only need to compute the object/transform: s->m_object = m_scene->objectPlug()->getValue(); s->m_transform = m_scene->transformPlug()->getValue(); } } catch( const std::exception &e ) { std::string name; ScenePlug::pathToString( path, name ); IECore::msg( IECore::Msg::Error, "InteractiveRender::update", name + ": " + e.what() ); } return s; }
virtual void *operator()( void *item ) { SceneGraph *s = (SceneGraph*)item; ScenePlug::ScenePath path; s->path( path ); std::string name; ScenePlug::pathToString( path, name ); try { if( !m_editMode ) { // outputting scene for the first time - do some attribute block tracking: if( path.size() ) { for( int i = m_previousPath.size(); i >= (int)path.size(); --i ) { --m_attrBlockCounter; m_renderer->attributeEnd(); } } m_previousPath = path; ++m_attrBlockCounter; m_renderer->attributeBegin(); // set the name for this location: m_renderer->setAttribute( "name", new StringData( name ) ); } // transform: if( !m_editMode ) { m_renderer->concatTransform( s->m_transform ); } // attributes: if( s->m_attributes ) { if( m_editMode ) { CompoundDataMap parameters; parameters["exactscopename"] = new StringData( name ); m_renderer->editBegin( "attribute", parameters ); } outputAttributes( s->m_attributes.get(), m_renderer ); s->m_attributes = NULL; if( m_editMode ) { m_renderer->editEnd(); } } // object: if( s->m_object && !m_editMode ) { if( const VisibleRenderable *renderable = runTimeCast< const VisibleRenderable >( s->m_object.get() ) ) { renderable->render( m_renderer ); } s->m_object = 0; } } catch( const std::exception &e ) { IECore::msg( IECore::Msg::Error, "InteractiveRender::update", name + ": " + e.what() ); } return NULL; }