world/src/anchor.rs

81 lines
1.4 KiB
Rust

use glam::{DMat3, DVec3};
use crate::{
terrain::Terrain,
generator::Generator,
};
#[derive(Clone, Copy)]
pub struct Neighbor {
pub distance:f64,
pub position:DVec3,
pub transform:DMat3,
}
impl Neighbor {
pub fn new() -> Self
{
Self {
distance:0.,
position:DVec3::ZERO,
transform:DMat3::IDENTITY,
}
}
}
#[derive(Clone, Copy)]
pub struct Octave {
pub frequency:f64,
pub amplitude:f64,
}
impl Octave {
pub fn new() -> Self
{
Self {
frequency:1.,
amplitude:1.,
}
}
}
#[derive(Clone, Copy)]
pub struct Geography {
pub elevation:f64,
pub octaves:[Octave; 4],
}
impl Geography {
pub fn new() -> Self
{
Self {
elevation:0.,
octaves:[Octave::new(); 4],
}
}
}
#[derive(Clone)]
pub struct Anchor {
pub position:DVec3,
pub centroid:DVec3,
pub basis:DMat3,
pub ibasis:DMat3,
pub neighbors:[Neighbor; 3],
pub terrain:Terrain,
pub geography:Geography,
}
impl Anchor {
pub fn new() -> Self
{
Self {
position:DVec3::ZERO,
centroid:DVec3::ZERO,
basis:DMat3::IDENTITY,
ibasis:DMat3::IDENTITY,
neighbors:[Neighbor::new(); 3],
terrain:Terrain::new(Generator::new()),
geography:Geography::new(),
}
}
}