Skip to content
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

Allow displaying of unloaded prims as bounding boxes #1145

Merged

Conversation

marktucker
Copy link
Contributor

Provide an optional feature in the UsdImagingDelegate to display unloaded
prims with payloads as bounding boxes. Requires that the prim is of Model
kind and has an extentsHint authored, or is a UsdGeomBoundable and has
an extent authored.

Built on the work from Animal Logic here:
https://github.com/AnimalLogic/USD/tree/display_unloaded_prims
And taking into account Pixar's recommendations here:
#788
And also adding support for native and point instanced primitives.

…aded

prims with payloads as bounding boxes. Requires that the prim is of Model
kind and has an extentsHint authored, or is a UsdGeomBoundable and has
an extent authored.

Built on the work from Animal Logic here:
https://github.com/AnimalLogic/USD/tree/display_unloaded_prims
And taking into account Pixar's recommendations here:
PixarAnimationStudios#788
And also adding support for native and point instanced primitives.
@marktucker
Copy link
Contributor Author

I'm not sure how to create regression tests for this... Here is a sample file I've been using to test this feature. It contains straightforward payloads, payloads with native and point instancers, and payloads with nested point instancing and native instancing.
payloads.zip

There is one case that seems to not work properly, which is the nested native instancing. But that case doesn't seem to work even without any of these changes. Unloading the payloads causes the geometry to disappear (and with these changes, no bounding boxes are visible), but loading the payloads again does not make the geometry reappear (with this feature enabled or disabled). So I think that's an existing bug with instances/payloads/hydra?

The other aspect of this commit not reflected in this sample file is a payload with a large extentsHint array, or where the payload is directly on a Boundable prim with an "extent" attribute lofted out of the payload. But I did run tests with both these cases to make sure that UsdImagingGLDrawModeAdapter::_ComputeExtent is working properly.

@jilliene
Copy link

Filed as internal issue #USD-5935

Copy link
Member

@spiffmon spiffmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @marktucker - this cleaned up nicely!

@@ -252,6 +252,19 @@ class UsdImagingDelegate : public HdSceneDelegate, public TfWeakBase {
USDIMAGING_API
void SetWindowPolicy(CameraUtilConformWindowPolicy policy);

/// Sets display of unloaded prims as bounding boxes.
/// Unloaded prims will need to satisfay one of the following set of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "satisfay"

/// 1. The prim is a UsdGeomBoundable with an authored 'extent' attribute.
/// 2. The prim is a UsdPrim.IsModel() and has an authored 'extentsHint'
/// attribute (see UsdGeomModelAPI::GetExtentsHint).
/// Effective only for delegates that support draw modes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add "(see GetUsdDrawModesEnabled())" ?

UsdGeomBBoxCache bboxCache(UsdTimeCode::EarliestTime(), purposes, true);
return bboxCache.ComputeUntransformedBound(prim).ComputeAlignedBox();

if (prim.IsLoaded()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving this note partly for other reviewers, but can you add an XXX comment here saying that it seems problematic that we are using using EarliestTime() here?

Not something to change as part of this feature, but it definitely strikes me as a problem for animated models.

extentsHint.size() == 2) {
extent = GfRange3d(extentsHint[0], extentsHint[1]);
}
else if ((attr = UsdGeomModelAPI(prim).GetExtentsHintAttr()) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof... Can you leave an XXX comment that ideally we'd push the "compute unloaded" bit into UsdGeomBBoxCache, and therby not need to replicate all this logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was pretty uncomfortable using the std::find over purposes in here, which is part of why I didn't want to push this into UsdGeomBBoxCache myself. But it was the only way I could think of to achieve generality in the face of the possibility of GetOrderedPurposeTokens changing in some way.

Come to think of it, the test for size() < 8 is an unnecessary hard coding of a value, so I'll change that too... Would you suggest completely removing the test for an upper bound on the size of extentsHint, or test that size() <= purposeTokens.size() * 2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, given the way we've defined extentsHint, and the iteration you're doing through purposeTokens, I don't think you need an upper bounds check at all.

future work, and removing the upper bound check on the size of the
extentsHint array.
@pixar-oss pixar-oss merged commit 5eb6ac2 into PixarAnimationStudios:dev Mar 26, 2020
@marktucker marktucker deleted the dev_display_unloaded_payloads branch April 9, 2020 02:20
DDoS pushed a commit to autodesk-forks/USD that referenced this pull request Jul 31, 2024
…raytracing-metal-2

Update acceleration structure implementation and shader code management
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants