summaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-31 23:36:08 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-31 23:36:08 -0700
commit2335bd23e3b4e09177ff02e236612b78c1730b9c (patch)
tree75d54f1c346d05d5caec3a4170386e8b45ac2115 /src/content
parent9e0ec02fcbb3b82a2a73d2713c41af5a6c4523f9 (diff)
argmax materials
Diffstat (limited to 'src/content')
-rw-r--r--src/content/world/mines.rs40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/content/world/mines.rs b/src/content/world/mines.rs
index d7e23bc..9e24a37 100644
--- a/src/content/world/mines.rs
+++ b/src/content/world/mines.rs
@@ -1,7 +1,11 @@
use fastnoise_lite::{FastNoiseLite, FractalType};
use glam::IVec2;
-use crate::{content::materials::MaterialId, proc_gen::Biome, sim::cell::Cell};
+use crate::{
+ content::materials::MaterialId,
+ proc_gen::{Biome, InterpolatedPixel, tileset_loader::TilePixelType},
+ sim::cell::Cell,
+};
const ROUGHNESS: f32 = 0.375;
@@ -12,22 +16,40 @@ pub struct MinesBiome {
impl MinesBiome {
pub fn new() -> Self {
let mut edge_roughness = FastNoiseLite::new();
- edge_roughness.octaves = 2;
- edge_roughness.fractal_type = FractalType::Ridged;
+ edge_roughness.set_fractal_type(Some(FractalType::Ridged));
+ edge_roughness.set_fractal_octaves(Some(2));
MinesBiome { edge_roughness }
}
}
impl Biome for MinesBiome {
- fn cell(&self, solidity: f32, world: IVec2) -> Cell {
+ fn fragment(&self, pixel: InterpolatedPixel, world: IVec2) -> Cell {
let world = world.as_vec2();
-
let displacement = ROUGHNESS * self.edge_roughness.get_noise_2d(world.x, world.y);
- if solidity + displacement <= 0.0 {
- return Cell::void();
- }
+ match pixel.interpolated_pixel_index {
+ 0 => {
+ if pixel.interpolated_solidity + displacement <= 0.0 {
+ return Cell::void();
+ }
+
+ Cell::from_material(MaterialId::Dirt)
+ }
+ 12 => {
+ if pixel.interpolated_solidity + displacement <= 0.0 {
+ return Cell::void();
+ }
- Cell::from_material(MaterialId::Dirt)
+ Cell::from_material(MaterialId::Water)
+ }
+ 13 => {
+ if pixel.interpolated_solidity + displacement <= 0.0 {
+ return Cell::void();
+ }
+
+ Cell::from_material(MaterialId::Wood)
+ }
+ _ => Cell::void(),
+ }
}
}