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

HYDRA-703 : Fix mesh adapter transform update #20

Merged
merged 3 commits into from
Nov 27, 2023

Conversation

debloip-adsk
Copy link
Collaborator

@debloip-adsk debloip-adsk commented Nov 24, 2023

This PR fixes an issue with MeshAdapters where their transform was not being dirtied properly, and thus not updated correctly in the viewport. Since this issue was not MeshAdapter-specific and only highlighted a larger-scale problem, I've fixed the problem in the other places where it appeared.

@debloip-adsk debloip-adsk changed the title Debloip/hydra 703/fix mesh adapter transform update HYDRA-703 : Fix mesh adapter transform update Nov 24, 2023
@debloip-adsk debloip-adsk force-pushed the debloip/HYDRA-703/fix-mesh-adapter-transform-update branch from 204d7d1 to 85b5275 Compare November 24, 2023 21:24
@debloip-adsk debloip-adsk marked this pull request as ready for review November 24, 2023 21:43
Comment on lines 104 to +106
auto* adapter = reinterpret_cast<MayaHydraCameraAdapter*>(clientData);
adapter->MarkDirty(HdCamera::DirtyTransform);
adapter->InvalidateTransform();
adapter->MarkDirty(HdCamera::DirtyTransform);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There were a couple places where we were dirtying the transform before invalidating it. I've unified all instances of this sequence of operations to first invalidate the transform and then dirty it.

@@ -210,9 +210,9 @@ void MayaHydraDagAdapter::CreateCallbacks()
void MayaHydraDagAdapter::MarkDirty(HdDirtyBits dirtyBits)
{
if (dirtyBits != 0) {
GetSceneProducer()->GetRenderIndex().GetChangeTracker().MarkRprimDirty(GetID(), dirtyBits);
GetSceneProducer()->MarkRprimDirty(GetID(), dirtyBits);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line is where everything originates, as it is what caused (and now fixed) the issue for MeshAdapter; however, this line being the problem only highlighted a larger problem, which is that we were still using the Hydra 1.0 way of dirtying prims in some places in our Maya-native SceneIndex (and this is why this PR may be a bit larger than expected).

@@ -26,7 +26,7 @@

PXR_NAMESPACE_OPEN_SCOPE

using SceneIndicesVector = std::vector<HdSceneIndexBasePtr>;//Be careful, these are not not Ref counted. Elements could become dangling
using SceneIndicesVector = std::vector<HdSceneIndexBaseRefPtr>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See this comment and discussion : #4 (comment). Doing this now because I added a utility observer class along with the unit test for this issue, and that class needs its observed SceneIndex to remain valid for its whole lifetime.

Comment on lines +946 to +968
void MayaHydraSceneIndex::MarkRprimDirty(const SdfPath& id, HdDirtyBits dirtyBits) {
_MarkPrimDirty(id, dirtyBits, HdDirtyBitsTranslator::RprimDirtyBitsToLocatorSet);
}

void MayaHydraSceneIndex::MarkSprimDirty(const SdfPath& id, HdDirtyBits dirtyBits)
{
_MarkPrimDirty(id, dirtyBits, HdDirtyBitsTranslator::SprimDirtyBitsToLocatorSet);
}

void MayaHydraSceneIndex::MarkBprimDirty(const SdfPath& id, HdDirtyBits dirtyBits)
{
_MarkPrimDirty(id, dirtyBits, HdDirtyBitsTranslator::BprimDirtyBitsToLocatorSet);
}

void MayaHydraSceneIndex::MarkInstancerDirty(const SdfPath& id, HdDirtyBits dirtyBits)
{
_MarkPrimDirty(id, dirtyBits, HdDirtyBitsTranslator::InstancerDirtyBitsToLocatorSet);
}

void MayaHydraSceneIndex::_MarkPrimDirty(
const SdfPath& id,
HdDirtyBits dirtyBits,
DirtyBitsToLocatorsFunc dirtyBitsToLocatorsFunc)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Broke up the previous MarkPrimDirty method into separate prim-category-specific methods : the reason for this is because there does not seem to be a reliable way to determine which DirtyBitsToLocatorSet method to use purely based off a prim's type. While this does look more like Hydra 1.0 in terms of API design, it also matches more closely how HdChangeTracker handles these calls for its own emulated scene index. When our different adapters all move to using Hydra 2.0 APIs, we can change this.

@debloip-adsk debloip-adsk self-assigned this Nov 24, 2023
@debloip-adsk
Copy link
Collaborator Author

lilike-adsk
lilike-adsk previously approved these changes Nov 27, 2023
Copy link
Collaborator

@lilike-adsk lilike-adsk left a comment

Choose a reason for hiding this comment

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

good catch!

@debloip-adsk debloip-adsk added ready-for-merge Development process is finished, PR is ready for merge bug Something isn't working test labels Nov 27, 2023
@roopavr-adsk roopavr-adsk merged commit 55fffe7 into dev Nov 27, 2023
10 checks passed
@roopavr-adsk roopavr-adsk deleted the debloip/HYDRA-703/fix-mesh-adapter-transform-update branch November 27, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-merge Development process is finished, PR is ready for merge test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants