diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 366e67d461..6bdac8b03b 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1247,13 +1247,13 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex auto _far = scene->camera->m_far; auto fov = scene->camera->m_fov; auto cz = glm::length(scene->camera->m_lodcenter); - if (depth != 0) { -// depth = depth * 2 - 1; -// cz = 2 * _near * _far / ((_far + _near) - depth * (_far - _near)); - glm::vec4 ndc = {0, 0, depth, 1}; - glm::vec4 clip_c = glm::inverse(scene->camera->m_proj) * ndc; - clip_c /= clip_c.w; - cz = -clip_c.z; + if (depth != 1) { + depth = depth * 2 - 1; + cz = 2 * _near * _far / ((_far + _near) - depth * (_far - _near)); +// glm::vec4 ndc = {0, 0, depth, 1}; +// glm::vec4 clip_c = glm::inverse(scene->camera->m_proj) * ndc; +// clip_c /= clip_c.w; +// cz = -clip_c.z; } auto w = scene->camera->m_nx; auto h = scene->camera->m_ny; diff --git a/zenovis/src/Camera.cpp b/zenovis/src/Camera.cpp index 95df945c7a..cb7ae06e5d 100644 --- a/zenovis/src/Camera.cpp +++ b/zenovis/src/Camera.cpp @@ -54,10 +54,10 @@ void Camera::placeCamera(glm::vec3 pos, glm::vec3 front, glm::vec3 up) { m_view = glm::lookAt(m_lodcenter, m_lodcenter + m_lodfront, m_lodup); if (m_ortho_mode) { auto radius = glm::length(m_lodcenter); - m_proj = glm::orthoZO(-radius * getAspect(), radius * getAspect(), -radius, - radius, m_far, m_near); + m_proj = glm::ortho(-radius * getAspect(), radius * getAspect(), -radius, + radius, m_near, m_far); } else { - m_proj = glm::perspectiveZO(glm::radians(m_fov), getAspect(), m_far, m_near); + m_proj = glm::perspective(glm::radians(m_fov), getAspect(), m_near, m_far); } } @@ -80,7 +80,7 @@ void Camera::updateMatrix() { void Camera::setResolution(int nx, int ny) { m_nx = nx; m_ny = ny; - m_proj = glm::perspectiveZO(glm::radians(m_fov), getAspect(), m_far, m_near); + m_proj = glm::perspective(glm::radians(m_fov), getAspect(), m_near, m_far); } void Camera::setResolutionInfo(bool block, int nx, int ny) { diff --git a/zenovis/src/bate/FrameBufferPicker.cpp b/zenovis/src/bate/FrameBufferPicker.cpp index 2249b22cf5..afb7ad51c3 100644 --- a/zenovis/src/bate/FrameBufferPicker.cpp +++ b/zenovis/src/bate/FrameBufferPicker.cpp @@ -312,9 +312,6 @@ struct FrameBufferPicker : IPicker { if (scene->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)); - glDepthFunc(GL_GREATER); - CHECK_GL(glClearDepth(0.0)); // shader uniform obj_shader->use(); @@ -346,9 +343,6 @@ struct FrameBufferPicker : IPicker { if (scene->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)); - glDepthFunc(GL_GREATER); - CHECK_GL(glClearDepth(0.0)); // CHECK_GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); // ----- draw points ----- @@ -374,9 +368,6 @@ struct FrameBufferPicker : IPicker { if (scene->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)); - glDepthFunc(GL_GREATER); - CHECK_GL(glClearDepth(0.0)); // CHECK_GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); // ----- draw lines ----- prim_shader->use(); @@ -425,9 +416,6 @@ struct FrameBufferPicker : IPicker { if (scene->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)); - glDepthFunc(GL_GREATER); - CHECK_GL(glClearDepth(0.0)); // CHECK_GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); // ----- draw triangles ----- prim_shader->use(); diff --git a/zenovis/src/bate/RenderEngineBate.cpp b/zenovis/src/bate/RenderEngineBate.cpp index 4de7e4e444..a5f601ed38 100644 --- a/zenovis/src/bate/RenderEngineBate.cpp +++ b/zenovis/src/bate/RenderEngineBate.cpp @@ -43,9 +43,6 @@ struct RenderEngineBate : RenderEngine { void draw() override { auto guard = setupState(); - CHECK_GL(glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)); - glDepthFunc(GL_GREATER); - CHECK_GL(glClearDepth(0.0)); CHECK_GL(glClearColor(scene->drawOptions->bgcolor.r, scene->drawOptions->bgcolor.g, scene->drawOptions->bgcolor.b, 0.0f)); CHECK_GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));