Skip to content

Commit

Permalink
[dev] add Stamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
legobadman committed Sep 25, 2024
1 parent 64d5768 commit 139af88
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
15 changes: 15 additions & 0 deletions ui/zenoedit/launch/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,21 @@ static void serializeGraph(IGraphsModel* pGraphsModel, const QModelIndex& subgId
AddStringList({"bindNodeInput", viewerIdent, "object", ident, output.info.name}, writer);
bool isStatic = opts & OPT_ONCE;
AddVariantList({"setNodeInput", viewerIdent, "isStatic", isStatic}, "int", writer);

if (name == "Stamp") {
//stamp节点要特殊处理,控制zencache是否导出
auto iterParam = params.find("mode");
if (iterParam != params.end()) {
QString mode = iterParam.value().value.toString();
AddVariantList({ "setNodeParam", viewerIdent, "mode", mode }, "string", writer);
}
iterParam = params.find("name");
if (iterParam != params.end()) {
QString name = iterParam.value().value.toString();
AddVariantList({ "setNodeParam", viewerIdent, "name", name }, "string", writer);
}
}

AddStringList({"completeNode", viewerIdent}, writer);
break; //current node is not a subgraph node, so only one output is needed to view this obj.
}
Expand Down
21 changes: 21 additions & 0 deletions zeno/src/nodes/PortalNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ ZENDEFNODE(Route, {
});


struct Stamp : zeno::INode {
virtual void apply() override {
if (has_input("input")) {
auto obj = get_input("input");
set_output("output", std::move(obj));
}
else {
set_output("output", std::make_shared<zeno::DummyObject>());
}
}
};

ZENDEFNODE(Stamp, {
{"input"},
{"output"},
{{"enum UnChanged DataChange ShapeChange TotalChange", "mode", "UnChanged"},
{"string", "name", ""}},
{"lifecycle"}
});


struct Clone : zeno::INode {
virtual void apply() override {
auto obj = get_input("object");
Expand Down
24 changes: 20 additions & 4 deletions zeno/src/nodes/ToNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ struct ToView : zeno::INode {
virtual void apply() override {
auto p = get_input("object");
bool isStatic = has_input("isStatic") ? get_input2<bool>("isStatic") : false;
std::string mode = has_input("mode:") ? get_input2<std::string>("mode:") : "";
std::string name = has_input("name:") ? get_input2<std::string>("name:") : "";

//auto pp = isStatic && hasViewed ? std::make_shared<DummyObject>() : p->clone();
auto addtoview = [&] (auto const &addtoview, zany const &p, std::string const &postfix) -> void {
auto addtoview = [&] (auto const &addtoview, zany const &p, std::string const &postfix,
std::string const &mode, std::string const &name) -> void {
if (auto *lst = dynamic_cast<ListObject *>(p.get())) {
log_info("ToView got ListObject (size={}), expanding", lst->arr.size());
for (size_t i = 0; i < lst->arr.size(); i++) {
zany const &lp = lst->arr[i];
addtoview(addtoview, lp, postfix + ":LIST" + std::to_string(i));
addtoview(addtoview, lp, postfix + ":LIST" + std::to_string(i), mode, name);
}
return;
}
Expand Down Expand Up @@ -56,14 +60,25 @@ struct ToView : zeno::INode {
key.append(std::to_string(getThisSession()->globalState->frameid));
key.push_back(':');
key.append(std::to_string(getThisSession()->globalState->sessionid));

if (!name.empty()) {
key = name;
}
if (!mode.empty()) {
auto& ud = pp->userData();
ud.set2("stamp_mode", mode);
}

log_debug("ToView: add view object [{}] of type {}", key, cppdemangle(typeid(*p)));
getThisSession()->globalComm->addViewObject(key, std::move(pp));
set_output2("viewid", std::move(key));
}
}
};

addtoview(addtoview, p, {});
//在计算端,没法addViewObject,就相当于没法导cache
if (mode != "UnChanged")
addtoview(addtoview, p, {}, mode, name);
hasViewed = true;
set_output("object", std::move(p));
}
Expand All @@ -72,7 +87,8 @@ struct ToView : zeno::INode {
ZENDEFNODE(ToView, {
{"object", {"bool", "isStatic", "0"}},
{"object", {"string", "viewid"}},
{},
{{"string", "mode", "TotalChange"},
{"string", "name", ""}},
{"layout"},
});

Expand Down
9 changes: 9 additions & 0 deletions zenovis/src/optx/RenderEngineOptx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,15 @@ struct GraphicsManager {
}
}

if (0) {
auto& ud = obj->userData();
if (ud.has("stamp_mode")) {
std::string stamp_mode = ud.get2<std::string>("stamp_mode");
if (!stamp_mode.empty()) {
}
}
}

auto ig = std::make_unique<ZxxGraphic>(key, obj);

zeno::log_info("load_object: loaded graphics to {}", ig.get());
Expand Down

0 comments on commit 139af88

Please sign in to comment.