Skip to content

Commit

Permalink
Merge pull request #2082 from zenustech/optix-viewport-pause
Browse files Browse the repository at this point in the history
optix-viewport-pause
  • Loading branch information
legobadman authored Feb 28, 2025
2 parents d2b49f3 + c125b52 commit 63b1d12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ui/zenoedit/dock/docktabcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,9 @@ void DockContent_View::initToolbar(QHBoxLayout* pToolLayout)
pToolLayout->addWidget(m_background);
m_camera_setting = new QPushButton("Camera");
pToolLayout->addWidget(m_camera_setting);
m_pause = new QPushButton("Pause");
m_pause->setCheckable(true);
pToolLayout->addWidget(m_pause);
}

{
Expand Down Expand Up @@ -987,6 +990,11 @@ void DockContent_View::initConnections()
}
});
}
if (m_pause) {
connect(m_pause, &QPushButton::clicked, this, [=](bool bToggled) {
zeno::getSession().userData().set2("viewport-optix-pause", bToggled);
});
}
if (m_Reset) {
connect(m_Reset, &QPushButton::clicked, this, [=](bool bToggled) {
auto *scene = m_pDisplay->getZenoVis()->getSession()->get_scene();
Expand Down
1 change: 1 addition & 0 deletions ui/zenoedit/dock/docktabcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class DockContent_View : public DockToolbarWidget
ZToolBarButton* m_rotateBtn;
ZToolBarButton* m_resizeViewport;
QPushButton *m_camera_setting = nullptr;
QPushButton *m_pause = nullptr;
QCheckBox *m_background;
QCheckBox *m_uv_mode = nullptr;
QCheckBox *m_depth = nullptr;
Expand Down
5 changes: 4 additions & 1 deletion zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,8 +3127,12 @@ void optixrender(int fbo, int samples, bool denoise, bool simpleRender) {
// updateState( *output_buffer_transmit, state.params);
// updateState( *output_buffer_background, state.params);

auto &ud = zeno::getSession().userData();
const int max_samples_once = 1;
for (int f = 0; f < samples; f += max_samples_once) { // 张心欣不要改这里
if (ud.get2<bool>("viewport-optix-pause", false)) {
continue;
}

state.params.samples_per_launch = std::min(samples - f, max_samples_once);
launchSubframe( *output_buffer_o, state, denoise);
Expand All @@ -3138,7 +3142,6 @@ void optixrender(int fbo, int samples, bool denoise, bool simpleRender) {
#ifdef OPTIX_BASE_GL
displaySubframe( *output_buffer_o, *gl_display_o, state, fbo );
#endif
auto &ud = zeno::getSession().userData();
if (ud.has("optix_image_path")) {
auto path = ud.get2<std::string>("optix_image_path");
auto p = (*output_buffer_o).getHostPointer();
Expand Down

0 comments on commit 63b1d12

Please sign in to comment.