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-126933 - [GitHub#2804] Maya crashes if USD instanceable is used together with varying visibility #3059

Merged
merged 2 commits into from
May 5, 2023
Merged
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
11 changes: 10 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,15 @@ HdReprSharedPtr MayaUsdRPrim::_InitReprCommon(
auto* const param = static_cast<HdVP2RenderParam*>(_delegate->GetRenderParam());
auto& drawScene = param->GetDrawScene();

// See if the primitive is instanced
auto delegate = drawScene.GetUsdImagingDelegate();
auto instancerId = delegate->GetInstancerId(id);
bool instanced = !instancerId.IsEmpty();
// The additional condition below is to prevent a crash in USD function GetScenePrimPath
instanced &= !delegate->GetInstanceIndices(instancerId, id).empty();

// display layers handling
if (!drawScene.GetUsdImagingDelegate()->GetInstancerId(id).IsEmpty()) {
if (instanced) {
// Sync display layer modes for instanced prims.
// This also sets the value of '_useInstancedDisplayLayerModes' that identifies whether
// display layer modes will be handled on per-primitive or per-instance basis
Expand Down Expand Up @@ -884,6 +891,8 @@ void MayaUsdRPrim::_SyncSharedData(
// If instancer is dirty, update instancing map
if (HdChangeTracker::IsInstancerDirty(*dirtyBits, id)) {
bool instanced = !refThis.GetInstancerId().IsEmpty();
// The additional condition below is to prevent a crash in USD function GetScenePrimPath
instanced &= !delegate->GetInstanceIndices(refThis.GetInstancerId(), id).empty();

// UpdateInstancingMapEntry is not multithread-safe, so enqueue the call
_delegate->GetVP2ResourceRegistry().EnqueueCommit([this, id, instanced]() {
Expand Down