started adding spart, need to vendor and change it

This commit is contained in:
joe 2026-01-19 20:15:54 -08:00
parent 583e541fbd
commit 16706c8338
4 changed files with 79 additions and 2 deletions

12
Cargo.lock generated
View file

@ -336,8 +336,10 @@ dependencies = [
"bevy", "bevy",
"dirs", "dirs",
"include_dir", "include_dir",
"ordered-float",
"rusqlite", "rusqlite",
"rusqlite_migration", "rusqlite_migration",
"spart",
"steel-core", "steel-core",
] ]
@ -4793,6 +4795,16 @@ dependencies = [
"serde", "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]] [[package]]
name = "spin" name = "spin"
version = "0.10.0" version = "0.10.0"

View file

@ -7,8 +7,10 @@ edition = "2024"
bevy = { version = "0.18", default-features = false, features = ["2d"] } bevy = { version = "0.18", default-features = false, features = ["2d"] }
dirs = "6.0.0" dirs = "6.0.0"
include_dir = "0.7.4" include_dir = "0.7.4"
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"] }
rusqlite_migration = { version = "2.3.0", features = ["from-directory"] } rusqlite_migration = { version = "2.3.0", features = ["from-directory"] }
spart = "0.5.0"
steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" } steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" }
# Enable a small amount of optimization in the dev profile. # Enable a small amount of optimization in the dev profile.

63
src/geom.rs Normal file
View file

@ -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<Ordering> {
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!()
}
}

View file

@ -1,8 +1,8 @@
//! Renders a 2D scene containing a single, moving sprite.
use bevy::prelude::*; use bevy::prelude::*;
use db::init_db; use db::init_db;
mod db; mod db;
mod geom;
fn main() { fn main() {
App::new() App::new()
@ -19,7 +19,7 @@ enum Direction {
} }
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let conn = init_db().unwrap(); let _conn = init_db().unwrap();
commands.spawn(Camera2d); commands.spawn(Camera2d);
commands.spawn(( commands.spawn((