From e17f01e15c092799ce4ad4b0c11e46374e19033d Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 21 Aug 2026 22:53:20 +0200 Subject: feat(engine): store perspective projection fov as degrees --- engine/src/projection.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/engine/src/projection.rs b/engine/src/projection.rs index e2d5cc1..2191a93 100644 --- a/engine/src/projection.rs +++ b/engine/src/projection.rs @@ -37,7 +37,8 @@ impl Projection #[derive(Debug, Clone, Reflection)] pub struct Perspective { - pub fov_radians: f32, + /// Field-of-view in degrees + pub fov_degs: f32, pub far: f32, pub near: f32, } @@ -51,12 +52,13 @@ impl Perspective { let mut out = Matrix::new(); + let fov_rads = self.fov_degs.to_radians(); + match clip_volume { ClipVolume::NegOneToOne => { out[MatrixCellPos { row: 0, col: 0 }] = - (1.0 / (self.fov_radians / 2.0).tan()) / aspect; - out[MatrixCellPos { row: 1, col: 1 }] = - 1.0 / (self.fov_radians / 2.0).tan(); + (1.0 / (fov_rads / 2.0).tan()) / aspect; + out[MatrixCellPos { row: 1, col: 1 }] = 1.0 / (fov_rads / 2.0).tan(); out[MatrixCellPos { row: 2, col: 2 }] = (self.near + self.far) / (self.near - self.far); out[MatrixCellPos { row: 2, col: 3 }] = @@ -74,7 +76,7 @@ impl Default for Perspective fn default() -> Self { Self { - fov_radians: 80.0f32.to_radians(), + fov_degs: 80.0, far: 100.0, near: 0.1, } -- cgit v1.2.3-18-g5258