HdPrman: Add TfToken support for Riley params, among other
authorblevin <blevin@users.noreply.github.com>
Sat, 3 Feb 2024 04:00:39 +0000 (20:00 -0800)
committerpixar-oss <pixar-oss@users.noreply.github.com>
Sat, 3 Feb 2024 04:11:16 +0000 (20:11 -0800)
types, by re-using type case dispatch provided by
SetParamFromVtValue

(Internal change: 2314105)

third_party/renderman-25/plugin/hdPrman/renderParam.cpp

index 6f834a58ea612223646027db97b720eb68971b95..24e5cd50550c9033196103be8917b85fd8f9d098 100644 (file)
@@ -1371,30 +1371,11 @@ RtParamList
 _ToRtParamList(VtDictionary const& dict)
 {
     RtParamList params;
-    // TODO: Replace with VtVisitValue()
     for (auto const& entry: dict) {
         RtUString riName(entry.first.c_str());
-
-        if (entry.second.IsHolding<int>()) {
-            params.SetInteger(riName, entry.second.UncheckedGet<int>());
-        } else if (entry.second.IsHolding<float>()) {
-            params.SetFloat(riName, entry.second.UncheckedGet<float>());
-        } else if (entry.second.IsHolding<std::string>()) {
-            params.SetString(riName,
-                RtUString(entry.second.UncheckedGet<std::string>().c_str()));
-        } else if (entry.second.IsHolding<VtArray<int>>()) {
-            auto const& array = entry.second.UncheckedGet<VtArray<int>>();
-            params.SetIntegerArray(riName, array.data(), array.size());
-        } else if (entry.second.IsHolding<VtArray<float>>()) {
-            auto const& array = entry.second.UncheckedGet<VtArray<float>>();
-            params.SetFloatArray(riName, array.data(), array.size());
-        } else {
-            TF_CODING_ERROR("Unimplemented setting %s of type %s\n",
-                            entry.first.c_str(),
-                            entry.second.GetTypeName().c_str());
-        }
+        HdPrman_Utils::SetParamFromVtValue(riName, entry.second,
+                                           /* role = */ TfToken(), &params);
     }
-
     return params;
 }