From 16706c8338e0ba7941c586295e90e5afda92f0a4 Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 19 Jan 2026 20:15:54 -0800 Subject: [PATCH] started adding spart, need to vendor and change it --- Cargo.lock | 12 ++++++++++ Cargo.toml | 2 ++ src/geom.rs | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 4 ++-- 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/geom.rs diff --git a/Cargo.lock b/Cargo.lock index e5f866b..a6a3578 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -336,8 +336,10 @@ dependencies = [ "bevy", "dirs", "include_dir", + "ordered-float", "rusqlite", "rusqlite_migration", + "spart", "steel-core", ] @@ -4793,6 +4795,16 @@ dependencies = [ "serde", ] +[[package]] +name = "spart" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a05d85e94c16e35b2f963dee2eaa6f6b2494ee5dad740b045b139c5614872d6" +dependencies = [ + "ordered-float", + "tracing", +] + [[package]] name = "spin" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 1da681d..34350fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,10 @@ edition = "2024" bevy = { version = "0.18", default-features = false, features = ["2d"] } dirs = "6.0.0" include_dir = "0.7.4" +ordered-float = "5.1.0" rusqlite = { version = "0.37", default-features = false, features = ["bundled", "blob", "functions", "jiff"] } rusqlite_migration = { version = "2.3.0", features = ["from-directory"] } +spart = "0.5.0" steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" } # Enable a small amount of optimization in the dev profile. diff --git a/src/geom.rs b/src/geom.rs new file mode 100644 index 0000000..c436045 --- /dev/null +++ b/src/geom.rs @@ -0,0 +1,63 @@ +use std::cmp::Ordering; + +use bevy::prelude::*; +use ordered_float::OrderedFloat; +use spart::{geometry::BoundingVolume, rstar_tree::RStarTreeObject}; + +#[derive(Debug, Clone)] +pub struct Point { + pub point: Vec2, + pub entity: Entity, +} + +impl PartialEq for Point { + fn eq(&self, other: &Self) -> bool { + OrderedFloat(self.point.x) == OrderedFloat(other.point.x) + && OrderedFloat(self.point.y) == OrderedFloat(other.point.y) + && self.entity == other.entity + } +} + +impl PartialOrd for Point { + fn partial_cmp(&self, other: &Self) -> Option { + match (OrderedFloat(self.point.x), OrderedFloat(self.point.y)) + .partial_cmp(&(OrderedFloat(other.point.x), OrderedFloat(other.point.y))) + { + Some(Ordering::Equal) => self.entity.partial_cmp(&other.entity), + other => other, + } + } +} + +impl RStarTreeObject for Point { + type B = PointBox; + + fn mbr(&self) -> Self::B { + todo!() + } +} + +#[derive(Debug, Clone)] +pub struct PointBox; + +impl BoundingVolume for PointBox { + fn area(&self) -> f64 { + todo!() + } + + fn union(&self, other: &Self) -> Self { + todo!() + } + + fn intersects(&self, other: &Self) -> bool { + todo!() + } + + fn overlap(&self, other: &Self) -> f64 { + todo!() + } + + fn margin(&self) -> f64 { + todo!() + } +} diff --git a/src/main.rs b/src/main.rs index 1a5124f..672a0b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ -//! Renders a 2D scene containing a single, moving sprite. use bevy::prelude::*; use db::init_db; mod db; +mod geom; fn main() { App::new() @@ -19,7 +19,7 @@ enum Direction { } fn setup(mut commands: Commands, asset_server: Res) { - let conn = init_db().unwrap(); + let _conn = init_db().unwrap(); commands.spawn(Camera2d); commands.spawn((