mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-15 15:28:31 +00:00
Inline redundant method
This commit is contained in:
parent
7b16d4a04e
commit
8fc2a139c9
@ -1,7 +1,5 @@
|
|||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
use nalgebra::Perspective3;
|
|
||||||
|
|
||||||
use super::{Aabb, LineSegment, Point, Triangle, Vector};
|
use super::{Aabb, LineSegment, Point, Triangle, Vector};
|
||||||
|
|
||||||
/// An affine transform
|
/// An affine transform
|
||||||
@ -118,27 +116,6 @@ impl Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Project transform according to camera specification, return data as an array.
|
|
||||||
/// Used primarily for graphics code.
|
|
||||||
pub fn project_to_array(
|
|
||||||
&self,
|
|
||||||
aspect_ratio: f64,
|
|
||||||
fovy: f64,
|
|
||||||
znear: f64,
|
|
||||||
zfar: f64,
|
|
||||||
) -> [f64; 16] {
|
|
||||||
let projection = Perspective3::new(aspect_ratio, fovy, znear, zfar);
|
|
||||||
|
|
||||||
let mut array = [0.; 16];
|
|
||||||
array.copy_from_slice(
|
|
||||||
(projection.to_projective() * self.inner)
|
|
||||||
.matrix()
|
|
||||||
.as_slice(),
|
|
||||||
);
|
|
||||||
|
|
||||||
array
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transform the given axis-aligned bounding box
|
/// Transform the given axis-aligned bounding box
|
||||||
pub fn transform_aabb(&self, aabb: &Aabb<3>) -> Aabb<3> {
|
pub fn transform_aabb(&self, aabb: &Aabb<3>) -> Aabb<3> {
|
||||||
Aabb {
|
Aabb {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
|
use nalgebra::Perspective3;
|
||||||
|
|
||||||
use crate::camera::Camera;
|
use crate::camera::Camera;
|
||||||
|
|
||||||
@ -18,13 +19,24 @@ impl Transform {
|
|||||||
let field_of_view_in_y = 2.
|
let field_of_view_in_y = 2.
|
||||||
* ((camera.field_of_view_in_x() / 2.).tan() / aspect_ratio).atan();
|
* ((camera.field_of_view_in_x() / 2.).tan() / aspect_ratio).atan();
|
||||||
|
|
||||||
let transform = camera.camera_to_model().project_to_array(
|
let transform = {
|
||||||
|
let projection = Perspective3::new(
|
||||||
aspect_ratio,
|
aspect_ratio,
|
||||||
field_of_view_in_y,
|
field_of_view_in_y,
|
||||||
camera.near_plane(),
|
camera.near_plane(),
|
||||||
camera.far_plane(),
|
camera.far_plane(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut array = [0.; 16];
|
||||||
|
array.copy_from_slice(
|
||||||
|
(projection.to_projective() * camera.camera_to_model().inner)
|
||||||
|
.matrix()
|
||||||
|
.as_slice(),
|
||||||
|
);
|
||||||
|
|
||||||
|
array
|
||||||
|
};
|
||||||
|
|
||||||
Self(transform.map(|scalar| scalar as f32))
|
Self(transform.map(|scalar| scalar as f32))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user