start on scheme ffi
This commit is contained in:
parent
31d7262554
commit
4f66323e84
9 changed files with 40 additions and 7 deletions
4
.rustfmt.toml
Normal file
4
.rustfmt.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
wrap_comments = true
|
||||||
|
edition = "2024"
|
||||||
3
Cargo.lock
generated
3
Cargo.lock
generated
|
|
@ -351,7 +351,7 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autobats"
|
name = "autobarts"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
|
|
@ -365,6 +365,7 @@ dependencies = [
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rusqlite_migration",
|
"rusqlite_migration",
|
||||||
"steel-core",
|
"steel-core",
|
||||||
|
"steel-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "autobats"
|
name = "autobarts"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
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"] }
|
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
include_dir = "0.7.4"
|
include_dir = "0.7.4"
|
||||||
ordered-float = "5.1.0"
|
ordered-float = "5.1.0"
|
||||||
|
|
@ -13,6 +12,7 @@ rstar = "0.12.2"
|
||||||
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"] }
|
||||||
steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" }
|
steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" }
|
||||||
|
steel-derive = { 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.
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|
@ -25,6 +25,7 @@ opt-level = 3
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
rand_hc = "0.4.0"
|
rand_hc = "0.4.0"
|
||||||
|
criterion = { version = "0.8.1", default-features = false, features = ["cargo_bench_support", "rayon"] }
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "benchmarks"
|
name = "benchmarks"
|
||||||
|
|
|
||||||
4
assets/scripts/tank.scm
Normal file
4
assets/scripts/tank.scm
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
(struct point (x))
|
||||||
|
|
||||||
|
(define (dist p1 p2)
|
||||||
|
)
|
||||||
|
|
@ -86,7 +86,7 @@ fn range_query(c: &mut Criterion) {
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
benches,
|
benches,
|
||||||
//bulk_load_baseline,
|
bulk_load_baseline,
|
||||||
// bulk_load_comparison,
|
// bulk_load_comparison,
|
||||||
// tree_creation_quality,
|
// tree_creation_quality,
|
||||||
range_query
|
range_query
|
||||||
|
|
@ -95,7 +95,7 @@ criterion_main!(benches);
|
||||||
|
|
||||||
fn create_random_points(num_points: usize, seed: &[u8; 32]) -> Vec<Point> {
|
fn create_random_points(num_points: usize, seed: &[u8; 32]) -> Vec<Point> {
|
||||||
let mut rng = Hc128Rng::from_seed(*seed);
|
let mut rng = Hc128Rng::from_seed(*seed);
|
||||||
let r = (-10_000.0)..=10_000.0;
|
let r = (-1_000.0)..=1_000.0;
|
||||||
(0..num_points)
|
(0..num_points)
|
||||||
.map(|_| Point::new(rng.random_range(r.clone()), rng.random_range(r.clone())))
|
.map(|_| Point::new(rng.random_range(r.clone()), rng.random_range(r.clone())))
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
||||||
21
src/ffi.rs
Normal file
21
src/ffi.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
use steel::steel_vm::{engine::Engine, register_fn::RegisterFn};
|
||||||
|
|
||||||
|
use crate::geom::*;
|
||||||
|
|
||||||
|
//pub struct
|
||||||
|
|
||||||
|
pub fn get_vm() -> Engine {
|
||||||
|
let mut vm = Engine::new();
|
||||||
|
vm.register_type::<Point>("point?");
|
||||||
|
vm.register_fn("dist2", dist2);
|
||||||
|
vm.register_fn("dist", dist);
|
||||||
|
vm
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dist2(p1: &Point, p2: &Point) -> f32 {
|
||||||
|
p1.point.distance_squared(p2.point)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dist(p1: &Point, p2: &Point) -> f32 {
|
||||||
|
p1.point.distance(p2.point)
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,9 @@ use std::cmp::Ordering;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use rstar::Point as PointTrait;
|
use rstar::Point as PointTrait;
|
||||||
|
use steel_derive::Steel;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, Steel)]
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
pub point: Vec2,
|
pub point: Vec2,
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod db;
|
pub mod db;
|
||||||
|
pub mod ffi;
|
||||||
pub mod geom;
|
pub mod geom;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use autobats::db::init_db;
|
use autobarts::db::init_db;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue