Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
10.5.x.x (relative to 10.5.15.3)
10.5.x.x (relative to 10.5.15.4)
========

10.5.15.4 (relative to 10.5.15.3)
========

Improvements
-----

- IECoreUSD: Added support for root level tags (reading/writing) to our IECoreUSD::SceneCacheData plugin.

Fixes
-----

- IECoreUSD: Fixed crash when using invalid file path with IECoreUSD::SceneCacheFileFormat.

10.5.15.3 (relative to 10.5.15.2)
=========
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SConsignFile()
ieCoreMilestoneVersion = 10 # for announcing major milestones - may contain all of the below
ieCoreMajorVersion = 5 # backwards-incompatible changes
ieCoreMinorVersion = 15 # new backwards-compatible features
ieCorePatchVersion = 3 # bug fixes
ieCorePatchVersion = 4 # bug fixes
ieCoreVersionSuffix = "" # used for alpha/beta releases. Example: "a1", "b2", etc.

###########################################################################################
Expand Down
24 changes: 22 additions & 2 deletions contrib/IECoreUSD/src/IECoreUSD/SceneCacheData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void SceneCacheData::addReference( ConstSceneInterfacePtr scene, SpecData& spec,
addValueClip( spec, times, actives, linkFileName, linkRootPath.GetText() );
}

void SceneCacheData::addInternalRoot( TfTokenVector children )
void SceneCacheData::addInternalRoot( TfTokenVector children, IECoreScene::ConstSceneInterfacePtr scene )
{
// add transform for internal root.
SdfPath internalRootPath = SdfPath::AbsoluteRootPath().AppendChild( SceneCacheDataAlgo::internalRootNameToken() );
Expand All @@ -237,6 +237,26 @@ void SceneCacheData::addInternalRoot( TfTokenVector children )
// steal root children
internalRootSpec.fields.push_back( FieldValuePair( SdfChildrenKeys->PrimChildren, children ) );

// add collection
FieldValuePair propertyChildren;
propertyChildren.first = SdfChildrenKeys->PropertyChildren;
TfTokenVector properties;

// we don't want to keep children tags in this case.
m_collections.clear();

SceneInterface::NameList tags;
scene->readTags( tags );
for ( auto& tag : tags )
{
m_collections[tag].push_back( internalRootPath );
}

addCollections( internalRootSpec, properties, internalRootPath );

propertyChildren.second = properties;
internalRootSpec.fields.push_back( propertyChildren );

m_data[internalRootPath] = internalRootSpec;
}

Expand Down Expand Up @@ -344,7 +364,7 @@ void SceneCacheData::loadSceneIntoCache( ConstSceneInterfacePtr scene )
// end timecode
spec.fields.push_back( FieldValuePair( SdfFieldKeys->EndTimeCode, lastFrame ) );

addInternalRoot( children );
addInternalRoot( children, scene );

// add internal root as single child
children.clear();
Expand Down
2 changes: 1 addition & 1 deletion contrib/IECoreUSD/src/IECoreUSD/SceneCacheData.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class SceneCacheData : public SdfAbstractData
void addCollections( SpecData& spec, TfTokenVector& properties, const SdfPath& primPath );
void addReference( IECoreScene::ConstSceneInterfacePtr scene, SpecData& spec, TfTokenVector& children );
void addValueClip( SpecData& spec, const VtVec2dArray times, const VtVec2dArray actives, const std::string& assetPath, const std::string& primPath);
void addInternalRoot( TfTokenVector children );
void addInternalRoot( TfTokenVector children, IECoreScene::ConstSceneInterfacePtr scene );

VtValue getTimeSampleMap( const SdfPath& path, const TfToken& field, const VtValue& value ) const;

Expand Down
17 changes: 17 additions & 0 deletions contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ bool UsdSceneCacheFileFormat::WriteToFile( const SdfLayer& layer, const std::str
SceneInterfacePtr outScene;

outScene = SdfFileFormatSharedSceneWriters::get( filePath );
if ( !outScene )
{
IECore::msg( IECore::Msg::Error, "UsdSceneCacheFileFormat::WriteToFile", boost::format( "Invalid file path \"%s\" for layer \"%s\"." ) % filePath % layer.GetIdentifier() );
return false;
}

SceneInterface::NameList childNames;
usdScene->childNames( childNames );
Expand Down Expand Up @@ -370,6 +375,18 @@ void UsdSceneCacheFileFormat::writeLocation(
}
}
}
// internal root is mapped to the SceneInterface root '/'
else
{
SceneInterface::NameList tags;
inChild->readTags( tags );
// round trip internal tag name
for ( auto& tag : tags )
{
tag = SceneCacheDataAlgo::fromInternalName( tag );
}
outChild->writeTags( tags );
}

// recursion
SceneInterface::NameList grandChildNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "SdfFileFormatSharedSceneWriters.h"

#include "IECore/LRUCache.h"
#include "IECore/MessageHandler.h"

using namespace IECore;
using namespace IECoreScene;
Expand All @@ -61,7 +62,15 @@ class Cache : public SceneLRUCache

static SceneInterfacePtr fileCacheGetter( const std::string &fileName, size_t &cost )
{
SceneInterfacePtr result = SceneInterface::create( fileName, IECore::IndexedIO::Write );
SceneInterfacePtr result = nullptr;
try
{
result = SceneInterface::create( fileName, IECore::IndexedIO::Write );
}
catch ( ... )
{
IECore::msg( IECore::Msg::Error, "SdfFileFormatSharedSceneWriters::SceneLRUCache", boost::format( "Unable to open file path \"%s\" for writing IndexedIo data." ) % fileName );
}
cost = 1;
return result;
}
Expand Down
26 changes: 26 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/SceneCacheFileFormatTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def testTagsLoadedAsCollections( self ):
# includes
fileName = os.path.join( self.temporaryDirectory(), "testUSDTags.scc" )
m = IECoreScene.SceneCache( fileName, IECore.IndexedIO.OpenMode.Write )
m.writeTags( ["geoId:chessy"] )
t = m.createChild( "t" )
s = t.createChild( "s" )
t.writeTags( ["t1", "all", "asset-(12)"] )
Expand All @@ -330,6 +331,16 @@ def testTagsLoadedAsCollections( self ):
stage = pxr.Usd.Stage.Open( fileName )
root = stage.GetPseudoRoot()

tagInternalRootPrim = root.GetPrimAtPath( f"/{IECoreUSD.SceneCacheDataAlgo.internalRootName()}" )
self.assertEqual(
tagInternalRootPrim.GetRelationship(
"collection:{}:includes".format(
IECoreUSD.SceneCacheDataAlgo.toInternalName( "geoId:chessy" )
)
).GetTargets(),
[ pxr.Sdf.Path( f"/{IECoreUSD.SceneCacheDataAlgo.internalRootName()}" ) ]
)

tagPrim = root.GetPrimAtPath( "/{}/t".format( IECoreUSD.SceneCacheDataAlgo.internalRootName() ) )
self.assertTrue( tagPrim )

Expand All @@ -346,6 +357,10 @@ def testTagsLoadedAsCollections( self ):
stage.Export( exportPath )

scene = IECoreScene.SharedSceneInterfaces.get( exportPath )
# check root tags
self.assertTrue( "geoId:chessy" in scene.readTags() )

# check children tags
for tag, paths in tags.items():
for path in paths:
child = scene.scene( IECoreScene.SceneInterface.stringToPath( path ) )
Expand Down Expand Up @@ -939,6 +954,17 @@ def testSceneWrite( self ):
stage.Export( exportPath )
self.assertTrue( os.path.exists( exportPath ) )

# invalid path
invalidExportPath = os.path.join( self.temporaryDirectory(), "invalid", "invalid.scc" )
with IECore.CapturingMessageHandler() as mh :
stage.Export( invalidExportPath )

self.assertEqual( len( mh.messages ), 2 )
self.assertEqual( mh.messages[0].level, IECore.Msg.Level.Error )
self.assertEqual( mh.messages[0].context, "SdfFileFormatSharedSceneWriters::SceneLRUCache" )
self.assertEqual( mh.messages[1].level, IECore.Msg.Level.Error )
self.assertEqual( mh.messages[1].context, "UsdSceneCacheFileFormat::WriteToFile" )

# root
layer = pxr.Sdf.Layer.FindOrOpen( linkFileName )

Expand Down