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

MAYA-124702: retrieve ufe runtime id by data source integer reference #2933

27 changes: 23 additions & 4 deletions lib/mayaUsd/sceneIndex/proxyShapeSceneIndexPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#if PXR_VERSION >= 2211

#if WANT_UFE_BUILD
#include <mayaUsd/ufe/Global.h>
#endif

#include <pxr/imaging/hd/flatteningSceneIndex.h>
#include <pxr/imaging/hd/retainedDataSource.h>
#include <pxr/imaging/hd/sceneIndexPlugin.h>
Expand All @@ -29,6 +33,9 @@
#include <maya/MObjectHandle.h>
#include <maya/MSelectionList.h>
#include <maya/MString.h>
#if WANT_UFE_BUILD
#include <ufe/rtid.h>
#endif

PXR_NAMESPACE_OPEN_SCOPE

Expand All @@ -47,12 +54,24 @@ HdSceneIndexBaseRefPtr MayaUsdProxyShapeMayaNodeSceneIndexPlugin::_AppendSceneIn
const HdContainerDataSourceHandle& inputArgs)
{
using HdMObjectDataSource = HdRetainedTypedSampledDataSource<MObject>;
using HdMObjectDataSourceHandle = HdRetainedTypedSampledDataSource<MObject>::Handle;
static TfToken dataSourceNodePathEntry("object");
HdDataSourceBaseHandle dataSourceEntryPathHandle = inputArgs->Get(dataSourceNodePathEntry);
if (HdMObjectDataSourceHandle dataSourceEntryPath
= HdMObjectDataSource::Cast(dataSourceEntryPathHandle)) {
MObject dagNode = dataSourceEntryPath->GetTypedValue(0.0f);
#if WANT_UFE_BUILD
using HdRtidRefDataSource = HdRetainedTypedSampledDataSource<Ufe::Rtid&>;
static TfToken dataSourceRuntimeEntry("runtime");
HdDataSourceBaseHandle dataSourceEntryRuntimeHandle = inputArgs->Get(dataSourceRuntimeEntry);
#endif

if (auto dataSourceEntryNodePath = HdMObjectDataSource::Cast(dataSourceEntryPathHandle)) {
#if WANT_UFE_BUILD
auto dataSourceEntryRuntime = HdRtidRefDataSource::Cast(dataSourceEntryRuntimeHandle);
if (TF_VERIFY(dataSourceEntryRuntime, "Error UFE runtime id data source not found")) {
Ufe::Rtid& id = dataSourceEntryRuntime->GetTypedValue(0.0f);
id = MayaUsd::ufe::getUsdRunTimeId();
TF_VERIFY(id != 0, "Invalid UFE runtime id");
}
#endif
MObject dagNode = dataSourceEntryNodePath->GetTypedValue(0.0f);
MStatus status;
MFnDependencyNode dependNodeFn(dagNode, &status);
if (!TF_VERIFY(status, "Error getting MFnDependencyNode")) {
Expand Down