Formatting with newer cargo fmt
.
No meaningful code change, only formatting.
This commit is contained in:
parent
df27f7b829
commit
6d21a30840
|
@ -12,8 +12,8 @@ use ray::AccelRay;
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
|
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
||||||
use super::ACCEL_TRAV_TIME;
|
|
||||||
use super::ACCEL_NODE_RAY_TESTS;
|
use super::ACCEL_NODE_RAY_TESTS;
|
||||||
|
use super::ACCEL_TRAV_TIME;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct BVH<'a> {
|
pub struct BVH<'a> {
|
||||||
|
|
|
@ -11,10 +11,10 @@ use lerp::lerp_slice;
|
||||||
use ray::AccelRay;
|
use ray::AccelRay;
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
|
|
||||||
use bvh_order::{calc_traversal_code, SplitAxes, TRAVERSAL_TABLE};
|
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
||||||
use super::ACCEL_TRAV_TIME;
|
|
||||||
use super::ACCEL_NODE_RAY_TESTS;
|
use super::ACCEL_NODE_RAY_TESTS;
|
||||||
|
use super::ACCEL_TRAV_TIME;
|
||||||
|
use bvh_order::{calc_traversal_code, SplitAxes, TRAVERSAL_TABLE};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct BVH4<'a> {
|
pub struct BVH4<'a> {
|
||||||
|
@ -87,7 +87,8 @@ impl<'a> BVH4<'a> {
|
||||||
rays[0].dir_inv.y() < 0.0,
|
rays[0].dir_inv.y() < 0.0,
|
||||||
rays[0].dir_inv.z() < 0.0,
|
rays[0].dir_inv.z() < 0.0,
|
||||||
];
|
];
|
||||||
let ray_code = ray_sign_is_neg[0] as usize + ((ray_sign_is_neg[1] as usize) << 1)
|
let ray_code = ray_sign_is_neg[0] as usize
|
||||||
|
+ ((ray_sign_is_neg[1] as usize) << 1)
|
||||||
+ ((ray_sign_is_neg[2] as usize) << 2);
|
+ ((ray_sign_is_neg[2] as usize) << 2);
|
||||||
&TRAVERSAL_TABLE[ray_code]
|
&TRAVERSAL_TABLE[ray_code]
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@ use lerp::lerp_slice;
|
||||||
use math::{Normal, Point, Vector};
|
use math::{Normal, Point, Vector};
|
||||||
use shading::surface_closure::SurfaceClosure;
|
use shading::surface_closure::SurfaceClosure;
|
||||||
|
|
||||||
use super::LightAccel;
|
|
||||||
use super::objects_split::sah_split;
|
use super::objects_split::sah_split;
|
||||||
|
use super::LightAccel;
|
||||||
|
|
||||||
const ARITY_LOG2: usize = 3; // Determines how much to collapse the binary tree,
|
const ARITY_LOG2: usize = 3; // Determines how much to collapse the binary tree,
|
||||||
// implicitly defining the light tree's arity. 1 = no collapsing, leave as binary
|
// implicitly defining the light tree's arity. 1 = no collapsing, leave as binary
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
mod bvh_base;
|
|
||||||
mod bvh;
|
mod bvh;
|
||||||
mod bvh4;
|
mod bvh4;
|
||||||
|
mod bvh_base;
|
||||||
mod light_array;
|
mod light_array;
|
||||||
mod light_tree;
|
mod light_tree;
|
||||||
mod objects_split;
|
mod objects_split;
|
||||||
|
@ -12,8 +12,8 @@ use shading::surface_closure::SurfaceClosure;
|
||||||
|
|
||||||
pub use self::bvh::{BVHNode, BVH};
|
pub use self::bvh::{BVHNode, BVH};
|
||||||
pub use self::bvh4::{BVH4, BVH4Node};
|
pub use self::bvh4::{BVH4, BVH4Node};
|
||||||
pub use self::light_tree::LightTree;
|
|
||||||
pub use self::light_array::LightArray;
|
pub use self::light_array::LightArray;
|
||||||
|
pub use self::light_tree::LightTree;
|
||||||
|
|
||||||
// Track BVH traversal time
|
// Track BVH traversal time
|
||||||
thread_local! {
|
thread_local! {
|
||||||
|
|
|
@ -293,8 +293,8 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::cmp::Ordering;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
fn quick_select_ints(list: &mut [i32], i: usize) {
|
fn quick_select_ints(list: &mut [i32], i: usize) {
|
||||||
quick_select(list, i, |a, b| {
|
quick_select(list, i, |a, b| {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::iter::Iterator;
|
||||||
use std::ops::{BitOr, BitOrAssign};
|
use std::ops::{BitOr, BitOrAssign};
|
||||||
|
|
||||||
use lerp::{lerp, lerp_slice, Lerp};
|
use lerp::{lerp, lerp_slice, Lerp};
|
||||||
use math::{Matrix4x4, Point, fast_minf32};
|
use math::{fast_minf32, Matrix4x4, Point};
|
||||||
use ray::AccelRay;
|
use ray::AccelRay;
|
||||||
|
|
||||||
const BBOX_MAXT_ADJUST: f32 = 1.00000024;
|
const BBOX_MAXT_ADJUST: f32 = 1.00000024;
|
||||||
|
|
|
@ -11,8 +11,8 @@ use std::path::Path;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use half::f16;
|
use half::f16;
|
||||||
use png_encode_mini;
|
|
||||||
use openexr;
|
use openexr;
|
||||||
|
use png_encode_mini;
|
||||||
|
|
||||||
use color::{xyz_to_rec709_e, XYZ};
|
use color::{xyz_to_rec709_e, XYZ};
|
||||||
|
|
||||||
|
@ -259,7 +259,9 @@ impl<'a> Drop for Bucket<'a> {
|
||||||
|
|
||||||
// Find matching bucket and remove it
|
// Find matching bucket and remove it
|
||||||
let i = bucket_list.iter().position(|bucket| {
|
let i = bucket_list.iter().position(|bucket| {
|
||||||
(bucket.0).0 == self.min.0 && (bucket.0).1 == self.min.1 && (bucket.1).0 == self.max.0
|
(bucket.0).0 == self.min.0
|
||||||
|
&& (bucket.0).1 == self.min.1
|
||||||
|
&& (bucket.1).0 == self.max.0
|
||||||
&& (bucket.1).1 == self.max.1
|
&& (bucket.1).1 == self.max.1
|
||||||
});
|
});
|
||||||
bucket_list.swap_remove(i.unwrap());
|
bucket_list.swap_remove(i.unwrap());
|
||||||
|
|
87
src/lerp.rs
87
src/lerp.rs
|
@ -198,95 +198,22 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn lerp_matrix() {
|
fn lerp_matrix() {
|
||||||
let a = Matrix4x4::new_from_values(
|
let a = Matrix4x4::new_from_values(
|
||||||
0.0,
|
0.0, 2.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
3.0,
|
|
||||||
4.0,
|
|
||||||
5.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
10.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
14.0,
|
|
||||||
15.0,
|
|
||||||
);
|
);
|
||||||
let b = Matrix4x4::new_from_values(
|
let b = Matrix4x4::new_from_values(
|
||||||
-1.0,
|
-1.0, 1.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
1.0,
|
|
||||||
3.0,
|
|
||||||
4.0,
|
|
||||||
5.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
10.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
14.0,
|
|
||||||
15.0,
|
|
||||||
16.0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let c1 = Matrix4x4::new_from_values(
|
let c1 = Matrix4x4::new_from_values(
|
||||||
-0.25,
|
-0.25, 1.75, 2.25, 3.25, 4.25, 5.25, 6.25, 7.25, 8.25, 9.25, 10.25, 11.25, 12.25,
|
||||||
1.75,
|
13.25, 14.25, 15.25,
|
||||||
2.25,
|
|
||||||
3.25,
|
|
||||||
4.25,
|
|
||||||
5.25,
|
|
||||||
6.25,
|
|
||||||
7.25,
|
|
||||||
8.25,
|
|
||||||
9.25,
|
|
||||||
10.25,
|
|
||||||
11.25,
|
|
||||||
12.25,
|
|
||||||
13.25,
|
|
||||||
14.25,
|
|
||||||
15.25,
|
|
||||||
);
|
);
|
||||||
let c2 = Matrix4x4::new_from_values(
|
let c2 = Matrix4x4::new_from_values(
|
||||||
-0.5,
|
-0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5,
|
||||||
1.5,
|
|
||||||
2.5,
|
|
||||||
3.5,
|
|
||||||
4.5,
|
|
||||||
5.5,
|
|
||||||
6.5,
|
|
||||||
7.5,
|
|
||||||
8.5,
|
|
||||||
9.5,
|
|
||||||
10.5,
|
|
||||||
11.5,
|
|
||||||
12.5,
|
|
||||||
13.5,
|
|
||||||
14.5,
|
|
||||||
15.5,
|
|
||||||
);
|
);
|
||||||
let c3 = Matrix4x4::new_from_values(
|
let c3 = Matrix4x4::new_from_values(
|
||||||
-0.75,
|
-0.75, 1.25, 2.75, 3.75, 4.75, 5.75, 6.75, 7.75, 8.75, 9.75, 10.75, 11.75, 12.75,
|
||||||
1.25,
|
13.75, 14.75, 15.75,
|
||||||
2.75,
|
|
||||||
3.75,
|
|
||||||
4.75,
|
|
||||||
5.75,
|
|
||||||
6.75,
|
|
||||||
7.75,
|
|
||||||
8.75,
|
|
||||||
9.75,
|
|
||||||
10.75,
|
|
||||||
11.75,
|
|
||||||
12.75,
|
|
||||||
13.75,
|
|
||||||
14.75,
|
|
||||||
15.75,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(a.lerp(b, 0.0), a);
|
assert_eq!(a.lerp(b, 0.0), a);
|
||||||
|
|
|
@ -6,8 +6,10 @@ use color::{Color, SpectralSample, XYZ};
|
||||||
use lerp::lerp_slice;
|
use lerp::lerp_slice;
|
||||||
use math::{cross, dot, Matrix4x4, Normal, Point, Vector};
|
use math::{cross, dot, Matrix4x4, Normal, Point, Vector};
|
||||||
use ray::{AccelRay, Ray};
|
use ray::{AccelRay, Ray};
|
||||||
use sampling::{spherical_triangle_solid_angle, triangle_surface_area,
|
use sampling::{
|
||||||
uniform_sample_spherical_triangle, uniform_sample_triangle};
|
spherical_triangle_solid_angle, triangle_surface_area, uniform_sample_spherical_triangle,
|
||||||
|
uniform_sample_triangle,
|
||||||
|
};
|
||||||
use shading::surface_closure::{EmitClosure, SurfaceClosureUnion};
|
use shading::surface_closure::{EmitClosure, SurfaceClosureUnion};
|
||||||
use shading::SurfaceShader;
|
use shading::SurfaceShader;
|
||||||
use surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData};
|
use surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData};
|
||||||
|
|
|
@ -66,12 +66,12 @@ use clap::{App, Arg};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
|
use accel::{BVH4Node, BVHNode};
|
||||||
|
use bbox::BBox;
|
||||||
use parse::{parse_scene, DataTree};
|
use parse::{parse_scene, DataTree};
|
||||||
use ray::{AccelRay, Ray};
|
use ray::{AccelRay, Ray};
|
||||||
use surface::SurfaceIntersection;
|
|
||||||
use renderer::LightPath;
|
use renderer::LightPath;
|
||||||
use bbox::BBox;
|
use surface::SurfaceIntersection;
|
||||||
use accel::{BVH4Node, BVHNode};
|
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
|
|
||||||
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use nom::{digit, multispace, IResult, Needed};
|
|
||||||
use nom::IResult::*;
|
use nom::IResult::*;
|
||||||
|
use nom::{digit, multispace, IResult, Needed};
|
||||||
|
|
||||||
// Consumes any whitespace, including zero whitespace
|
// Consumes any whitespace, including zero whitespace
|
||||||
named!(any_space<Option<&[u8]>>, opt!(complete!(multispace)));
|
named!(any_space<Option<&[u8]>>, opt!(complete!(multispace)));
|
||||||
|
@ -154,9 +154,9 @@ fn take_decimal_real(i: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use nom::IResult::*;
|
|
||||||
use super::take_decimal_real;
|
use super::take_decimal_real;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use nom::IResult::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ws_u32_1() {
|
fn ws_u32_1() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
pub mod basics;
|
||||||
mod data_tree;
|
mod data_tree;
|
||||||
|
mod psy;
|
||||||
mod psy_assembly;
|
mod psy_assembly;
|
||||||
mod psy_light;
|
mod psy_light;
|
||||||
mod psy_mesh_surface;
|
mod psy_mesh_surface;
|
||||||
mod psy_surface_shader;
|
mod psy_surface_shader;
|
||||||
mod psy;
|
|
||||||
pub mod basics;
|
|
||||||
|
|
||||||
pub use self::data_tree::DataTree;
|
pub use self::data_tree::DataTree;
|
||||||
pub use self::psy::parse_scene;
|
pub use self::psy::parse_scene;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::result::Result;
|
|
||||||
use std::f32;
|
use std::f32;
|
||||||
|
use std::result::Result;
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ use scene::Scene;
|
||||||
use scene::World;
|
use scene::World;
|
||||||
|
|
||||||
use super::basics::{ws_f32, ws_u32};
|
use super::basics::{ws_f32, ws_u32};
|
||||||
use super::DataTree;
|
|
||||||
use super::psy_assembly::parse_assembly;
|
use super::psy_assembly::parse_assembly;
|
||||||
use super::psy_light::parse_distant_disk_light;
|
use super::psy_light::parse_distant_disk_light;
|
||||||
|
use super::DataTree;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PsyParseError {
|
pub enum PsyParseError {
|
||||||
|
@ -565,43 +565,15 @@ fn parse_world<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result<World<'a>,
|
||||||
pub fn parse_matrix(contents: &str) -> Result<Matrix4x4, PsyParseError> {
|
pub fn parse_matrix(contents: &str) -> Result<Matrix4x4, PsyParseError> {
|
||||||
if let IResult::Done(_, ns) = closure!(terminated!(
|
if let IResult::Done(_, ns) = closure!(terminated!(
|
||||||
tuple!(
|
tuple!(
|
||||||
ws_f32,
|
ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32, ws_f32,
|
||||||
ws_f32,
|
ws_f32, ws_f32, ws_f32, ws_f32, ws_f32
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32,
|
|
||||||
ws_f32
|
|
||||||
),
|
),
|
||||||
eof!()
|
eof!()
|
||||||
))(contents.as_bytes())
|
))(contents.as_bytes())
|
||||||
{
|
{
|
||||||
return Ok(Matrix4x4::new_from_values(
|
return Ok(Matrix4x4::new_from_values(
|
||||||
ns.0,
|
ns.0, ns.4, ns.8, ns.12, ns.1, ns.5, ns.9, ns.13, ns.2, ns.6, ns.10, ns.14, ns.3, ns.7,
|
||||||
ns.4,
|
ns.11, ns.15,
|
||||||
ns.8,
|
|
||||||
ns.12,
|
|
||||||
ns.1,
|
|
||||||
ns.5,
|
|
||||||
ns.9,
|
|
||||||
ns.13,
|
|
||||||
ns.2,
|
|
||||||
ns.6,
|
|
||||||
ns.10,
|
|
||||||
ns.14,
|
|
||||||
ns.3,
|
|
||||||
ns.7,
|
|
||||||
ns.11,
|
|
||||||
ns.15,
|
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return Err(PsyParseError::UnknownError(0));
|
return Err(PsyParseError::UnknownError(0));
|
||||||
|
|
|
@ -6,11 +6,11 @@ use mem_arena::MemArena;
|
||||||
|
|
||||||
use scene::{Assembly, AssemblyBuilder, Object};
|
use scene::{Assembly, AssemblyBuilder, Object};
|
||||||
|
|
||||||
use super::DataTree;
|
use super::psy::{parse_matrix, PsyParseError};
|
||||||
use super::psy_light::{parse_rectangle_light, parse_sphere_light};
|
use super::psy_light::{parse_rectangle_light, parse_sphere_light};
|
||||||
use super::psy_mesh_surface::parse_mesh_surface;
|
use super::psy_mesh_surface::parse_mesh_surface;
|
||||||
use super::psy_surface_shader::parse_surface_shader;
|
use super::psy_surface_shader::parse_surface_shader;
|
||||||
use super::psy::{parse_matrix, PsyParseError};
|
use super::DataTree;
|
||||||
|
|
||||||
pub fn parse_assembly<'a>(
|
pub fn parse_assembly<'a>(
|
||||||
arena: &'a MemArena,
|
arena: &'a MemArena,
|
||||||
|
|
|
@ -6,13 +6,13 @@ use nom::IResult;
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use math::Vector;
|
|
||||||
use color::{rec709_e_to_xyz, XYZ};
|
use color::{rec709_e_to_xyz, XYZ};
|
||||||
use light::{DistantDiskLight, RectangleLight, SphereLight};
|
use light::{DistantDiskLight, RectangleLight, SphereLight};
|
||||||
|
use math::Vector;
|
||||||
|
|
||||||
use super::basics::ws_f32;
|
use super::basics::ws_f32;
|
||||||
use super::DataTree;
|
|
||||||
use super::psy::PsyParseError;
|
use super::psy::PsyParseError;
|
||||||
|
use super::DataTree;
|
||||||
|
|
||||||
pub fn parse_distant_disk_light<'a>(
|
pub fn parse_distant_disk_light<'a>(
|
||||||
arena: &'a MemArena,
|
arena: &'a MemArena,
|
||||||
|
|
|
@ -9,9 +9,9 @@ use mem_arena::MemArena;
|
||||||
use math::{Normal, Point};
|
use math::{Normal, Point};
|
||||||
use surface::triangle_mesh::TriangleMesh;
|
use surface::triangle_mesh::TriangleMesh;
|
||||||
|
|
||||||
use super::basics::{ws_usize, ws_f32};
|
use super::basics::{ws_f32, ws_usize};
|
||||||
use super::DataTree;
|
|
||||||
use super::psy::PsyParseError;
|
use super::psy::PsyParseError;
|
||||||
|
use super::DataTree;
|
||||||
|
|
||||||
// pub struct TriangleMesh {
|
// pub struct TriangleMesh {
|
||||||
// time_samples: usize,
|
// time_samples: usize,
|
||||||
|
|
|
@ -10,8 +10,8 @@ use color::{rec709_e_to_xyz, XYZ};
|
||||||
use shading::{SimpleSurfaceShader, SurfaceShader};
|
use shading::{SimpleSurfaceShader, SurfaceShader};
|
||||||
|
|
||||||
use super::basics::ws_f32;
|
use super::basics::ws_f32;
|
||||||
use super::DataTree;
|
|
||||||
use super::psy::PsyParseError;
|
use super::psy::PsyParseError;
|
||||||
|
use super::DataTree;
|
||||||
|
|
||||||
// pub struct TriangleMesh {
|
// pub struct TriangleMesh {
|
||||||
// time_samples: usize,
|
// time_samples: usize,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use halton;
|
||||||
|
|
||||||
use accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME};
|
use accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME};
|
||||||
use algorithm::partition_pair;
|
use algorithm::partition_pair;
|
||||||
use color::{Color, SpectralSample, map_0_1_to_wavelength, XYZ};
|
use color::{map_0_1_to_wavelength, Color, SpectralSample, XYZ};
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
use fp_utils::robust_ray_origin;
|
use fp_utils::robust_ray_origin;
|
||||||
use hash::hash_u32;
|
use hash::hash_u32;
|
||||||
|
@ -476,7 +476,8 @@ impl LightPath {
|
||||||
self.time,
|
self.time,
|
||||||
isect,
|
isect,
|
||||||
);
|
);
|
||||||
let found_light = if light_info.is_none() || light_info.pdf() <= 0.0
|
let found_light = if light_info.is_none()
|
||||||
|
|| light_info.pdf() <= 0.0
|
||||||
|| light_info.selection_pdf() <= 0.0
|
|| light_info.selection_pdf() <= 0.0
|
||||||
{
|
{
|
||||||
false
|
false
|
||||||
|
@ -558,9 +559,9 @@ impl LightPath {
|
||||||
// Calculate and store the light that will be contributed
|
// Calculate and store the light that will be contributed
|
||||||
// to the film plane if the light is not in shadow.
|
// to the film plane if the light is not in shadow.
|
||||||
let light_mis_pdf = power_heuristic(light_pdf, closure_pdf);
|
let light_mis_pdf = power_heuristic(light_pdf, closure_pdf);
|
||||||
self.pending_color_addition = light_info.color().e * attenuation.e
|
self.pending_color_addition =
|
||||||
* self.light_attenuation
|
light_info.color().e * attenuation.e * self.light_attenuation
|
||||||
/ (light_mis_pdf * light_sel_pdf);
|
/ (light_mis_pdf * light_sel_pdf);
|
||||||
|
|
||||||
*ray = shadow_ray;
|
*ray = shadow_ray;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
mod monte_carlo;
|
mod monte_carlo;
|
||||||
|
|
||||||
pub use self::monte_carlo::{cosine_sample_hemisphere, spherical_triangle_solid_angle,
|
pub use self::monte_carlo::{
|
||||||
square_to_circle, triangle_surface_area, uniform_sample_cone,
|
cosine_sample_hemisphere, spherical_triangle_solid_angle, square_to_circle,
|
||||||
uniform_sample_cone_pdf, uniform_sample_hemisphere,
|
triangle_surface_area, uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_hemisphere,
|
||||||
uniform_sample_sphere, uniform_sample_spherical_triangle,
|
uniform_sample_sphere, uniform_sample_spherical_triangle, uniform_sample_triangle,
|
||||||
uniform_sample_triangle};
|
};
|
||||||
|
|
|
@ -2,16 +2,16 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use accel::{LightAccel, LightTree};
|
|
||||||
use accel::BVH4;
|
use accel::BVH4;
|
||||||
|
use accel::{LightAccel, LightTree};
|
||||||
use bbox::{transform_bbox_slice_from, BBox};
|
use bbox::{transform_bbox_slice_from, BBox};
|
||||||
use boundable::Boundable;
|
use boundable::Boundable;
|
||||||
use color::SpectralSample;
|
use color::SpectralSample;
|
||||||
use lerp::lerp_slice;
|
use lerp::lerp_slice;
|
||||||
use light::SurfaceLight;
|
use light::SurfaceLight;
|
||||||
use math::{Matrix4x4, Normal, Point};
|
use math::{Matrix4x4, Normal, Point};
|
||||||
use surface::{Surface, SurfaceIntersection};
|
|
||||||
use shading::SurfaceShader;
|
use shading::SurfaceShader;
|
||||||
|
use surface::{Surface, SurfaceIntersection};
|
||||||
use transform_stack::TransformStack;
|
use transform_stack::TransformStack;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -92,12 +92,7 @@ impl<'a> Assembly<'a> {
|
||||||
|
|
||||||
// Sample the light
|
// Sample the light
|
||||||
let (color, sample_geo, pdf) = light.sample_from_point(
|
let (color, sample_geo, pdf) = light.sample_from_point(
|
||||||
&xform,
|
&xform, idata.pos, uvw.0, uvw.1, wavelength, time,
|
||||||
idata.pos,
|
|
||||||
uvw.0,
|
|
||||||
uvw.1,
|
|
||||||
wavelength,
|
|
||||||
time,
|
|
||||||
);
|
);
|
||||||
return Some((color, sample_geo, pdf, sel_pdf));
|
return Some((color, sample_geo, pdf, sel_pdf));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ pub mod surface_closure;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use color::{Color, XYZ};
|
|
||||||
use self::surface_closure::{EmitClosure, GTRClosure, LambertClosure, SurfaceClosureUnion};
|
use self::surface_closure::{EmitClosure, GTRClosure, LambertClosure, SurfaceClosureUnion};
|
||||||
|
use color::{Color, XYZ};
|
||||||
use surface::SurfaceIntersectionData;
|
use surface::SurfaceIntersectionData;
|
||||||
|
|
||||||
/// Trait for surface shaders.
|
/// Trait for surface shaders.
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
use std::f32::consts::PI as PI_32;
|
use std::f32::consts::PI as PI_32;
|
||||||
|
|
||||||
use color::SpectralSample;
|
use color::SpectralSample;
|
||||||
|
use lerp::lerp;
|
||||||
use math::{clamp, dot, zup_to_vec, Normal, Vector};
|
use math::{clamp, dot, zup_to_vec, Normal, Vector};
|
||||||
use sampling::cosine_sample_hemisphere;
|
use sampling::cosine_sample_hemisphere;
|
||||||
use lerp::lerp;
|
|
||||||
|
|
||||||
const INV_PI: f32 = 1.0 / PI_32;
|
const INV_PI: f32 = 1.0 / PI_32;
|
||||||
const H_PI: f32 = PI_32 / 2.0;
|
const H_PI: f32 = PI_32 / 2.0;
|
||||||
|
@ -430,9 +430,8 @@ impl GTRClosure {
|
||||||
let roughness2 = self.roughness * self.roughness;
|
let roughness2 = self.roughness * self.roughness;
|
||||||
|
|
||||||
// Calculate top half of equation
|
// Calculate top half of equation
|
||||||
let top = 1.0
|
let top = 1.0 - ((roughness2.powf(1.0 - self.tail_shape) * (1.0 - u)) + u)
|
||||||
- ((roughness2.powf(1.0 - self.tail_shape) * (1.0 - u)) + u)
|
.powf(1.0 / (1.0 - self.tail_shape));
|
||||||
.powf(1.0 / (1.0 - self.tail_shape));
|
|
||||||
|
|
||||||
// Calculate bottom half of equation
|
// Calculate bottom half of equation
|
||||||
let bottom = 1.0 - roughness2;
|
let bottom = 1.0 - roughness2;
|
||||||
|
|
|
@ -132,11 +132,13 @@ pub fn intersect_ray(ray: &Ray, tri: (Point, Point, Point)) -> Option<(f32, f32,
|
||||||
///
|
///
|
||||||
/// Returns the point and the error magnitude of the point.
|
/// Returns the point and the error magnitude of the point.
|
||||||
pub fn surface_point(tri: (Point, Point, Point), bary: (f32, f32, f32)) -> (Point, f32) {
|
pub fn surface_point(tri: (Point, Point, Point), bary: (f32, f32, f32)) -> (Point, f32) {
|
||||||
let pos = ((tri.0.into_vector() * bary.0) + (tri.1.into_vector() * bary.1)
|
let pos = ((tri.0.into_vector() * bary.0)
|
||||||
|
+ (tri.1.into_vector() * bary.1)
|
||||||
+ (tri.2.into_vector() * bary.2))
|
+ (tri.2.into_vector() * bary.2))
|
||||||
.into_point();
|
.into_point();
|
||||||
|
|
||||||
let pos_err = (((tri.0.into_vector().abs() * bary.0) + (tri.1.into_vector().abs() * bary.1)
|
let pos_err = (((tri.0.into_vector().abs() * bary.0)
|
||||||
|
+ (tri.1.into_vector().abs() * bary.1)
|
||||||
+ (tri.2.into_vector().abs() * bary.2)) * fp_gamma(7))
|
+ (tri.2.into_vector().abs() * bary.2)) * fp_gamma(7))
|
||||||
.co
|
.co
|
||||||
.h_max();
|
.h_max();
|
||||||
|
|
|
@ -10,8 +10,8 @@ use math::{cross, dot, Matrix4x4, Normal, Point};
|
||||||
use ray::{AccelRay, Ray};
|
use ray::{AccelRay, Ray};
|
||||||
use shading::SurfaceShader;
|
use shading::SurfaceShader;
|
||||||
|
|
||||||
use super::{Surface, SurfaceIntersection, SurfaceIntersectionData};
|
|
||||||
use super::triangle;
|
use super::triangle;
|
||||||
|
use super::{Surface, SurfaceIntersection, SurfaceIntersectionData};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct TriangleMesh<'a> {
|
pub struct TriangleMesh<'a> {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use algorithm::partition;
|
use algorithm::partition;
|
||||||
|
use color::{rec709_to_xyz, XYZ};
|
||||||
use lerp::lerp_slice;
|
use lerp::lerp_slice;
|
||||||
use ray::{AccelRay, Ray};
|
use ray::{AccelRay, Ray};
|
||||||
use scene::{Assembly, InstanceType, Object};
|
use scene::{Assembly, InstanceType, Object};
|
||||||
|
use shading::{SimpleSurfaceShader, SurfaceShader};
|
||||||
use surface::SurfaceIntersection;
|
use surface::SurfaceIntersection;
|
||||||
use transform_stack::TransformStack;
|
use transform_stack::TransformStack;
|
||||||
use shading::{SimpleSurfaceShader, SurfaceShader};
|
|
||||||
use color::{rec709_to_xyz, XYZ};
|
|
||||||
|
|
||||||
pub struct Tracer<'a> {
|
pub struct Tracer<'a> {
|
||||||
rays: Vec<AccelRay>,
|
rays: Vec<AccelRay>,
|
||||||
|
|
|
@ -195,7 +195,8 @@ fn rgb_to_xyz(chroma: Chromaticities, y: f64) -> [[f64; 3]; 3] {
|
||||||
let z = (1.0 - chroma.w.0 - chroma.w.1) * y / chroma.w.1;
|
let z = (1.0 - chroma.w.0 - chroma.w.1) * y / chroma.w.1;
|
||||||
|
|
||||||
// Scale factors for matrix rows
|
// Scale factors for matrix rows
|
||||||
let d = chroma.r.0 * (chroma.b.1 - chroma.g.1) + chroma.b.0 * (chroma.g.1 - chroma.r.1)
|
let d = chroma.r.0 * (chroma.b.1 - chroma.g.1)
|
||||||
|
+ chroma.b.0 * (chroma.g.1 - chroma.r.1)
|
||||||
+ chroma.g.0 * (chroma.r.1 - chroma.b.1);
|
+ chroma.g.0 * (chroma.r.1 - chroma.b.1);
|
||||||
|
|
||||||
let sr = (x * (chroma.b.1 - chroma.g.1)
|
let sr = (x * (chroma.b.1 - chroma.g.1)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use std;
|
use std;
|
||||||
use std::ops::{Index, IndexMut, Mul};
|
use std::ops::{Index, IndexMut, Mul};
|
||||||
|
|
||||||
use float4::{Float4, transpose, invert};
|
use float4::{invert, transpose, Float4};
|
||||||
|
|
||||||
use super::Point;
|
use super::Point;
|
||||||
|
|
||||||
|
@ -202,22 +202,7 @@ mod tests {
|
||||||
let a = Matrix4x4::new();
|
let a = Matrix4x4::new();
|
||||||
let b = Matrix4x4::new();
|
let b = Matrix4x4::new();
|
||||||
let c = Matrix4x4::new_from_values(
|
let c = Matrix4x4::new_from_values(
|
||||||
1.1,
|
1.1, 0.0, 0.0, 0.0, 0.0, 1.1, 0.0, 0.0, 0.0, 0.0, 1.1, 0.0, 0.0, 0.0, 0.0, 1.1,
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.1,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.1,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(a, b);
|
assert_eq!(a, b);
|
||||||
|
@ -228,57 +213,13 @@ mod tests {
|
||||||
fn aproximate_equality_test() {
|
fn aproximate_equality_test() {
|
||||||
let a = Matrix4x4::new();
|
let a = Matrix4x4::new();
|
||||||
let b = Matrix4x4::new_from_values(
|
let b = Matrix4x4::new_from_values(
|
||||||
1.001,
|
1.001, 0.0, 0.0, 0.0, 0.0, 1.001, 0.0, 0.0, 0.0, 0.0, 1.001, 0.0, 0.0, 0.0, 0.0, 1.001,
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.001,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.001,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.001,
|
|
||||||
);
|
);
|
||||||
let c = Matrix4x4::new_from_values(
|
let c = Matrix4x4::new_from_values(
|
||||||
1.003,
|
1.003, 0.0, 0.0, 0.0, 0.0, 1.003, 0.0, 0.0, 0.0, 0.0, 1.003, 0.0, 0.0, 0.0, 0.0, 1.003,
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.003,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.003,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.003,
|
|
||||||
);
|
);
|
||||||
let d = Matrix4x4::new_from_values(
|
let d = Matrix4x4::new_from_values(
|
||||||
-1.001,
|
-1.001, 0.0, 0.0, 0.0, 0.0, -1.001, 0.0, 0.0, 0.0, 0.0, -1.001, 0.0, 0.0, 0.0, 0.0,
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
-1.001,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
-1.001,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
-1.001,
|
-1.001,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -290,58 +231,14 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn multiply_test() {
|
fn multiply_test() {
|
||||||
let a = Matrix4x4::new_from_values(
|
let a = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 13.0, 7.0, 15.0, 3.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
7.0,
|
|
||||||
15.0,
|
|
||||||
3.0,
|
|
||||||
);
|
);
|
||||||
let b = Matrix4x4::new_from_values(
|
let b = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 5.0, 9.0, 13.0, 2.0, 6.0, 10.0, 14.0, 3.0, 7.0, 11.0, 15.0, 4.0, 8.0, 12.0, 16.0,
|
||||||
5.0,
|
|
||||||
9.0,
|
|
||||||
13.0,
|
|
||||||
2.0,
|
|
||||||
6.0,
|
|
||||||
10.0,
|
|
||||||
14.0,
|
|
||||||
3.0,
|
|
||||||
7.0,
|
|
||||||
11.0,
|
|
||||||
15.0,
|
|
||||||
4.0,
|
|
||||||
8.0,
|
|
||||||
12.0,
|
|
||||||
16.0,
|
|
||||||
);
|
);
|
||||||
let c = Matrix4x4::new_from_values(
|
let c = Matrix4x4::new_from_values(
|
||||||
266.0,
|
266.0, 141.0, 331.0, 188.5, 292.0, 158.0, 366.0, 213.0, 318.0, 175.0, 401.0, 237.5,
|
||||||
141.0,
|
344.0, 192.0, 436.0, 262.0,
|
||||||
331.0,
|
|
||||||
188.5,
|
|
||||||
292.0,
|
|
||||||
158.0,
|
|
||||||
366.0,
|
|
||||||
213.0,
|
|
||||||
318.0,
|
|
||||||
175.0,
|
|
||||||
401.0,
|
|
||||||
237.5,
|
|
||||||
344.0,
|
|
||||||
192.0,
|
|
||||||
436.0,
|
|
||||||
262.0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(a * b, c);
|
assert_eq!(a * b, c);
|
||||||
|
@ -350,22 +247,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn inverse_test() {
|
fn inverse_test() {
|
||||||
let a = Matrix4x4::new_from_values(
|
let a = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 0.33, 0.0, -2.0, 0.0, 1.0, 0.0, 0.0, 2.1, 0.7, 1.3, 0.0, 0.0, 0.0, 0.0, -1.0,
|
||||||
0.33,
|
|
||||||
0.0,
|
|
||||||
-2.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
2.1,
|
|
||||||
0.7,
|
|
||||||
1.3,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
-1.0,
|
|
||||||
);
|
);
|
||||||
let b = a.inverse();
|
let b = a.inverse();
|
||||||
let c = Matrix4x4::new();
|
let c = Matrix4x4::new();
|
||||||
|
@ -376,40 +258,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn transpose_test() {
|
fn transpose_test() {
|
||||||
let a = Matrix4x4::new_from_values(
|
let a = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
2.0,
|
|
||||||
3.0,
|
|
||||||
4.0,
|
|
||||||
5.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
10.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
14.0,
|
|
||||||
15.0,
|
|
||||||
16.0,
|
|
||||||
);
|
);
|
||||||
let b = Matrix4x4::new_from_values(
|
let b = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 5.0, 9.0, 13.0, 2.0, 6.0, 10.0, 14.0, 3.0, 7.0, 11.0, 15.0, 4.0, 8.0, 12.0, 16.0,
|
||||||
5.0,
|
|
||||||
9.0,
|
|
||||||
13.0,
|
|
||||||
2.0,
|
|
||||||
6.0,
|
|
||||||
10.0,
|
|
||||||
14.0,
|
|
||||||
3.0,
|
|
||||||
7.0,
|
|
||||||
11.0,
|
|
||||||
15.0,
|
|
||||||
4.0,
|
|
||||||
8.0,
|
|
||||||
12.0,
|
|
||||||
16.0,
|
|
||||||
);
|
);
|
||||||
let c = a.transposed();
|
let c = a.transposed();
|
||||||
|
|
||||||
|
|
|
@ -183,8 +183,8 @@ impl CrossProduct for Normal {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use super::super::{CrossProduct, DotProduct, Matrix4x4};
|
use super::super::{CrossProduct, DotProduct, Matrix4x4};
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add() {
|
fn add() {
|
||||||
|
@ -217,22 +217,7 @@ mod tests {
|
||||||
fn mul_matrix_1() {
|
fn mul_matrix_1() {
|
||||||
let n = Normal::new(1.0, 2.5, 4.0);
|
let n = Normal::new(1.0, 2.5, 4.0);
|
||||||
let m = Matrix4x4::new_from_values(
|
let m = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 13.0, 7.0, 15.0, 3.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
7.0,
|
|
||||||
15.0,
|
|
||||||
3.0,
|
|
||||||
);
|
);
|
||||||
let nm = Normal::new(-19.258825, 5.717648, -1.770588);
|
let nm = Normal::new(-19.258825, 5.717648, -1.770588);
|
||||||
assert!(((n * m) - nm).length2() < 0.00001);
|
assert!(((n * m) - nm).length2() < 0.00001);
|
||||||
|
|
|
@ -155,8 +155,8 @@ impl Mul<Matrix4x4> for Point {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use super::super::{Matrix4x4, Vector};
|
use super::super::{Matrix4x4, Vector};
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn norm() {
|
fn norm() {
|
||||||
|
@ -189,22 +189,7 @@ mod tests {
|
||||||
fn mul_matrix_1() {
|
fn mul_matrix_1() {
|
||||||
let p = Point::new(1.0, 2.5, 4.0);
|
let p = Point::new(1.0, 2.5, 4.0);
|
||||||
let m = Matrix4x4::new_from_values(
|
let m = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 0.0, 0.0, 0.0, 1.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
);
|
);
|
||||||
let pm = Point::new(15.5, 54.0, 70.0);
|
let pm = Point::new(15.5, 54.0, 70.0);
|
||||||
assert_eq!(p * m, pm);
|
assert_eq!(p * m, pm);
|
||||||
|
@ -214,22 +199,7 @@ mod tests {
|
||||||
fn mul_matrix_2() {
|
fn mul_matrix_2() {
|
||||||
let p = Point::new(1.0, 2.5, 4.0);
|
let p = Point::new(1.0, 2.5, 4.0);
|
||||||
let m = Matrix4x4::new_from_values(
|
let m = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 2.0, 3.0, 1.0, 5.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
2.0,
|
|
||||||
3.0,
|
|
||||||
1.0,
|
|
||||||
5.0,
|
|
||||||
);
|
);
|
||||||
let mut pm = Point::new(15.5, 54.0, 70.0);
|
let mut pm = Point::new(15.5, 54.0, 70.0);
|
||||||
pm.co.set_3(18.5);
|
pm.co.set_3(18.5);
|
||||||
|
@ -241,40 +211,10 @@ mod tests {
|
||||||
// Make sure matrix multiplication composes the way one would expect
|
// Make sure matrix multiplication composes the way one would expect
|
||||||
let p = Point::new(1.0, 2.5, 4.0);
|
let p = Point::new(1.0, 2.5, 4.0);
|
||||||
let m1 = Matrix4x4::new_from_values(
|
let m1 = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 13.0, 7.0, 15.0, 3.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
7.0,
|
|
||||||
15.0,
|
|
||||||
3.0,
|
|
||||||
);
|
);
|
||||||
let m2 = Matrix4x4::new_from_values(
|
let m2 = Matrix4x4::new_from_values(
|
||||||
4.0,
|
4.0, 1.0, 2.0, 3.5, 3.0, 6.0, 5.0, 2.0, 2.0, 2.0, 4.0, 12.0, 5.0, 7.0, 8.0, 11.0,
|
||||||
1.0,
|
|
||||||
2.0,
|
|
||||||
3.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
5.0,
|
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
4.0,
|
|
||||||
12.0,
|
|
||||||
5.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
11.0,
|
|
||||||
);
|
);
|
||||||
println!("{:?}", m1 * m2);
|
println!("{:?}", m1 * m2);
|
||||||
|
|
||||||
|
|
|
@ -192,8 +192,8 @@ impl CrossProduct for Vector {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use super::super::{CrossProduct, DotProduct, Matrix4x4};
|
use super::super::{CrossProduct, DotProduct, Matrix4x4};
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add() {
|
fn add() {
|
||||||
|
@ -226,22 +226,7 @@ mod tests {
|
||||||
fn mul_matrix_1() {
|
fn mul_matrix_1() {
|
||||||
let v = Vector::new(1.0, 2.5, 4.0);
|
let v = Vector::new(1.0, 2.5, 4.0);
|
||||||
let m = Matrix4x4::new_from_values(
|
let m = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 13.0, 7.0, 15.0, 3.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
13.0,
|
|
||||||
7.0,
|
|
||||||
15.0,
|
|
||||||
3.0,
|
|
||||||
);
|
);
|
||||||
let mut vm = Vector::new(14.0, 46.0, 58.0);
|
let mut vm = Vector::new(14.0, 46.0, 58.0);
|
||||||
vm.co.set_3(90.5);
|
vm.co.set_3(90.5);
|
||||||
|
@ -252,22 +237,7 @@ mod tests {
|
||||||
fn mul_matrix_2() {
|
fn mul_matrix_2() {
|
||||||
let v = Vector::new(1.0, 2.5, 4.0);
|
let v = Vector::new(1.0, 2.5, 4.0);
|
||||||
let m = Matrix4x4::new_from_values(
|
let m = Matrix4x4::new_from_values(
|
||||||
1.0,
|
1.0, 2.0, 2.0, 1.5, 3.0, 6.0, 7.0, 8.0, 9.0, 2.0, 11.0, 12.0, 0.0, 0.0, 0.0, 1.0,
|
||||||
2.0,
|
|
||||||
2.0,
|
|
||||||
1.5,
|
|
||||||
3.0,
|
|
||||||
6.0,
|
|
||||||
7.0,
|
|
||||||
8.0,
|
|
||||||
9.0,
|
|
||||||
2.0,
|
|
||||||
11.0,
|
|
||||||
12.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
);
|
);
|
||||||
let vm = Vector::new(14.0, 46.0, 58.0);
|
let vm = Vector::new(14.0, 46.0, 58.0);
|
||||||
assert_eq!(v * m, vm);
|
assert_eq!(v * m, vm);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::slice;
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::mem::{align_of, size_of};
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
use std::mem::{align_of, size_of};
|
||||||
|
use std::slice;
|
||||||
|
|
||||||
const GROWTH_FRACTION: usize = 8; // 1/N (smaller number leads to bigger allocations)
|
const GROWTH_FRACTION: usize = 8; // 1/N (smaller number leads to bigger allocations)
|
||||||
const DEFAULT_MIN_BLOCK_SIZE: usize = 1 << 10; // 1 KiB
|
const DEFAULT_MIN_BLOCK_SIZE: usize = 1 << 10; // 1 KiB
|
||||||
|
|
Loading…
Reference in New Issue
Block a user