From 78a752ac44b4f966b02bf89650928fb4e3817549 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Fri, 12 Apr 2024 14:03:21 +0800 Subject: [PATCH 01/29] m_near 0.001 --- zenovis/src/Camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zenovis/src/Camera.cpp b/zenovis/src/Camera.cpp index aca4d46924..56a0354de5 100644 --- a/zenovis/src/Camera.cpp +++ b/zenovis/src/Camera.cpp @@ -82,7 +82,7 @@ void Camera::placeCamera(glm::vec3 pos, glm::vec3 front, glm::vec3 up) { m_proj = glm::orthoZO(-radius * getAspect(), radius * getAspect(), -radius, radius, m_far, m_near); } else { - m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), m_near); + m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), 0.001); } } From 02f21d2ce99fe2985106493d4d7741164bfbf07d Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Fri, 12 Apr 2024 15:35:13 +0800 Subject: [PATCH 02/29] seperate-aov --- ui/zenoedit/launch/optixcmd.cpp | 3 + zenovis/xinxinoptix/optixPathTracer.cpp | 86 ++++++++++++++++--------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/ui/zenoedit/launch/optixcmd.cpp b/ui/zenoedit/launch/optixcmd.cpp index 8bde9a3374..3a9ed37175 100644 --- a/ui/zenoedit/launch/optixcmd.cpp +++ b/ui/zenoedit/launch/optixcmd.cpp @@ -51,6 +51,7 @@ int optixcmd(const QCoreApplication& app, int port) {"video", "video", "export video"}, {"aov", "aov", "aov"}, {"exr", "exr", "exr"}, + {"mask", "mask", "mask"}, {"needDenoise", "needDenoise", "needDenoise"}, {"videoname", "videoname", "export video's name"}, {"subzsg", "subgraphzsg", "subgraph zsg file path"}, @@ -116,6 +117,8 @@ int optixcmd(const QCoreApplication& app, int port) ud.set2("output_aov", enableAOV != 0); ud.set2("output_exr", exportExr != 0); ud.set2("optix_show_background", optixShowBackground); + int enableMask = cmdParser.isSet("mask") ? cmdParser.value("mask").toInt() : 0; + ud.set2("output_mask", enableMask != 0); param.videoName = cmdParser.isSet("videoname") ? cmdParser.value("videoname") : "output.mp4"; param.subZsg = cmdParser.isSet("subzsg") ? cmdParser.value("subzsg") : ""; #else diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index d4251bdb72..4f4ba44181 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -3809,6 +3809,26 @@ static void save_exr(float3* ptr, int w, int h, std::string path) { } } } +static void save_png_data(std::string path, int w, int h, float* ptr) { + std::vector data; + data.reserve(w * h * 3); + for (auto i = 0; i < w * h * 3; i++) { + data.push_back(std::lround(ptr[i] * 255.0f)); + } + std::string native_path = zeno::create_directories_when_write_file(path); + stbi_flip_vertically_on_write(1); + stbi_write_png(native_path.c_str(), w, h, 3, data.data(),0); +} +static void save_png_color(std::string path, int w, int h, float* ptr) { + std::vector data; + data.reserve(w * h * 3); + for (auto i = 0; i < w * h * 3; i++) { + data.push_back(std::lround(pow(ptr[i], 1.0f/2.2f) * 255.0f)); + } + std::string native_path = zeno::create_directories_when_write_file(path); + stbi_flip_vertically_on_write(1); + stbi_write_png(native_path.c_str(), w, h, 3, data.data(),0); +} void optixrender(int fbo, int samples, bool denoise, bool simpleRender) { bool imageRendered = false; @@ -3849,40 +3869,44 @@ void optixrender(int fbo, int samples, bool denoise, bool simpleRender) { bool enable_output_mask = zeno::getSession().userData().get2("output_mask", false); auto exr_path = path.substr(0, path.size() - 4) + ".exr"; if (enable_output_mask) { - std::vector data; - data.reserve(w * h * 3); - float* ptr = (float *)optixgetimg_extra("mask"); - for (auto i = 0; i < w * h * 3; i++) { - data.push_back(int(ptr[i])); - } - std::string native_path = zeno::create_directories_when_write_file(path + "_mask.png"); - stbi_flip_vertically_on_write(1); - stbi_write_png(native_path.c_str(), w, h, 3, data.data(),0); + path = path.substr(0, path.size() - 4); + save_png_data(path + "_mask.png", w, h, (float*)optixgetimg_extra("mask")); } // AOV if (enable_output_aov) { - zeno::create_directories_when_write_file(exr_path); - SaveMultiLayerEXR( - { - (float*)optixgetimg_extra("color"), - (float*)optixgetimg_extra("diffuse"), - (float*)optixgetimg_extra("specular"), - (float*)optixgetimg_extra("transmit"), - (float*)optixgetimg_extra("background"), - (float*)optixgetimg_extra("mask"), - }, - w, - h, - { - "", - "diffuse.", - "specular.", - "transmit.", - "background.", - "mask.", - }, - exr_path.c_str() - ); + if (enable_output_exr) { + zeno::create_directories_when_write_file(exr_path); + SaveMultiLayerEXR( + { + (float*)optixgetimg_extra("color"), + (float*)optixgetimg_extra("diffuse"), + (float*)optixgetimg_extra("specular"), + (float*)optixgetimg_extra("transmit"), + (float*)optixgetimg_extra("background"), + (float*)optixgetimg_extra("mask"), + }, + w, + h, + { + "", + "diffuse.", + "specular.", + "transmit.", + "background.", + "mask.", + }, + exr_path.c_str() + ); + + } + else { + path = path.substr(0, path.size() - 4); + save_png_color(path + ".aov.diffuse.png", w, h, (float*)optixgetimg_extra("diffuse")); + save_png_color(path + ".aov.specular.png", w, h, (float*)optixgetimg_extra("specular")); + save_png_color(path + ".aov.transmit.png", w, h, (float*)optixgetimg_extra("transmit")); + save_png_data(path + ".aov.background.png", w, h, (float*)optixgetimg_extra("background")); + save_png_data(path + ".aov.mask.png", w, h, (float*)optixgetimg_extra("mask")); + } } else { if (enable_output_exr) { From 726587e92855a64ce25bf95805857382297b35cc Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Fri, 12 Apr 2024 18:24:31 +0800 Subject: [PATCH 03/29] vertex color --- projects/Alembic/ReadAlembic.cpp | 59 +++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/projects/Alembic/ReadAlembic.cpp b/projects/Alembic/ReadAlembic.cpp index 98ca8a6639..f76e33fda2 100644 --- a/projects/Alembic/ReadAlembic.cpp +++ b/projects/Alembic/ReadAlembic.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef ZENO_WITH_PYTHON3 #include @@ -417,6 +418,62 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro } attr_from_data_vec(prim, samp.getScope(), p.getName(), data); } + else if (IC4fGeomParam::matches(p)) { + IC4fGeomParam param(arbattrs, p.getName()); + + IC4fGeomParam::Sample samp = param.getIndexedValue(iSS); + std::vector data; + data.resize(samp.getVals()->size()); + std::vector data_xyz(samp.getVals()->size()); + std::vector data_w(samp.getVals()->size()); + for (auto i = 0; i < samp.getVals()->size(); i++) { + auto v = samp.getVals()->get()[i]; + data[i] = {v[0], v[1], v[2], v[3]}; + data_xyz[i] = {v[0], v[1], v[2]}; + data_w[i] = v[3]; + } + if (!read_done) { + log_info("[alembic] C4f attr {}, len {}.", p.getName(), data.size()); + } + attr_from_data_vec(prim, samp.getScope(), p.getName(), data); + attr_from_data_vec(prim, samp.getScope(), p.getName() + "_rgb", data_xyz); + attr_from_data_vec(prim, samp.getScope(), p.getName() + "_a", data_w); + } + else { + log_info("[alembic] unknown attr {}.", p.getName()); + zeno::log_info("getExtent {} ", p.getDataType().getExtent()); + zeno::log_info("getNumBytes {} ", p.getDataType().getNumBytes()); + zeno::log_info("getPod {} ", p.getDataType().getPod()); + } + } + { + if (prim->loops.attr_keys().size() == 0) { + return; + } + if (prim->loops.attr_keys().size() == 1 && prim->loops.has_attr("uvs")) { + return; + } + if (!prim->loops.has_attr("uvs")) { + prim->loops.add_attr("uvs"); + prim->uvs.emplace_back(); + } + { + std::vector uvs(prim->loops.size()); + auto &uv_index = prim->loops.attr("uvs"); + for (auto i = 0; i < prim->loops.size(); i++) { + uvs[i] = prim->uvs[uv_index[i]]; + } + prim->uvs.values = uvs; + std::iota(uv_index.begin(), uv_index.end(), 0); + prim->loops.foreach_attr([&] (auto const &key, auto &arr) { + if (key == "uvs") { + return; + } + using T = std::decay_t; + auto &attr = prim->uvs.add_attr(key); + std::copy(arr.begin(), arr.end(), attr.begin()); + }); + } } } @@ -1358,7 +1415,7 @@ ZENDEFNODE(PrimsFilterInUserdata, { {"bool", "fuzzy", "0"}, }, { - {"out"}, + {"list", "out"}, }, {}, {"alembic"}, From 900ab28e2fe0ca6a2792745ae0f2dbb981a768b8 Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Fri, 19 Apr 2024 14:48:19 +0800 Subject: [PATCH 04/29] start zeno in logpanel --- ui/zenoedit/main.cpp | 17 +++++++++++++++++ ui/zenoedit/panel/zlogpanel.cpp | 32 +++++++++++++++++++++++++++++++ ui/zenoedit/panel/zlogpanel.h | 2 ++ ui/zenoedit/zenomainwindow.cpp | 34 +++++++++++++++++++++++++++++++++ ui/zenoedit/zenomainwindow.h | 1 + 5 files changed, 86 insertions(+) diff --git a/ui/zenoedit/main.cpp b/ui/zenoedit/main.cpp index ea814138eb..eb08bdd615 100644 --- a/ui/zenoedit/main.cpp +++ b/ui/zenoedit/main.cpp @@ -139,5 +139,22 @@ int main(int argc, char *argv[]) ZenoMainWindow mainWindow; zeno::getSession().eventCallbacks->triggerEvent("editorConstructed"); mainWindow.showMaximized(); + if (argc >= 2) { + QCommandLineParser cmdParser; + cmdParser.addHelpOption(); + cmdParser.addOptions({ + {"zsg", "zsg", "zsg"}, + {"paramsJson", "paramsJson", "paramsJson"} + }); + cmdParser.process(a); + QString zsgPath; + if (cmdParser.isSet("zsg")) + zsgPath = cmdParser.value("zsg"); + QString paramsJson; + if (cmdParser.isSet("paramsJson")) + paramsJson = cmdParser.value("paramsJson"); + if (!zsgPath.isEmpty()) + mainWindow.openFileAndUpdateParam(zsgPath, paramsJson); + } return a.exec(); } diff --git a/ui/zenoedit/panel/zlogpanel.cpp b/ui/zenoedit/panel/zlogpanel.cpp index 12cee1962c..eb1dbff6a8 100644 --- a/ui/zenoedit/panel/zlogpanel.cpp +++ b/ui/zenoedit/panel/zlogpanel.cpp @@ -322,7 +322,39 @@ void ZPlainLogPanel::initMsgs() } } +void ZPlainLogPanel::contextMenuEvent(QContextMenuEvent* event) +{ + QMenu menu; + if (this->textCursor().hasSelection()) + { + QString text = this->textCursor().selectedText(); + menu.addAction(tr("Start Program"), this, [=]() { + QString str = R"(\")"; + QString newStr = R"(""")"; + QString cmd = text; + cmd = cmd.replace(str, newStr); + QProcess process; + auto cmdArgs = process.splitCommand(cmd); + process.setProgram(cmdArgs.takeFirst()); + QStringList args; + for (int i = 0; i < cmdArgs.size(); i++) + { + QString arg = cmdArgs.at(i); + if (arg == "--zsg" || arg == "--paramsJson") + { + args << arg << cmdArgs.at(++i); + } + } + process.setArguments(args); + if (!process.startDetached()) + zeno::log_error("Program start error!"); + }); + menu.addAction(tr("&Copy"), this, &ZPlainLogPanel::copy, QKeySequence::Copy); + } + menu.addAction(tr("Select All"), this, &ZPlainLogPanel::selectAll, QKeySequence::SelectAll); + menu.exec(cursor().pos()); +} ZlogPanel::ZlogPanel(QWidget* parent) : QWidget(parent) diff --git a/ui/zenoedit/panel/zlogpanel.h b/ui/zenoedit/panel/zlogpanel.h index b9cf17b9cc..2224149f70 100644 --- a/ui/zenoedit/panel/zlogpanel.h +++ b/ui/zenoedit/panel/zlogpanel.h @@ -97,6 +97,8 @@ class ZPlainLogPanel : public QPlainTextEdit public: ZPlainLogPanel(QWidget* parent = nullptr); void initMsgs(); +protected: + void contextMenuEvent(QContextMenuEvent* event) override; }; diff --git a/ui/zenoedit/zenomainwindow.cpp b/ui/zenoedit/zenomainwindow.cpp index cf807a8282..4b611cf62d 100644 --- a/ui/zenoedit/zenomainwindow.cpp +++ b/ui/zenoedit/zenomainwindow.cpp @@ -1801,6 +1801,40 @@ bool ZenoMainWindow::isRecordByCommandLine() const return m_bRecordByCommandLine; } +void ZenoMainWindow::openFileAndUpdateParam(const QString& zsgPath, const QString& paramsJson) +{ + if (!zsgPath.isEmpty()) + { + openFile(zsgPath); + } + if (!paramsJson.isEmpty()) + { + qDebug() << paramsJson; + //parse paramsJson + rapidjson::Document configDoc; + configDoc.Parse(paramsJson.toUtf8()); + if (!configDoc.IsObject()) + { + zeno::log_error("config file is corrupted"); + } + IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel(); + ZASSERT_EXIT(pGraphsModel); + FuckQMap commands = pGraphsModel->commandParams(); + for (auto& [key, param] : commands) + { + if (configDoc.HasMember(param.name.toUtf8())) + { + const auto& value = UiHelper::parseJson(configDoc[param.name.toStdString().c_str()], nullptr); + const auto& index = pGraphsModel->indexFromPath(key); + if (index.isValid()) + { + pGraphsModel->ModelSetData(index, value, ROLE_PARAM_VALUE); + } + } + } + } +} + void ZenoMainWindow::sortRecentFile(QStringList &lst) { qSort(lst.begin(), lst.end(), [](const QString &s1, const QString &s2) { diff --git a/ui/zenoedit/zenomainwindow.h b/ui/zenoedit/zenomainwindow.h index ad50437b73..2ccae1f137 100644 --- a/ui/zenoedit/zenomainwindow.h +++ b/ui/zenoedit/zenomainwindow.h @@ -55,6 +55,7 @@ class ZenoMainWindow : public QMainWindow void sortRecentFile(QStringList &lst); bool isOnlyOptixWindow() const; bool isRecordByCommandLine() const; + void openFileAndUpdateParam(const QString& path, const QString& paramJson); QLineEdit* selected = nullptr; ZenoLights* lightPanel = nullptr; From c357ffa94d11490892fb0f0ec0e1c22707e69813 Mon Sep 17 00:00:00 2001 From: luzh Date: Fri, 19 Apr 2024 16:17:53 +0800 Subject: [PATCH 05/29] [fix] get prim socket name on transformation. --- ui/zenoedit/viewportinteraction/nodesync.cpp | 12 ++++++++---- ui/zenoedit/viewportinteraction/nodesync.h | 3 ++- ui/zenoedit/viewportinteraction/transform.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/zenoedit/viewportinteraction/nodesync.cpp b/ui/zenoedit/viewportinteraction/nodesync.cpp index 71ca50f29a..d6083f306a 100644 --- a/ui/zenoedit/viewportinteraction/nodesync.cpp +++ b/ui/zenoedit/viewportinteraction/nodesync.cpp @@ -81,7 +81,7 @@ std::optional NodeSyncMgr::checkNodeLinkedSpecificNode(const QMode auto this_outputs = node.data(ROLE_OUTPUTS).value(); auto this_node_id = node.data(ROLE_OBJID).toString(); // TransformPrimitive-1f4erf21 auto this_node_type = this_node_id.section("-", 1); // TransformPrimitive - auto prim_sock_name = getPrimSockName(this_node_type.toStdString()); + auto prim_sock_name = getPrimSockName(node); QString sockName = QString::fromLocal8Bit(prim_sock_name.c_str()); if (this_outputs.find(sockName) == this_outputs.end()) @@ -195,14 +195,18 @@ void NodeSyncMgr::updateNodeParamString(NodeLocation node_location, } std::string NodeSyncMgr::getPrimSockName(const std::string& node_type) { + //6666666666666666666666666666 if (m_prim_sock_map.find(node_type) != m_prim_sock_map.end()) return m_prim_sock_map[node_type]; return "prim"; } -std::string NodeSyncMgr::getPrimSockName(NodeLocation& node_location) { - auto node_type = node_location.node.data(ROLE_OBJID).toString().section("-", 1); - return getPrimSockName(node_type.toStdString()); +std::string NodeSyncMgr::getPrimSockName(const QModelIndex& nodeIdx) { + auto node_type = nodeIdx.data(ROLE_OBJID).toString().section("-", 1); + OUTPUT_SOCKETS outputs = nodeIdx.data(ROLE_OUTPUTS).value(); + ZASSERT_EXIT(!outputs.isEmpty(), ""); + QString name = outputs.begin()->key(); + return name.toStdString(); } } \ No newline at end of file diff --git a/ui/zenoedit/viewportinteraction/nodesync.h b/ui/zenoedit/viewportinteraction/nodesync.h index 85d495006a..04abfe93c2 100644 --- a/ui/zenoedit/viewportinteraction/nodesync.h +++ b/ui/zenoedit/viewportinteraction/nodesync.h @@ -164,7 +164,7 @@ class NodeSyncMgr { // other tool functions std::string getPrimSockName(const std::string& node_type); - std::string getPrimSockName(NodeLocation& node_location); + std::string getPrimSockName(const QModelIndex& nodeIdx); NodeSyncMgr(const NodeSyncMgr &) = delete; const NodeSyncMgr &operator=(const NodeSyncMgr &) = delete; @@ -175,6 +175,7 @@ class NodeSyncMgr { registerDefaultSocketName(); }; void registerDefaultSocketName() { + //дÕâ´úÂëÕæÀÏÁù m_prim_sock_map["BindMaterial"] = "object"; m_prim_sock_map["TransformPrimitive"] = "outPrim"; } diff --git a/ui/zenoedit/viewportinteraction/transform.cpp b/ui/zenoedit/viewportinteraction/transform.cpp index 16cde2b064..cac59fb4b4 100644 --- a/ui/zenoedit/viewportinteraction/transform.cpp +++ b/ui/zenoedit/viewportinteraction/transform.cpp @@ -314,7 +314,7 @@ void FakeTransformer::createNewTransformNode(NodeLocation& node_location, const std::string& obj_name) { auto& node_sync = NodeSyncMgr::GetInstance(); - auto out_sock = node_sync.getPrimSockName(node_location); + auto out_sock = node_sync.getPrimSockName(node_location.node); auto new_node_location = node_sync.generateNewNode(node_location, "PrimitiveTransform", out_sock, From 01d6239347c294a32e4d74a33f73db4ef55a4026 Mon Sep 17 00:00:00 2001 From: luzh Date: Mon, 22 Apr 2024 15:30:44 +0800 Subject: [PATCH 06/29] add cleanupWhenExit interface for engine. and call them when exit. --- ui/zenoedit/dock/ztabdockwidget.cpp | 4 ++-- ui/zenoedit/dock/ztabdockwidget.h | 2 +- ui/zenoedit/viewport/displaywidget.cpp | 6 ++++-- ui/zenoedit/viewport/displaywidget.h | 2 +- ui/zenoedit/viewport/optixviewport.cpp | 11 +++++++++++ ui/zenoedit/viewport/optixviewport.h | 3 +++ ui/zenoedit/viewport/viewportwidget.cpp | 6 ++++++ ui/zenoedit/viewport/viewportwidget.h | 1 + ui/zenoedit/viewport/zenovis.cpp | 10 ++++++++++ ui/zenoedit/viewport/zenovis.h | 1 + ui/zenoedit/zenomainwindow.cpp | 12 ++---------- zenovis/include/zenovis/RenderEngine.h | 1 + zenovis/include/zenovis/Scene.h | 1 + zenovis/src/Scene.cpp | 11 +++++++++++ zenovis/src/bate/RenderEngineBate.cpp | 4 ++++ zenovis/src/optx/RenderEngineOptx.cpp | 4 ++++ zenovis/src/zhxx/RenderEngineZhxx.cpp | 4 ++++ 17 files changed, 67 insertions(+), 16 deletions(-) diff --git a/ui/zenoedit/dock/ztabdockwidget.cpp b/ui/zenoedit/dock/ztabdockwidget.cpp index 56d20b09c7..32322ccce4 100644 --- a/ui/zenoedit/dock/ztabdockwidget.cpp +++ b/ui/zenoedit/dock/ztabdockwidget.cpp @@ -119,7 +119,7 @@ QWidget* ZTabDockWidget::widget() const return m_tabWidget; } -void ZTabDockWidget::testCleanupGL() +void ZTabDockWidget::cleanupView() { for (int i = 0; i < m_tabWidget->count(); i++) { @@ -127,7 +127,7 @@ void ZTabDockWidget::testCleanupGL() if (DockContent_View* pDis = qobject_cast(wid)) { DisplayWidget* pWid = pDis->getDisplayWid(); if (pWid) - pWid->testCleanUp(); + pWid->cleanupView(); } } } diff --git a/ui/zenoedit/dock/ztabdockwidget.h b/ui/zenoedit/dock/ztabdockwidget.h index 91ade1f1a6..89a5d07da1 100644 --- a/ui/zenoedit/dock/ztabdockwidget.h +++ b/ui/zenoedit/dock/ztabdockwidget.h @@ -46,7 +46,7 @@ class ZTabDockWidget : public QDockWidget void onPrimitiveSelected(const std::unordered_set& primids); void onUpdateViewport(const QString& action); void updateLights(); - void testCleanupGL(); + void cleanupView(); static PANEL_TYPE title2Type(const QString &title); diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index dbe2b70626..5b83f270e0 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -84,10 +84,12 @@ void DisplayWidget::initRecordMgr() [=](int frameid) { zeno::log_info("frame {} has been recorded", frameid); }); } -void DisplayWidget::testCleanUp() +void DisplayWidget::cleanupView() { if (m_glView) - m_glView->testCleanUp(); + m_glView->cleanUpView(); + else + m_optixView->cleanupView(); } void DisplayWidget::cleanUpScene() diff --git a/ui/zenoedit/viewport/displaywidget.h b/ui/zenoedit/viewport/displaywidget.h index f31186e8f6..5aaa263850 100644 --- a/ui/zenoedit/viewport/displaywidget.h +++ b/ui/zenoedit/viewport/displaywidget.h @@ -28,7 +28,7 @@ class DisplayWidget : public QWidget QSize sizeHint() const override; Zenovis* getZenoVis() const; void runAndRecord(const VideoRecInfo& info); - void testCleanUp(); + void cleanupView(); void cleanUpScene(); void beforeRun(); void afterRun(); diff --git a/ui/zenoedit/viewport/optixviewport.cpp b/ui/zenoedit/viewport/optixviewport.cpp index cb85615c84..47c4f80c2c 100644 --- a/ui/zenoedit/viewport/optixviewport.cpp +++ b/ui/zenoedit/viewport/optixviewport.cpp @@ -331,6 +331,11 @@ void OptixWorker::onCleanUpScene() m_zenoVis->cleanUpScene(); } +void OptixWorker::onCleanUpView() +{ + m_zenoVis->cleanupView(); +} + void OptixWorker::onSetBackground(bool bShowBg) { auto& ud = zeno::getSession().userData(); @@ -427,6 +432,7 @@ ZOptixViewport::ZOptixViewport(QWidget* parent) connect(this, &ZOptixViewport::sig_modifyLightData, m_worker, &OptixWorker::onModifyLightData); connect(this, &ZOptixViewport::sig_updateCameraProp, m_worker, &OptixWorker::onUpdateCameraProp); connect(this, &ZOptixViewport::sig_cleanUpScene, m_worker, &OptixWorker::onCleanUpScene); + connect(this, &ZOptixViewport::sig_cleanUpView, m_worker, &OptixWorker::onCleanUpView); connect(this, &ZOptixViewport::sig_setBackground, m_worker, &OptixWorker::onSetBackground); connect(this, &ZOptixViewport::sig_setdata_on_optix_thread, m_worker, &OptixWorker::onSetData); @@ -505,6 +511,11 @@ void ZOptixViewport::cleanUpScene() emit sig_cleanUpScene(); } +void ZOptixViewport::cleanupView() +{ + emit sig_cleanUpView(); +} + void ZOptixViewport::modifyLightData(UI_VECTYPE pos, UI_VECTYPE scale, UI_VECTYPE rotate, UI_VECTYPE color, float intensity, QString name, UI_VECTYPE skipParam) { emit sig_modifyLightData(pos, scale, rotate, color, intensity, name, skipParam); diff --git a/ui/zenoedit/viewport/optixviewport.h b/ui/zenoedit/viewport/optixviewport.h index d7ef63a06b..e9864b38bb 100644 --- a/ui/zenoedit/viewport/optixviewport.h +++ b/ui/zenoedit/viewport/optixviewport.h @@ -42,6 +42,7 @@ public slots: void onModifyLightData(UI_VECTYPE pos, UI_VECTYPE scale, UI_VECTYPE rotate, UI_VECTYPE color, float intensity, QString nodename, UI_VECTYPE skipParam); void onUpdateCameraProp(float aperture, float disPlane, UI_VECTYPE skipParam = UI_VECTYPE()); void onCleanUpScene(); + void onCleanUpView(); void onSetBackground(bool bShowBg); void onSetData(float, float, float, bool, bool); @@ -84,6 +85,7 @@ class ZOptixViewport : public QWidget void setSlidFeq(int feq); void modifyLightData(UI_VECTYPE pos, UI_VECTYPE scale, UI_VECTYPE rotate, UI_VECTYPE color, float intensity, QString name, UI_VECTYPE skipParam); void cleanUpScene(); + void cleanupView(); zenovis::ZOptixCameraSettingInfo getdata_from_optix_thread(); void setdata_on_optix_thread(zenovis::ZOptixCameraSettingInfo value); @@ -107,6 +109,7 @@ class ZOptixViewport : public QWidget void sig_modifyLightData(UI_VECTYPE pos, UI_VECTYPE scale, UI_VECTYPE rotate, UI_VECTYPE color, float intensity, QString name, UI_VECTYPE skipParam); void sig_updateCameraProp(float aperture, float disPlane, UI_VECTYPE skipParam = UI_VECTYPE()); void sig_cleanUpScene(); + void sig_cleanUpView(); void sig_setBackground(bool bShowBg); void sig_setdata_on_optix_thread(float, float, float, bool, bool); diff --git a/ui/zenoedit/viewport/viewportwidget.cpp b/ui/zenoedit/viewport/viewportwidget.cpp index db0866c991..d43bcc9375 100644 --- a/ui/zenoedit/viewport/viewportwidget.cpp +++ b/ui/zenoedit/viewport/viewportwidget.cpp @@ -133,6 +133,12 @@ void ViewportWidget::testCleanUp() m_fakeTrans.reset(); } +void ViewportWidget::cleanUpView() +{ + if (m_zenovis) + m_zenovis->cleanupView(); +} + namespace { struct OpenGLProcAddressHelper { inline static QGLContext *ctx; diff --git a/ui/zenoedit/viewport/viewportwidget.h b/ui/zenoedit/viewport/viewportwidget.h index 3a40259b1f..af8e7a55af 100644 --- a/ui/zenoedit/viewport/viewportwidget.h +++ b/ui/zenoedit/viewport/viewportwidget.h @@ -25,6 +25,7 @@ class ViewportWidget : public QGLWidget ViewportWidget(QWidget* parent = nullptr); ~ViewportWidget(); void testCleanUp(); + void cleanUpView(); void initializeGL() override; void resizeGL(int nx, int ny) override; void paintGL() override; diff --git a/ui/zenoedit/viewport/zenovis.cpp b/ui/zenoedit/viewport/zenovis.cpp index 2b879b210e..423e87da16 100644 --- a/ui/zenoedit/viewport/zenovis.cpp +++ b/ui/zenoedit/viewport/zenovis.cpp @@ -120,6 +120,16 @@ void Zenovis::cleanUpScene() pScene->cleanUpScene(); } +void Zenovis::cleanupView() +{ + if (!session) + return; + + auto pScene = session->get_scene(); + ZASSERT_EXIT(pScene); + pScene->cleanupView(); +} + void Zenovis::startPlay(bool bPlaying) { m_playing = bPlaying; diff --git a/ui/zenoedit/viewport/zenovis.h b/ui/zenoedit/viewport/zenovis.h index e1c0c1977c..5062249232 100644 --- a/ui/zenoedit/viewport/zenovis.h +++ b/ui/zenoedit/viewport/zenovis.h @@ -54,6 +54,7 @@ public slots: void setLoopPlaying(bool enable); bool isLoopPlaying(); void cleanUpScene(); + void cleanupView(); //private: void doFrameUpdate(); diff --git a/ui/zenoedit/zenomainwindow.cpp b/ui/zenoedit/zenomainwindow.cpp index cf807a8282..750bea4488 100644 --- a/ui/zenoedit/zenomainwindow.cpp +++ b/ui/zenoedit/zenomainwindow.cpp @@ -1387,16 +1387,8 @@ void ZenoMainWindow::closeEvent(QCloseEvent *event) //clean up opengl components. auto docks = findChildren(QString(), Qt::FindDirectChildrenOnly); - for (ZTabDockWidget *pDock : docks) { - pDock->close(); - try { - //pDock->testCleanupGL(); - } catch (...) { - //QString errMsg = QString::fromLatin1(e.what()); - int j; - j = 0; - } - //delete pDock; + for (ZTabDockWidget* pDock : docks) { + pDock->cleanupView(); } // trigger destroy event diff --git a/zenovis/include/zenovis/RenderEngine.h b/zenovis/include/zenovis/RenderEngine.h index a5c0ad58b9..7ce48ce0b5 100644 --- a/zenovis/include/zenovis/RenderEngine.h +++ b/zenovis/include/zenovis/RenderEngine.h @@ -16,6 +16,7 @@ struct RenderEngine { virtual void draw(bool record) = 0; virtual void update() = 0; virtual void cleanupOptix() = 0; + virtual void cleanupWhenExit() = 0; virtual ~RenderEngine() = default; }; diff --git a/zenovis/include/zenovis/Scene.h b/zenovis/include/zenovis/Scene.h index 9f7a6adbd0..2d379bc035 100644 --- a/zenovis/include/zenovis/Scene.h +++ b/zenovis/include/zenovis/Scene.h @@ -44,6 +44,7 @@ struct Scene : zeno::disable_copy { void draw(bool record); bool loadFrameObjects(int frameid); void cleanUpScene(); + void cleanupView(); void switchRenderEngine(std::string const &name); std::vector record_frame_offline(int hdrSize = 1, int rgbComps = 3); bool cameraFocusOnNode(std::string const &nodeid, zeno::vec3f ¢er, float &radius); diff --git a/zenovis/src/Scene.cpp b/zenovis/src/Scene.cpp index 347814a3ae..11df211415 100644 --- a/zenovis/src/Scene.cpp +++ b/zenovis/src/Scene.cpp @@ -48,6 +48,17 @@ Scene::Scene() switchRenderEngine("bate"); } +void Scene::cleanupView() +{ + if (!renderMan) + return; + + RenderEngine* pEngine = renderMan->getEngine(); + if (pEngine) { + pEngine->cleanupWhenExit(); + } +} + void Scene::cleanUpScene() { if (objectsMan) diff --git a/zenovis/src/bate/RenderEngineBate.cpp b/zenovis/src/bate/RenderEngineBate.cpp index 2a67d741ac..9a324ffd91 100644 --- a/zenovis/src/bate/RenderEngineBate.cpp +++ b/zenovis/src/bate/RenderEngineBate.cpp @@ -95,6 +95,10 @@ struct RenderEngineBate : RenderEngine { void cleanupOptix() override { } + + void cleanupWhenExit() override { + + } }; static auto definer = RenderManager::registerRenderEngine("bate"); diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index 4e8542328c..b6ba4c66c2 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -1395,6 +1395,10 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy { void cleanupOptix() override { } + + void cleanupWhenExit() override { + + } }; static auto definer = RenderManager::registerRenderEngine("optx"); diff --git a/zenovis/src/zhxx/RenderEngineZhxx.cpp b/zenovis/src/zhxx/RenderEngineZhxx.cpp index 8ee8ed1621..ac3a5c1913 100644 --- a/zenovis/src/zhxx/RenderEngineZhxx.cpp +++ b/zenovis/src/zhxx/RenderEngineZhxx.cpp @@ -126,6 +126,10 @@ struct RenderEngineZhxx : RenderEngine, zeno::disable_copy { void cleanupOptix() override { } + + void cleanupWhenExit() override { + + } }; static auto definer = RenderManager::registerRenderEngine("zhxx"); From 217ebdf4bc2ffdc172fe7dd8a4f8c4374b86c692 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Mon, 22 Apr 2024 15:50:56 +0800 Subject: [PATCH 07/29] step 1 --- zenovis/src/bate/RenderEngineBate.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zenovis/src/bate/RenderEngineBate.cpp b/zenovis/src/bate/RenderEngineBate.cpp index 9a324ffd91..91f569e24c 100644 --- a/zenovis/src/bate/RenderEngineBate.cpp +++ b/zenovis/src/bate/RenderEngineBate.cpp @@ -16,6 +16,7 @@ struct RenderEngineBate : RenderEngine { std::unique_ptr primHighlight; std::unique_ptr fbr; Scene *scene; + bool released = false; auto setupState() { return std::tuple{ @@ -44,6 +45,9 @@ struct RenderEngineBate : RenderEngine { } void draw(bool record) override { + if (released) { + return; + } auto guard = setupState(); CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); glDepthFunc(GL_GREATER); @@ -97,7 +101,12 @@ struct RenderEngineBate : RenderEngine { } void cleanupWhenExit() override { - + released = true; + vao = nullptr; + graphicsMan = nullptr; + hudGraphics.clear(); + primHighlight = nullptr; + fbr = nullptr; } }; From 9a4c07a215981993711d73aa8118bf5112fece95 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Mon, 22 Apr 2024 15:57:28 +0800 Subject: [PATCH 08/29] step 2 --- zenovis/src/bate/RenderEngineBate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/zenovis/src/bate/RenderEngineBate.cpp b/zenovis/src/bate/RenderEngineBate.cpp index 91f569e24c..7fa2c4d43e 100644 --- a/zenovis/src/bate/RenderEngineBate.cpp +++ b/zenovis/src/bate/RenderEngineBate.cpp @@ -102,6 +102,7 @@ struct RenderEngineBate : RenderEngine { void cleanupWhenExit() override { released = true; + scene->shaderMan = nullptr; vao = nullptr; graphicsMan = nullptr; hudGraphics.clear(); From 6b784ac2b8d7b1c47466213423d67b9587c3b185 Mon Sep 17 00:00:00 2001 From: teachmain Date: Mon, 22 Apr 2024 17:05:10 +0800 Subject: [PATCH 09/29] SetUserData node add default data type sting --- zeno/src/nodes/PortalNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zeno/src/nodes/PortalNodes.cpp b/zeno/src/nodes/PortalNodes.cpp index ae10e01858..79adf7787e 100644 --- a/zeno/src/nodes/PortalNodes.cpp +++ b/zeno/src/nodes/PortalNodes.cpp @@ -193,7 +193,7 @@ struct SetUserData2 : zeno::INode { }; ZENDEFNODE(SetUserData2, { - {"object", {"string", "key", ""}, "data"}, + {"object", {"string", "key", ""}, {"string","data",""}}, {"object"}, {}, {"lifecycle"}, From f80d91193e9c8dbb842d7550dd269bfe3f7f61f5 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Mon, 22 Apr 2024 17:20:24 +0800 Subject: [PATCH 10/29] step 3 --- ui/zenoedit/viewport/cameracontrol.cpp | 16 +++++++++++++--- ui/zenoedit/viewport/cameracontrol.h | 4 ++-- ui/zenoedit/viewport/viewportwidget.cpp | 3 +++ zeno/src/utils/log.cpp | 5 ++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/zenoedit/viewport/cameracontrol.cpp b/ui/zenoedit/viewport/cameracontrol.cpp index b1fd4683f2..2978c63ba2 100644 --- a/ui/zenoedit/viewport/cameracontrol.cpp +++ b/ui/zenoedit/viewport/cameracontrol.cpp @@ -116,10 +116,12 @@ void CameraControl::fakeMousePressEvent(QMouseEvent *event) if (event->button() == Qt::MiddleButton) { middle_button_pressed = true; } + auto m_picker = this->m_picker.lock(); + auto m_transformer = this->m_transformer.lock(); if (scene->camera->m_need_sync) { scene->camera->m_need_sync = false; if (bool(m_picker) && scene->camera->m_auto_radius) { - this->m_picker->set_picked_depth_callback([&] (float depth, int x, int y) { + m_picker->set_picked_depth_callback([&] (float depth, int x, int y) { if (depth < 0.001f) { return; } @@ -133,7 +135,7 @@ void CameraControl::fakeMousePressEvent(QMouseEvent *event) }); int mid_x = int(this->res().x() * 0.5); int mid_y = int(this->res().y() * 0.5); - this->m_picker->pick_depth(mid_x, mid_y); + m_picker->pick_depth(mid_x, mid_y); } } int button = Qt::NoButton; @@ -227,6 +229,7 @@ void CameraControl::lookTo(int dir) { } void CameraControl::clearTransformer() { + auto m_transformer = this->m_transformer.lock(); if (!m_transformer) return; m_transformer->clear(); @@ -234,6 +237,7 @@ void CameraControl::clearTransformer() { void CameraControl::changeTransformOperation(const QString &node) { + auto m_transformer = this->m_transformer.lock(); if (!m_transformer) return; @@ -256,6 +260,7 @@ void CameraControl::changeTransformOperation(const QString &node) void CameraControl::changeTransformOperation(int mode) { + auto m_transformer = this->m_transformer.lock(); if (!m_transformer) return; @@ -270,6 +275,7 @@ void CameraControl::changeTransformOperation(int mode) void CameraControl::changeTransformCoordSys() { + auto m_transformer = this->m_transformer.lock(); if (!m_transformer) return; m_transformer->changeCoordSys(); @@ -278,6 +284,7 @@ void CameraControl::changeTransformCoordSys() void CameraControl::resizeTransformHandler(int dir) { + auto m_transformer = this->m_transformer.lock(); if (!m_transformer) return; m_transformer->resizeHandler(dir); @@ -286,6 +293,7 @@ void CameraControl::resizeTransformHandler(int dir) void CameraControl::fakeMouseMoveEvent(QMouseEvent *event) { + auto m_transformer = this->m_transformer.lock(); bool ctrl_pressed = event->modifiers() & Qt::ControlModifier; bool alt_pressed = event->modifiers() & Qt::AltModifier; @@ -467,6 +475,7 @@ void CameraControl::fakeWheelEvent(QWheelEvent *event) { void CameraControl::fakeMouseDoubleClickEvent(QMouseEvent *event) { auto pos = event->pos(); + auto m_picker = this->m_picker.lock(); if (!m_picker) return; auto scene = m_zenovis->getSession()->get_scene(); @@ -580,7 +589,8 @@ void CameraControl::fakeMouseReleaseEvent(QMouseEvent *event) { middle_button_pressed = false; } if (event->button() == Qt::LeftButton) { - + auto m_transformer = this->m_transformer.lock(); + auto m_picker = this->m_picker.lock(); //if (Zenovis::GetInstance().m_bAddPoint == true) { //float x = (float)event->x() / m_res.x(); //float y = (float)event->y() / m_res.y(); diff --git a/ui/zenoedit/viewport/cameracontrol.h b/ui/zenoedit/viewport/cameracontrol.h index a82c073aff..61cfc6c75b 100644 --- a/ui/zenoedit/viewport/cameracontrol.h +++ b/ui/zenoedit/viewport/cameracontrol.h @@ -64,8 +64,8 @@ class CameraControl : public QObject QVector2D m_res; QSet m_pressedKeys; - std::shared_ptr m_picker; - std::shared_ptr m_transformer; + std::weak_ptr m_picker; + std::weak_ptr m_transformer; Zenovis* m_zenovis; bool middle_button_pressed = false; diff --git a/ui/zenoedit/viewport/viewportwidget.cpp b/ui/zenoedit/viewport/viewportwidget.cpp index d43bcc9375..07b5e47f2e 100644 --- a/ui/zenoedit/viewport/viewportwidget.cpp +++ b/ui/zenoedit/viewport/viewportwidget.cpp @@ -137,6 +137,9 @@ void ViewportWidget::cleanUpView() { if (m_zenovis) m_zenovis->cleanupView(); + + m_picker = nullptr; + m_fakeTrans = nullptr; } namespace { diff --git a/zeno/src/utils/log.cpp b/zeno/src/utils/log.cpp index 705efd62b7..12bf11179e 100644 --- a/zeno/src/utils/log.cpp +++ b/zeno/src/utils/log.cpp @@ -34,14 +34,17 @@ ZENO_API void __impl_log_print(log_level_t level, source_location const &loc, st //*os << ansiclr::fg[make_array(ansiclr::white, ansiclr::cyan, ansiclr::green, //ansiclr::cyan | ansiclr::light, ansiclr::yellow | ansiclr::light, //ansiclr::red | ansiclr::light)[linlev]]; - *os << format("[{} {02d}:{02d}:{02d}.{03d}] ({}:{}) {}\n", + auto content = format("[{} {02d}:{02d}:{02d}.{03d}] ({}:{}) {}\n", "TDICWE"[linlev], mss / 1000 / 60 / 60 % 24, mss / 1000 / 60 % 60, mss / 1000 % 60, mss % 1000, loc.file_name(), loc.line(), msg); //*os << ansiclr::reset; + *os << content; os->flush(); + if (level == log_level_t::error) + std::cerr << content; } namespace { From caddb475572a646018e1bc7b65fe624ffea3ba5a Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Wed, 24 Apr 2024 18:25:58 +0800 Subject: [PATCH 11/29] send record task to server --- ui/include/common.h | 4 +- ui/zenoedit/dialog/zrecorddlg.cpp | 21 ++++- ui/zenoedit/dialog/zrecorddlg.h | 4 +- ui/zenoedit/dialog/zrecorddlg.ui | 61 +++++++++++--- ui/zenoedit/viewport/displaywidget.cpp | 92 +++++++++++++++++++++ ui/zenoedit/viewport/displaywidget.h | 1 + ui/zenoedit/viewport/recordvideomgr.h | 4 + ui/zenoio/reader/zsgreader.cpp | 2 + ui/zenoio/writer/zsgwriter.cpp | 2 + ui/zenomodel/src/modelacceptor.cpp | 1 + zeno/include/zeno/funcs/ParseObjectFromUi.h | 1 + 11 files changed, 176 insertions(+), 17 deletions(-) diff --git a/ui/include/common.h b/ui/include/common.h index b08ab97851..3441dcf7ea 100644 --- a/ui/include/common.h +++ b/ui/include/common.h @@ -40,7 +40,9 @@ struct RECORD_SETTING bool bMask; bool bExr; - RECORD_SETTING() : fps(24), bitrate(200000), numMSAA(0), numOptix(1), width(1280), height(720), bExportVideo(false), needDenoise(false), bAutoRemoveCache(true), bAov(false), bExr(false), bMask(false) {} + QString exePath; + + RECORD_SETTING() : fps(24), bitrate(200000), numMSAA(0), numOptix(1), width(1280), height(720), bExportVideo(false), needDenoise(false), bAutoRemoveCache(true), bAov(false), bExr(false), bMask(false){} }; struct LAYOUT_SETTING { diff --git a/ui/zenoedit/dialog/zrecorddlg.cpp b/ui/zenoedit/dialog/zrecorddlg.cpp index 5465740b82..02d8978686 100644 --- a/ui/zenoedit/dialog/zrecorddlg.cpp +++ b/ui/zenoedit/dialog/zrecorddlg.cpp @@ -6,6 +6,7 @@ #include "zeno/utils/UserData.h" #include "zassert.h" #include "settings/zsettings.h" +#include ZRecordVideoDlg::ZRecordVideoDlg(QWidget* parent) @@ -38,6 +39,14 @@ ZRecordVideoDlg::ZRecordVideoDlg(QWidget* parent) m_ui->cbPresets->addItems({"540P", "720P", "1080P", "2K", "4K"}); m_ui->cbPresets->setCurrentIndex(1); + CALLBACK_SWITCH cbSwitch = [=](bool bOn) { + zenoApp->getMainWindow()->setInDlgEventLoop(bOn); //deal with ubuntu dialog slow problem when update viewport. + }; + m_exePath = new ZPathEdit(cbSwitch, this); + m_exePath->setProperty("control", CONTROL_READPATH); + m_exePath->setText(info.exePath); + m_ui->m_sendToServerWidget->layout()->addWidget(m_exePath); + m_ui->m_sendToServerWidget->hide(); QSettings settings(zsCompanyName, zsEditor); bool enableCache = settings.value("zencache-enable").isValid() ? settings.value("zencache-enable").toBool() : true; @@ -66,6 +75,9 @@ ZRecordVideoDlg::ZRecordVideoDlg(QWidget* parent) connect(m_ui->btnGroup, SIGNAL(accepted()), this, SLOT(accept())); connect(m_ui->btnGroup, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->m_chkSendToServer, &QCheckBox::stateChanged, this, [&]() { + m_ui->m_sendToServerWidget->setVisible(m_ui->m_chkSendToServer->isChecked()); + }); } bool ZRecordVideoDlg::getInfo(VideoRecInfo &info) @@ -87,6 +99,12 @@ bool ZRecordVideoDlg::getInfo(VideoRecInfo &info) info.bExportEXR = m_ui->cbExportEXR->checkState() == Qt::Checked; info.needDenoise = m_ui->cbNeedDenoise->checkState() == Qt::Checked; info.bAutoRemoveCache = m_ui->cbRemoveAfterRender->checkState() == Qt::Checked; + info.bSendToServer = m_ui->m_chkSendToServer->checkState() == Qt::Checked; + if (info.bSendToServer) + { + info.exePath = m_exePath->text(); + info.taskName = m_ui->m_taskName->text(); + } if (path.isEmpty()) { QTemporaryDir dir; @@ -127,8 +145,9 @@ bool ZRecordVideoDlg::getInfo(VideoRecInfo &info) record_settings.bAov = m_ui->cbAOV->checkState() == Qt::Checked; record_settings.bMask = m_ui->cbMask->checkState() == Qt::Checked; record_settings.bExr = info.bExportEXR; + record_settings.exePath = info.exePath; zenoApp->graphsManagment()->setRecordSettings(record_settings); return true; -} +} \ No newline at end of file diff --git a/ui/zenoedit/dialog/zrecorddlg.h b/ui/zenoedit/dialog/zrecorddlg.h index 1dcc03c8b1..5116832f74 100644 --- a/ui/zenoedit/dialog/zrecorddlg.h +++ b/ui/zenoedit/dialog/zrecorddlg.h @@ -10,15 +10,15 @@ namespace Ui #include "viewport/viewportwidget.h" #include "viewport/recordvideomgr.h" +class ZPathEdit; class ZRecordVideoDlg : public QDialog { Q_OBJECT public: ZRecordVideoDlg(QWidget* parent = nullptr); bool getInfo(VideoRecInfo &info); - private: Ui::RecordVideoDlg* m_ui; + ZPathEdit* m_exePath; }; - #endif \ No newline at end of file diff --git a/ui/zenoedit/dialog/zrecorddlg.ui b/ui/zenoedit/dialog/zrecorddlg.ui index 71c3a8ed68..162b5fc3ea 100644 --- a/ui/zenoedit/dialog/zrecorddlg.ui +++ b/ui/zenoedit/dialog/zrecorddlg.ui @@ -7,7 +7,7 @@ 0 0 413 - 408 + 510 @@ -181,23 +181,58 @@ - - - Qt::Vertical - - - - 20 - 40 - + + + remove cache after render - + - + - remove cache after render + Send to server + + + + + + + + 0 + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Task name + + + + + + + + + + exe path + + + + diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 5b83f270e0..8226ec9c0a 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -842,6 +842,12 @@ void DisplayWidget::onRecord() QMessageBox::warning(nullptr, tr("Record"), tr("The output path is invalid, please choose another path.")); return; } + //send task to server + if (recInfo.bSendToServer) + { + sendTaskToServer(recInfo); + return; + } //validation. LAUNCH_PARAM launchParam; @@ -1011,6 +1017,92 @@ void DisplayWidget::onRecord() m_sliderFeq = curSlidFeq; } +void DisplayWidget::sendTaskToServer(const VideoRecInfo& info) +{ + QString cmd = info.exePath + " --record " + "true"; + if (!zenoApp->graphsManagment()) + return; + QString path = zenoApp->graphsManagment()->zsgPath(); + if (!path.startsWith("O:") && !path.startsWith("M:") && !path.startsWith("P:")) + { + //copy zsg + QString destFileDir = "O:/sendToServer/" + info.taskName + QString::number(QDateTime::currentDateTime().toTime_t()); + QFileInfo fileInfo(path); + QString fileName = fileInfo.fileName(); + QDir dir(destFileDir); + dir.mkpath(destFileDir); + QString destFilePath = dir.filePath(fileName); + QFile sourceFile(path); + if (!sourceFile.copy(destFilePath)) { + zeno::log_error("Failed to copy file"); + return; + } + else + path = destFilePath; + } + //task cmd + cmd = cmd + " --zsg " + path; + cmd = cmd + " --sample " + QString::number(info.numOptix); + cmd = cmd + " --optix " + "1"; + cmd = cmd + " --path " + info.record_path; + cmd = cmd + " --pixel " + QString("%1x%2").arg(info.res[0]).arg(info.res[1]); + cmd = cmd + " --aov " + "0"; + cmd = cmd + " --needDenoise " + QString::number(info.needDenoise); + cmd = cmd + " --exr " + QString::number(info.bExportEXR); + cmd = cmd + " --videoname " + info.videoname; + cmd = cmd + " --video " + QString::number(info.bExportVideo); + cmd = cmd + " --cachePath " + "C:/tmp/"; + if (zenoApp->getMainWindow()) + { + auto timelineInfo = zenoApp->getMainWindow()->timelineInfo(); + cmd = cmd + " --sframe " + QString::number(timelineInfo.beginFrame); + cmd = cmd + " --frame " + QString::number(timelineInfo.endFrame - timelineInfo.beginFrame + 1); + } + + //save json file + rapidjson::StringBuffer s; + RAPIDJSON_WRITER writer(s); + { + JsonArrayBatch arrayBatch(writer); + { + JsonObjBatch objBatch(writer); + QString key = info.taskName + ":all"; + writer.Key(key.toUtf8()); + { + JsonObjBatch objBatch1(writer); + writer.Key("cmd"); + { + JsonArrayBatch cmdBatch(writer); + writer.String(cmd.toUtf8()); + } + writer.Key("deps"); + { + JsonArrayBatch depsBatch(writer); + } + writer.Key("name"); + writer.String(key.toUtf8()); + } + } + } + QString str = QString::fromUtf8(s.GetString()); + QFileInfo fileInfo(path); + QString filePath = fileInfo.dir().absolutePath() + "/"+ info.taskName + ".json"; + QFile file(filePath); + zeno::log_debug("saving {} chars to file [{}]", str.size(), filePath.toStdString()); + if (!file.open(QIODevice::WriteOnly)) { + zeno::log_error("Failed to open file for write: {} ({})", filePath.toStdString(), + file.errorString().toStdString()); + return; + } + file.write(str.toUtf8()); + file.close(); + //python cmd + cmd = "python O:/send.py --file " + filePath + " --name " + info.taskName; + QProcess process; + process.execute(cmd); + file.remove(); +} + void DisplayWidget::onFrameFinish(int frame) { if (m_recordMgr.getRecordInfo().bAutoRemoveCache) diff --git a/ui/zenoedit/viewport/displaywidget.h b/ui/zenoedit/viewport/displaywidget.h index 5aaa263850..076a483a2f 100644 --- a/ui/zenoedit/viewport/displaywidget.h +++ b/ui/zenoedit/viewport/displaywidget.h @@ -106,6 +106,7 @@ private slots: private: bool isOptxRendering() const; void initRecordMgr(); + void sendTaskToServer(const VideoRecInfo& info); ViewportWidget* m_glView; #ifdef ZENO_OPTIX_PROC diff --git a/ui/zenoedit/viewport/recordvideomgr.h b/ui/zenoedit/viewport/recordvideomgr.h index b19819dbab..744acf5b54 100644 --- a/ui/zenoedit/viewport/recordvideomgr.h +++ b/ui/zenoedit/viewport/recordvideomgr.h @@ -21,6 +21,10 @@ struct VideoRecInfo bool bRecordByCommandLine = false; bool bAutoRemoveCache = false; bool bExportEXR = false; + + bool bSendToServer = false; + QString exePath; + QString taskName; }; Q_DECLARE_METATYPE(VideoRecInfo); diff --git a/ui/zenoio/reader/zsgreader.cpp b/ui/zenoio/reader/zsgreader.cpp index 9caaf50c7e..cdc928509d 100644 --- a/ui/zenoio/reader/zsgreader.cpp +++ b/ui/zenoio/reader/zsgreader.cpp @@ -494,6 +494,8 @@ void ZsgReader::_parseSettings(const rapidjson::Value& jsonSettings, IAcceptor* info.bAov = jsonRecordInfo[recordinfo::bAov].GetBool(); if (jsonRecordInfo.HasMember(recordinfo::bExr) && jsonRecordInfo[recordinfo::bExr].IsBool()) info.bExr = jsonRecordInfo[recordinfo::bExr].GetBool(); + if (jsonRecordInfo.HasMember(recordinfo::exePath)) + info.exePath = jsonRecordInfo[recordinfo::exePath].GetString(); pAcceptor->setRecordInfo(info); } if (jsonSettings.HasMember("layoutinfo") && jsonSettings["layoutinfo"].IsObject()) diff --git a/ui/zenoio/writer/zsgwriter.cpp b/ui/zenoio/writer/zsgwriter.cpp index 87b23db771..b8ee879f9f 100644 --- a/ui/zenoio/writer/zsgwriter.cpp +++ b/ui/zenoio/writer/zsgwriter.cpp @@ -613,6 +613,8 @@ void ZsgWriter::dumpSettings(const APP_SETTINGS settings, RAPIDJSON_WRITER& writ writer.Bool(info.bAov); writer.Key(recordinfo::bExr); writer.Bool(info.bExr); + writer.Key(recordinfo::exePath); + writer.String(info.exePath.toUtf8()); writer.EndObject(); writer.Key("layoutinfo"); diff --git a/ui/zenomodel/src/modelacceptor.cpp b/ui/zenomodel/src/modelacceptor.cpp index 59154b103c..cc202191ba 100644 --- a/ui/zenomodel/src/modelacceptor.cpp +++ b/ui/zenomodel/src/modelacceptor.cpp @@ -79,6 +79,7 @@ void ModelAcceptor::setRecordInfo(const RECORD_SETTING& info) m_recordInfo.bAutoRemoveCache = info.bAutoRemoveCache; m_recordInfo.bAov = info.bAov; m_recordInfo.bExr = info.bExr; + m_recordInfo.exePath = info.exePath; } void ModelAcceptor::setLayoutInfo(const LAYOUT_SETTING& info) diff --git a/zeno/include/zeno/funcs/ParseObjectFromUi.h b/zeno/include/zeno/funcs/ParseObjectFromUi.h index 1633a4d75c..3c9bd32ce8 100644 --- a/zeno/include/zeno/funcs/ParseObjectFromUi.h +++ b/zeno/include/zeno/funcs/ParseObjectFromUi.h @@ -49,6 +49,7 @@ namespace iotags { constexpr const char* bAutoRemoveCache = "auto-remove-cache"; constexpr const char* bAov = "aov"; constexpr const char* bExr = "exr"; + constexpr const char* exePath = "exePath"; } namespace layoutinfo { From 6578a425a27c01e7e6f7c90a8ce8c46ea6cb5186 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Wed, 24 Apr 2024 20:19:28 +0800 Subject: [PATCH 12/29] fix-abc-vertex-color --- projects/Alembic/ReadAlembic.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/Alembic/ReadAlembic.cpp b/projects/Alembic/ReadAlembic.cpp index f76e33fda2..591c2aa5ad 100644 --- a/projects/Alembic/ReadAlembic.cpp +++ b/projects/Alembic/ReadAlembic.cpp @@ -348,7 +348,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro if (IFloatGeomParam::matches(p)) { IFloatGeomParam param(arbattrs, p.getName()); - IFloatGeomParam::Sample samp = param.getIndexedValue(iSS); + IFloatGeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); for (auto i = 0; i < samp.getVals()->size(); i++) { @@ -362,7 +362,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro else if (IInt32GeomParam::matches(p)) { IInt32GeomParam param(arbattrs, p.getName()); - IInt32GeomParam::Sample samp = param.getIndexedValue(iSS); + IInt32GeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); for (auto i = 0; i < samp.getVals()->size(); i++) { @@ -376,7 +376,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro else if (IV3fGeomParam::matches(p)) { IV3fGeomParam param(arbattrs, p.getName()); - IV3fGeomParam::Sample samp = param.getIndexedValue(iSS); + IV3fGeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); for (auto i = 0; i < samp.getVals()->size(); i++) { @@ -391,7 +391,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro else if (IN3fGeomParam::matches(p)) { IN3fGeomParam param(arbattrs, p.getName()); - IN3fGeomParam::Sample samp = param.getIndexedValue(iSS); + IN3fGeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); for (auto i = 0; i < samp.getVals()->size(); i++) { @@ -406,7 +406,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro else if (IC3fGeomParam::matches(p)) { IC3fGeomParam param(arbattrs, p.getName()); - IC3fGeomParam::Sample samp = param.getIndexedValue(iSS); + IC3fGeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); for (auto i = 0; i < samp.getVals()->size(); i++) { @@ -421,7 +421,7 @@ static void read_attributes2(std::shared_ptr prim, ICompoundPro else if (IC4fGeomParam::matches(p)) { IC4fGeomParam param(arbattrs, p.getName()); - IC4fGeomParam::Sample samp = param.getIndexedValue(iSS); + IC4fGeomParam::Sample samp = param.getExpandedValue(iSS); std::vector data; data.resize(samp.getVals()->size()); std::vector data_xyz(samp.getVals()->size()); From 7e515dccfc3867aaec9093afae8e082ee1a3fa2d Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Thu, 25 Apr 2024 11:32:46 +0800 Subject: [PATCH 13/29] fix bug about writting json file --- ui/zenoedit/viewport/displaywidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 8226ec9c0a..3d8aef13ec 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1070,7 +1070,7 @@ void DisplayWidget::sendTaskToServer(const VideoRecInfo& info) writer.Key(key.toUtf8()); { JsonObjBatch objBatch1(writer); - writer.Key("cmd"); + writer.Key("cmds"); { JsonArrayBatch cmdBatch(writer); writer.String(cmd.toUtf8()); @@ -1100,7 +1100,7 @@ void DisplayWidget::sendTaskToServer(const VideoRecInfo& info) cmd = "python O:/send.py --file " + filePath + " --name " + info.taskName; QProcess process; process.execute(cmd); - file.remove(); + //file.remove(); } void DisplayWidget::onFrameFinish(int frame) From dfd55f3dec40175cd0c795daec4788bc32cb2cf1 Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Thu, 25 Apr 2024 11:37:04 +0800 Subject: [PATCH 14/29] remove json file --- ui/zenoedit/viewport/displaywidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 3d8aef13ec..6a54d66d14 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1100,7 +1100,7 @@ void DisplayWidget::sendTaskToServer(const VideoRecInfo& info) cmd = "python O:/send.py --file " + filePath + " --name " + info.taskName; QProcess process; process.execute(cmd); - //file.remove(); + file.remove(); } void DisplayWidget::onFrameFinish(int frame) From b2db0a0bb61bb86620d923e92978fb0ae23c5323 Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Thu, 25 Apr 2024 14:21:29 +0800 Subject: [PATCH 15/29] excute script by python --- ui/zenoedit/viewport/displaywidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 6a54d66d14..920d3dfe8d 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1096,10 +1096,11 @@ void DisplayWidget::sendTaskToServer(const VideoRecInfo& info) } file.write(str.toUtf8()); file.close(); - //python cmd - cmd = "python O:/send.py --file " + filePath + " --name " + info.taskName; - QProcess process; - process.execute(cmd); + //python script + QString script = R"(import os +os.system("python O:/send.py --file %1 --name %2"))"; + script = script.arg(filePath, info.taskName); + AppHelper::pythonExcute(script); file.remove(); } From a40b3ebe338d01b36c89f071fa8d73294b466e3a Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Mon, 29 Apr 2024 19:14:34 +0800 Subject: [PATCH 16/29] step 4 --- zenovis/src/bate/RenderEngineBate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/zenovis/src/bate/RenderEngineBate.cpp b/zenovis/src/bate/RenderEngineBate.cpp index 7fa2c4d43e..556ea28634 100644 --- a/zenovis/src/bate/RenderEngineBate.cpp +++ b/zenovis/src/bate/RenderEngineBate.cpp @@ -103,6 +103,7 @@ struct RenderEngineBate : RenderEngine { void cleanupWhenExit() override { released = true; scene->shaderMan = nullptr; + scene->drawOptions->handler = nullptr; vao = nullptr; graphicsMan = nullptr; hudGraphics.clear(); From ed17906143afcfa1e1a802df8ba4c3d119821ace Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Mon, 6 May 2024 18:44:36 +0800 Subject: [PATCH 17/29] mark error when path is invalid --- ui/zenoedit/dialog/zeditparamlayoutdlg.cpp | 45 ++++++++++++++++++++++ ui/zenoedit/dialog/zeditparamlayoutdlg.h | 1 + ui/zenoedit/dialog/zeditparamlayoutdlg.ui | 31 +++++++++++++++ ui/zenoedit/panel/zenoproppanel.cpp | 4 ++ ui/zenomodel/customui/customuirw.cpp | 3 +- ui/zenoui/comctrl/gv/zenogvhelper.cpp | 5 +++ ui/zenoui/comctrl/gv/zenoparamwidget.cpp | 10 +++-- ui/zenoui/comctrl/gv/zgraphicstextitem.cpp | 32 +++++++++++++++ ui/zenoui/comctrl/gv/zgraphicstextitem.h | 2 + ui/zenoui/comctrl/gv/zitemfactory.cpp | 9 +++++ ui/zenoui/comctrl/zpathedit.cpp | 9 ++++- ui/zenoui/comctrl/zwidgetfactory.cpp | 9 +++++ 12 files changed, 154 insertions(+), 6 deletions(-) diff --git a/ui/zenoedit/dialog/zeditparamlayoutdlg.cpp b/ui/zenoedit/dialog/zeditparamlayoutdlg.cpp index ee5010a4da..c307e91fd9 100644 --- a/ui/zenoedit/dialog/zeditparamlayoutdlg.cpp +++ b/ui/zenoedit/dialog/zeditparamlayoutdlg.cpp @@ -16,6 +16,8 @@ #include "iotags.h" #include #include +#include "zenoapplication.h" +#include "zenomainwindow.h" static CONTROL_ITEM_INFO controlList[] = { {"Tab", CONTROL_NONE, "", ":/icons/parameter_control_tab.svg"}, @@ -188,6 +190,7 @@ ZEditParamLayoutDlg::ZEditParamLayoutDlg(QStandardItemModel* pModel, bool bNodeU connect(m_ui->editStep, SIGNAL(editingFinished()), this, SLOT(onStepEditFinished())); connect(m_ui->cbControl, SIGNAL(currentIndexChanged(int)), this, SLOT(onControlItemChanged(int))); connect(m_ui->cbTypes, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeItemChanged(int))); + connect(m_ui->m_pathFilterEdit, SIGNAL(editingFinished()), this, SLOT(onPathFilterFinished())); m_ui->itemsTable->setHorizontalHeaderLabels({ tr("Item Name") }); connect(m_ui->itemsTable, SIGNAL(cellChanged(int, int)), this, SLOT(onComboTableItemsCellChanged(int, int))); @@ -458,6 +461,9 @@ void ZEditParamLayoutDlg::onTreeCurrentChanged(const QModelIndex& current, const } return pCurrentItem->data(ROLE_PARAM_VALUE); }; + cbSets.cbSwitch = [=](bool bOn) { + zenoApp->getMainWindow()->setInDlgEventLoop(bOn); + }; QWidget *valueControl = zenoui::createWidget(deflVal, ctrl, dataType, cbSets, controlProperties); if (valueControl) { valueControl->setEnabled(bEditable); @@ -648,6 +654,19 @@ void ZEditParamLayoutDlg::switchStackProperties(int ctrl, VParamItem* pItem) m_ui->editStep->setText(QString::number(info.step)); m_ui->editMin->setText(QString::number(info.min)); m_ui->editMax->setText(QString::number(info.max)); + } else if (ctrl == CONTROL_READPATH || ctrl == CONTROL_WRITEPATH) + { + m_ui->stackProperties->setCurrentIndex(3); + QVariantMap pros = controlProperties.toMap(); + if (pros.find("filter") != pros.end()) + { + QString filter = pros["filter"].toString(); + m_ui->m_pathFilterEdit->setText(filter); + } + else + { + m_ui->m_pathFilterEdit->setText(""); + } } else { m_ui->stackProperties->setCurrentIndex(0); } @@ -836,6 +855,26 @@ void ZEditParamLayoutDlg::onMaxEditFinished() updateSliderInfo(); } +void ZEditParamLayoutDlg::onPathFilterFinished() +{ + QModelIndex layerIdx = m_ui->paramsView->currentIndex(); + if (!layerIdx.isValid() && layerIdx.data(ROLE_VPARAM_TYPE) != VPARAM_PARAM) + return; + + CONTROL_PROPERTIES properties = layerIdx.data(ROLE_VPARAM_CTRL_PROPERTIES).value(); + QString filter = m_ui->m_pathFilterEdit->text(); + properties["filter"] = filter; + proxyModelSetData(layerIdx, properties, ROLE_VPARAM_CTRL_PROPERTIES); + //update control. + QLayoutItem* pLayoutItem = m_ui->gridLayout->itemAtPosition(rowValueControl, 1); + if (pLayoutItem) { + QWidget* pControl = pLayoutItem->widget(); + if (pControl) { + pControl->setProperty("filter", filter); + } + } +} + void ZEditParamLayoutDlg::onControlItemChanged(int idx) { const QString& controlName = m_ui->cbControl->itemText(idx); @@ -863,6 +902,9 @@ void ZEditParamLayoutDlg::onControlItemChanged(int idx) value = UiHelper::initDefaultValue(dataType); QVariant controlProperties = layerIdx.data(ROLE_VPARAM_CTRL_PROPERTIES); cbSets.cbGetIndexData = [=]() -> QVariant { return UiHelper::initVariantByControl(ctrl); }; + cbSets.cbSwitch = [=](bool bOn) { + zenoApp->getMainWindow()->setInDlgEventLoop(bOn); + }; QWidget *valueControl = zenoui::createWidget(value, ctrl, dataType, cbSets, controlProperties); if (valueControl) { valueControl->setEnabled(m_pGraphsModel->IsSubGraphNode(m_nodeIdx)); @@ -898,6 +940,9 @@ void ZEditParamLayoutDlg::onTypeItemChanged(int idx) }; QVariant controlProperties = layerIdx.data(ROLE_VPARAM_CTRL_PROPERTIES); cbSets.cbGetIndexData = [=]() -> QVariant { return pItem->data(ROLE_PARAM_VALUE); }; + cbSets.cbSwitch = [=](bool bOn) { + zenoApp->getMainWindow()->setInDlgEventLoop(bOn); + }; QWidget *valueControl = zenoui::createWidget(pItem->data(ROLE_PARAM_VALUE), pItem->m_ctrl, dataType, cbSets, controlProperties); if (valueControl) { valueControl->setEnabled(m_pGraphsModel->IsSubGraphNode(m_nodeIdx)); diff --git a/ui/zenoedit/dialog/zeditparamlayoutdlg.h b/ui/zenoedit/dialog/zeditparamlayoutdlg.h index 0b6cef828f..becace4722 100644 --- a/ui/zenoedit/dialog/zeditparamlayoutdlg.h +++ b/ui/zenoedit/dialog/zeditparamlayoutdlg.h @@ -63,6 +63,7 @@ private slots: void onComboTableItemsCellChanged(int row, int column); void onProxyItemNameChanged(const QModelIndex& itemIdx, const QString& oldPath, const QString& newName); void onViewParamDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); + void onPathFilterFinished(); private: void initUI(); diff --git a/ui/zenoedit/dialog/zeditparamlayoutdlg.ui b/ui/zenoedit/dialog/zeditparamlayoutdlg.ui index 9b7d665e96..5522cfbfb5 100644 --- a/ui/zenoedit/dialog/zeditparamlayoutdlg.ui +++ b/ui/zenoedit/dialog/zeditparamlayoutdlg.ui @@ -469,6 +469,37 @@ + + + + + + + + Filter + + + + + + + + + + + + Qt::Vertical + + + + 20 + 162 + + + + + + diff --git a/ui/zenoedit/panel/zenoproppanel.cpp b/ui/zenoedit/panel/zenoproppanel.cpp index 3c9ab10f4e..75fff46908 100644 --- a/ui/zenoedit/panel/zenoproppanel.cpp +++ b/ui/zenoedit/panel/zenoproppanel.cpp @@ -753,6 +753,10 @@ void ZenoPropPanel::onViewParamDataChanged(const QModelIndex& topLeft, const QMo pSpinBox->setRange(info.min, info.max); } } + else if (value.type() == QMetaType::QVariantMap && value.toMap().contains("filter")) + { + ctrl.pControl->setProperty("filter", value.toMap()["filter"]); + } } else if (role == ROLE_VPARAM_TOOLTIP) { diff --git a/ui/zenomodel/customui/customuirw.cpp b/ui/zenomodel/customui/customuirw.cpp index b7684ddf9f..91b824fc22 100644 --- a/ui/zenomodel/customui/customuirw.cpp +++ b/ui/zenomodel/customui/customuirw.cpp @@ -171,7 +171,8 @@ namespace zenomodel ZASSERT_EXIT(paramVal.HasMember("control"), param); const rapidjson::Value& controlObj = paramVal["control"]; - if (controlObj.HasMember("items") || (controlObj.HasMember("step") && controlObj.HasMember("min") && controlObj.HasMember("max"))) + if (controlObj.HasMember("items") || controlObj.HasMember("filter") || + (controlObj.HasMember("step") && controlObj.HasMember("min") && controlObj.HasMember("max"))) { JsonHelper::importControl(controlObj, param.m_info.control, param.controlInfos); } diff --git a/ui/zenoui/comctrl/gv/zenogvhelper.cpp b/ui/zenoui/comctrl/gv/zenogvhelper.cpp index 651c19e2e7..45a80d892b 100644 --- a/ui/zenoui/comctrl/gv/zenogvhelper.cpp +++ b/ui/zenoui/comctrl/gv/zenogvhelper.cpp @@ -208,6 +208,11 @@ void ZenoGvHelper::setCtrlProperties(QGraphicsItem *item, const QVariant &value pSpinBox->setSliderInfo(info); } } + ZenoParamPathEdit* pEditItem = qgraphicsitem_cast(item); + if (pEditItem && map.contains("filter")) + { + pEditItem->setProperty("filter", map["filter"]); + } } } diff --git a/ui/zenoui/comctrl/gv/zenoparamwidget.cpp b/ui/zenoui/comctrl/gv/zenoparamwidget.cpp index ad4e9b822d..1a0e8619ac 100644 --- a/ui/zenoui/comctrl/gv/zenoparamwidget.cpp +++ b/ui/zenoui/comctrl/gv/zenoparamwidget.cpp @@ -314,11 +314,15 @@ void ZenoParamPathEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) QDir dir = fileInfo.dir(); dirPath = dir.path(); } - + QString filter = this->property("filter").toString(); + if (filter.isEmpty()) + { + filter = "All Files(*);;"; + } if (m_control == CONTROL_READPATH) { - path = QFileDialog::getOpenFileName(nullptr, "File to Open", dirPath, "All Files(*);;"); + path = QFileDialog::getOpenFileName(nullptr, "File to Open", dirPath, filter); } else if (m_control == CONTROL_WRITEPATH) { - path = QFileDialog::getSaveFileName(nullptr, "Path to Save", dirPath, "All Files(*);;"); + path = QFileDialog::getSaveFileName(nullptr, "Path to Save", dirPath, filter); } else { path = QFileDialog::getExistingDirectory(nullptr, "Path to Save", ""); } diff --git a/ui/zenoui/comctrl/gv/zgraphicstextitem.cpp b/ui/zenoui/comctrl/gv/zgraphicstextitem.cpp index 1b37bf4d10..70a9096562 100644 --- a/ui/zenoui/comctrl/gv/zgraphicstextitem.cpp +++ b/ui/zenoui/comctrl/gv/zgraphicstextitem.cpp @@ -385,6 +385,7 @@ ZEditableTextItem::ZEditableTextItem(const QString &text, QGraphicsItem *parent) , m_bShowSlider(false) , m_pSlider(nullptr) , m_bValidating(false) + , m_validState(QValidator::Acceptable) { _base::setText(text); initUI(text); @@ -396,6 +397,7 @@ ZEditableTextItem::ZEditableTextItem(QGraphicsItem* parent) , m_bShowSlider(false) , m_pSlider(nullptr) , m_bValidating(false) + , m_validState(QValidator::Acceptable) { initUI(""); } @@ -422,6 +424,13 @@ void ZEditableTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->setPen(pen); painter->drawRect(rc); } else { + if (m_validState != QValidator::Acceptable) + { + pen.setJoinStyle(Qt::MiterJoin); + pen.setColor(QColor(200, 84, 79)); + painter->setPen(pen); + painter->drawRect(rc); + } painter->fillRect(rc, col); } _base::paint(painter, option, widget); @@ -489,6 +498,11 @@ void ZEditableTextItem::onContentsChanged() else { m_acceptableText = editText; } + if (m_validState != ret) + { + m_validState = ret; + update(); + } iVal = 0; } } @@ -591,6 +605,24 @@ void ZEditableTextItem::keyReleaseEvent(QKeyEvent* event) return _base::keyReleaseEvent(event); } +bool ZEditableTextItem::event(QEvent * event) +{ + if (event->type() == QEvent::DynamicPropertyChange) + { + QDynamicPropertyChangeEvent* evt = static_cast(event); + if (evt->propertyName() == "filter") { + QString filter = property("filter").toString(); + if (!filter.isEmpty()) + { + QRegExp rx(filter); + rx.setPatternSyntax(QRegExp::Wildcard); + m_validator = new QRegExpValidator(rx, this); + } + } + } + return _base::event(event); +} + void ZEditableTextItem::focusInEvent(QFocusEvent* event) { _base::focusInEvent(event); diff --git a/ui/zenoui/comctrl/gv/zgraphicstextitem.h b/ui/zenoui/comctrl/gv/zgraphicstextitem.h index 20630f6956..94ba170c57 100644 --- a/ui/zenoui/comctrl/gv/zgraphicstextitem.h +++ b/ui/zenoui/comctrl/gv/zgraphicstextitem.h @@ -119,6 +119,7 @@ class ZEditableTextItem : public ZGraphicsLayoutItem void focusOutEvent(QFocusEvent* event) override; void keyPressEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override; + bool event(QEvent* evt) override; private slots: void onContentsChanged(); @@ -134,6 +135,7 @@ private slots: bool m_bFocusIn; bool m_bValidating; bool m_bShowSlider; + QValidator::State m_validState; }; class ZenoSocketItem; diff --git a/ui/zenoui/comctrl/gv/zitemfactory.cpp b/ui/zenoui/comctrl/gv/zitemfactory.cpp index 1fe5804349..74e8b13d11 100644 --- a/ui/zenoui/comctrl/gv/zitemfactory.cpp +++ b/ui/zenoui/comctrl/gv/zitemfactory.cpp @@ -160,6 +160,15 @@ namespace zenoui pPathEditor->setData(GVKEY_SIZEHINT, ZenoStyle::dpiScaledSize(QSizeF(200, zenoui::g_ctrlHeight))); pPathEditor->setData(GVKEY_SIZEPOLICY, QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); pPathEditor->setData(GVKEY_TYPE, type); + if (controlProps.type() == QMetaType::QVariantMap) + { + QVariantMap props = controlProps.toMap(); + if (props.find("filter") != props.end()) + { + auto filter = props["filter"].toStringList(); + pPathEditor->setProperty("filter", filter); + } + } QObject::connect(pPathEditor, &ZenoParamPathEdit::editingFinished, [=]() { cbSet.cbEditFinished(pPathEditor->text()); diff --git a/ui/zenoui/comctrl/zpathedit.cpp b/ui/zenoui/comctrl/zpathedit.cpp index a8b45f6e9d..4bbae9e1d7 100644 --- a/ui/zenoui/comctrl/zpathedit.cpp +++ b/ui/zenoui/comctrl/zpathedit.cpp @@ -24,12 +24,17 @@ void ZPathEdit::initUI(const CALLBACK_SWITCH& cbSwitch) QObject::connect(this, &ZLineEdit::btnClicked, [=]() { int ctrl = this->property("control").toInt(); + QString filter = this->property("filter").toString(); + if (filter.isEmpty()) + { + filter = "All Files(*);;"; + } QString path; cbSwitch(true); if (ctrl == CONTROL_READPATH) { - path = QFileDialog::getOpenFileName(nullptr, "File to Open", "", "All Files(*);;"); + path = QFileDialog::getOpenFileName(nullptr, "File to Open", "", filter); } else if (ctrl == CONTROL_WRITEPATH) { - path = QFileDialog::getSaveFileName(nullptr, "Path to Save", "", "All Files(*);;"); + path = QFileDialog::getSaveFileName(nullptr, "Path to Save", "", filter); } else { path = QFileDialog::getExistingDirectory(nullptr, "Path to Save", ""); } diff --git a/ui/zenoui/comctrl/zwidgetfactory.cpp b/ui/zenoui/comctrl/zwidgetfactory.cpp index 37da1b7ef5..399ac78a9f 100644 --- a/ui/zenoui/comctrl/zwidgetfactory.cpp +++ b/ui/zenoui/comctrl/zwidgetfactory.cpp @@ -76,6 +76,15 @@ namespace zenoui ZPathEdit *pathLineEdit = new ZPathEdit(cbSet.cbSwitch,value.toString()); pathLineEdit->setFixedHeight(ZenoStyle::dpiScaled(zenoui::g_ctrlHeight)); pathLineEdit->setProperty("control", ctrl); + if (properties.type() == QMetaType::QVariantMap) + { + QVariantMap props = properties.toMap(); + if (props.find("filter") != props.end()) + { + auto filter = props["filter"].toStringList(); + pathLineEdit->setProperty("filter", filter); + } + } QObject::connect(pathLineEdit, &ZLineEdit::textEditFinished, [=]() { cbSet.cbEditFinished(pathLineEdit->text()); From 1e2ee53aa2c513493a927bf996b31c9341b81de1 Mon Sep 17 00:00:00 2001 From: luzh Date: Wed, 8 May 2024 16:14:29 +0800 Subject: [PATCH 18/29] update ver. --- ui/zenoedit/zenoedit.rc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/zenoedit/zenoedit.rc b/ui/zenoedit/zenoedit.rc index 3ee1d6adf7..30a237cd8b 100644 --- a/ui/zenoedit/zenoedit.rc +++ b/ui/zenoedit/zenoedit.rc @@ -48,8 +48,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,315 - PRODUCTVERSION 1,3,0,315 + FILEVERSION 1,3,0,501 + PRODUCTVERSION 1,3,0,501 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -66,12 +66,12 @@ BEGIN BEGIN VALUE "CompanyName", "ZENUSTECH" VALUE "FileDescription", "Zeno Editor" - VALUE "FileVersion", "1.3.0.315" + VALUE "FileVersion", "1.3.0.501" VALUE "InternalName", "zenoedit.rc" VALUE "LegalCopyright", "Copyright (C) 2023" VALUE "OriginalFilename", "zenoedit.rc" VALUE "ProductName", "Zeno" - VALUE "ProductVersion", "1.3.0.315" + VALUE "ProductVersion", "1.3.0.501" END END BLOCK "VarFileInfo" From 852743129680fd65a173a4a86e79ee8f2549bc32 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Sat, 11 May 2024 15:21:15 +0800 Subject: [PATCH 19/29] outputPoint --- projects/Alembic/WriteAlembic.cpp | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/projects/Alembic/WriteAlembic.cpp b/projects/Alembic/WriteAlembic.cpp index cc44da2d02..268fedc56c 100644 --- a/projects/Alembic/WriteAlembic.cpp +++ b/projects/Alembic/WriteAlembic.cpp @@ -547,6 +547,7 @@ void prim_to_poly_if_only_vertex(PrimitiveObject* p) { struct WriteAlembic2 : INode { OArchive archive; OPolyMesh meshyObj; + OPoints pointsObj; std::string usedPath; std::map verts_attrs; std::map loops_attrs; @@ -582,7 +583,12 @@ struct WriteAlembic2 : INode { "None" ); real_frame_start = -1; - meshyObj = OPolyMesh( OObject( archive, 1 ), "mesh" ); + if (get_input2("outputPoint")) { + pointsObj = OPoints (OObject( archive, 1 ), "points"); + } + else { + meshyObj = OPolyMesh( OObject( archive, 1 ), "mesh" ); + } verts_attrs.clear(); loops_attrs.clear(); polys_attrs.clear(); @@ -602,7 +608,7 @@ struct WriteAlembic2 : INode { if (flipFrontBack) { primFlipFaces(prim.get()); } - { + if (!get_input2("outputPoint")) { prim_to_poly_if_only_vertex(prim.get()); // Create a PolyMesh class. OPolyMeshSchema &mesh = meshyObj.getSchema(); @@ -683,6 +689,27 @@ struct WriteAlembic2 : INode { } } } + else { + OPointsSchema &points = pointsObj.getSchema(); + OCompoundProperty user = points.getUserProperties(); + write_user_data(user_attrs, "", prim, user, frameid, real_frame_start); + points.setTimeSampling(1); + OPointsSchema::Sample samp(V3fArraySample( ( const V3f * )prim->verts.data(), prim->verts.size() )); + std::vector ids(prim->verts.size()); + if (prim->verts.attr_is("id")) { + auto &ids_ = prim->verts.attr("id"); + for (auto i = 0; i < prim->verts.size(); i++) { + ids[i] = ids_[i]; + } + } + else { + std::iota(ids.begin(), ids.end(), 0); + } + samp.setIds(Alembic::Abc::UInt64ArraySample(ids.data(), ids.size())); + write_velocity(prim, samp); + write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, points, frameid, real_frame_start, prim_size_per_frame); + points.set( samp ); + } } }; @@ -695,6 +722,7 @@ ZENDEFNODE(WriteAlembic2, { {"int", "frame_end", "100"}, {"float", "fps", "25"}, {"bool", "flipFrontBack", "1"}, + {"bool", "outputPoint", "0"}, }, { }, From 1d9d333a3c2da5f0863adb4b0922bf7eda47bc1f Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Sat, 11 May 2024 22:36:33 +0800 Subject: [PATCH 20/29] fix empty prim --- projects/Alembic/ReadAlembic.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/Alembic/ReadAlembic.cpp b/projects/Alembic/ReadAlembic.cpp index 591c2aa5ad..9f2a75c8cf 100644 --- a/projects/Alembic/ReadAlembic.cpp +++ b/projects/Alembic/ReadAlembic.cpp @@ -1218,6 +1218,10 @@ ZENDEFNODE(ReadAlembic, { }); std::shared_ptr abc_split_by_name(std::shared_ptr prim, bool add_when_none) { + auto list = std::make_shared(); + if (prim->verts.size() == 0) { + return list; + } int faceset_count = prim->userData().get2("faceset_count"); if (add_when_none && faceset_count == 0) { auto name = prim->userData().get2("_abc_name"); @@ -1228,7 +1232,6 @@ std::shared_ptr abc_split_by_name(std::shared_ptr p for (auto f = 0; f < faceset_count; f++) { faceset_map[f] = {}; } - auto list = std::make_shared(); if (prim->polys.size()) { auto &faceset = prim->polys.add_attr("faceset"); for (auto j = 0; j < faceset.size(); j++) { From 3e1ccc52cdb7a7875f00d8a1dec5a7e6d8f5407a Mon Sep 17 00:00:00 2001 From: zhuohy <1445643474@qq.com> Date: Tue, 14 May 2024 16:41:57 +0800 Subject: [PATCH 21/29] add cache shortcut --- ui/zenoedit/nodesys/zenosubgraphscene.cpp | 22 ++++++++++---------- ui/zenoedit/nodesys/zenosubgraphscene.h | 6 +----- ui/zenoedit/settings/zenosettingsmanager.cpp | 1 + ui/zenoedit/settings/zsettings.h | 1 + 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.cpp b/ui/zenoedit/nodesys/zenosubgraphscene.cpp index 42a84b2c38..6e2b33ce3e 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.cpp +++ b/ui/zenoedit/nodesys/zenosubgraphscene.cpp @@ -42,9 +42,6 @@ ZenoSubGraphScene::ZenoSubGraphScene(QObject *parent) : QGraphicsScene(parent) , m_tempLink(nullptr) - , m_bOnceOn(false) - , m_bBypassOn(false) - , m_bViewOn(false) { ZtfUtil &inst = ZtfUtil::GetInstance(); m_nodeParams = inst.toUtilParam(inst.loadZtf(":/templates/node-example.xml")); @@ -1228,21 +1225,24 @@ void ZenoSubGraphScene::keyPressEvent(QKeyEvent* event) } else if (!event->isAccepted() && uKey == ZenoSettingsManager::GetInstance().getShortCut(ShortCut_Once)) { - updateNodeStatus(m_bOnceOn, OPT_ONCE); + updateNodeStatus(OPT_ONCE); } else if (!event->isAccepted() && uKey == ZenoSettingsManager::GetInstance().getShortCut(ShortCut_Bypass)) { - updateNodeStatus(m_bBypassOn, OPT_MUTE); + updateNodeStatus(OPT_MUTE); } else if (!event->isAccepted() && uKey == ZenoSettingsManager::GetInstance().getShortCut(ShortCut_View)) { - updateNodeStatus(m_bViewOn, OPT_VIEW); + updateNodeStatus(OPT_VIEW); + } + else if (!event->isAccepted() && uKey == ZenoSettingsManager::GetInstance().getShortCut(ShortCut_Cache)) + { + updateNodeStatus(OPT_CACHE); } } -void ZenoSubGraphScene::updateNodeStatus(bool &bOn, int option) +void ZenoSubGraphScene::updateNodeStatus(int option) { - bOn = !bOn; for (const QModelIndex &idx : selectNodesIndice()) { IGraphsModel *pGraphsModel = zenoApp->graphsManagment()->currentModel(); @@ -1250,10 +1250,10 @@ void ZenoSubGraphScene::updateNodeStatus(bool &bOn, int option) STATUS_UPDATE_INFO info; int options = idx.data(ROLE_OPTIONS).toInt(); info.oldValue = options; - if (bOn) - options |= option; - else + if (options & option) options &= (~option); + else + options |= option; info.role = ROLE_OPTIONS; info.newValue = options; pGraphsModel->updateNodeStatus(idx.data(ROLE_OBJID).toString(), info, m_subgIdx); diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.h b/ui/zenoedit/nodesys/zenosubgraphscene.h index 8b877ac6e1..b44e3c1668 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.h +++ b/ui/zenoedit/nodesys/zenosubgraphscene.h @@ -75,7 +75,7 @@ private slots: void onTempLinkClosed(); ZenoNode* createNode(const QModelIndex& idx, const NodeUtilParam& params); void initLink(const QModelIndex& linkIdx); - void updateNodeStatus(bool &bOn, int option); + void updateNodeStatus(int option); NodeUtilParam m_nodeParams; QPersistentModelIndex m_subgIdx; //index to the subgraphmodel or node in "graphsModel" @@ -85,10 +85,6 @@ private slots: ZenoTempLink* m_tempLink; QVector> m_selChanges; - - bool m_bOnceOn; - bool m_bBypassOn; - bool m_bViewOn; }; #endif diff --git a/ui/zenoedit/settings/zenosettingsmanager.cpp b/ui/zenoedit/settings/zenosettingsmanager.cpp index 11a2753453..2a3d70d846 100644 --- a/ui/zenoedit/settings/zenosettingsmanager.cpp +++ b/ui/zenoedit/settings/zenosettingsmanager.cpp @@ -214,6 +214,7 @@ QVector ZenoSettingsManager::getDefaultShortCutInfo(int style) {ShortCut_View, QObject::tr("View"), "V"}, {ShortCut_Once, QObject::tr("Once"), "C"}, {ShortCut_Bypass, QObject::tr("Bypass"), "B"}, + {ShortCut_Cache, QObject::tr("Cache"), "X"}, {ShortCut_FloatPanel, QObject::tr("Float Panel"), "P"}, {ShortCut_CoordSys, QObject::tr("CoordSys"), "M"}, {ShortCut_InitHandler, QObject::tr("Init Handler"), "Backspace"}, diff --git a/ui/zenoedit/settings/zsettings.h b/ui/zenoedit/settings/zsettings.h index 3192e99576..42682047ff 100644 --- a/ui/zenoedit/settings/zsettings.h +++ b/ui/zenoedit/settings/zsettings.h @@ -63,6 +63,7 @@ const char *const ShortCut_SelectAllNodes = "Select All Nodes"; const char *const ShortCut_View = "View"; const char *const ShortCut_Bypass = "Bypass"; const char *const ShortCut_Once = "Once"; +const char* const ShortCut_Cache = "Cache"; const char *const ShortCut_MovingView = "Moving View"; const char *const ShortCut_RotatingView = "Rotating View"; const char *const ShortCut_ScalingView = "Scaling View"; From d2ad9ed43d33a7a0eccc44c4a31cf81c3ef0e7b6 Mon Sep 17 00:00:00 2001 From: luzh Date: Wed, 15 May 2024 09:20:31 +0800 Subject: [PATCH 22/29] update ver. --- ui/zenoedit/zenoedit.rc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/zenoedit/zenoedit.rc b/ui/zenoedit/zenoedit.rc index 30a237cd8b..1b36cb2d25 100644 --- a/ui/zenoedit/zenoedit.rc +++ b/ui/zenoedit/zenoedit.rc @@ -48,8 +48,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,501 - PRODUCTVERSION 1,3,0,501 + FILEVERSION 1,3,0,515 + PRODUCTVERSION 1,3,0,515 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -66,12 +66,12 @@ BEGIN BEGIN VALUE "CompanyName", "ZENUSTECH" VALUE "FileDescription", "Zeno Editor" - VALUE "FileVersion", "1.3.0.501" + VALUE "FileVersion", "1.3.0.515" VALUE "InternalName", "zenoedit.rc" VALUE "LegalCopyright", "Copyright (C) 2023" VALUE "OriginalFilename", "zenoedit.rc" VALUE "ProductName", "Zeno" - VALUE "ProductVersion", "1.3.0.501" + VALUE "ProductVersion", "1.3.0.515" END END BLOCK "VarFileInfo" From 06791fc6d0fe5d3e7655d068a9112ceb9519d3cb Mon Sep 17 00:00:00 2001 From: luzh Date: Thu, 16 May 2024 16:16:35 +0800 Subject: [PATCH 23/29] just remove all cache flags. --- ui/zenoedit/nodesys/zenosubgraphscene.cpp | 18 +++++++++++++++++- ui/zenoedit/nodesys/zenosubgraphscene.h | 1 + ui/zenoedit/zenoedit.rc | 8 ++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.cpp b/ui/zenoedit/nodesys/zenosubgraphscene.cpp index 6e2b33ce3e..35f3089b2d 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.cpp +++ b/ui/zenoedit/nodesys/zenosubgraphscene.cpp @@ -1237,7 +1237,23 @@ void ZenoSubGraphScene::keyPressEvent(QKeyEvent* event) } else if (!event->isAccepted() && uKey == ZenoSettingsManager::GetInstance().getShortCut(ShortCut_Cache)) { - updateNodeStatus(OPT_CACHE); + removeNodeCache(); + } +} + +void ZenoSubGraphScene::removeNodeCache() +{ + for (const QModelIndex& idx : selectNodesIndice()) + { + IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel(); + ZASSERT_EXIT(pGraphsModel); + STATUS_UPDATE_INFO info; + int options = idx.data(ROLE_OPTIONS).toInt(); + info.oldValue = options; + options &= (~(int)OPT_CACHE); + info.role = ROLE_OPTIONS; + info.newValue = options; + pGraphsModel->updateNodeStatus(idx.data(ROLE_OBJID).toString(), info, m_subgIdx); } } diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.h b/ui/zenoedit/nodesys/zenosubgraphscene.h index b44e3c1668..a1e6451c91 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.h +++ b/ui/zenoedit/nodesys/zenosubgraphscene.h @@ -76,6 +76,7 @@ private slots: ZenoNode* createNode(const QModelIndex& idx, const NodeUtilParam& params); void initLink(const QModelIndex& linkIdx); void updateNodeStatus(int option); + void removeNodeCache(); NodeUtilParam m_nodeParams; QPersistentModelIndex m_subgIdx; //index to the subgraphmodel or node in "graphsModel" diff --git a/ui/zenoedit/zenoedit.rc b/ui/zenoedit/zenoedit.rc index 1b36cb2d25..aa4b6b811a 100644 --- a/ui/zenoedit/zenoedit.rc +++ b/ui/zenoedit/zenoedit.rc @@ -48,8 +48,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,515 - PRODUCTVERSION 1,3,0,515 + FILEVERSION 1,3,1,515 + PRODUCTVERSION 1,3,1,515 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -66,12 +66,12 @@ BEGIN BEGIN VALUE "CompanyName", "ZENUSTECH" VALUE "FileDescription", "Zeno Editor" - VALUE "FileVersion", "1.3.0.515" + VALUE "FileVersion", "1.3.1.515" VALUE "InternalName", "zenoedit.rc" VALUE "LegalCopyright", "Copyright (C) 2023" VALUE "OriginalFilename", "zenoedit.rc" VALUE "ProductName", "Zeno" - VALUE "ProductVersion", "1.3.0.515" + VALUE "ProductVersion", "1.3.1.515" END END BLOCK "VarFileInfo" From 40ee0ac9372888899c9a8d227411407f023f5948 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Thu, 16 May 2024 18:38:57 +0800 Subject: [PATCH 24/29] improve-clone --- zeno/src/nodes/PortalNodes.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zeno/src/nodes/PortalNodes.cpp b/zeno/src/nodes/PortalNodes.cpp index 79adf7787e..b447e09575 100644 --- a/zeno/src/nodes/PortalNodes.cpp +++ b/zeno/src/nodes/PortalNodes.cpp @@ -74,12 +74,16 @@ struct Clone : zeno::INode { return; } set_output("newObject", std::move(newobj)); + set_output("origin", obj); } }; ZENDEFNODE(Clone, { {"object"}, - {"newObject"}, + { + "newObject", + "origin", + }, {}, {"lifecycle"}, }); From e978bcea914feb6a6657699798beac4ad7a35bcf Mon Sep 17 00:00:00 2001 From: littlemine Date: Tue, 21 May 2024 20:41:29 +0800 Subject: [PATCH 25/29] for zpc upd --- projects/CUDA/remesh/simplification.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/CUDA/remesh/simplification.cpp b/projects/CUDA/remesh/simplification.cpp index 76318867eb..f4773d2db8 100644 --- a/projects/CUDA/remesh/simplification.cpp +++ b/projects/CUDA/remesh/simplification.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "zensim/container/Bht.hpp" #include "zensim/omp/execution/ExecutionPolicy.hpp" From c33ca04143cabb6c402754c92df34750e5a0b033 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Thu, 23 May 2024 01:51:29 +0800 Subject: [PATCH 26/29] fbx-improve --- projects/FBX/FBXSDK.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/FBX/FBXSDK.cpp b/projects/FBX/FBXSDK.cpp index 9e60135789..1cee6f6b68 100644 --- a/projects/FBX/FBXSDK.cpp +++ b/projects/FBX/FBXSDK.cpp @@ -9,8 +9,6 @@ #include #include -#ifdef ZENO_FBXSDK -#include #include "zeno/utils/log.h" #include #include "zeno/types/PrimitiveObject.h" @@ -19,6 +17,9 @@ #include #include +#ifdef ZENO_FBXSDK +#include + namespace FBX{ void GetChildNodePathRecursive(FbxNode* node, std::string& path) { if (node->GetParent()) { @@ -1089,6 +1090,9 @@ ZENDEFNODE(NewFBXImportCamera, { {}, {"primitive"}, }); +} +#endif +namespace zeno { struct NewFBXBoneDeform : INode { std::vector getBoneNames(PrimitiveObject *prim) { auto boneName_count = prim->userData().get2("boneName_count"); @@ -1173,7 +1177,7 @@ struct NewFBXBoneDeform : INode { auto &bi = prim->verts.add_attr("boneName"); auto &bw = prim->verts.add_attr("boneWeight"); size_t vert_count = prim->verts.size(); - #pragma omp parallel for +#pragma omp parallel for for (auto i = 0; i < vert_count; i++) { auto opos = prim->verts[i]; vec3f pos = {}; @@ -1302,5 +1306,4 @@ ZENDEFNODE(BoneTransformView, { {}, {"debug"}, }); -} -#endif \ No newline at end of file +} \ No newline at end of file From 4e91975cad77145a0fb40644a0548ad1be574b5e Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Thu, 23 May 2024 20:41:15 +0800 Subject: [PATCH 27/29] improve-abc-to-maya --- projects/Alembic/WriteAlembic.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/projects/Alembic/WriteAlembic.cpp b/projects/Alembic/WriteAlembic.cpp index 268fedc56c..8f6ec7220a 100644 --- a/projects/Alembic/WriteAlembic.cpp +++ b/projects/Alembic/WriteAlembic.cpp @@ -674,7 +674,9 @@ struct WriteAlembic2 : INode { uvsamp); write_velocity(prim, mesh_samp); write_normal(prim, mesh_samp); - write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, mesh, frameid, real_frame_start, prim_size_per_frame); + if (get_input2("outputToMaya") == false) { + write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, mesh, frameid, real_frame_start, prim_size_per_frame); + } mesh.set( mesh_samp ); } else { @@ -684,7 +686,9 @@ struct WriteAlembic2 : INode { Int32ArraySample( vertex_count_per_face.data(), vertex_count_per_face.size() )); write_velocity(prim, mesh_samp); write_normal(prim, mesh_samp); - write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, mesh, frameid, real_frame_start, prim_size_per_frame); + if (get_input2("outputToMaya") == false) { + write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, mesh, frameid, real_frame_start, prim_size_per_frame); + } mesh.set( mesh_samp ); } } @@ -707,7 +711,9 @@ struct WriteAlembic2 : INode { } samp.setIds(Alembic::Abc::UInt64ArraySample(ids.data(), ids.size())); write_velocity(prim, samp); - write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, points, frameid, real_frame_start, prim_size_per_frame); + if (get_input2("outputToMaya") == false) { + write_attrs(verts_attrs, loops_attrs, polys_attrs, "", prim, points, frameid, real_frame_start, prim_size_per_frame); + } points.set( samp ); } } @@ -723,6 +729,7 @@ ZENDEFNODE(WriteAlembic2, { {"float", "fps", "25"}, {"bool", "flipFrontBack", "1"}, {"bool", "outputPoint", "0"}, + {"bool", "outputToMaya", "0"}, }, { }, @@ -944,7 +951,9 @@ struct WriteAlembicPrims : INode { uvsamp); write_velocity(prim, mesh_samp); write_normal(prim, mesh_samp); - write_attrs(verts_attrs, loops_attrs, polys_attrs, path, prim, mesh, frameid, real_frame_start, prim_size_per_frame[path]); + if (get_input2("outputToMaya") == false) { + write_attrs(verts_attrs, loops_attrs, polys_attrs, path, prim, mesh, frameid, real_frame_start, prim_size_per_frame[path]); + } mesh.set( mesh_samp ); } else { @@ -954,7 +963,9 @@ struct WriteAlembicPrims : INode { Int32ArraySample( vertex_count_per_face.data(), vertex_count_per_face.size() )); write_velocity(prim, mesh_samp); write_normal(prim, mesh_samp); - write_attrs(verts_attrs, loops_attrs, polys_attrs, path, prim, mesh, frameid, real_frame_start, prim_size_per_frame[path]); + if (get_input2("outputToMaya") == false) { + write_attrs(verts_attrs, loops_attrs, polys_attrs, path, prim, mesh, frameid, real_frame_start, prim_size_per_frame[path]); + } mesh.set( mesh_samp ); } } @@ -973,6 +984,7 @@ ZENDEFNODE(WriteAlembicPrims, { {"int", "frame_end", "100"}, {"float", "fps", "25"}, {"bool", "flipFrontBack", "1"}, + {"bool", "outputToMaya", "0"}, }, { }, From 4773fbd4acbe216d8ef6b96b328497a3ffbe4ab0 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Wed, 29 May 2024 18:01:02 +0800 Subject: [PATCH 28/29] fix-selectmode-when-delete --- ui/zenoedit/nodesys/zenosubgraphscene.cpp | 4 ++++ ui/zenoedit/viewport/cameracontrol.cpp | 4 ++-- ui/zenoedit/viewport/displaywidget.cpp | 12 ++++++++---- ui/zenoedit/viewportinteraction/picker.cpp | 16 ++++++++-------- zenovis/include/zenovis/Scene.h | 5 ++++- zenovis/src/Scene.cpp | 8 ++++++++ zenovis/src/bate/FrameBufferPicker.cpp | 12 ++++++------ zenovis/src/bate/HudGraphicPrimHighlight.cpp | 8 ++++---- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.cpp b/ui/zenoedit/nodesys/zenosubgraphscene.cpp index 35f3089b2d..789d3c4eb4 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.cpp +++ b/ui/zenoedit/nodesys/zenosubgraphscene.cpp @@ -48,6 +48,9 @@ ZenoSubGraphScene::ZenoSubGraphScene(QObject *parent) // bsp tree index causes crash when removeItem and delete item. for safety, disable it. // https://stackoverflow.com/questions/38458830/crash-after-qgraphicssceneremoveitem-with-custom-item-class setItemIndexMethod(QGraphicsScene::NoIndex); + connect(this, &ZenoSubGraphScene::selectionChanged, this, [=]() { + afterSelectionChanged(); + }); } ZenoSubGraphScene::~ZenoSubGraphScene() @@ -1015,6 +1018,7 @@ void ZenoSubGraphScene::onRowsAboutToBeRemoved(const QModelIndex& subgIdx, const QString id = idx.data(ROLE_OBJID).toString(); ZASSERT_EXIT(m_nodes.find(id) != m_nodes.end()); ZenoNode* pNode = m_nodes[id]; + pNode->setSelected(false); if (qobject_cast(pNode)) { GroupNode *pBlackboard = qobject_cast(pNode); diff --git a/ui/zenoedit/viewport/cameracontrol.cpp b/ui/zenoedit/viewport/cameracontrol.cpp index 2978c63ba2..3ee954ef05 100644 --- a/ui/zenoedit/viewport/cameracontrol.cpp +++ b/ui/zenoedit/viewport/cameracontrol.cpp @@ -668,7 +668,7 @@ void CameraControl::fakeMouseReleaseEvent(QMouseEvent *event) { } else { m_picker->pick(releasePos.x(), releasePos.y()); m_picker->sync_to_scene(); - if (scene->select_mode == zenovis::PICK_MODE::PICK_OBJECT) + if (scene->get_select_mode() == zenovis::PICK_MODE::PICK_OBJECT) onPrimSelected(); m_transformer->clear(); m_transformer->addObject(m_picker->get_picked_prims()); @@ -703,7 +703,7 @@ void CameraControl::fakeMouseReleaseEvent(QMouseEvent *event) { m_picker->pick(x0, y0, x1, y1, mode); m_picker->sync_to_scene(); - if (scene->select_mode == zenovis::PICK_MODE::PICK_OBJECT) + if (scene->get_select_mode() == zenovis::PICK_MODE::PICK_OBJECT) onPrimSelected(); m_transformer->clear(); m_transformer->addObject(m_picker->get_picked_prims()); diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 920d3dfe8d..5a01efa4ef 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1337,11 +1337,11 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex // read selected mode auto select_mode_str = zeno::NodeSyncMgr::GetInstance().getInputValString(nodes[0], "mode"); if (select_mode_str == "triangle") - scene->select_mode = zenovis::PICK_MODE::PICK_MESH; + scene->set_select_mode(zenovis::PICK_MODE::PICK_MESH); else if (select_mode_str == "line") - scene->select_mode = zenovis::PICK_MODE::PICK_LINE; + scene->set_select_mode(zenovis::PICK_MODE::PICK_LINE); else - scene->select_mode = zenovis::PICK_MODE::PICK_VERTEX; + scene->set_select_mode(zenovis::PICK_MODE::PICK_VERTEX); // read selected elements string node_context; auto node_selected_str = zeno::NodeSyncMgr::GetInstance().getParamValString(nodes[0], "selected"); @@ -1353,7 +1353,7 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex node_context += prim_name + ":" + e.toStdString() + " "; if (picker) - picker->load_from_str(node_context, scene->select_mode, zeno::SELECTION_MODE::NORMAL); + picker->load_from_str(node_context, scene->get_select_mode(), zeno::SELECTION_MODE::NORMAL); } if (picker) { picker->sync_to_scene(); @@ -1365,6 +1365,10 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex picker->sync_to_scene(); picker->focus(""); picker->set_picked_elems_callback({}); + { + picker->clear(); + scene->set_select_mode(zenovis::PICK_MODE::PICK_OBJECT); + } } } zenoApp->getMainWindow()->updateViewport(); diff --git a/ui/zenoedit/viewportinteraction/picker.cpp b/ui/zenoedit/viewportinteraction/picker.cpp index 2f9714d141..43ded13b37 100644 --- a/ui/zenoedit/viewportinteraction/picker.cpp +++ b/ui/zenoedit/viewportinteraction/picker.cpp @@ -108,7 +108,7 @@ void Picker::pick(int x, int y) { // scene->select_mode = zenovis::PICK_MODE::PICK_MESH; auto selected = picker->getPicked(x, y); - if (scene->select_mode == zenovis::PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == zenovis::PICK_MODE::PICK_OBJECT) { if (selected.empty()) { selected_prims.clear(); return; @@ -150,7 +150,7 @@ void Picker::pick(int x0, int y0, int x1, int y1, SELECTION_MODE mode) { ZASSERT_EXIT(scene); auto selected = picker->getPicked(x0, y0, x1, y1); // qDebug() << "pick: " << selected.c_str(); - if (scene->select_mode == zenovis::PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == zenovis::PICK_MODE::PICK_OBJECT) { if (selected.empty()) { selected_prims.clear(); return; @@ -158,7 +158,7 @@ void Picker::pick(int x0, int y0, int x1, int y1, SELECTION_MODE mode) { load_from_str(selected, zenovis::PICK_MODE::PICK_OBJECT, SELECTION_MODE::NORMAL); } else { - load_from_str(selected, scene->select_mode, mode); + load_from_str(selected, scene->get_select_mode(), mode); if (picked_elems_callback) picked_elems_callback(selected_elements); } } @@ -177,10 +177,10 @@ string Picker::just_pick_prim(int x, int y) { auto scene = this->scene(); ZASSERT_EXIT(scene, ""); - auto store_mode = scene->select_mode; - scene->select_mode = zenovis::PICK_MODE::PICK_OBJECT; + auto store_mode = scene->get_select_mode(); + scene->set_select_mode(zenovis::PICK_MODE::PICK_OBJECT); auto res = picker->getPicked(x, y); - scene->select_mode = store_mode; + scene->set_select_mode(store_mode); return res; } @@ -252,7 +252,7 @@ void Picker::save_context() { auto scene = this->scene(); ZASSERT_EXIT(scene); - select_mode_context = scene->select_mode; + select_mode_context = scene->get_select_mode(); selected_prims_context = std::move(selected_prims); selected_elements_context = std::move(selected_elements); } @@ -263,7 +263,7 @@ void Picker::load_context() { auto scene = this->scene(); ZASSERT_EXIT(scene); - scene->select_mode = select_mode_context; + scene->set_select_mode(select_mode_context); selected_prims = std::move(selected_prims_context); selected_elements = std::move(selected_elements_context); select_mode_context = zenovis::PICK_MODE::PICK_NONE; diff --git a/zenovis/include/zenovis/Scene.h b/zenovis/include/zenovis/Scene.h index 2d379bc035..45f358bd0c 100644 --- a/zenovis/include/zenovis/Scene.h +++ b/zenovis/include/zenovis/Scene.h @@ -30,7 +30,6 @@ enum class PICK_MODE { struct Scene : zeno::disable_copy { std::optional select_box = {}; std::unordered_set selected = {}; - PICK_MODE select_mode = PICK_MODE::PICK_OBJECT; std::unordered_map> selected_elements = {}; std::unique_ptr camera; std::unique_ptr drawOptions; @@ -50,6 +49,10 @@ struct Scene : zeno::disable_copy { bool cameraFocusOnNode(std::string const &nodeid, zeno::vec3f ¢er, float &radius); static void loadGLAPI(void *procaddr); void* getOptixImg(int &w, int &h); + void set_select_mode(PICK_MODE _select_mode); + PICK_MODE get_select_mode(); +private: + PICK_MODE select_mode = PICK_MODE::PICK_OBJECT; }; } // namespace zenovis diff --git a/zenovis/src/Scene.cpp b/zenovis/src/Scene.cpp index 11df211415..c54654e662 100644 --- a/zenovis/src/Scene.cpp +++ b/zenovis/src/Scene.cpp @@ -15,6 +15,7 @@ #ifdef ZENO_ENABLE_OPTIX #include "../xinxinoptix/xinxinoptixapi.h" #endif +//#include #include #include @@ -113,6 +114,13 @@ bool Scene::loadFrameObjects(int frameid) { return inserted; } +void Scene::set_select_mode(PICK_MODE _select_mode) { +// zeno::log_info("{} -> {}", magic_enum::enum_name(select_mode), magic_enum::enum_name(_select_mode)); + select_mode = _select_mode; +} +PICK_MODE Scene::get_select_mode() { + return select_mode; +} void Scene::draw(bool record) { if (renderMan->getDefaultEngineName() != "optx") { diff --git a/zenovis/src/bate/FrameBufferPicker.cpp b/zenovis/src/bate/FrameBufferPicker.cpp index c414589810..c0e8ffafc3 100644 --- a/zenovis/src/bate/FrameBufferPicker.cpp +++ b/zenovis/src/bate/FrameBufferPicker.cpp @@ -309,7 +309,7 @@ struct FrameBufferPicker : IPicker { vbo->attribute(0, sizeof(float) * 0, sizeof(float) * 3, GL_FLOAT, 3); bool pick_particle = false; - if (scene->select_mode == PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == PICK_MODE::PICK_OBJECT) { pick_particle = prim->tris->empty() && prim->quads->empty() && prim->polys->empty() && prim->loops->empty(); CHECK_GL(glEnable(GL_DEPTH_TEST)); CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); @@ -343,7 +343,7 @@ struct FrameBufferPicker : IPicker { CHECK_GL(glDisable(GL_DEPTH_TEST)); } - if (scene->select_mode == PICK_MODE::PICK_VERTEX || pick_particle) { + if (scene->get_select_mode() == PICK_MODE::PICK_VERTEX || pick_particle) { // ----- enable depth test ----- CHECK_GL(glEnable(GL_DEPTH_TEST)); CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); @@ -387,7 +387,7 @@ struct FrameBufferPicker : IPicker { CHECK_GL(glDisable(GL_DEPTH_TEST)); } - if (scene->select_mode == PICK_MODE::PICK_LINE) { + if (scene->get_select_mode() == PICK_MODE::PICK_LINE) { // ----- enable depth test ----- CHECK_GL(glEnable(GL_DEPTH_TEST)); CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); @@ -454,7 +454,7 @@ struct FrameBufferPicker : IPicker { CHECK_GL(glDisable(GL_DEPTH_TEST)); } - if (scene->select_mode == PICK_MODE::PICK_MESH) { + if (scene->get_select_mode() == PICK_MODE::PICK_MESH) { // ----- enable depth test ----- CHECK_GL(glEnable(GL_DEPTH_TEST)); CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); @@ -541,7 +541,7 @@ struct FrameBufferPicker : IPicker { fbo->unbind(); string result; - if (scene->select_mode == PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == PICK_MODE::PICK_OBJECT) { if (!pixel.has_object() || !id_table.count(pixel.obj_id)) return ""; result = id_table[pixel.obj_id]; } @@ -594,7 +594,7 @@ struct FrameBufferPicker : IPicker { fbo->unbind(); string result; - if (scene->select_mode == PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == PICK_MODE::PICK_OBJECT) { unordered_set selected_obj; // fetch selected objects' ids for (int i = 0; i < pixel_count; i++) { diff --git a/zenovis/src/bate/HudGraphicPrimHighlight.cpp b/zenovis/src/bate/HudGraphicPrimHighlight.cpp index 833dcc5028..1e6cbee273 100644 --- a/zenovis/src/bate/HudGraphicPrimHighlight.cpp +++ b/zenovis/src/bate/HudGraphicPrimHighlight.cpp @@ -75,7 +75,7 @@ struct PrimitiveHighlight : IGraphicDraw { CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); glDepthFunc(GL_GREATER); CHECK_GL(glClearDepth(0.0)); - if (scene->select_mode == PICK_MODE::PICK_OBJECT) { + if (scene->get_select_mode() == PICK_MODE::PICK_OBJECT) { for (const auto &prim_id : scene->selected) { // ----- get primitive ----- PrimitiveObject *prim = nullptr; @@ -143,7 +143,7 @@ struct PrimitiveHighlight : IGraphicDraw { vbo->attribute(0, sizeof(float) * 0, sizeof(float) * 3, GL_FLOAT, 3); // ----- draw selected vertices ----- - if (scene->select_mode == PICK_MODE::PICK_VERTEX) { + if (scene->get_select_mode() == PICK_MODE::PICK_VERTEX) { // prepare indices CHECK_GL(glEnable(GL_PROGRAM_POINT_SIZE)); vector ind(selected_count); @@ -159,7 +159,7 @@ struct PrimitiveHighlight : IGraphicDraw { } // ----- draw selected edges ----- - if (scene->select_mode == PICK_MODE::PICK_LINE) { + if (scene->get_select_mode() == PICK_MODE::PICK_LINE) { if (prim->lines->empty()) return; // prepare indices vector ind(selected_count); @@ -175,7 +175,7 @@ struct PrimitiveHighlight : IGraphicDraw { } // ----- draw selected meshes ----- - if (scene->select_mode == PICK_MODE::PICK_MESH) { + if (scene->get_select_mode() == PICK_MODE::PICK_MESH) { // prepare indices vector ind(selected_count); int i = 0; From f989144d07e79b31cf9469cb09221c13cd39de1f Mon Sep 17 00:00:00 2001 From: littlemine Date: Thu, 30 May 2024 18:14:47 +0800 Subject: [PATCH 29/29] p2p attrib assign --- projects/CUDA/utils/Primitives.cpp | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/projects/CUDA/utils/Primitives.cpp b/projects/CUDA/utils/Primitives.cpp index a795fdb7fb..f5d60cb5e6 100644 --- a/projects/CUDA/utils/Primitives.cpp +++ b/projects/CUDA/utils/Primitives.cpp @@ -4633,6 +4633,54 @@ ZENDEFNODE(AdvanceFrame, { {"zs_geom"}, }); +struct PrimAssignRefAttrib : INode { + virtual void apply() override { + auto points = get_input("prim"); + auto prim = get_input("ref_prim"); + auto idTag = get_input2("pointIdTag"); + auto tag = get_input2("attribTag"); + + auto pointIndex = points->attr(idTag); + + auto assignAttrib = [&pointIndex](auto &dstAttrib, const auto &srcAttrib) { + if constexpr (zs::is_same_v) { + #pragma omp parallel for + for (auto index = 0; index < dstAttrib.size(); ++index) { + dstAttrib[index] = srcAttrib[(int)pointIndex[index]]; + } + } else + throw std::runtime_error( + fmt::format("destination attrib [{}], source attrib [{}]\n", + zs::get_var_type_str(dstAttrib), zs::get_var_type_str(srcAttrib))); + }; + + if (tag == "pos") { + assignAttrib(points->verts.values, prim->verts.values); + } else { + zs::match([&verts = points->verts, &tag](const auto &src) { + verts.add_attr(tag); + })(prim->verts.attr(tag)); + zs::match([&assignAttrib](auto &dst, const auto &src) { + assignAttrib(dst, src); + })(points->verts.attr(tag), prim->verts.attr(tag)); + } + + set_output("prim", get_input("prim")); + } +}; + +ZENDEFNODE(PrimAssignRefAttrib, { + { + "prim", + "ref_prim", + {"string", "pointIdTag", "bvh_id"}, + {"string", "attribTag"}, + }, + {"prim"}, + {}, + {"primitive"}, + }); + struct RemovePrimitiveTopo : INode { void apply() override { auto prim = get_input2("prim");