Skip to content

Commit 2e0520d

Browse files
committed
SceneCacheData: Add support for root location tags added to the internal root.
In USD, we can't add collections to the absolute root `/` so we leverage the internal root (used to work around the limitation with referencing layer in USD that get read of the file's pseudo root) to store the tags/collections.
1 parent a90a7e7 commit 2e0520d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

contrib/IECoreUSD/src/IECoreUSD/SceneCacheData.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void SceneCacheData::addReference( ConstSceneInterfacePtr scene, SpecData& spec,
217217
addValueClip( spec, times, actives, linkFileName, linkRootPath.GetText() );
218218
}
219219

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

240+
// add collection
241+
FieldValuePair propertyChildren;
242+
propertyChildren.first = SdfChildrenKeys->PropertyChildren;
243+
TfTokenVector properties;
244+
245+
// we don't want to keep children tags in this case.
246+
m_collections.clear();
247+
248+
SceneInterface::NameList tags;
249+
scene->readTags( tags );
250+
for ( auto& tag : tags )
251+
{
252+
m_collections[tag].push_back( internalRootPath );
253+
}
254+
255+
addCollections( internalRootSpec, properties, internalRootPath );
256+
257+
propertyChildren.second = properties;
258+
internalRootSpec.fields.push_back( propertyChildren );
259+
240260
m_data[internalRootPath] = internalRootSpec;
241261
}
242262

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

347-
addInternalRoot( children );
367+
addInternalRoot( children, scene );
348368

349369
// add internal root as single child
350370
children.clear();

contrib/IECoreUSD/src/IECoreUSD/SceneCacheData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class SceneCacheData : public SdfAbstractData
179179
void addCollections( SpecData& spec, TfTokenVector& properties, const SdfPath& primPath );
180180
void addReference( IECoreScene::ConstSceneInterfacePtr scene, SpecData& spec, TfTokenVector& children );
181181
void addValueClip( SpecData& spec, const VtVec2dArray times, const VtVec2dArray actives, const std::string& assetPath, const std::string& primPath);
182-
void addInternalRoot( TfTokenVector children );
182+
void addInternalRoot( TfTokenVector children, IECoreScene::ConstSceneInterfacePtr scene );
183183

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

0 commit comments

Comments
 (0)