Skip to content

Commit f65348f

Browse files
committed
Fix FOV slider
1 parent 161bca3 commit f65348f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/brush-ui/src/ui_process.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,14 @@ impl UiProcess {
139139
}
140140

141141
pub fn set_cam_fov(&self, fov_y: f64) {
142-
self.write().camera.fov_y = fov_y;
142+
let mut inner = self.write();
143+
// Scale fov_x proportionally to maintain the camera's aspect ratio.
144+
// This allows setting FOV smaller than the dataset FOV.
145+
let old_fov_y = inner.camera.fov_y;
146+
let aspect = (inner.camera.fov_x / 2.0).tan() / (old_fov_y / 2.0).tan();
147+
inner.camera.fov_y = fov_y;
148+
inner.camera.fov_x = 2.0 * (aspect * (fov_y / 2.0).tan()).atan();
149+
drop(inner);
143150
self.read().repaint();
144151
}
145152

0 commit comments

Comments
 (0)