-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-104213 - add a new USD stage to an empty scene #478
MAYA-104213 - add a new USD stage to an empty scene #478
Conversation
…scene * New USD notice type for stage invalidate. Send this notice when certain attributes (like filepath) are changed. From the StagesSubject receiver of this notice we also send the new Ufe::ObjectInvalidate() notification. * When proxy shape compute is called if no filepath was attached, we create an in memory stage. * Added dirty state to UsdStageMap. When dirty it will rebuild when a new request for stage info is made. * Cleanup: renamed "UsdMayaProxyStageSetNotice" -> "MayaUsdProxyStageSetNotice". * Added new menu item "Stage with New Layer".
@@ -27,11 +27,11 @@ PXR_NAMESPACE_OPEN_SCOPE | |||
class MayaUsdProxyShapeBase; | |||
|
|||
/// Notice sent when the ProxyShape loads a new stage | |||
class UsdMayaProxyStageSetNotice : public TfNotice | |||
class MayaUsdProxyStageBaseNotice : public TfNotice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this one "UsdMaya" -> "MayaUsd" and made it a base notice class. Below created this existing one (deriving from this base) and new one for stage invalidate.
else if (!usdStage) { | ||
// Create a new stage in memory with an anonymous root layer. | ||
UsdStageCacheContext ctx(UsdMayaStageCache::Get()); | ||
usdStage = UsdStage::CreateInMemory("", loadSet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty string is for the identifier, which is used when naming the root layer. Here we just want it named as the default "anon", rather than "tmp.usda"
@@ -797,6 +802,7 @@ MayaUsdProxyShapeBase::setDependentsDirty(const MPlug& plug, MPlugArray& plugArr | |||
plug == loadPayloadsAttr || | |||
plug == inStageDataAttr) { | |||
_IncreaseUsdStageVersion(); | |||
MayaUsdProxyStageInvalidateNotice(*this).Send(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send the new stage invalidate notice whenever one of the plugs that affects outStageDataAttr changes.
StagesSubject::Ptr me(this); | ||
for (auto stage : ProxyShapeHandler::getAllStages()) | ||
{ | ||
fStageListeners[stage] = TfNotice::Register( | ||
me, &StagesSubject::stageChanged, stage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not get the stages here as that will pull, but the new stage may not be ready yet.
g_StageMap.clear(); | ||
auto proxyShapeNames = ProxyShapeHandler::getAllNames(); | ||
for (const auto& psn : proxyShapeNames) | ||
{ | ||
MDagPath dag = nameToDagPath(psn); | ||
Ufe::Path ufePath = dagPathToUfe(dag); | ||
auto stage = ProxyShapeHandler::dagPathToStage(psn); | ||
g_StageMap.addItem(ufePath, stage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this code was moved into the stage map. We just set it dirty now. It will be rebuilt when queried.
#if UFE_PREVIEW_VERSION_NUM >= 2014 | ||
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(notice.GetProxyShape().ufePath()); | ||
auto notification = Ufe::SubtreeInvalidate(sceneItem); | ||
Ufe::Scene::notifySubtreeInvalidate(notification); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send a new UFE subtree invalidate notice when the stage is invalidated. Clients like the Outliner can use this to re-build.
UsdStageWeakPtr UsdStageMap::stage(const Ufe::Path& path) | ||
{ | ||
rebuildIfDirty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the query methods on the stage map, will now rebuild first if the map is flagged as dirty.
auto proxyShapeNames = ProxyShapeHandler::getAllNames(); | ||
for (const auto& psn : proxyShapeNames) | ||
{ | ||
MDagPath dag = nameToDagPath(psn); | ||
Ufe::Path ufePath = dagPathToUfe(dag); | ||
auto stage = ProxyShapeHandler::dagPathToStage(psn); | ||
addItem(ufePath, stage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was moved from the StagesSubject.
@@ -103,6 +112,7 @@ global proc mayaUsdMenu_createMenuCallback() { | |||
-label "Universal Scene Description (USD)" | |||
-annotation "Create a USD stage" | |||
-version $mayaVersion`; | |||
menuItem -runTimeCommand mayaUsdCreateStageWithNewLayer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New menu item to create a new empty USD stage.
# Simply create a proxy shape. Since it does not have a USD file associated | ||
# (in the .filePath attribute), the proxy shape base will create an empty | ||
# stage in memory. This will create the session and root layer as well. | ||
shapeNode = cmds.createNode('mayaUsdProxyShape', name='stageShape') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the changes in the proxyshapebase (to create stage in memory when no file attr) we simply need to create a proxy shape node here. That will create the stage, which will create the root layer and session layer.
@pilarmolinalopez Would you be available to review these changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following tests FAILED:
12 - testObject3d (Failed)
15 - testTransform3dTranslate (Failed)
99 - TestPxrUsdTranslators (Failed)
…scene * Fix broken unitttests: 12 - testObject3d (Failed) 15 - testTransform3dTranslate (Failed) 99 - TestPxrUsdTranslators (Failed)
@@ -398,6 +398,18 @@ MStatus ProxyShape::setDependentsDirty(const MPlug& plugBeingDirtied, MPlugArray | |||
{ | |||
MHWRender::MRenderer::setGeometryDrawDirty(thisMObject(), true); | |||
} | |||
|
|||
if (plugBeingDirtied == outStageData() || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProxyShapeBase is a base class...shouldn't we just forward it to the base class instead of making a copy?
Changes: 1.fix light transform and material binding issues due to usd 23.08 2.make mayaHydraSceneIndex derive from HdRetainedScneIndex in usd 23.08
MAYA-104213 - As a user, I'd like to add a new USD stage to an empty scene