Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix primmerge and update userdata nodes #1341

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", ""}},
Ashheer marked this conversation as resolved.
Show resolved Hide resolved
{"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
Loading