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

UsdPrim::ComputeExpandedPrimIndex doesn't set PcpPrimIndexInputs::USD( true ) #3526

Open
Kryptarchy opened this issue Feb 7, 2025 · 1 comment

Comments

@Kryptarchy
Copy link

Description of Issue

I'm trying to implement a function that checks whether or not an edit can be made to a prim at the current edit target. I can do this through UsdPrim::GetPrimIndex by finding the edit target in the node range and checking PcpNodeRef::IsInert.

UsdPrim::GetPrimIndex doesn't include sites that do not (yet) contribute opinions as UsdPrim::ComputeExpandedPrimIndex does. But if I try and use ComputeExpandedPrimIndex then PcpNodeRef::IsInert always returns false, even on nodes that are inert with GetPrimIndex.

The reason appears to be because ComputeExpandedPrimIndex doesn't set the USD flag on the PcpPrimIndexInputs it creates which makes it so that instance proxies aren't marked as inert in Pcp_PrimIndexIsInstanceable.

This prevents me from checking if edits can be made to a prim at the current edit target when the edit target doesn't yet have contributing opinions to the prim.

Originally posted about it in the AOUSD forums: https://forum.aousd.org/t/checking-if-a-prim-can-be-edited-at-edit-target/2182/1

Steps to Reproduce

pxr::SdfLayerRefPtr instancedLayer = pxr::SdfLayer::New( nullptr, "instanced.usda" );
pxr::SdfPrimSpecHandle instancedRoot = pxr::SdfPrimSpec::New( instancedLayer, "instanced_root", pxr::SdfSpecifierDef );
instancedLayer->SetDefaultPrim( instancedRoot->GetNameToken() );
pxr::SdfPrimSpec::New( instancedRoot, "child", pxr::SdfSpecifierDef );

pxr::SdfLayerRefPtr layer = pxr::SdfLayer::New( nullptr, "bundle.usda" );
pxr::SdfPrimSpecHandle root = pxr::SdfPrimSpec::New( layer, "root", pxr::SdfSpecifierDef );
layer->SetDefaultPrim( root->GetNameToken() );

pxr::SdfPrimSpecHandle instance = pxr::SdfPrimSpec::New( root, "instance", pxr::SdfSpecifierDef );
instance->GetReferenceList().Add( pxr::SdfReference( instancedLayer->GetIdentifier() ) );
instance->SetInstanceable( true );

pxr::SdfVariantSpec::New( pxr::SdfVariantSetSpec::New( root, "variant" ), "selected" );
root->GetVariantSetNameList().Prepend( "variant" );
root->SetVariantSelection( "variant", "selected" );

pxr::UsdStageRefPtr stage = pxr::UsdStage::Open( layer );
pxr::UsdPrim proxy = stage->GetPrimAtPath( pxr::SdfPath( "/root/instance/child" ) );

const pxr::PcpPrimIndex& primIndex = proxy.GetPrimIndex();
pxr::PcpPrimIndex expandedPrimIndex = proxy.ComputeExpandedPrimIndex();

TF_STATUS( "UsdPrim::GetPrimIndex:" );
for( const pxr::PcpNodeRef& node : primIndex.GetNodeRange() )
{
	TF_STATUS( "\tis inert (%s): %d", node.GetPath().GetText(), node.IsInert() );
}

TF_STATUS( "UsdPrim::ComputeExpandedPrimIndex:" );
for( const pxr::PcpNodeRef& node : expandedPrimIndex.GetNodeRange() )
{
	TF_STATUS( "\tis inert (%s): %d", node.GetPath().GetText(), node.IsInert() );
}

Expected Output:

UsdPrim::GetPrimIndex:
	/root/instance/child is inert : 1
	/instanced_root/child is inert : 0
UsdPrim::ComputeExpandedPrimIndex:
	/root/instance/child is inert: 1
	/root{variant=selected}instance/child is inert: 1
	/instanced_root/child is inert: 0

Actual Output:

UsdPrim::GetPrimIndex:
	/root/instance/child is inert : 1
	/instanced_root/child is inert : 0
UsdPrim::ComputeExpandedPrimIndex:
	/root/instance/child is inert: 0
	/root{variant=selected}instance/child is inert: 0
	/instanced_root/child is inert: 0

System Information (OS, Hardware)

Windows 10

Package Versions

USD 23.5.0

Build Flags

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10662

(This is an automated message. See here for more information.)

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

No branches or pull requests

2 participants