#11617 - Fixed calculation of camera's tight frustrum around box (SPE-2023)

This commit is contained in:
enricoturri1966 2023-11-09 09:55:37 +01:00
parent 82efbd6143
commit bf3772d68a

View File

@ -373,6 +373,8 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
std::pair<double, double> ret; std::pair<double, double> ret;
auto& [near_z, far_z] = ret; auto& [near_z, far_z] = ret;
set_distance(DefaultDistance);
// box in eye space // box in eye space
const BoundingBoxf3 eye_box = box.transformed(m_view_matrix); const BoundingBoxf3 eye_box = box.transformed(m_view_matrix);
near_z = -eye_box.max.z(); near_z = -eye_box.max.z();
@ -396,15 +398,6 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
near_z += delta; near_z += delta;
far_z += delta; far_z += delta;
} }
// The following is commented out because it causes flickering of the 3D scene GUI
// when the bounding box of the scene gets large enough
// We need to introduce some smarter code to move the camera back and forth in such case
// else if (near_z > 2.0 * FrustrumMinNearZ && m_distance > DefaultDistance) {
// float delta = m_distance - DefaultDistance;
// set_distance(DefaultDistance);
// near_z -= delta;
// far_z -= delta;
// }
return ret; return ret;
} }