From f07a783db13c24718ca61abb0805bb157c8025de Mon Sep 17 00:00:00 2001 From: Andrew Kaufman Date: Wed, 21 May 2014 15:57:59 -0700 Subject: [PATCH 1/3] Using new changingHierarchy attribute to mark children that appear/disappear over time. The previous behaviour used scene:visible exclusively for this test, which ran into issues when trying to pass that attribute through from the liveScene. --- include/IECoreHoudini/ROP_SceneCacheWriter.h | 1 + src/IECoreHoudini/ROP_SceneCacheWriter.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/IECoreHoudini/ROP_SceneCacheWriter.h b/include/IECoreHoudini/ROP_SceneCacheWriter.h index 22b99f6598..5a92a452e0 100644 --- a/include/IECoreHoudini/ROP_SceneCacheWriter.h +++ b/include/IECoreHoudini/ROP_SceneCacheWriter.h @@ -80,6 +80,7 @@ class ROP_SceneCacheWriter : public ROP_Node private : static const IECore::SceneInterface::Name &visibleAttribute; + static const IECore::SceneInterface::Name &changingHierarchyAttribute; bool linked( const std::string &file ) const; diff --git a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp b/src/IECoreHoudini/ROP_SceneCacheWriter.cpp index 1cca584bc1..a4d23c3885 100644 --- a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp +++ b/src/IECoreHoudini/ROP_SceneCacheWriter.cpp @@ -80,6 +80,7 @@ PRM_Default ROP_SceneCacheWriter::rootObjectDefault( 0, "/obj" ); PRM_SpareData ROP_SceneCacheWriter::forceObjectsSpareData; const SceneInterface::Name &ROP_SceneCacheWriter::visibleAttribute( "scene:visible" ); +const SceneInterface::Name &ROP_SceneCacheWriter::changingHierarchyAttribute( "sceneInterface:changingHierarchy" ); OP_TemplatePair *ROP_SceneCacheWriter::buildParameters() { @@ -387,11 +388,12 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, if ( time != m_startTime ) { + outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); outChild->writeAttribute( visibleAttribute, new BoolData( false ), time - 1e-6 ); } } - if ( outChild->hasAttribute( visibleAttribute ) ) + if ( outChild->hasAttribute( changingHierarchyAttribute ) ) { outChild->writeAttribute( visibleAttribute, new BoolData( true ), time ); } @@ -416,6 +418,7 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, outChild->writeAttribute( visibleAttribute, new BoolData( true ), time - 1e-6 ); } + outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); outChild->writeAttribute( visibleAttribute, new BoolData( false ), time ); } } From 1fd38c74a551a2fbd6c80c4e072b8c1229eade0f Mon Sep 17 00:00:00 2001 From: Andrew Kaufman Date: Wed, 21 May 2014 15:57:22 -0700 Subject: [PATCH 2/3] Making SceneInterface::visibilityName a reference --- include/IECore/SceneInterface.h | 4 ++-- src/IECore/SceneInterface.cpp | 4 ++-- src/IECorePython/SceneInterfaceBinding.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/IECore/SceneInterface.h b/include/IECore/SceneInterface.h index d9a4e970bc..724c61626a 100644 --- a/include/IECore/SceneInterface.h +++ b/include/IECore/SceneInterface.h @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -93,7 +93,7 @@ class SceneInterface : public RunTimeTyped /// Utility variable that can be used anytime you want to refer to the root path in the Scene. static const Path &rootPath; /// Name of the visibility attribute - static const Name visibilityName; + static const Name &visibilityName; /// Create an instance of a subclass which is able to open the file found at "path". /// Files can be opened for Read, Write, or Append depending on the derived classes. diff --git a/src/IECore/SceneInterface.cpp b/src/IECore/SceneInterface.cpp index 56312a45c3..b6692da76c 100644 --- a/src/IECore/SceneInterface.cpp +++ b/src/IECore/SceneInterface.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -42,7 +42,7 @@ IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( SceneInterface ) const SceneInterface::Name &SceneInterface::rootName = IndexedIO::rootName; const SceneInterface::Path &SceneInterface::rootPath = IndexedIO::rootPath; -const SceneInterface::Name SceneInterface::visibilityName( "scene:visible" ); +const SceneInterface::Name &SceneInterface::visibilityName( "scene:visible" ); class SceneInterface::CreatorMap : public std::map< std::pair< std::string, IndexedIO::OpenModeFlags >, CreatorFn> { diff --git a/src/IECorePython/SceneInterfaceBinding.cpp b/src/IECorePython/SceneInterfaceBinding.cpp index 18731d79c5..b0eb663cf2 100644 --- a/src/IECorePython/SceneInterfaceBinding.cpp +++ b/src/IECorePython/SceneInterfaceBinding.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -268,7 +268,7 @@ void bindSceneInterface() .def( "create", SceneInterface::create ).staticmethod( "create" ) .def( "supportedExtensions", supportedExtensions, ( arg("modes") = IndexedIO::Read|IndexedIO::Write|IndexedIO::Append ) ).staticmethod( "supportedExtensions" ) - .add_static_property( "visibilityName", make_getter(&SceneInterface::visibilityName, return_value_policy() ) ) + .def_readonly("visibilityName", &SceneInterface::visibilityName ) ; } From 53d6e6ba4ddb70ec238f2a6205ed05741728da64 Mon Sep 17 00:00:00 2001 From: Andrew Kaufman Date: Wed, 21 May 2014 16:10:38 -0700 Subject: [PATCH 3/3] Using SceneInterface::visibilityName now that it exists --- include/IECoreHoudini/ROP_SceneCacheWriter.h | 1 - src/IECoreHoudini/ROP_SceneCacheWriter.cpp | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/IECoreHoudini/ROP_SceneCacheWriter.h b/include/IECoreHoudini/ROP_SceneCacheWriter.h index 5a92a452e0..b78f7b525c 100644 --- a/include/IECoreHoudini/ROP_SceneCacheWriter.h +++ b/include/IECoreHoudini/ROP_SceneCacheWriter.h @@ -79,7 +79,6 @@ class ROP_SceneCacheWriter : public ROP_Node private : - static const IECore::SceneInterface::Name &visibleAttribute; static const IECore::SceneInterface::Name &changingHierarchyAttribute; bool linked( const std::string &file ) const; diff --git a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp b/src/IECoreHoudini/ROP_SceneCacheWriter.cpp index a4d23c3885..f33828a502 100644 --- a/src/IECoreHoudini/ROP_SceneCacheWriter.cpp +++ b/src/IECoreHoudini/ROP_SceneCacheWriter.cpp @@ -79,7 +79,6 @@ PRM_Default ROP_SceneCacheWriter::fileDefault( 0, "$HIP/output.scc" ); PRM_Default ROP_SceneCacheWriter::rootObjectDefault( 0, "/obj" ); PRM_SpareData ROP_SceneCacheWriter::forceObjectsSpareData; -const SceneInterface::Name &ROP_SceneCacheWriter::visibleAttribute( "scene:visible" ); const SceneInterface::Name &ROP_SceneCacheWriter::changingHierarchyAttribute( "sceneInterface:changingHierarchy" ); OP_TemplatePair *ROP_SceneCacheWriter::buildParameters() @@ -389,13 +388,13 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, if ( time != m_startTime ) { outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); - outChild->writeAttribute( visibleAttribute, new BoolData( false ), time - 1e-6 ); + outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( false ), time - 1e-6 ); } } if ( outChild->hasAttribute( changingHierarchyAttribute ) ) { - outChild->writeAttribute( visibleAttribute, new BoolData( true ), time ); + outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( true ), time ); } ROP_RENDER_CODE status = doWrite( liveChild, outChild, time, progress ); @@ -405,7 +404,7 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, } } - // turn visibleAttribute off if the child disappears + // turn visibility off if the child disappears SceneInterface::NameList outChildren; outScene->childNames( outChildren ); for ( SceneInterface::NameList::iterator it = outChildren.begin(); it != outChildren.end(); ++it ) @@ -413,13 +412,13 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene, if ( !liveScene->hasChild( *it ) ) { SceneInterfacePtr outChild = outScene->child( *it ); - if ( !outChild->hasAttribute( visibleAttribute ) ) + if ( !outChild->hasAttribute( IECore::SceneInterface::visibilityName ) ) { - outChild->writeAttribute( visibleAttribute, new BoolData( true ), time - 1e-6 ); + outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( true ), time - 1e-6 ); } outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time ); - outChild->writeAttribute( visibleAttribute, new BoolData( false ), time ); + outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( false ), time ); } }