Skip to content

Commit

Permalink
Merge pull request #1935 from zenustech/fix-camera
Browse files Browse the repository at this point in the history
fix-camera
  • Loading branch information
legobadman authored Jun 7, 2024
2 parents 4c8bfce + c97314d commit ea6f82e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ui/zenoedit/viewport/displaywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions zenovis/include/zenovis/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 2 additions & 2 deletions zenovis/src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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)
{
Expand Down

0 comments on commit ea6f82e

Please sign in to comment.