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

HYDRA-496: Fix for crash on new scene with a USD Stage inside the Maya scene #3325

Merged
merged 6 commits into from
Sep 14, 2023
Merged
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
7 changes: 7 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeStageExtraData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ MStatus MayaUsdProxyShapeStageExtraData::finalize()
return status;
}

/* static */
bool MayaUsdProxyShapeStageExtraData::containsProxyShape(MayaUsdProxyShapeBase& proxyShape)
{
auto it = getTrackedProxyShapes().find(&proxyShape);
return it != getTrackedProxyShapes().end();
}

/* static */
void MayaUsdProxyShapeStageExtraData::addProxyShape(MayaUsdProxyShapeBase& proxyShape)
{
Expand Down
4 changes: 4 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeStageExtraData.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class MayaUsdProxyShapeStageExtraData
MAYAUSD_CORE_PUBLIC
static void saveAllStageData();

/// \brief verify if the proxyshape requested is still valid
MAYAUSD_CORE_PUBLIC
static bool containsProxyShape(MayaUsdProxyShapeBase& proxyShape);

/// \brief save load rules of tracked proxy shapes.
MAYAUSD_CORE_PUBLIC
static void saveAllLoadRules();
Expand Down
10 changes: 8 additions & 2 deletions lib/mayaUsd/sceneIndex/proxyShapeSceneIndexPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#if PXR_VERSION >= 2211

#include <mayaUsd/nodes/proxyShapeStageExtraData.h>
#include <mayaUsd/ufe/Global.h>
#include <mayaUsd/ufe/Utils.h>

Expand Down Expand Up @@ -191,7 +192,7 @@ HdSceneIndexBaseRefPtr MayaUsdProxyShapeMayaNodeSceneIndexPlugin::_AppendSceneIn
sceneIndex = HdFlatteningSceneIndex::New(sceneIndex, flatteningInputArgs);
sceneIndex = UsdImagingDrawModeSceneIndex::New(sceneIndex, /* inputArgs = */ nullptr);
#else
//#For USD 23.08 and later, HD_API_VERSION=54 in USD 23.08
// #For USD 23.08 and later, HD_API_VERSION=54 in USD 23.08
static const bool _displayUnloadedPrimsWithBounds = true;

HdContainerDataSourceHandle const stageInputArgs = HdRetainedContainerDataSource::New(
Expand Down Expand Up @@ -311,9 +312,14 @@ void MayaUsdProxyShapeSceneIndex::onTimeChanged(void* data)
instance->UpdateTime();
}

bool MayaUsdProxyShapeSceneIndex::isProxyShapeValid()
{
return MayaUsdProxyShapeStageExtraData::containsProxyShape(*_proxyShape);
}

void MayaUsdProxyShapeSceneIndex::UpdateTime()
{
if (_usdImagingStageSceneIndex && _proxyShape) {
if (_usdImagingStageSceneIndex && _proxyShape && isProxyShapeValid()) {
_usdImagingStageSceneIndex->SetTime(_proxyShape->getTime());
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/mayaUsd/sceneIndex/proxyShapeSceneIndexPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class MayaUsdProxyShapeSceneIndex : public HdSingleInputFilteringSceneIndexBase

void StageSet(const MayaUsdProxyStageSetNotice& notice);

bool isProxyShapeValid();

void Populate();

protected:
Expand Down