diff options
| author | HampusM <hampus@hampusmat.com> | 2026-08-21 22:53:20 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-08-21 22:53:20 +0200 |
| commit | e17f01e15c092799ce4ad4b0c11e46374e19033d (patch) | |
| tree | eedc8d5214a43e02606e98960b72f59133670417 /engine/src | |
| parent | 7679dd68398cc70162e96777a40db86a1c37eef8 (diff) | |
Diffstat (limited to 'engine/src')
| -rw-r--r-- | engine/src/projection.rs | 12 |
1 files 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, } |
