tweak
This commit is contained in:
parent
ccb598ac1f
commit
24b7709b4c
4 changed files with 23 additions and 12 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
|
@ -357,8 +357,10 @@ dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"criterion",
|
"criterion",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"glam 0.31.0",
|
||||||
"include_dir",
|
"include_dir",
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
|
"rand",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rusqlite_migration",
|
"rusqlite_migration",
|
||||||
"steel-core",
|
"steel-core",
|
||||||
|
|
@ -985,7 +987,7 @@ dependencies = [
|
||||||
"arrayvec 0.7.6",
|
"arrayvec 0.7.6",
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"glam",
|
"glam 0.30.10",
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"libm",
|
"libm",
|
||||||
"rand",
|
"rand",
|
||||||
|
|
@ -1159,7 +1161,7 @@ dependencies = [
|
||||||
"downcast-rs 2.0.2",
|
"downcast-rs 2.0.2",
|
||||||
"erased-serde",
|
"erased-serde",
|
||||||
"foldhash 0.2.0",
|
"foldhash 0.2.0",
|
||||||
"glam",
|
"glam 0.30.10",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.0",
|
||||||
"inventory",
|
"inventory",
|
||||||
"petgraph",
|
"petgraph",
|
||||||
|
|
@ -1219,7 +1221,7 @@ dependencies = [
|
||||||
"downcast-rs 2.0.2",
|
"downcast-rs 2.0.2",
|
||||||
"encase",
|
"encase",
|
||||||
"fixedbitset",
|
"fixedbitset",
|
||||||
"glam",
|
"glam 0.30.10",
|
||||||
"image",
|
"image",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.0",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
|
@ -2874,6 +2876,15 @@ dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glam"
|
||||||
|
version = "0.31.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74a4d85559e2637d3d839438b5b3d75c31e655276f9544d72475c36b92fabbed"
|
||||||
|
dependencies = [
|
||||||
|
"libm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|
@ -3073,7 +3084,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "29a164ceff4500f2a72b1d21beaa8aa8ad83aec2b641844c659b190cb3ea2e0b"
|
checksum = "29a164ceff4500f2a72b1d21beaa8aa8ad83aec2b641844c659b190cb3ea2e0b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"constgebra",
|
"constgebra",
|
||||||
"glam",
|
"glam 0.30.10",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ edition = "2024"
|
||||||
bevy = { version = "0.18", default-features = false, features = ["2d"] }
|
bevy = { version = "0.18", default-features = false, features = ["2d"] }
|
||||||
criterion = { version = "0.8.1", default-features = false, features = ["cargo_bench_support", "rayon"] }
|
criterion = { version = "0.8.1", default-features = false, features = ["cargo_bench_support", "rayon"] }
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
|
glam = { version = "0.31.0", default-features = false, features = ["libm"] }
|
||||||
include_dir = "0.7.4"
|
include_dir = "0.7.4"
|
||||||
ordered-float = "5.1.0"
|
ordered-float = "5.1.0"
|
||||||
rusqlite = { version = "0.37", default-features = false, features = ["bundled", "blob", "functions", "jiff"] }
|
rusqlite = { version = "0.37", default-features = false, features = ["bundled", "blob", "functions", "jiff"] }
|
||||||
|
|
@ -27,3 +28,6 @@ inherits = "release"
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "main"
|
name = "main"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rand = "0.9.2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use criterion::criterion_main;
|
use criterion::criterion_main;
|
||||||
|
|
||||||
mod bench_insert_bulk;
|
//mod bench_insert_bulk;
|
||||||
mod bench_range_search;
|
mod bench_range_search;
|
||||||
|
|
||||||
criterion_main!(bench_insert_bulk::benches, bench_range_search::benches,);
|
criterion_main!(bench_range_search::benches,);
|
||||||
|
|
|
||||||
|
|
@ -105,15 +105,11 @@ impl RStarTree {
|
||||||
|
|
||||||
pub fn range_search(&self, query_point: &Point, radius: f32) -> Vec<&Point> {
|
pub fn range_search(&self, query_point: &Point, radius: f32) -> Vec<&Point> {
|
||||||
let query_bbox = Aabb2d::new(query_point.point, Vec2::splat(radius));
|
let query_bbox = Aabb2d::new(query_point.point, Vec2::splat(radius));
|
||||||
let r2 = radius * radius;
|
let r2 = radius.powi(2);
|
||||||
let candidates = self.range_search_bbox(&query_bbox);
|
let candidates = self.range_search_bbox(&query_bbox);
|
||||||
candidates
|
candidates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|&other| {
|
.filter(|&other| query_point.point.distance_squared(other.point) <= r2)
|
||||||
((query_point.point.x - other.point.x) + (query_point.point.y - other.point.y))
|
|
||||||
.powi(2)
|
|
||||||
<= r2
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue