Open nvmkuruc opened 1 month ago
Filed as internal issue #USD-9486
We suspect the issue is the VariantName
grammar in pathParser.h
which is used to validate variant names should be using PEGTL_NS::plus
instead of PEGTL_NS::star
to reject empty variant names.
Thanks, @nvmkuruc - we think the problem is actually the usda parser: it should reject your asset with the unnamed variant in it - it's only once an unnamed variant gets created that things go to pot (so we should reject in the creation of VariantSpec's as well). pathParser needs to accept empty variant names so that we can construct paths that identify the VariantSet.
Description of Issue
Sdf (seemingly erroneously) permits unnamed variants, but Usd does not. This creates two situations.
layer.GetObjectAtPath('/prim{variantSet=}')
should always return a variant set spec but it erroneously returns the unnamed variant spec when specified.Sdf should always return the variant set spec and should warn or error if it considers the variant set invalid due to an unnamed variant.
Steps to Reproduce
def "prim" (append variantSets = "color" variants = { string color = "red"} ){ variantSet "color" = { "yellow" { int i = 0 } "red" { int i = 7 } } }
/prim{color=}
refers to the variant set spec."yellow"
with the empty string.def "prim" (append variantSets = "color" variants = {string color = "red"}){ variantSet "color" = { "" { int i = 0 } "red" { int i = 7 } } }
usdcat
on the layer. You should get this output, where the variant set containing the unnamed variant has been completely removed without warning or error.def "prim" ( variants = { string color = "red" } append variantSets = "color" ) { }