diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 5a01efa4ef..46fcc826e1 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1383,12 +1383,10 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex Zenovis *pZenovis = m_glView->getZenoVis(); ZASSERT_EXIT(pZenovis && pZenovis->getSession()); auto scene = pZenovis->getSession()->get_scene(); - auto _near = scene->camera->m_near; - auto _far = scene->camera->m_far; auto fov = scene->camera->m_fov; auto cz = glm::length(scene->camera->m_lodcenter); if (depth != 0) { - cz = scene->camera->m_near / depth; + cz = scene->camera->inf_z_near / depth; } auto w = scene->camera->m_nx; auto h = scene->camera->m_ny; diff --git a/zenovis/include/zenovis/Camera.h b/zenovis/include/zenovis/Camera.h index 00126d5de2..c6b1983006 100644 --- a/zenovis/include/zenovis/Camera.h +++ b/zenovis/include/zenovis/Camera.h @@ -20,6 +20,7 @@ struct ZOptixCameraSettingInfo { }; struct Camera { + float inf_z_near = 0.001f; int m_nx{512}, m_ny{512}; glm::mat4x4 m_view{1}, m_proj{1}; diff --git a/zenovis/src/Camera.cpp b/zenovis/src/Camera.cpp index 56a0354de5..232d820946 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(), 0.001); + m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), inf_z_near); } } @@ -107,7 +107,7 @@ void Camera::updateMatrix() { void Camera::setResolution(int nx, int ny) { m_nx = nx; m_ny = ny; - m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), m_near); + m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), inf_z_near); } void Camera::setResolutionInfo(bool block, int nx, int ny) {