diff --git a/zeno/include/zeno/types/UserData.h b/zeno/include/zeno/types/UserData.h index 80b7ab29ea..7b8762cedd 100644 --- a/zeno/include/zeno/types/UserData.h +++ b/zeno/include/zeno/types/UserData.h @@ -76,6 +76,12 @@ struct UserData { m_data[name] = std::move(value); } + void merge(const UserData& name) { + for (const auto& pair : name.m_data) { + m_data.insert(pair); + } + } + template [[deprecated("use set2(name, value)")]] void setLiterial(std::string const &name, T &&value) { diff --git a/zeno/src/nodes/PortalNodes.cpp b/zeno/src/nodes/PortalNodes.cpp index 191c05ba46..8bb135dd4a 100644 --- a/zeno/src/nodes/PortalNodes.cpp +++ b/zeno/src/nodes/PortalNodes.cpp @@ -180,9 +180,24 @@ ZENDEFNODE(SetUserData, { {"object", "data"}, {"object"}, {{"string", "key", ""}}, - {"lifecycle"}, + {"deprecated"}, }); +struct SetUserData2 : zeno::INode { + virtual void apply() override { + auto object = get_input("object"); + auto key = get_input2("key"); + object->userData().set(key, get_input("data")); + set_output("object", std::move(object)); + } +}; + +ZENDEFNODE(SetUserData2, { + {"object", {"string", "key", ""}, "data"}, + {"object"}, + {}, + {"lifecycle"}, +}); struct GetUserData : zeno::INode { virtual void apply() override { @@ -199,7 +214,7 @@ ZENDEFNODE(GetUserData, { {"object"}, {"data", {"bool", "hasValue"}}, {{"string", "key", ""}}, - {"lifecycle"}, + {"deprecated"}, }); struct GetUserData2 : zeno::INode { @@ -224,15 +239,16 @@ ZENDEFNODE(GetUserData2, { struct DelUserData : zeno::INode { virtual void apply() override { auto object = get_input("object"); - auto key = get_param("key"); + auto key = get_input2("key"); object->userData().del(key); + set_output("object", std::move(object)); } }; ZENDEFNODE(DelUserData, { + {{"string", "key", ""}, "object"}, {"object"}, {}, - {{"string", "key", ""}}, {"lifecycle"}, }); diff --git a/zeno/src/nodes/neo/PrimMerge.cpp b/zeno/src/nodes/neo/PrimMerge.cpp index b6c256902d..7d75e04a13 100644 --- a/zeno/src/nodes/neo/PrimMerge.cpp +++ b/zeno/src/nodes/neo/PrimMerge.cpp @@ -559,6 +559,9 @@ struct PrimMerge : INode { } } int oMatNum = matNameList.size(); + for(auto &p:primList){ + outprim->userData().merge(p->userData()); + } outprim->userData().set2("matNum", oMatNum); //auto outprim = std::make_shared(*primList[0]); set_output("prim", std::move(outprim)); diff --git a/zeno/src/nodes/prim/WBTestFunction.cpp b/zeno/src/nodes/prim/WBTestFunction.cpp index 65a7b2f951..d565b9041a 100644 --- a/zeno/src/nodes/prim/WBTestFunction.cpp +++ b/zeno/src/nodes/prim/WBTestFunction.cpp @@ -413,28 +413,6 @@ ZENO_DEFNODE(VisPrimAttrValue_Modify)( { {"WBTest"}, }); - /////////////////// -/* SetUserDate_M */ -/////////////////// -struct SetUserData_M : zeno::INode { - virtual void apply() override { - auto object = get_input("object"); - //auto key = get_param("key"); - auto key = get_input2("key"); - object->userData().set(key, get_input("data")); - set_output("object", std::move(object)); - } -}; - -ZENDEFNODE(SetUserData_M, { - {{"string", "key", ""}, "object", "data"}, - {"object"}, - { - //{"string", "key", ""} - }, - {"WBTest"}, -}); - // FDGather.cpp template