diff --git a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp index 9542c7bec8..9ee2aee1d8 100644 --- a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp +++ b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp @@ -19,6 +19,12 @@ #include "flowViewport/fvpUtils.h" #include "flowViewport/debugCodes.h" +#include +#include +#include +#include +#include +#include #if PXR_VERSION >= 2403 #include @@ -587,6 +593,11 @@ WireframeSelectionHighlightSceneIndex::_TrimMeshForSelectedGeomSubsets(const HdC if (!meshTopologySchema.IsDefined()) { return originalDataSource; } + HdDataSourceLocator pointsValueLocator = HdDataSourceLocator(HdPrimvarsSchemaTokens->primvars, HdPrimvarsSchemaTokens->points, HdPrimvarSchemaTokens->primvarValue); + auto pointsValueDataSource = HdTypedSampledDataSource>::Cast(HdContainerDataSource::Get(originalDataSource, pointsValueLocator)); + if (!pointsValueDataSource) { + return originalDataSource; + } // Collect faces to keep based on selected GeomSubsets std::unordered_set faceIndicesToKeep; @@ -622,6 +633,7 @@ WireframeSelectionHighlightSceneIndex::_TrimMeshForSelectedGeomSubsets(const HdC VtArray originalFaceVertexIndices = meshTopologySchema.GetFaceVertexIndices()->GetTypedValue(0); VtArray trimmedFaceVertexCounts; VtArray trimmedFaceVertexIndices; + int maxVertexIndex = 0; size_t iFaceCounts = 0; size_t iFaceIndices = 0; while (iFaceCounts < originalFaceVertexCounts.size() && iFaceIndices < originalFaceVertexIndices.size()) { @@ -630,7 +642,11 @@ WireframeSelectionHighlightSceneIndex::_TrimMeshForSelectedGeomSubsets(const HdC if (faceIndicesToKeep.find(iFaceCounts) != faceIndicesToKeep.end()) { trimmedFaceVertexCounts.push_back(currFaceCount); for (int faceIndicesOffset = 0; faceIndicesOffset < currFaceCount; faceIndicesOffset++) { - trimmedFaceVertexIndices.push_back(originalFaceVertexIndices[iFaceIndices + faceIndicesOffset]); + int vertexIndex = originalFaceVertexIndices[iFaceIndices + faceIndicesOffset]; + trimmedFaceVertexIndices.push_back(vertexIndex); + if (vertexIndex > maxVertexIndex) { + maxVertexIndex = vertexIndex; + } } } @@ -643,6 +659,10 @@ WireframeSelectionHighlightSceneIndex::_TrimMeshForSelectedGeomSubsets(const HdC dataSourceEditor.Set(faceVertexCountsLocator, HdRetainedTypedSampledDataSource::New(trimmedFaceVertexCounts)); dataSourceEditor.Set(faceVertexIndicesLocator, HdRetainedTypedSampledDataSource::New(trimmedFaceVertexIndices)); + auto points = pointsValueDataSource->GetTypedValue(0); + points.resize(maxVertexIndex + 1); + dataSourceEditor.Set(pointsValueLocator, HdRetainedTypedSampledDataSource>::New(points)); + return dataSourceEditor.Finish(); } #endif