From a55c43c7349d0cc280229f69ea7c9bf2993e15ed Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Wed, 18 Oct 2023 23:38:11 +0900 Subject: [PATCH] allow string type for `inputs:varname` --- src/tydra/render-data.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tydra/render-data.cc b/src/tydra/render-data.cc index bc53d8b6..1cb0203b 100644 --- a/src/tydra/render-data.cc +++ b/src/tydra/render-data.cc @@ -1256,7 +1256,7 @@ bool RenderSceneConverter::ConvertUVTexture(const Path &tex_abs_path, // Get value producing attribute(i.e, follow .connection and return // terminal Attribute value) - value::token varname; + std::string varname; TerminalAttributeValue attr; if (!tydra::EvaluateAttribute(*_stage, *readerPrim, "inputs:varname", &attr, &err)) { @@ -1267,18 +1267,22 @@ bool RenderSceneConverter::ConvertUVTexture(const Path &tex_abs_path, } if (auto pv = attr.as()) { - varname = *pv; + varname = (*pv).str(); + } else if (auto pvs = attr.as()) { + varname = (*pvs); + } else if (auto pvsd = attr.as()) { + varname = (*pvsd).value; } else { PUSH_ERROR_AND_RETURN( - "`inputs:varname` must be `token` type, but got " + + "`inputs:varname` must be `string` or `token` type, but got " + attr.type_name()); } - if (varname.str().empty()) { + if (varname.empty()) { PUSH_ERROR_AND_RETURN("`inputs:varname` is empty token."); } DCOUT("inputs:varname = " << varname); - tex.varname_uv = varname.str(); + tex.varname_uv = varname; } else if (const UsdTransform2d *ptransform = pshader->value.as()) { auto result = ConvertTexTransform2d(*_stage, path, *ptransform, &tex);