This commit is contained in:
Joshua Barretto 2022-02-14 16:16:34 +00:00 committed by Sam
parent aab552afc5
commit 6e46b4ddef
3 changed files with 21 additions and 11 deletions

1
Cargo.lock generated
View File

@ -6439,7 +6439,6 @@ dependencies = [
"futures-util", "futures-util",
"hashbrown 0.11.2", "hashbrown 0.11.2",
"humantime", "humantime",
"inline_tweak",
"itertools", "itertools",
"lazy_static", "lazy_static",
"num_cpus", "num_cpus",

View File

@ -23,7 +23,7 @@ common-net = { package = "veloren-common-net", path = "../common/net" }
world = { package = "veloren-world", path = "../world" } world = { package = "veloren-world", path = "../world" }
network = { package = "veloren-network", path = "../network", features = ["metrics", "compression", "quic"], default-features = false } network = { package = "veloren-network", path = "../network", features = ["metrics", "compression", "quic"], default-features = false }
inline_tweak = "1.0.8" #inline_tweak = "1.0.8"
specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46" } specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46" }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "8be2abcddf8f524cb5876e8dd20a7e47cfaf7573" } specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "8be2abcddf8f524cb5876e8dd20a7e47cfaf7573" }

View File

@ -90,12 +90,18 @@ impl std::fmt::Debug for Primitive {
Primitive::Pyramid { aabb, inset } => { Primitive::Pyramid { aabb, inset } => {
f.debug_tuple("Pyramid").field(&aabb).field(&inset).finish() f.debug_tuple("Pyramid").field(&aabb).field(&inset).finish()
}, },
Primitive::Ramp { aabb, inset, dir } => { Primitive::Ramp { aabb, inset, dir } => f
f.debug_tuple("Ramp").field(&aabb).field(&inset).field(&dir).finish() .debug_tuple("Ramp")
}, .field(&aabb)
Primitive::Gable { aabb, inset, dir } => { .field(&inset)
f.debug_tuple("Gable").field(&aabb).field(&inset).field(&dir).finish() .field(&dir)
}, .finish(),
Primitive::Gable { aabb, inset, dir } => f
.debug_tuple("Gable")
.field(&aabb)
.field(&inset)
.field(&dir)
.finish(),
Primitive::Cylinder(aabb) => f.debug_tuple("Cylinder").field(&aabb).finish(), Primitive::Cylinder(aabb) => f.debug_tuple("Cylinder").field(&aabb).finish(),
Primitive::Cone(aabb) => f.debug_tuple("Cone").field(&aabb).finish(), Primitive::Cone(aabb) => f.debug_tuple("Cone").field(&aabb).finish(),
Primitive::Sphere(aabb) => f.debug_tuple("Sphere").field(&aabb).finish(), Primitive::Sphere(aabb) => f.debug_tuple("Sphere").field(&aabb).finish(),
@ -523,7 +529,9 @@ impl Fill {
self.get_bounds_opt(tree, *a), self.get_bounds_opt(tree, *a),
self.get_bounds_opt(tree, *b), self.get_bounds_opt(tree, *b),
|a, b| a.intersection(b), |a, b| a.intersection(b),
).into_iter().collect(), )
.into_iter()
.collect(),
Primitive::Union(a, b) => { Primitive::Union(a, b) => {
fn jaccard(x: Aabb<i32>, y: Aabb<i32>) -> f32 { fn jaccard(x: Aabb<i32>, y: Aabb<i32>) -> f32 {
@ -538,7 +546,10 @@ impl Fill {
if let Some(aabb) = inputs.pop() { if let Some(aabb) = inputs.pop() {
results.push(aabb); results.push(aabb);
for a in &inputs { for a in &inputs {
let best = results.iter().enumerate().max_by_key(|(_, b)| (jaccard(*a, **b) * 1000.0) as usize); let best = results
.iter()
.enumerate()
.max_by_key(|(_, b)| (jaccard(*a, **b) * 1000.0) as usize);
match best { match best {
Some((i, b)) if jaccard(*a, *b) > 0.3 => { Some((i, b)) if jaccard(*a, *b) > 0.3 => {
let mut aabb = results.swap_remove(i); let mut aabb = results.swap_remove(i);
@ -616,7 +627,7 @@ impl Fill {
pub fn get_bounds(&self, tree: &Store<Primitive>, prim: Id<Primitive>) -> Aabb<i32> { pub fn get_bounds(&self, tree: &Store<Primitive>, prim: Id<Primitive>) -> Aabb<i32> {
self.get_bounds_opt(tree, prim) self.get_bounds_opt(tree, prim)
.unwrap_or(Aabb::new_empty(Vec3::zero())) .unwrap_or_else(|| Aabb::new_empty(Vec3::zero()))
} }
} }