-
Notifications
You must be signed in to change notification settings - Fork 202
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-125149 - When "Enable Overrides" is unchecked for a Display Layer USD Data still uses Bounding Box #2611
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,21 +177,20 @@ void MayaUsdRPrim::_UpdateTransform( | |
} | ||
|
||
// Local-to-world transformation | ||
MMatrix& worldMatrix = drawItemData._worldMatrix; | ||
sharedData.bounds.GetMatrix().Get(worldMatrix.matrix); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this call inside if-statements fixes an issue with bound box dimensions when a display layer is switched to bound box mode in multi-viewport |
||
|
||
// The bounding box draw item uses a globally-shared unit wire cube as the | ||
// geometry and transfers scale and offset of the bounds to world matrix. | ||
if (isBoundingBoxItem) { | ||
if ((itemDirtyBits & (HdChangeTracker::DirtyExtent | HdChangeTracker::DirtyTransform)) | ||
&& !range.IsEmpty()) { | ||
sharedData.bounds.GetMatrix().Get(drawItemData._worldMatrix.matrix); | ||
|
||
const GfVec3d midpoint = range.GetMidpoint(); | ||
const GfVec3d size = range.GetSize(); | ||
|
||
MPoint midp(midpoint[0], midpoint[1], midpoint[2]); | ||
midp *= worldMatrix; | ||
midp *= drawItemData._worldMatrix; | ||
|
||
auto& m = worldMatrix.matrix; | ||
auto& m = drawItemData._worldMatrix.matrix; | ||
m[0][0] *= size[0]; | ||
m[0][1] *= size[0]; | ||
m[0][2] *= size[0]; | ||
|
@@ -212,6 +211,7 @@ void MayaUsdRPrim::_UpdateTransform( | |
stateToCommit._worldMatrix = &drawItemData._worldMatrix; | ||
} | ||
} else if (itemDirtyBits & HdChangeTracker::DirtyTransform) { | ||
sharedData.bounds.GetMatrix().Get(drawItemData._worldMatrix.matrix); | ||
stateToCommit._worldMatrix = &drawItemData._worldMatrix; | ||
} | ||
} | ||
|
@@ -724,14 +724,18 @@ void MayaUsdRPrim::_SyncDisplayLayerModes(const HdRprim& | |
for (unsigned int i = 0; i < ancestorDisplayLayers.length(); i++) { | ||
MFnDependencyNode displayLayerNodeFn(ancestorDisplayLayers[i]); | ||
MPlug layerEnabled = displayLayerNodeFn.findPlug("enabled"); | ||
MPlug layerVisible = displayLayerNodeFn.findPlug("visibility"); | ||
MPlug layerHidesOnPlayback = displayLayerNodeFn.findPlug("hideOnPlayback"); | ||
MPlug layerDisplayType = displayLayerNodeFn.findPlug("displayType"); | ||
MPlug levelOfDetail = displayLayerNodeFn.findPlug("levelOfDetail"); | ||
MPlug shading = displayLayerNodeFn.findPlug("shading"); | ||
MPlug texturing = displayLayerNodeFn.findPlug("texturing"); | ||
|
||
_displayLayerModes._visibility &= layerEnabled.asBool() ? layerVisible.asBool() : true; | ||
if (!layerEnabled.asBool()) { | ||
continue; | ||
} | ||
Comment on lines
+727
to
+729
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properly handle display layer's attribute "enable" |
||
|
||
MPlug layerVisible = displayLayerNodeFn.findPlug("visibility"); | ||
MPlug layerHidesOnPlayback = displayLayerNodeFn.findPlug("hideOnPlayback"); | ||
MPlug layerDisplayType = displayLayerNodeFn.findPlug("displayType"); | ||
MPlug levelOfDetail = displayLayerNodeFn.findPlug("levelOfDetail"); | ||
MPlug shading = displayLayerNodeFn.findPlug("shading"); | ||
MPlug texturing = displayLayerNodeFn.findPlug("texturing"); | ||
|
||
_displayLayerModes._visibility &= layerVisible.asBool(); | ||
_displayLayerModes._hideOnPlayback |= layerHidesOnPlayback.asBool(); | ||
_displayLayerModes._texturing = texturing.asBool(); | ||
if (levelOfDetail.asShort() != 0) { | ||
|
@@ -767,13 +771,13 @@ void MayaUsdRPrim::_SyncSharedData( | |
} | ||
|
||
if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { | ||
bool usdVisibility = delegate->GetVisible(id); | ||
sharedData.visible = delegate->GetVisible(id) && _displayLayerModes._visibility; | ||
|
||
// Invisible rprims don't get calls to Sync or _PropagateDirtyBits while | ||
// they are invisible. This means that when a prim goes from visible to | ||
// invisible that we must update every repr, because if we switch reprs while | ||
// invisible we'll get no chance to update! | ||
if (!usdVisibility) | ||
if (!sharedData.visible) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes an issue with visibility when a display layer is switched into invisible state while in multi-viewport |
||
_MakeOtherReprRenderItemsInvisible(reprToken, reprs); | ||
|
||
// Update "hide on playback" status | ||
|
@@ -788,8 +792,6 @@ void MayaUsdRPrim::_SyncSharedData( | |
_ForEachRenderItem(reprs, setHideOnPlayback); | ||
#endif | ||
} | ||
|
||
sharedData.visible = usdVisibility && _displayLayerModes._visibility; | ||
} | ||
|
||
#if PXR_VERSION > 2111 | ||
|
@@ -914,4 +916,31 @@ SdfPath MayaUsdRPrim::_GetUpdatedMaterialId(HdRprim* rprim, HdSceneDelegate* del | |
return materialId; | ||
} | ||
|
||
bool MayaUsdRPrim::_GetMaterialPrimvars( | ||
HdRenderIndex& renderIndex, | ||
const SdfPath& materialId, | ||
TfTokenVector& primvars) | ||
{ | ||
const HdVP2Material* material = static_cast<const HdVP2Material*>( | ||
renderIndex.GetSprim(HdPrimTypeTokens->material, materialId)); | ||
if (!material || !material->GetSurfaceShader(TfToken())) { | ||
return false; | ||
} | ||
|
||
// Get basic primvars | ||
primvars = material->GetRequiredPrimvars(TfToken()); | ||
|
||
// Get extra primvars | ||
if (material->GetSurfaceShader(HdReprTokens->smoothHull)) { | ||
const auto& extraPrimvars = material->GetRequiredPrimvars(HdReprTokens->smoothHull); | ||
for (const auto& extraPrimvar : extraPrimvars) { | ||
if (std::find(primvars.begin(), primvars.end(), extraPrimvar) == primvars.end()) { | ||
primvars.push_back(extraPrimvar); | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -882,13 +882,10 @@ void HdVP2Mesh::Sync( | |
|| HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->primvar) || instancerDirty) { | ||
|
||
auto addRequiredPrimvars = [&](const SdfPath& materialId) { | ||
const HdVP2Material* material = static_cast<const HdVP2Material*>( | ||
renderIndex.GetSprim(HdPrimTypeTokens->material, materialId)); | ||
TfToken materialNetworkToken = _GetMaterialNetworkToken(reprToken); | ||
const TfTokenVector& requiredPrimvars | ||
= material && material->GetSurfaceShader(materialNetworkToken) | ||
? material->GetRequiredPrimvars(materialNetworkToken) | ||
: sFallbackShaderPrimvars; | ||
TfTokenVector requiredPrimvars; | ||
if (!_GetMaterialPrimvars(renderIndex, materialId, requiredPrimvars)) { | ||
requiredPrimvars = sFallbackShaderPrimvars; | ||
} | ||
Comment on lines
+885
to
+888
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since primvars (and their vertex buffers) are shared among all representations, we need to include here all required primvars from all available material networks, which is done inside _GetMaterialPrimvars method. |
||
|
||
for (const auto& requiredPrimvar : requiredPrimvars) { | ||
if (!_PrimvarIsRequired(requiredPrimvar)) { | ||
|
@@ -1697,7 +1694,7 @@ void HdVP2Mesh::_UpdateDrawItem( | |
const GfRange3d& range = _sharedData.bounds.GetRange(); | ||
|
||
_UpdateTransform(stateToCommit, _sharedData, itemDirtyBits, isBBoxItem); | ||
MMatrix& worldMatrix = drawItemData._worldMatrix; | ||
const MMatrix& worldMatrix = drawItemData._worldMatrix; | ||
|
||
// If the mesh is instanced, create one new instance per transform. | ||
// The current instancer invalidation tracking makes it hard for | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,19 +143,14 @@ void HdVP2Points::Sync( | |
if (HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->normals) | ||
|| HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->widths) | ||
|| HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->primvar)) { | ||
const HdVP2Material* material = static_cast<const HdVP2Material*>( | ||
renderIndex.GetSprim(HdPrimTypeTokens->material, GetMaterialId())); | ||
|
||
TfTokenVector materialPrimvars; | ||
const TfTokenVector* requiredPrimvars = &sFallbackShaderPrimvars; | ||
TfToken materialNetworkToken = _GetMaterialNetworkToken(reprToken); | ||
if (material && material->GetSurfaceShader(materialNetworkToken)) { | ||
materialPrimvars = material->GetRequiredPrimvars(materialNetworkToken); | ||
materialPrimvars.push_back(HdTokens->widths); | ||
requiredPrimvars = &materialPrimvars; | ||
TfTokenVector requiredPrimvars; | ||
if (!_GetMaterialPrimvars(renderIndex, GetMaterialId(), requiredPrimvars)) { | ||
requiredPrimvars = sFallbackShaderPrimvars; | ||
} else { | ||
requiredPrimvars.push_back(HdTokens->widths); | ||
Comment on lines
+146
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since primvars (and their vertex buffers) are shared among all representations, we need to include here all required primvars from all available material networks, which is done inside _GetMaterialPrimvars method. |
||
} | ||
|
||
_UpdatePrimvarSources(delegate, *dirtyBits, *requiredPrimvars); | ||
_UpdatePrimvarSources(delegate, *dirtyBits, requiredPrimvars); | ||
} | ||
|
||
if (*dirtyBits & HdChangeTracker::DirtyDisplayStyle) { | ||
|
@@ -589,7 +584,7 @@ void HdVP2Points::_UpdateDrawItem( | |
const GfRange3d& range = _sharedData.bounds.GetRange(); | ||
|
||
_UpdateTransform(stateToCommit, _sharedData, itemDirtyBits, isBoundingBoxItem); | ||
MMatrix& worldMatrix = drawItemData._worldMatrix; | ||
const MMatrix& worldMatrix = drawItemData._worldMatrix; | ||
|
||
// If the prim is instanced, create one new instance per transform. | ||
// The current instancer invalidation tracking makes it hard for | ||
|
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.
Since primvars (and their vertex buffers) are shared among all representations, we need to include here all required primvars from all available material networks, which is done inside _GetMaterialPrimvars method.