Tried out Itertools::tuple_combinations

This commit is contained in:
Jarrod Doyle 2023-09-22 21:50:26 +01:00
parent 58cda59b78
commit 43d5259af2
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
3 changed files with 21 additions and 1 deletions

16
Cargo.lock generated
View File

@ -7,6 +7,7 @@ name = "csg"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"glam", "glam",
"itertools",
] ]
[[package]] [[package]]
@ -16,8 +17,23 @@ dependencies = [
"csg", "csg",
] ]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]] [[package]]
name = "glam" name = "glam"
version = "0.24.1" version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42218cb640844e3872cc3c153dc975229e080a6c4733b34709ef445610550226" checksum = "42218cb640844e3872cc3c153dc975229e080a6c4733b34709ef445610550226"
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]

View File

@ -7,3 +7,4 @@ edition = "2021"
[dependencies] [dependencies]
glam = "0.24.1" glam = "0.24.1"
itertools = "0.11.0"

View File

@ -81,7 +81,10 @@ impl Brush {
} }
fn calculate_raw_vertices(&mut self) { 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 mut intersections = vec![];
let len = self.planes.len(); let len = self.planes.len();
for i in 0..(len - 2) { for i in 0..(len - 2) {