Hello everyone,
I’ve been delving into the USD framework and came across something in the SdfPath
implementation that I find a bit puzzling, specifically regarding how property paths are handled. I’m hoping to get some insights or clarifications.
In the Sdf_PathNode::FindOrCreatePrimProperty
function, there’s a comment that says:
Sdf_PathPropNodeHandle
Sdf_PathNode::FindOrCreatePrimProperty(Sdf_PathNode const *parent,
const TfToken &name,
TfFunctionRef<bool ()> isValid)
{
// NOTE! We explicitly set the parent to null here in order to create a
// separate prefix tree for property-like paths.
return _FindOrCreate<Sdf_PrimPropertyPathNode>(
*_primPropertyNodes, isValid, nullptr, name);
}.
This implies that property nodes are created with a null parent, which makes sense considering SdfPath
comprises a primitive part and a property part. The property part doesn’t need a separate parent since it’s associated with the primitive part. This would mean that in the pool for property nodes, a property like .color
is stored once, irrespective of its usage across different primitives.
However, I’m a bit confused about how this aligns with the _WriteTextToBuffer
method, which is used for generating string representations of paths:
// in Sdf_PathNode::_WriteTextToBuffer
Sdf_PathNode const *curNode = propPart;
while (curNode) {
curNode->_WriteText(out);
curNode = curNode->GetParentNode();
}
Given that property nodes are supposedly created with null parents, how does this loop iterate more than once? Does this indicate that a property node can indeed have a parent? Or is there something I’m missing in how _WriteTextToBuffer
functions?
Additionally, I’m curious about the possibility of nested property structures like /path/to/prim.color.r
, where both color
and r
are properties. Is such a hierarchy feasible within USD’s path structure?
Thank you -ms