mod error;
mod gpu;
mod layout;
mod quadtree;
mod shaders;
pub use error::LayoutError;
pub use layout::{GpuLayout, LayoutConfig, LayoutState};
pub use quadtree::QuadTree;
pub type Result<T> = std::result::Result<T, LayoutError>;
#[derive(Debug, Clone, Copy, Default, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
pub struct Position {
pub x: f32,
pub y: f32,
}
impl Position {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
#[derive(Debug, Clone, Copy, Default, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
pub struct Velocity {
pub x: f32,
pub y: f32,
}
#[derive(Debug, Clone, Copy, Default, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
pub struct Edge {
pub source: u32,
pub target: u32,
}
impl Edge {
pub fn new(source: u32, target: u32) -> Self {
Self { source, target }
}
}
#[derive(Debug, Clone, Copy, Default, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
pub struct QuadTreeNode {
pub center_x: f32,
pub center_y: f32,
pub mass: f32,
pub width: f32,
pub child_nw: i32,
pub child_ne: i32,
pub child_sw: i32,
pub child_se: i32,
}
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct LayoutParams {
pub node_count: u32,
pub edge_count: u32,
pub tree_size: u32,
pub dt: f32,
pub damping: f32,
pub repulsion: f32,
pub attraction: f32,
pub theta: f32,
pub gravity: f32,
pub ideal_length: f32,
}
impl Default for LayoutParams {
fn default() -> Self {
Self {
node_count: 0,
edge_count: 0,
tree_size: 0,
dt: 0.016, damping: 0.9,
repulsion: 1000.0,
attraction: 0.01,
theta: 0.8, gravity: 0.1,
ideal_length: 50.0,
}
}
}
unsafe impl bytemuck::Pod for LayoutParams {}
unsafe impl bytemuck::Zeroable for LayoutParams {}