summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/src/projection.rs12
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,
}