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

MAYA-105827 - Compute extents for modified GPrims #1112

Merged
merged 12 commits into from
Feb 5, 2021

Conversation

JGamache-autodesk
Copy link
Collaborator

@JGamache-autodesk JGamache-autodesk commented Jan 26, 2021

The UsdGeomBoundable requirements state that extents must be explicitly authored if any GPrim attribute that affect extents is authored.
This PR tries to keep the extents in sync by recomputing them at notification time.

Temporary: Do not trust GPrim extents until we add code to restore
the integrity of the data model following an attribute change.

See UsdGeomBoundable::GetExtentAttr() for details.
@@ -540,7 +540,10 @@ void HdVP2Mesh::Sync(
}

if (HdChangeTracker::IsExtentDirty(*dirtyBits, id)) {
_sharedData.bounds.SetRange(delegate->GetExtent(id));
// Do not trust GPrim extents until we add code to restore the integrity of the data model

Choose a reason for hiding this comment

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

Looks good. Please also test the bounding box display mode in the 3d view.

Choose a reason for hiding this comment

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

Maybe better to add a doc here saying VP2 will compute the bounds when none is provided.

Choose a reason for hiding this comment

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

Second thought: bounding box display mode might be broken by this change.

Choose a reason for hiding this comment

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

If it is broken, we can keep storing the extent in the shared data, but each draw item can opt in/out on using it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bounding box was indeed broken (as well as selection when switching to wireframe using wrong BB). This should fix it.

Copy link
Contributor

@williamkrick williamkrick left a comment

Choose a reason for hiding this comment

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

I'll leave this in request changed until Huidong's question gets answered.

@JGamache-autodesk JGamache-autodesk changed the title MAYA-105827 - Let Maya compute GPrim bounds MAYA-105827 - Compute extents for modified GPrims Jan 27, 2021
// If the attribute is not part of the primitive schema, it does not affect extents
const UsdPrimDefinition& primDefinition = changedPrim.GetPrimDefinition();
if (!primDefinition.GetSchemaAttributeSpec(changedPropertyToken)) {
continue;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Filters out the transform notifications when manipulating USD objects.

return;
}

UsdEditContext editContext(stage, stage->GetSessionLayer());

Choose a reason for hiding this comment

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

Here is a bit of a problem. The session layer is not serialized together with the root layer.

I would assume that this notification will happen right after the authoring operation and for that, we already have the right edit target set. What's the reason for changing the edit target?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this line introduces bugs. I will remove it.

if (extentsAttr && extentsAttr.HasValue()) {
VtVec3fArray extent(2);
if (UsdGeomBoundable::ComputeExtentFromPlugins(
boundableObj, UsdTimeCode::Default(), &extent)) {

Choose a reason for hiding this comment

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

Here is another challenging place. What if the extent is animated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I must say that reacting by notification is probably not appropriate. There is not enough context to know if the values is/was animated which forces writing a single non-animated extent value. This makes the extent completely wrong if another untouched parameter is kept animated (radius and length of a capsule, for example). There is also no information stored for Undo, and no mechanism to store the undo data of an animated extent (same issue appears in Ufe Undo handler for TypedUsdAttribute::Set).

We could build a set of affected boundables and wait until the Compute function of the shape node is called. At this time we might have a better overall view of the state. We still end up with animation issues: we are expected to compute the extent at the current frame, but might be forced to recompute for the whole clip duration since we have absolutely no idea about the final animated state of the extent, and more specifically, which attributes affect the extent.

Copy link

@kxl-adsk kxl-adsk left a comment

Choose a reason for hiding this comment

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

We should request more testing to validate that there is no impact on performance for interactive manipulation.

@kxl-adsk
Copy link

kxl-adsk commented Feb 2, 2021

@JGamache-autodesk I know we are still checking the performance impact, but I took this change for a spin. We still have some work. Compilation fails with USD 20.02 due to change done in the prim (GetPrimDefinition is returning a different type in 20.02) and in sdfpath (GetAsString doesn't exist).

It would also be great to add a regression test since we don't have it tested by anything existing.

@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Feb 3, 2021
@kxl-adsk kxl-adsk merged commit 80cddd1 into dev Feb 5, 2021
@kxl-adsk kxl-adsk deleted the t_gamaj/MAYA-105827/let_maya_compute_bounds branch February 5, 2021 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants