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",
"hashbrown 0.11.2",
"humantime",
"inline_tweak",
"itertools",
"lazy_static",
"num_cpus",

View File

@ -23,7 +23,7 @@ common-net = { package = "veloren-common-net", path = "../common/net" }
world = { package = "veloren-world", path = "../world" }
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-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 } => {
f.debug_tuple("Pyramid").field(&aabb).field(&inset).finish()
},
Primitive::Ramp { aabb, inset, dir } => {
f.debug_tuple("Ramp").field(&aabb).field(&inset).field(&dir).finish()
},
Primitive::Gable { aabb, inset, dir } => {
f.debug_tuple("Gable").field(&aabb).field(&inset).field(&dir).finish()
},
Primitive::Ramp { aabb, inset, dir } => f
.debug_tuple("Ramp")
.field(&aabb)
.field(&inset)
.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::Cone(aabb) => f.debug_tuple("Cone").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, *b),
|a, b| a.intersection(b),
).into_iter().collect(),
)
.into_iter()
.collect(),
Primitive::Union(a, b) => {
fn jaccard(x: Aabb<i32>, y: Aabb<i32>) -> f32 {
@ -538,7 +546,10 @@ impl Fill {
if let Some(aabb) = inputs.pop() {
results.push(aabb);
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 {
Some((i, b)) if jaccard(*a, *b) > 0.3 => {
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> {
self.get_bounds_opt(tree, prim)
.unwrap_or(Aabb::new_empty(Vec3::zero()))
.unwrap_or_else(|| Aabb::new_empty(Vec3::zero()))
}
}