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-114130: selecting an instanced prim and then the stage shows incorrect selection hilite in viewport #1868

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
41 changes: 24 additions & 17 deletions lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,27 +2033,34 @@ void HdVP2Mesh::_UpdateDrawItem(
// or not drawing if the item is a selection highlight item.
instanceInfo.resize(instanceCount, modeDormant);

// Assign with the index to the active selection highlight color.
if (const auto state = drawScene.GetActiveSelectionState(id)) {
for (const auto& indexArray : state->instanceIndices) {
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) {
instanceInfo[index] = modeActive;
// Sometimes the calls to GetActiveSelectionState and GetLeadSelectionState
// return instance indices which do not match the current selection, and that
// causes incorrect drawing. Only call GetActiveSelectionState and GetLeadSelectionState
// when _selectionStatus is kPartiallySelected. If the object is fully lead or active
// then we already have the correct values in instanceInfo.
if (_selectionStatus == kPartiallySelected) {
// Assign with the index to the active selection highlight color.
if (const auto state = drawScene.GetActiveSelectionState(id)) {
for (const auto& indexArray : state->instanceIndices) {
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) {
instanceInfo[index] = modeActive;
}
}
}
}
}

// Assign with the index to the lead selection highlight color.
if (const auto state = drawScene.GetLeadSelectionState(id)) {
for (const auto& indexArray : state->instanceIndices) {
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) {
instanceInfo[index] = modeLead;
// Assign with the index to the lead selection highlight color.
if (const auto state = drawScene.GetLeadSelectionState(id)) {
for (const auto& indexArray : state->instanceIndices) {
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) {
instanceInfo[index] = modeLead;
}
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.