diff --git a/Cargo.lock b/Cargo.lock index a14a22e..5f5c32b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ name = "csg" version = "0.1.0" dependencies = [ "glam", + "itertools", ] [[package]] @@ -16,8 +17,23 @@ dependencies = [ "csg", ] +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "glam" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42218cb640844e3872cc3c153dc975229e080a6c4733b34709ef445610550226" + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] diff --git a/csg/Cargo.toml b/csg/Cargo.toml index f969eb9..5d04a1d 100644 --- a/csg/Cargo.toml +++ b/csg/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] glam = "0.24.1" +itertools = "0.11.0" diff --git a/csg/src/brush.rs b/csg/src/brush.rs index cb26afa..1c1ec54 100644 --- a/csg/src/brush.rs +++ b/csg/src/brush.rs @@ -81,7 +81,10 @@ impl Brush { } fn calculate_raw_vertices(&mut self) { - // Test all permutations of brush planes for intersections + // Test all combinations of brush planes for intersections + // I experimented with Itertools::(tuple_)combinations instead of this nested loop + // but it was about 2x slower + // TODO: Experiment more let mut intersections = vec![]; let len = self.planes.len(); for i in 0..(len - 2) {