Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
depth attenuation on meshes. fixed memory leaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
takashi310 committed Jan 14, 2022
1 parent 5eb4b30 commit e439bfc
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 9 deletions.
4 changes: 4 additions & 0 deletions fluorender/FluoRender/ClippingView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ void ClippingView::CalcBoundingBoxDemensions(double &w, double &h, double &d)
}
break;
}

w = w > 0 ? w : 1;
h = h > 0 ? h : 1;
d = d > 0 ? d : 1;
}

void ClippingView::GetSettings()
Expand Down
2 changes: 0 additions & 2 deletions fluorender/FluoRender/MPropView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ void MPropView::GetSettings()
{
m_r_st->Disable();
m_r_text->Disable();
str = wxString::Format("%.2f", m_md->GetRadScale());
m_r_text->ChangeValue(str);
}

SetEvtHandlerEnabled(true);
Expand Down
2 changes: 1 addition & 1 deletion fluorender/FluoRender/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool VRenderApp::OnInit()
std::string(VERSION_MAJOR_TAG) + std::string(".") +
std::string(VERSION_MINOR_TAG);
*/
std::string title = std::string(FLUORENDER_TITLE) + "1.4.2";
std::string title = std::string(FLUORENDER_TITLE) + "1.4.3";

m_frame = new VRenderFrame(
this,
Expand Down
45 changes: 45 additions & 0 deletions fluorender/FluoRender/SettingDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ BEGIN_EVENT_TABLE(SettingDlg, wxPanel)
EVT_TEXT(ID_PaintHistDepthText, SettingDlg::OnPaintHistDepthEdit)
//show
EVT_SHOW(SettingDlg::OnShow)
EVT_CHECKBOX(ID_UseFogMesh, SettingDlg::OnUseFogMeshCheck)
END_EVENT_TABLE()

wxWindow* SettingDlg::CreateProjectPage(wxWindow *parent)
Expand Down Expand Up @@ -242,6 +243,14 @@ wxWindow* SettingDlg::CreateRenderingPage(wxWindow *parent)
group1->Add(10, 5);
group1->Add(st);
group1->Add(10, 5);

//fog on mesh
wxBoxSizer *groupf = new wxStaticBoxSizer(new wxStaticBox(page, wxID_ANY, "Depth Attenuation"), wxVERTICAL);
m_use_fog_mesh_chk = new wxCheckBox(page, ID_UseFogMesh,
"Enable depth attenuation on meshes");
groupf->Add(10, 5);
groupf->Add(m_use_fog_mesh_chk);
groupf->Add(10, 5);

//depth peeling
wxBoxSizer *group2 = new wxStaticBoxSizer(
Expand Down Expand Up @@ -314,6 +323,8 @@ wxWindow* SettingDlg::CreateRenderingPage(wxWindow *parent)

sizerV->Add(10, 10);
sizerV->Add(group1, 0, wxEXPAND);
sizerV->Add(10, 10);
sizerV->Add(groupf, 0, wxEXPAND);
sizerV->Add(10, 10);
sizerV->Add(group2, 0, wxEXPAND);
sizerV->Add(10, 10);
Expand Down Expand Up @@ -656,6 +667,7 @@ void SettingDlg::GetSettings()
m_paint_hist_depth = 0;
m_stay_top = false;
m_show_cursor = true;
m_use_fog_mesh = false;

wxString expath = wxStandardPaths::Get().GetExecutablePath();
expath = expath.BeforeLast(GETSLASH(),NULL);
Expand Down Expand Up @@ -873,6 +885,12 @@ void SettingDlg::GetSettings()
fconfig.SetPath("/cl device");
fconfig.Read("device_id", &m_cl_device_id);
}
//depth attenuation
if (fconfig.Exists("/use fog mesh"))
{
fconfig.SetPath("/use fog mesh");
fconfig.Read("use_fog_mesh", &m_use_fog_mesh);
}

UpdateUI();
}
Expand Down Expand Up @@ -950,6 +968,8 @@ void SettingDlg::UpdateUI()
m_block_size_text->SetValue(wxString::Format("%d", m_force_brick_size));
m_response_time_text->SetValue(wxString::Format("%d", m_up_time));
m_main_mem_buf_text->SetValue(wxString::Format("%d", (int)m_main_mem_buf_size));

m_use_fog_mesh_chk->SetValue(m_use_fog_mesh);
}

void SettingDlg::SaveSettings()
Expand Down Expand Up @@ -1078,6 +1098,9 @@ void SettingDlg::SaveSettings()
//cl device
fconfig.SetPath("/cl device");
fconfig.Write("device_id", m_cl_device_id);

fconfig.SetPath("/use fog mesh");
fconfig.Write("use_fog_mesh", m_use_fog_mesh);

wxString expath = wxStandardPaths::Get().GetExecutablePath();
expath = expath.BeforeLast(GETSLASH(),NULL);
Expand Down Expand Up @@ -1323,6 +1346,28 @@ void SettingDlg::OnShadowDirEdit(wxCommandEvent &event)
}
}

void SettingDlg::OnUseFogMeshCheck(wxCommandEvent &event)
{
if (m_use_fog_mesh_chk->GetValue())
m_use_fog_mesh = true;
else
m_use_fog_mesh = false;

VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (vr_frame)
{
for (int i=0 ; i<(int)vr_frame->GetViewList()->size() ; i++)
{
VRenderView* vrv = (*vr_frame->GetViewList())[i];
if (vrv)
{
vrv->SetUseFogMesh(m_use_fog_mesh);
vrv->RefreshGL();
}
}
}
}

void SettingDlg::EnableStreaming(bool enable)
{
if (enable)
Expand Down
12 changes: 11 additions & 1 deletion fluorender/FluoRender/SettingDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class EXPORT_API SettingDlg : public wxPanel
ID_PaintHistDepthText,
//save/close
ID_SaveBtn,
ID_CloseBtn
ID_CloseBtn,
ID_UseFogMesh
};

public:
Expand Down Expand Up @@ -188,6 +189,9 @@ class EXPORT_API SettingDlg : public wxPanel
int GetGLProfileMask() {return m_gl_profile_mask;}
//cl device
int GetCLDeviceID() {return m_cl_device_id;}

bool GetUseFogMesh() {return m_use_fog_mesh;}
void SetUseFogMesh(bool val) {m_use_fog_mesh = val;}

private:
wxWindow* m_frame;
Expand Down Expand Up @@ -263,6 +267,8 @@ class EXPORT_API SettingDlg : public wxPanel
//full screen
bool m_stay_top;
bool m_show_cursor;

bool m_use_fog_mesh;

private:
//save project
Expand Down Expand Up @@ -319,6 +325,8 @@ class EXPORT_API SettingDlg : public wxPanel
//history depth
wxSlider *m_paint_hist_depth_sldr;
wxTextCtrl *m_paint_hist_depth_text;

wxCheckBox *m_use_fog_mesh_chk;

//save
wxButton *m_save_btn;
Expand Down Expand Up @@ -391,6 +399,8 @@ class EXPORT_API SettingDlg : public wxPanel
//paint history depth
void OnPaintHistDepthChange(wxScrollEvent &event);
void OnPaintHistDepthEdit(wxCommandEvent &event);

void OnUseFogMeshCheck(wxCommandEvent &event);

DECLARE_EVENT_TABLE();
};
Expand Down
1 change: 1 addition & 0 deletions fluorender/FluoRender/TreePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5049,6 +5049,7 @@ void TreePanel::doAction(ActionInfo *info)
m_toolbar->EnableTool(ID_BakeVolume, false);
}
}
delete info;
}

void TreePanel::OnSave(wxCommandEvent& event)
Expand Down
7 changes: 4 additions & 3 deletions fluorender/FluoRender/VRenderView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ VRenderVulkanView::VRenderVulkanView(wxWindow* frame,
m_loader_run(true),
m_ebd_run(true),
m_undo_keydown(false),
m_redo_keydown(false)
m_redo_keydown(false),
m_use_fog_mesh(false)
{
SetEvtHandlerEnabled(false);
Freeze();
Expand Down Expand Up @@ -1246,7 +1247,7 @@ void VRenderVulkanView::DrawMeshes(const std::unique_ptr<vks::VFrameBuffer>& fra
}

md->SetMatrices(m_mv_mat, m_proj_mat);
md->SetFog(m_use_fog, m_fog_intensity, m_fog_start, m_fog_end);
md->SetFog(m_use_fog && m_use_fog_mesh, m_fog_intensity, m_fog_start, m_fog_end);
md->SetDepthTex(depth_tex);
md->SetDevice(m_vulkan->devices[0]);
md->Draw(framebuf, clear_framebuf, peel);
Expand Down Expand Up @@ -1274,7 +1275,7 @@ void VRenderVulkanView::DrawMeshes(const std::unique_ptr<vks::VFrameBuffer>& fra
}

md->SetMatrices(m_mv_mat, m_proj_mat);
md->SetFog(m_use_fog, m_fog_intensity, m_fog_start, m_fog_end);
md->SetFog(m_use_fog && m_use_fog_mesh, m_fog_intensity, m_fog_start, m_fog_end);
md->SetDepthTex(depth_tex);
md->SetDevice(m_vulkan->devices[0]);
md->Draw(framebuf, clear_framebuf, peel);
Expand Down
14 changes: 14 additions & 0 deletions fluorender/FluoRender/VRenderView.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ class EXPORT_API VRenderVulkanView: public wxWindow
static wxCriticalSection* ms_pThreadCS;

void CalcAndSetCombinedClippingPlanes();

bool GetUseFogMesh() { return m_use_fog_mesh; }
void SetUseFogMesh(bool val) { m_use_fog_mesh = val; }

public:
//script run
Expand Down Expand Up @@ -1184,6 +1187,8 @@ class EXPORT_API VRenderVulkanView: public wxWindow

bool m_undo_keydown;
bool m_redo_keydown;

bool m_use_fog_mesh;

private:
#ifdef _WIN32
Expand Down Expand Up @@ -2087,6 +2092,15 @@ class EXPORT_API VRenderView: public wxPanel
void SetEmptyBlockDetectorActive(bool val) { if (m_glview) m_glview->SetEmptyBlockDetectorActive(val); }

void CalcAndSetCombinedClippingPlanes() { if (m_glview) m_glview->CalcAndSetCombinedClippingPlanes(); }

void SetUseFogMesh(bool val)
{
if (m_glview) m_glview->SetUseFogMesh(val);
}
bool GetUseFogMesh()
{
if (m_glview) return m_glview->GetUseFogMesh(); else return false;
}

public:
wxWindow* m_frame;
Expand Down
5 changes: 4 additions & 1 deletion fluorender/FluoRender/Vulkan/VulkanSwapChain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ class VulkanSwapChain
for (uint32_t i = 0; i < imageCount; i++)
{
vkDestroyImageView(device, buffers[i]->view, nullptr);
vkDestroySampler(device, buffers[i]->sampler, nullptr);
buffers[i]->sampler = VK_NULL_HANDLE;
}
fpDestroySwapchainKHR(device, oldSwapchain, nullptr);
}
Expand Down Expand Up @@ -478,7 +480,8 @@ class VulkanSwapChain
sampler.maxAnisotropy = 1.0;
sampler.anisotropyEnable = VK_FALSE;
sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
VK_CHECK_RESULT(vkCreateSampler(device, &sampler, nullptr, &buffers[i]->descriptor.sampler));
VK_CHECK_RESULT(vkCreateSampler(device, &sampler, nullptr, &buffers[i]->sampler));
buffers[i]->descriptor.sampler = buffers[i]->sampler;
buffers[i]->free_sampler = true;

VK_CHECK_RESULT(vkCreateImageView(device, &colorAttachmentView, nullptr, &buffers[i]->view));
Expand Down
2 changes: 1 addition & 1 deletion fluorender/FluoRender/Vulkan/vulkanexamplebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ void VulkanExampleBase::windowResize()
// Recreate swap chain
width = destWidth;
height = destHeight;
setupSwapChain();

if (width <= 0 || height <= 0)
{
Expand All @@ -644,6 +643,7 @@ void VulkanExampleBase::windowResize()
setupDepthStencil();
for (uint32_t i = 0; i < frameBuffers.size(); i++)
frameBuffers[i].reset();
setupSwapChain();
setupFrameBuffer();
/*
if ((width > 0.0f) && (height > 0.0f)) {
Expand Down
1 change: 1 addition & 0 deletions plugin_NA/vvd/NeuronAnnotatorPluginWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ void NAGuiPluginWindow::doAction(ActionInfo *info)
default:
break;
}
delete info;
}


Expand Down
1 change: 1 addition & 0 deletions plugin_fiji/vvd/FijiInterfacePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ void SampleGuiPlugin1::doAction(ActionInfo *info)
notifyAll(FI_COMMAND_FINISHED, info->data, info->size);
break;
}
delete info;
}

bool SampleGuiPlugin1::SendCommand(wxString command, bool send_mask)
Expand Down
1 change: 1 addition & 0 deletions plugin_fiji/vvd/FijiInterfacePluginWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ void SampleGuiPluginWindow1::doAction(ActionInfo *info)
}
break;
}
delete info;
}

void SampleGuiPluginWindow1::SendCommand(wxString com, bool send_mask)
Expand Down
1 change: 1 addition & 0 deletions plugin_nblast/vvd/NBLASTGuiPluginWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,7 @@ void NBLASTGuiPluginWindow::doAction(ActionInfo *info)
default:
break;
}
delete info;
}


Expand Down

0 comments on commit e439bfc

Please sign in to comment.