Hi! 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.
The specific usecase I have is that if a user has an instance proxy selected then the property panel should be disabled unless their edit target is set to a site where the prim isn’t a proxy. If this were to also catch other cases where an edit can’t be made that’s also fine.
First thing I found was UsdStage::_ValidateEditPrim
but it’s private and as noted in the comment in its implementation it’s not perfect. It’ll only return false if the prim is an instance proxy when the edit target is targeting the local layer and isn’t remapping the path.
So instead I started looking into the prim index to see if I could implement it with that and I think I got pretty close. If I use UsdPrim::GetPrimIndex
then it seems I can find the edit target in the node range and check PcpNodeRef::IsInert
(or probably PcpNodeRef::CanContributeSpecs
, I’m just not sure yet when a node is restricted due to permissions) whether or not the user can edit it.
GetPrimIndex
doesn’t however include all sites that do not (yet) contribute opinions, so instead I should probably use ComputeExpandedPrimIndex
. The problem with that is that it doesn’t set PcpPrimIndexInputs::USD(true)
which ends up having the effect that instance proxies aren’t marked as inert because in Pcp_PrimIndexIsInstanceable
it early outs unless primIndex.IsUSD()
is true or PCP_OVERRIDE_INSTANCEABLE=1
.
The next thing I looked into was to call PcpComputePrimIndex`` directly but because I can’t access the stage’s PcpCache
I need to create my own. Doing that appears to work, but it’s something that I’d probably like to avoid if possible.
So I have a couple of questions:
- Am I approaching this correct? Is there something I’m missing?
- Is it intentional that
UsdPrim::ComputeExpandedPrimIndex
doesn’t setPcpPrimIndexInputs::USD(true)
? If so, how experimental is settingPCP_OVERRIDE_INSTANCEABLE=1
? - Is rolling my own PcpCache advisable? It feels like I might end up with just having a duplicate cache to the one in the UsdStage.