| 94 | } |
| 95 | |
| 96 | glm::mat4 OrbitCamera::viewMatrixRelativeTo(const glm::dvec3& render_origin) const { |
| 97 | // Subtract the origin from the focal in DOUBLE, then add the (small) orbit offset |
| 98 | // radius·dir — so eye_rel/focal_rel stay near the radius scale even when the focal |
| 99 | // is at 1e6. With render_origin == focal, focal_rel is exactly 0. |
| 100 | const glm::vec3 focal_rel = toRenderSpace(state_.focal, render_origin); |
| 101 | const glm::vec3 eye_rel = focal_rel + state_.radius * sphericalDir(state_.azimuth, state_.elevation); |
| 102 | return glm::lookAt(eye_rel, focal_rel, glm::vec3{0.0f, 0.0f, 1.0f}); |
| 103 | } |
| 104 | |
| 105 | glm::mat4 OrbitCamera::projMatrix(float aspect) const { |
| 106 | // Decoupled adaptive near/far: near tracks the working distance (so close |