library: move from f64 to f32
They are faster to compute with, take less space --which means faster access because we use less cache lines--, and they are what is used by `bvh`...
This commit is contained in:
parent
5d03df960c
commit
7d28e21a70
|
@ -5,9 +5,9 @@ use derive_more::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign
|
|||
)]
|
||||
/// A structure to represent operations in the linear RGB colorspace.
|
||||
pub struct LinearColor {
|
||||
pub r: f64,
|
||||
pub g: f64,
|
||||
pub b: f64,
|
||||
pub r: f32,
|
||||
pub g: f32,
|
||||
pub b: f32,
|
||||
}
|
||||
|
||||
impl LinearColor {
|
||||
|
@ -19,7 +19,7 @@ impl LinearColor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(r: f64, g: f64, b: f64) -> Self {
|
||||
pub fn new(r: f32, g: f32, b: f32) -> Self {
|
||||
LinearColor { r, g, b }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use bvh::nalgebra::{Point2, Point3, Vector3};
|
||||
|
||||
pub type Point2D = Point2<f64>;
|
||||
pub type Point = Point3<f64>;
|
||||
pub type Vector = Vector3<f64>;
|
||||
pub type Point2D = Point2<f32>;
|
||||
pub type Point = Point3<f32>;
|
||||
pub type Vector = Vector3<f32>;
|
||||
|
||||
pub mod core;
|
||||
pub mod light;
|
||||
|
|
|
@ -10,5 +10,5 @@ pub trait Light: std::fmt::Debug {
|
|||
/// Represent a light which has an abstract position in the scene being rendered.
|
||||
pub trait SpatialLight: Light {
|
||||
/// Get a unit vector from the origin to the position of the light, and its distance
|
||||
fn to_source(&self, origin: &Point) -> (Vector, f64);
|
||||
fn to_source(&self, origin: &Point) -> (Vector, f32);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@ use bvh::ray::Ray;
|
|||
/// Represent an abstract shape inside the scene.
|
||||
pub trait Shape: Bounded + std::fmt::Debug {
|
||||
/// Return the distance at which the object intersects with the ray, or None if it does not.
|
||||
fn intersect(&self, ray: &Ray) -> Option<f64>;
|
||||
fn intersect(&self, ray: &Ray) -> Option<f32>;
|
||||
/// Return the unit vector corresponding to the normal at this point of the shape.
|
||||
fn normal(&self, point: &Point) -> Vector;
|
||||
/// Project the point from the shape's surface to its texel coordinates.
|
||||
fn project_texel(&self, point: &Point) -> Point2D;
|
||||
}
|
||||
|
||||
pub mod sphere;
|
||||
pub use sphere::*;
|
||||
|
|
Loading…
Reference in a new issue