diff options
author | metamuffin <metamuffin@disroot.org> | 2025-03-27 20:06:49 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-03-27 20:06:49 +0100 |
commit | 547e96ab9d22e1bacec2fc08454519560caca919 (patch) | |
tree | 60a7c6b451ce9d3bf482f41c688437035650158a /src/main.rs | |
parent | 9900745ec2981588e02863a4bdd5a21ed7eec909 (diff) | |
download | wearemapping-547e96ab9d22e1bacec2fc08454519560caca919.tar wearemapping-547e96ab9d22e1bacec2fc08454519560caca919.tar.bz2 wearemapping-547e96ab9d22e1bacec2fc08454519560caca919.tar.zst |
init js
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs index 7f13114..1ce78ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ pub mod spatial; use anyhow::Result; -use glam::DVec3; +use glam::{Affine3A, DAffine3, DVec3, Vec3}; use indicatif::ProgressIterator; use log::{debug, info}; use osm_pbf_reader::{Blobs, data::primitives::Primitive}; @@ -9,6 +9,7 @@ use rayon::iter::{ParallelBridge, ParallelIterator}; use spatial::{SpatialTree, octtree::Octtree}; use std::{collections::BTreeMap, env::args, f64::consts::PI, fs::File, io::BufWriter}; use weareshared::{ + graphics::GraphicsPart, helper::AABB, packets::Resource, resources::{Prefab, RespackEntry, SpatialIndex}, @@ -21,6 +22,7 @@ fn main() -> Result<()> { let inpath = args().nth(1).unwrap(); let outpath = args().nth(2).unwrap(); + info!("Indexing node positions..."); let node_positions = Blobs::from_path(&inpath)? .progress_count(1_500) .par_bridge() @@ -49,7 +51,7 @@ fn main() -> Result<()> { || BTreeMap::new(), |mut a, b| { if !a.is_empty() && !b.is_empty() { - debug!("merge positions {} + {}", a.len(), b.len()); + debug!("merge {} + {}", a.len(), b.len()); } a.extend(b); a @@ -64,11 +66,15 @@ fn main() -> Result<()> { info!("Done, depth={}", tree.depth()); let store = ResourceStore::new_memory(); + + info!("Exporting resources..."); let (_, root) = export_level(&tree, &store)?; let entry = Some(store.set(&RespackEntry { c_spatial_index: vec![root], ..Default::default() })?); + info!("Done, N={}", store.count()?); + let output = BufWriter::new(File::create(outpath)?); save_full_respack(output, &store, entry)?; @@ -88,7 +94,17 @@ fn export_level(node: &Octtree, store: &ResourceStore) -> Result<(AABB, Resource let prefab = if node.elems.is_empty() { None } else { + let local_origin = node.center; + let mut g = GraphicsPart::default(); + + use weareshared::graphics::GraphicsCommand::*; + g.push(StrokeWidth(0.001)); + g.push(Stroke(5)); + g.push(Point(Vec3::ZERO)); + Some(store.set(&Prefab { + transform: Some(DAffine3::from_translation(local_origin)), + graphics: vec![(Affine3A::IDENTITY, store.set(&g)?)], ..Default::default() })?) }; @@ -109,23 +125,12 @@ fn export_level(node: &Octtree, store: &ResourceStore) -> Result<(AABB, Resource type NodeID = u64; fn map_nodeid(id: i64) -> u64 { + // fn xorshift(mut x: u64) -> u64 { + // x ^= x << 13; + // x ^= x >> 7; + // x ^= x << 17; + // x + // } // xorshift(xorshift(xorshift(id as u64))) id as u64 } -fn xorshift(mut x: u64) -> u64 { - x ^= x << 13; - x ^= x >> 7; - x ^= x << 17; - x -} - -enum Elem { - Node { pos: DVec3 }, -} -impl Elem { - pub fn center(&self) -> DVec3 { - match self { - Elem::Node { pos } => *pos, - } - } -} |