| 103 | } |
| 104 | |
| 105 | glm::mat4 OrbitCamera::projMatrix(float aspect) const { |
| 106 | // Decoupled adaptive near/far: near tracks the working distance (so close |
| 107 | // inspection never clips), far reaches the whole scene, ratio-capped for depth |
| 108 | // precision. OrbitCamera is always perspective, so the working distance is the |
| 109 | // orbit radius. |
| 110 | const float d = state_.radius; |
| 111 | float near_plane = 0.0f; |
| 112 | float far_plane = 0.0f; |
| 113 | adaptiveNearFar(d, sceneReach(scene_bounds_, state_.focal), near_plane, far_plane); |
| 114 | return glm::perspective(state_.fov_y, aspect, near_plane, far_plane); |
| 115 | } |
| 116 | |
| 117 | glm::vec3 OrbitCamera::position() const { |
| 118 | return state_.focal + state_.radius * sphericalDir(state_.azimuth, state_.elevation); |