Skip to content

Commit 2360884

Browse files
Fix point instancer crash
Apply a fix similar to other palces in the same file. Not 100% it is entirely right, as my knowledge of the VP2 render delegate and instancer is not high.
1 parent 2c746b5 commit 2360884

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,15 @@ void MayaUsdRPrim::_SyncDisplayLayerModes(SdfPath const& id, bool instancedPrim)
778778
// Obtain scene prim path
779779
HdInstancerContext instancerContext;
780780
int instanceIndex = instancedPrim ? 0 : UsdImagingDelegate::ALL_INSTANCES;
781-
auto usdPath = drawScene.GetScenePrimPath(id, instanceIndex, &instancerContext);
781+
782+
auto delegate = drawScene.GetUsdImagingDelegate();
783+
auto instancerId = delegate->GetInstancerId(id);
784+
bool instanced = !instancerId.IsEmpty();
785+
// The additional condition below is to prevent a crash in USD function GetScenePrimPath
786+
instanced = (instanced && !delegate->GetInstanceIndices(instancerId, id).empty());
787+
788+
auto usdPath
789+
= instanced ? drawScene.GetScenePrimPath(id, instanceIndex, &instancerContext) : SdfPath();
782790

783791
// Native instances use per-instance _displayLayerModes
784792
if (instancedPrim && instancerContext.empty()) {

0 commit comments

Comments
 (0)