From da1ef5e08f9c7165267e9d2417f18959d29dc7f6 Mon Sep 17 00:00:00 2001 From: krickw Date: Tue, 21 Sep 2021 16:08:07 -0400 Subject: [PATCH 1/2] Do a bounds check before array access in case we're hitting the Pixar USD bug. --- lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index 7a5d82fb33..99a553ba71 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2007,7 +2007,12 @@ void HdVP2Mesh::_UpdateDrawItem( if (const auto state = drawScene.GetActiveSelectionState(id)) { for (const auto& indexArray : state->instanceIndices) { for (const auto index : indexArray) { - instanceInfo[index] = modeActive; + // This bounds check is necessary because of Pixar USD Issue 1516 + // Logged as MAYA-113682 + if (index >= 0 && index < (const int)instanceCount) + { + instanceInfo[index] = modeActive; + } } } } @@ -2016,7 +2021,12 @@ void HdVP2Mesh::_UpdateDrawItem( if (const auto state = drawScene.GetLeadSelectionState(id)) { for (const auto& indexArray : state->instanceIndices) { for (const auto index : indexArray) { - instanceInfo[index] = modeLead; + // This bounds check is necessary because of Pixar USD Issue 1516 + // Logged as MAYA-113682 + if (index >= 0 && index < (const int)instanceCount) + { + instanceInfo[index] = modeLead; + } } } } From 508bc51c14c669135ac823db60ac8cb7ca8bffa8 Mon Sep 17 00:00:00 2001 From: krickw Date: Tue, 21 Sep 2021 16:08:43 -0400 Subject: [PATCH 2/2] clang format --- lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index 99a553ba71..edf7c08571 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2009,8 +2009,7 @@ void HdVP2Mesh::_UpdateDrawItem( for (const auto index : indexArray) { // This bounds check is necessary because of Pixar USD Issue 1516 // Logged as MAYA-113682 - if (index >= 0 && index < (const int)instanceCount) - { + if (index >= 0 && index < (const int)instanceCount) { instanceInfo[index] = modeActive; } } @@ -2023,8 +2022,7 @@ void HdVP2Mesh::_UpdateDrawItem( for (const auto index : indexArray) { // This bounds check is necessary because of Pixar USD Issue 1516 // Logged as MAYA-113682 - if (index >= 0 && index < (const int)instanceCount) - { + if (index >= 0 && index < (const int)instanceCount) { instanceInfo[index] = modeLead; } }