Skip to content

Commit

Permalink
fix primmerge and update userdata nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashheer committed Aug 2, 2023
1 parent a9a4bf6 commit b5ce440
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
6 changes: 6 additions & 0 deletions zeno/include/zeno/types/UserData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class T>
[[deprecated("use set2(name, value)")]]
void setLiterial(std::string const &name, T &&value) {
Expand Down
24 changes: 20 additions & 4 deletions zeno/src/nodes/PortalNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("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 {
Expand All @@ -199,7 +214,7 @@ ZENDEFNODE(GetUserData, {
{"object"},
{"data", {"bool", "hasValue"}},
{{"string", "key", ""}},
{"lifecycle"},
{"deprecated"},
});

struct GetUserData2 : zeno::INode {
Expand All @@ -224,15 +239,16 @@ ZENDEFNODE(GetUserData2, {
struct DelUserData : zeno::INode {
virtual void apply() override {
auto object = get_input("object");
auto key = get_param<std::string>("key");
auto key = get_input2<std::string>("key");
object->userData().del(key);
set_output("object", std::move(object));
}
};

ZENDEFNODE(DelUserData, {
{{"string", "key", ""}, "object"},
{"object"},
{},
{{"string", "key", ""}},
{"lifecycle"},
});

Expand Down
3 changes: 3 additions & 0 deletions zeno/src/nodes/neo/PrimMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrimitiveObject>(*primList[0]);
set_output("prim", std::move(outprim));
Expand Down
22 changes: 0 additions & 22 deletions zeno/src/nodes/prim/WBTestFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("key");
auto key = get_input2<std::string>("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 <class T>
Expand Down

0 comments on commit b5ce440

Please sign in to comment.