-
Notifications
You must be signed in to change notification settings - Fork 5
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
HYDRA-1057 : GeomSubsets wireframe highlighting #148
HYDRA-1057 : GeomSubsets wireframe highlighting #148
Conversation
…ht mirror use counters
ad05cf6
to
2ccb0b0
Compare
const HdRetainedContainerDataSourceHandle sRefinedWireOnSurfaceDisplayStyleDataSource | ||
= HdRetainedContainerDataSource::New( | ||
HdLegacyDisplayStyleSchemaTokens->displayStyle, | ||
HdRetainedContainerDataSource::New( | ||
HdLegacyDisplayStyleSchemaTokens->reprSelector, | ||
HdRetainedTypedSampledDataSource<VtArray<TfToken>>::New( | ||
{ HdReprTokens->refinedWireOnSurf, TfToken(), TfToken() }))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything now uses separate prims with refinedWire
only
// Computes the mask to use for an instancer's selection highlight mirror | ||
// based on the instancer's topology and its selections. This allows | ||
// highlighting only specific instances in the case of instance selections. | ||
VtBoolArray _GetSelectionHighlightMask(const HdInstancerTopologySchema& originalInstancerTopology, const HdSelectionsSchema& selections) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a method
|
||
// Returns the overall data source for an instancer's selection highlight mirror. | ||
// This replaces the mask data source and blocks the selections data source. | ||
HdContainerDataSourceHandle _GetSelectionHighlightInstancerDataSource(const HdContainerDataSourceHandle& originalDataSource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a method
return VtBoolArray(nbInstances, false); | ||
}(); | ||
|
||
if (!selections.IsDefined()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the newly handled case and why this function and _GetSelectionHighlightInstancerDataSource
was moved to a method, in order to call GetSelectionHighlightPath
// There already exists an explicit selection highlight mirror for this child (e.g. point instance prototypes), | ||
// so don't create a duplicate implicit one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to avoid overdraw, as without the check everything still works, but a highlight could be drawn more than once
affectedOriginalPrimPaths.insert(affectedOriginalPrimPaths.end(), instancingRelatedPaths.begin(), instancingRelatedPaths.end()); | ||
return false; // We have found an instancer, don't process its children (nested instancers will be processed through the instancing-related paths). | ||
if (prim.primType == HdPrimTypeTokens->instancer || prim.primType == HdPrimTypeTokens->mesh) { | ||
if (direction & SelectionHighlightsCollectionDirection::Prototypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting the instancing-related paths in two prevents us from always traversing the entire instancing graph, and inadvertently creating selection highlights for non-selected prims. Without this, selecting an instanced mesh would create a highlight mirror for the mesh, then a highlight mirror for the instancer, but in creating the highlight mirror for the instancer and collecting its instancing paths, we would collect its other prototype paths, and then create highlight mirrors for those as well, even if they weren't actually selected.
@@ -1894,6 +1894,7 @@ void MtohRenderOverride::_PickByRegion( | |||
pickParams.viewMatrix.Set(viewMatrix.matrix); | |||
pickParams.projectionMatrix.Set(adjustedProjMatrix.matrix); | |||
pickParams.collection = _renderCollection; | |||
pickParams.collection.SetExcludePaths(_wireframeSelectionHighlightSceneIndex->GetSelectionHighlightMirrorPaths()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to exclude selection highlight prims. If we don't, selecting the highlight mirror of a mesh that is trimmed by a GeomSubset selection ends up selecting the original mesh, instead of selecting the GeomSubset.
// This method takes in a path to a prim in a selection highlight hierarchy and ensures that | ||
// the selection highlight graph is structured properly, and that the leaf mesh prims have | ||
// the proper display style. | ||
void assertSelectionHighlightCorrectness( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted and slightly tweaked from testPointInstancingWireframeHighlight.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I delved very deeply into the logic, but the tests pass, so that works for me.
As discussed, agree that the approach is the right one, and is the way to get the draw flexibility we need, but concerned about z-fighting and resulting decrease in quality. Can be addressed at a later time.
This PR adds selection highlighting for GeomSubsets.
A brief overview of the thought process behind the implementation : previously, non-instanced meshes were highlighted through the
refinedWireOnSurf
display style. However, this does not allow us to create a wireframe for a subset of the mesh. So the idea is to instead use the existing architecture that maintains a selection highlight mirror hierarchy, and have a mirror prim of the mesh with arefinedWire
display style. We can then edit this mirror mesh to only contain the topology related to the selected GeomSubsets. However, to do so, it is much simpler and more consistent to move away fromrefinedWireOnSurf
entirely, and just have mesh selections also use mirror prims : this way, we can use the selection highlight mirror hierarchy for everything, and we only have one consistent (though somewhat complex) way of handling all highlights.