Skip to content

Commit

Permalink
Merge pull request #219 from Walther/2024-11-26-chores
Browse files Browse the repository at this point in the history
2024-11-26 chores
  • Loading branch information
Walther authored Nov 26, 2024
2 parents 151d59f + 137f24e commit 0f7bb6b
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 104 deletions.
14 changes: 7 additions & 7 deletions clovers-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ clovers = { path = "../clovers", features = [

# External
blue-noise-sampler = "0.1.0"
clap = { version = "4.5.16", features = ["std", "derive"] }
clap = { version = "4.5.21", features = ["std", "derive"] }
human_format = "1.1.0"
humantime = "2.1.0"
image = { version = "0.25.2", features = ["png"], default-features = false }
img-parts = "0.3.0"
indicatif = { version = "0.17.8", features = [
image = { version = "0.25.5", features = ["png"], default-features = false }
img-parts = "0.3.1"
indicatif = { version = "0.17.9", features = [
"rayon",
], default-features = false }
nalgebra = { version = "0.33.0" }
nalgebra = { version = "0.33.2" }
palette = { version = "0.7.6", features = ["serializing"] }
paste = { version = "1.0.15" }
rand = { version = "0.8.5", features = ["small_rng"], default-features = false }
rayon = "1.10.0"
serde = { version = "1.0.209", features = ["derive"], default-features = false }
serde = { version = "1.0.215", features = ["derive"], default-features = false }
serde_json = { version = "1.0", features = ["alloc"], default-features = false }
time = { version = "0.3.36", default-features = false }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["time"] }

[dev-dependencies]
divan = "0.1.14"
divan = "0.1.16"
proptest = "1"
8 changes: 4 additions & 4 deletions clovers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ traces = ["tracing"]
[dependencies]
enum_dispatch = "0.3.13"
gltf = { version = "1.4.1", optional = true }
nalgebra = { version = "0.33.0" }
nalgebra = { version = "0.33.2" }
palette = { version = "0.7.6", features = ["serializing"] }
ply-rs = { version = "0.1.3", optional = true }
rand = { version = "0.8.5", features = ["small_rng"], default-features = false }
rand_distr = { version = "0.4.3", features = ["std_math"] }
serde = { version = "1.0.209", features = [
serde = { version = "1.0.215", features = [
"derive",
], default-features = false, optional = true }
stl_io = { version = "0.7.0", optional = true }
stl_io = { version = "0.8.3", optional = true }
tracing = { version = "0.1.40", optional = true }

[dev-dependencies]
divan = "0.1.14"
divan = "0.1.16"
proptest = "1"

[[bench]]
Expand Down
7 changes: 1 addition & 6 deletions clovers/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ impl AABB {
// TODO: this api is kind of annoying
#[must_use]
pub fn axis(&self, n: usize) -> &Interval {
match n {
0 => &self.x,
1 => &self.y,
2 => &self.z,
_ => panic!("AABB::axis called with invalid parameter: {n:?}"),
}
[&self.x, &self.y, &self.z][n]
}

/// Distance of a `Ray` to the bounding box.
Expand Down
6 changes: 1 addition & 5 deletions clovers/src/bvh/build/longest_axis_midpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ pub fn build(mut hitables: Vec<Hitable>) -> BVHNode {
// What is the axis with the largest span?
// TODO: horribly inefficient, improve!
let bounding: AABB = vec_bounding_box(&hitables).expect("No bounding box for objects");
let spans = [
bounding.axis(0).size(),
bounding.axis(1).size(),
bounding.axis(2).size(),
];
let spans = [bounding.x.size(), bounding.y.size(), bounding.z.size()];
let largest = Float::max(Float::max(spans[0], spans[1]), spans[2]);
#[allow(clippy::float_cmp)] // TODO: better code for picking the largest axis...
let axis: usize = spans.iter().position(|&x| x == largest).unwrap();
Expand Down
5 changes: 4 additions & 1 deletion clovers/src/hitable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ pub struct HitableList<'scene> {

impl<'scene> HitableList<'scene> {
/// Creates a new [`HitableList`].
///
/// # Panics
/// This method may panic if no finite bounding box can be created for the given `hitables`.
#[must_use]
pub fn new(hitables: Vec<Hitable<'scene>>) -> Self {
let aabb = vec_bounding_box(&hitables).unwrap();
let aabb = vec_bounding_box(&hitables).expect("No bounding box for hitables");
Self { hitables, aabb }
}

Expand Down
2 changes: 0 additions & 2 deletions clovers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
// TODO: temporarily allowing some in order to get a majority of clippy::pedantic enabled
#![allow(clippy::many_single_char_names)] // Lots of places with coordinates etc
#![allow(clippy::missing_panics_doc)] // TODO: remove panics where feasible later
#![allow(clippy::module_name_repetitions)]
// no_std required for gpu accelerated rendering
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
4 changes: 2 additions & 2 deletions clovers/src/materials/cone_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl MaterialTrait for ConeLight {
emit
} else {
// Make sure that the front face of the lamp is tinted, even outside the main lighting angle
let (r, g, b) = emit.into_components();
let scaling_factor = r.max(g).max(b);
let (red, green, blue) = emit.into_components();
let scaling_factor = red.max(green).max(blue);
if scaling_factor > 1.0 {
emit / scaling_factor
} else {
Expand Down
6 changes: 5 additions & 1 deletion clovers/src/objects/gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ pub struct GLTF<'scene> {
impl<'scene> GLTF<'scene> {
#[must_use]
/// Create a new STL object with the given initialization parameters.
///
/// # Panics
/// This method may panic if no finite bounding box can be created for the given `hitables`.
pub fn new(gltf_init: GLTFInit) -> Self {
let hitables: Vec<Hitable> = gltf_init.into();
let aabb = vec_bounding_box(&hitables).unwrap();
let aabb = vec_bounding_box(&hitables).expect("No bounding box for hitables");

GLTF { hitables, aabb }
}
Expand Down Expand Up @@ -200,6 +203,7 @@ pub struct GLTFTriangle<'scene> {

impl<'scene> GLTFTriangle<'scene> {
#[must_use]
#[allow(clippy::many_single_char_names)]
/// Initialize a new GLTF object
pub fn new(triangle: [Vec3; 3], material: &'scene GLTFMaterial<'scene>) -> Self {
// TODO: mostly adapted from Triangle, verify correctness!
Expand Down
5 changes: 4 additions & 1 deletion clovers/src/objects/ply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub struct PLYInit {

#[must_use]
/// Initializes a PLY
///
/// # Panics
/// This method may panic if a shared material is referenced in the object description, but cannot be found in the materials list.
pub fn initialize_ply<'scene>(
ply_init: PLYInit,
materials: &'scene [SharedMaterial],
Expand Down Expand Up @@ -105,7 +108,7 @@ pub fn initialize_ply<'scene>(
hitables.push(Hitable::Triangle(triangle));
}
// TODO: remove unwrap
let aabb = vec_bounding_box(&hitables).unwrap();
let aabb = vec_bounding_box(&hitables).expect("No bounding box for hitables");

PLY {
hitables,
Expand Down
1 change: 1 addition & 0 deletions clovers/src/objects/quad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Quad<'scene> {
impl<'scene> Quad<'scene> {
/// Creates a new quad
#[must_use]
#[allow(clippy::many_single_char_names)]
pub fn new(q: Position, u: Vec3, v: Vec3, material: &'scene Material) -> Quad<'scene> {
let n: Vec3 = u.cross(&v);
let normal = Unit::new_normalize(n);
Expand Down
3 changes: 3 additions & 0 deletions clovers/src/objects/stl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pub struct STLInit {

#[must_use]
/// Initializes an STL
///
/// # Panics
/// This method may panic if the referenced .stl file cannot be opened or if it cannot be parsed.
pub fn initialize_stl<'scene>(
stl_init: STLInit,
materials: &'scene [SharedMaterial],
Expand Down
3 changes: 3 additions & 0 deletions clovers/src/objects/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub struct Translate<'scene> {

impl<'scene> Translate<'scene> {
/// Creates a new `Translate` object. It wraps the given [Object] and has adjusted `hit()` and `bounding_box()` methods based on the `offset` given.
///
/// # Panics
/// This method may panic if the given object does not have a valid `AABB`.
#[must_use]
pub fn new(object: Box<Hitable<'scene>>, offset: Vec3) -> Self {
// TODO: time
Expand Down
2 changes: 2 additions & 0 deletions clovers/src/objects/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Triangle<'scene> {
impl<'scene> Triangle<'scene> {
/// Creates a new triangle from a coordinate point and two side vectors relative to the point
#[must_use]
#[allow(clippy::many_single_char_names)]
pub fn new(q: Position, u: Vec3, v: Vec3, material: &'scene Material) -> Triangle<'scene> {
let n: Vec3 = u.cross(&v);
let normal: Direction = Unit::new_normalize(n);
Expand Down Expand Up @@ -101,6 +102,7 @@ impl<'scene> Triangle<'scene> {

/// Creates a new triangle from three Cartesian space coordinates
#[must_use]
#[allow(clippy::many_single_char_names)]
pub fn from_coordinates(
a: Vec3,
b: Vec3,
Expand Down
3 changes: 3 additions & 0 deletions clovers/src/wavelength.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub fn random_wavelength(rng: &mut SmallRng) -> Wavelength {

// TODO: clippy fixes possible?
/// Given a sample seed from a sampler, return the approximate wavelenght.
///
/// # Panics
/// This method may panic if the runtime asserts are triggered. This would indicate a bug in the implementation.
#[must_use]
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
Expand Down
Loading

0 comments on commit 0f7bb6b

Please sign in to comment.