From 139af8872929e6e9f38e2bc0a51f36667cad4715 Mon Sep 17 00:00:00 2001 From: luzh Date: Wed, 25 Sep 2024 15:45:29 +0800 Subject: [PATCH] [dev] add Stamp. --- ui/zenoedit/launch/serialize.cpp | 15 +++++++++++++++ zeno/src/nodes/PortalNodes.cpp | 21 +++++++++++++++++++++ zeno/src/nodes/ToNodes.cpp | 24 ++++++++++++++++++++---- zenovis/src/optx/RenderEngineOptx.cpp | 9 +++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/ui/zenoedit/launch/serialize.cpp b/ui/zenoedit/launch/serialize.cpp index 5493f8e91c..9a5b54ec76 100644 --- a/ui/zenoedit/launch/serialize.cpp +++ b/ui/zenoedit/launch/serialize.cpp @@ -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. } diff --git a/zeno/src/nodes/PortalNodes.cpp b/zeno/src/nodes/PortalNodes.cpp index b447e09575..95133718de 100644 --- a/zeno/src/nodes/PortalNodes.cpp +++ b/zeno/src/nodes/PortalNodes.cpp @@ -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()); + } + } +}; + +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"); diff --git a/zeno/src/nodes/ToNodes.cpp b/zeno/src/nodes/ToNodes.cpp index 6bfa9c7528..c144c68f53 100644 --- a/zeno/src/nodes/ToNodes.cpp +++ b/zeno/src/nodes/ToNodes.cpp @@ -22,13 +22,17 @@ struct ToView : zeno::INode { virtual void apply() override { auto p = get_input("object"); bool isStatic = has_input("isStatic") ? get_input2("isStatic") : false; + std::string mode = has_input("mode:") ? get_input2("mode:") : ""; + std::string name = has_input("name:") ? get_input2("name:") : ""; + //auto pp = isStatic && hasViewed ? std::make_shared() : 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(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; } @@ -56,6 +60,15 @@ 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)); @@ -63,7 +76,9 @@ struct ToView : zeno::INode { } }; - addtoview(addtoview, p, {}); + //在计算端,没法addViewObject,就相当于没法导cache + if (mode != "UnChanged") + addtoview(addtoview, p, {}, mode, name); hasViewed = true; set_output("object", std::move(p)); } @@ -72,7 +87,8 @@ struct ToView : zeno::INode { ZENDEFNODE(ToView, { {"object", {"bool", "isStatic", "0"}}, {"object", {"string", "viewid"}}, - {}, + {{"string", "mode", "TotalChange"}, + {"string", "name", ""}}, {"layout"}, }); diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index 6652ea383e..86dfb398e5 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -1063,6 +1063,15 @@ struct GraphicsManager { } } + if (0) { + auto& ud = obj->userData(); + if (ud.has("stamp_mode")) { + std::string stamp_mode = ud.get2("stamp_mode"); + if (!stamp_mode.empty()) { + } + } + } + auto ig = std::make_unique(key, obj); zeno::log_info("load_object: loaded graphics to {}", ig.get());