Hi,
We have a mesh primitive in a Usd scene which has a variant in it. This is with Usd 23.11.
Say:
def Mesh "CubeOne" (
variants = {
string displacement = "none"
}
add variantSets = "displacement"
)
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
float[] primvars:__faceindex = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5] (
interpolation = "faceVarying"
)
string primvars:__gprimHandleid = "CubeOne"
string primvars:__handleid = "CubeOne"
color3f[] primvars:displayColor = [(0.217638, 0.217638, 0.217638)]
int primvars:gprimID = 903569
texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.375, 0.25), (0.625, 0.25), (0.625, 0.5), (0.375, 0.5), (0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.625, 0), (0.875, 0), (0.875, 0.25), (0.625, 0.25), (0.125, 0), (0.375, 0), (0.375, 0.25), (0.125, 0.25)] (
interpolation = "faceVarying"
)
uniform token[] xformOpOrder = ["xformOp:translate"]
variantSet "displacement" = {
"moved" {
double3 xformOp:translate = (-2, 2, 0.5)
}
"none" {
double3 xformOp:translate = (-2, 0, 0.5)
}
}
}
We look in C++ in a filtering scene index, e.g : MySceneIndex::GetPrim at the prim with :
auto prim = _GetInputSceneIndex()->GetPrim(primPath);
if(prim.primType == HdPrimTypeTokens->mesh) {
//Do things.
}
The prim is a HdPrimTypeTokens->mesh.
But if we set this prim which has the variant set as instanceable=true. It has no longer the type HdPrimTypeTokens->mesh, it seems like an unset prim type.
This change of prim type doesn’t happen for the meshes that have no variant set in them.
Is that expected ?
I can detect it’s an instance with :
bool
_IsUsdNativeInstance(const HdSceneIndexPrim &prim)
{
UsdImagingUsdPrimInfoSchema primInfoSchema =
UsdImagingUsdPrimInfoSchema::GetFromParent(prim.dataSource);
HdPathDataSourceHandle const ds = primInfoSchema.GetNiPrototypePath();
if (!ds) {
return false;
}
return !ds->GetTypedValue(0.0f).IsEmpty();
}
But is that enough ? As we want to deal only with meshes on this code.
BTW : using _IsUsdNativeInstance on a mesh prim that has instanceable=true and a variant set returns true and on a mesh prim that has instanceable=true but no variant set, it returns false.
Thank you.
Regards,
David Lanier
Autodesk.