Skip to content

Commit

Permalink
MAYA-108270 Improve draw performance for Rprims without extent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Huidong Chen committed Dec 1, 2020
1 parent a0d2df6 commit 30cb835
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 32 deletions.
37 changes: 21 additions & 16 deletions lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
37 changes: 21 additions & 16 deletions lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 30cb835

Please sign in to comment.