Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IECoreUSD : Add SceneAlgo::sceneFromStage #1123

Closed
wants to merge 2 commits into from

Conversation

andrewkaufman
Copy link
Member

This utility can be used to wrap a live in-memory pxr::UsdStage into an IECoreScene::SceneInterface (as though the stage was already written to a file).

I'm putting this up as a draft for now. It follows some discussion @johnhaddon and I had already, but I'm not convinced I like the utility method... As a client of SceneInterfaces, its confusing to not just call SceneInterface.create or SharedSceneInterfaces.get as normal...

I wonder if it'd be worth the extra effort of adding SceneInterface.create( const CompoundData *args ) (as we've discussed for other uses) and having USDScene check args for a stage, so we can replace the python access from

scene = IECoreUSD.SceneAlgo.sceneFromStage( stage )

to

scene = IECoreScene.SceneInterface.create( { "stage" : stage } )

Note also I've currently hard-coded to Read mode only when providing a stage. I'm not sure if that's a good idea, but it was easier to get the draft PR up today without testing write mode...

This utility can be used to wrap a live UsdStage into an IECoreScene::SceneInterface (as though the stage was already written to a file)
@andrewkaufman andrewkaufman added the usd Issues with the Cortex USD integration label Jan 27, 2021
@andrewkaufman andrewkaufman self-assigned this Jan 27, 2021
Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it's worth adding SceneInterface::create(), as we have other potential use cases for it. But you can't put a UsdStageRefPtr directly in a CompoundData, so we would need an alternative way of passing it. This snippet from the USD docs hints at one possible mechanism :

Caches provide a mechanism that associates a lightweight key, UsdStageCache::Id, with a cached stage. A UsdStageCache::Id can be converted to and from long int and string. This can be useful for communicating within a third party application that cannot transmit arbitrary C++ objects.

Worth investigating?

@andrewkaufman
Copy link
Member Author

I put up a WIP commit demoing the UsdStageCache idea. I'm not sure if its any better than the sceneFromStage function, the client still needs to know to do something special with the stage... I guess one advantage is it may be easier to shoe-horn a live stage into Gaffer by passing ids through a context.

But I also realized I have a pretty easy workaround for my immediate production need, generating a light-weight tmp usda file, so I'm going to close this PR for now.

We should take some time in the near future to spec out the SceneInterface::create( args ) mechanism (#1124).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usd Issues with the Cortex USD integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants