#usda 1.0
over "test"
{
over "a"
{
double3 xformOp:translate = (1, -2, 3)
}
}
If UsdAttribute API is being used, only override value (1, -2, 3) will be retrieved, the only way I figured out to get (0, 0, 0) from root layer will be like
auto tmp_stage = pxr::UsdStage::Open(stage->GetRootLayer());
auto attr = tmp_stage ->GetAttributeAtPath(_attr.GetPath());
pxr::VtValue value;
attr.Get(&value);
It has to re-open the root layer again to get rid of session layer, is there any better way to get the actual value at root layer ?
Unfortunately, PropertyStacks are not a robust means of fetching attribute values, except possibly in the case where all data is authored in defaults. If an attribute possess timeSamples or Value Clips, the PropertyStack will not provide you with the time-mapping information you’d need to correctly resolve a value. And once sparse array overrides are implemented, it will no longer be safe even to use PropertyStacks for resolving defaults, if the attribute is array valued.
The desired solution here is something I think we’ve filed, but have not yet scheduled, is the ability to provide an optional UsdEditTarget to UsdAttribute::Get(), which would be the layer/site to begin value resolution with.
In the meantime, the only thing I can suggest that is more efficient than reopening the stage is to mute the stage’s session layer, perform your necessary queries (better if you can batch them up to avoid needing to do this too many times), and then unmute it.
Understood, I used to assume that the UsdEditTarget should work, and tried it to specify the session layer only but the API still returned override value.