Skip to content

Commit

Permalink
Update project structure to cargo workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
lbirkert committed Aug 13, 2023
1 parent 27ca473 commit 3e246a6
Show file tree
Hide file tree
Showing 45 changed files with 970 additions and 421 deletions.
858 changes: 764 additions & 94 deletions Cargo.lock

Large diffs are not rendered by default.

46 changes: 8 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
[package]
name = "kelocam"
[workspace]
resolver = "2"
members = [
"crates/*",
]

[workspace.package]
version = "0.1.0"
authors = ["Lucas Birkert <kekontheworld@gmail.com>"]
edition = "2021"
rust-version = "1.65"


[dependencies]
egui = "0.22.0"
eframe = { version = "0.22.0", default-features = false, features = [
"default_fonts", # Embed the default egui fonts.
"wgpu",
] }
serialport = "4.2.0"
stl = "0.2.1"
bytemuck = { version = "1.13.1", features = ["derive"] }
tracing-subscriber = "0.3"
nalgebra = "0.32.3"
nalgebra-glm = "0.18.0"
rfd = "0.11.4"
futures = "0.3.28"
pollster = "0.3.0"
byteorder = "1.4.3"
image = "0.24.6"
rstar = "0.11.0"

[profile.release]
opt-level = 2 # fast and small wasm

# Optimize all dependencies even in debug builds:
[profile.dev.package."*"]
opt-level = 2
[patch.crates-io]

# If you want to use the bleeding edge version of egui and eframe:
# egui = { git = "https://github.com/emilk/egui", branch = "master" }
# eframe = { git = "https://github.com/emilk/egui", branch = "master" }

# If you fork https://github.com/emilk/egui you can test with:
# egui = { path = "../egui/crates/egui" }
# eframe = { path = "../egui/crates/eframe" }
lto = true
10 changes: 10 additions & 0 deletions crates/kelocam-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "kelocam-core"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
nalgebra = "0.32.3"
stl = "0.2.1"
15 changes: 15 additions & 0 deletions crates/kelocam-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# KeloCAM - Core module

This module contains all of the primitive structs KeloCAM uses, which includes

1. Axis
2. Line
3. Mesh
4. Path
5. Plane
6. Ray
7. Sphere
8. Square
9. Triangle

It has almost no dependencies and is easily testable.
File renamed without changes.
14 changes: 14 additions & 0 deletions crates/kelocam-core/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use nalgebra::Vector3;

pub trait Geometry: BoundingBox {}

pub trait BoundingBox {
/// Compute the minimum coordinate of the bounding box.
fn bb_min(&self) -> Vector3<f32>;
/// Compute the maximum coordinate of the bounding box.
fn bb_max(&self) -> Vector3<f32>;
/// Compute the minimum and maximum coordinate of the bounding box.
fn bb_min_max(&self) -> (Vector3<f32>, Vector3<f32>) {
(self.bb_min(), self.bb_max())
}
}
3 changes: 3 additions & 0 deletions src/core/mod.rs → crates/kelocam-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod ray;
pub mod sphere;
pub mod square;
pub mod triangle;
pub mod geometry;

pub use axis::Axis;
pub use line::Line;
Expand All @@ -17,3 +18,5 @@ pub use ray::Ray;
pub use sphere::Sphere;
pub use square::Square;
pub use triangle::Triangle;
pub use geometry::Geometry;
pub use geometry::BoundingBox;
17 changes: 17 additions & 0 deletions src/core/line.rs → crates/kelocam-core/src/line.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use nalgebra::Vector3;

use crate::{BoundingBox, Geometry};

use super::Plane;

#[derive(Debug)]
Expand Down Expand Up @@ -41,3 +43,18 @@ impl Line {
Some(b.lerp(a, t))
}
}

impl BoundingBox for Line {
fn bb_min(&self) -> Vector3<f32> {
self.a.inf(&self.b)
}

fn bb_max(&self) -> Vector3<f32> {
self.a.sup(&self.b)
}

fn bb_min_max(&self) -> (Vector3<f32>, Vector3<f32>) {
self.a.inf_sup(&self.b)
}
}
impl Geometry for Line {}
Loading

0 comments on commit 3e246a6

Please sign in to comment.