From 30cb8352a94f20407ab5ec1c02d76c3d9874f9a5 Mon Sep 17 00:00:00 2001 From: Huidong Chen Date: Mon, 30 Nov 2020 21:08:24 -0500 Subject: [PATCH] MAYA-108270 Improve draw performance for Rprims without extent If the Rprim has empty bounds, we will assign a null bounding box to the render item and Maya will compute the bounding box from the position data. --- .../render/vp2RenderDelegate/basisCurves.cpp | 37 +++++++++++-------- lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 37 +++++++++++-------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp index 69424cdb18..a9e3dee7dd 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp @@ -990,24 +990,29 @@ void HdVP2BasisCurves::_UpdateDrawItem( const GfRange3d& rangeToUse = isBoundingBoxItem ? _delegate->GetSharedBBoxGeom().GetRange() : range; - bool boundingBoxExpanded = false; - - const GfVec3d& min = rangeToUse.GetMin(); - const MPoint pntMin(min[0], min[1], min[2]); - if (!drawItemData._boundingBox.contains(pntMin)) { - drawItemData._boundingBox.expand(pntMin); - boundingBoxExpanded = true; - } + // If the Rprim has empty bounds, we will assign a null bounding box to the render item and + // Maya will compute the bounding box from the position data. + if (!rangeToUse.IsEmpty()) { + const GfVec3d& min = rangeToUse.GetMin(); + const GfVec3d& max = rangeToUse.GetMax(); + + bool boundingBoxExpanded = false; + + const MPoint pntMin(min[0], min[1], min[2]); + if (!drawItemData._boundingBox.contains(pntMin)) { + drawItemData._boundingBox.expand(pntMin); + boundingBoxExpanded = true; + } - const GfVec3d& max = rangeToUse.GetMax(); - const MPoint pntMax(max[0], max[1], max[2]); - if (!drawItemData._boundingBox.contains(pntMax)) { - drawItemData._boundingBox.expand(pntMax); - boundingBoxExpanded = true; - } + const MPoint pntMax(max[0], max[1], max[2]); + if (!drawItemData._boundingBox.contains(pntMax)) { + drawItemData._boundingBox.expand(pntMax); + boundingBoxExpanded = true; + } - if (boundingBoxExpanded) { - stateToCommit._boundingBox = &drawItemData._boundingBox; + if (boundingBoxExpanded) { + stateToCommit._boundingBox = &drawItemData._boundingBox; + } } } diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index 4966b2ba35..5653593f8b 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -1222,24 +1222,29 @@ void HdVP2Mesh::_UpdateDrawItem( const GfRange3d& rangeToUse = isBBoxItem ? _delegate->GetSharedBBoxGeom().GetRange() : range; - bool boundingBoxExpanded = false; - - const GfVec3d& min = rangeToUse.GetMin(); - const MPoint pntMin(min[0], min[1], min[2]); - if (!drawItemData._boundingBox.contains(pntMin)) { - drawItemData._boundingBox.expand(pntMin); - boundingBoxExpanded = true; - } + // If the Rprim has empty bounds, we will assign a null bounding box to the render item and + // Maya will compute the bounding box from the position data. + if (!rangeToUse.IsEmpty()) { + const GfVec3d& min = rangeToUse.GetMin(); + const GfVec3d& max = rangeToUse.GetMax(); + + bool boundingBoxExpanded = false; + + const MPoint pntMin(min[0], min[1], min[2]); + if (!drawItemData._boundingBox.contains(pntMin)) { + drawItemData._boundingBox.expand(pntMin); + boundingBoxExpanded = true; + } - const GfVec3d& max = rangeToUse.GetMax(); - const MPoint pntMax(max[0], max[1], max[2]); - if (!drawItemData._boundingBox.contains(pntMax)) { - drawItemData._boundingBox.expand(pntMax); - boundingBoxExpanded = true; - } + const MPoint pntMax(max[0], max[1], max[2]); + if (!drawItemData._boundingBox.contains(pntMax)) { + drawItemData._boundingBox.expand(pntMax); + boundingBoxExpanded = true; + } - if (boundingBoxExpanded) { - stateToCommit._boundingBox = &drawItemData._boundingBox; + if (boundingBoxExpanded) { + stateToCommit._boundingBox = &drawItemData._boundingBox; + } } }