fixes to branch after my whoops

This commit is contained in:
DemonicOnPc 2021-10-30 12:44:58 -04:00
parent a9cedee277
commit b7ac542ebb
11 changed files with 73 additions and 71 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,7 +16,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
enum WaterMode { enum WaterMode {
Underwater, Underwater,
Floating, Floating,
Surface, Ground,
} }
use WaterMode::*; use WaterMode::*;
@ -30,7 +30,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
)] = &[ )] = &[
// (density, Option<(base_density_proportion, wavelen, threshold)>) // (density, Option<(base_density_proportion, wavelen, threshold)>)
// Flowers // Flowers
(BlueFlower, Surface, |_, col| { (BlueFlower, Ground, |_, col| {
( (
close(col.temp, CONFIG.temperate_temp, 0.7).min(close( close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
col.humidity, col.humidity,
@ -42,7 +42,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 256.0, 0.25)), Some((0.0, 256.0, 0.25)),
) )
}), }),
(PinkFlower, Surface, |_, col| { (PinkFlower, Ground, |_, col| {
( (
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -51,7 +51,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.1)), Some((0.0, 100.0, 0.1)),
) )
}), }),
(PurpleFlower, Surface, |_, col| { (PurpleFlower, Ground, |_, col| {
( (
close(col.temp, CONFIG.temperate_temp, 0.7).min(close( close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
col.humidity, col.humidity,
@ -63,7 +63,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.1)), Some((0.0, 100.0, 0.1)),
) )
}), }),
(RedFlower, Surface, |_, col| { (RedFlower, Ground, |_, col| {
( (
close(col.temp, CONFIG.tropical_temp, 0.7).min(close( close(col.temp, CONFIG.tropical_temp, 0.7).min(close(
col.humidity, col.humidity,
@ -75,7 +75,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.1)), Some((0.0, 100.0, 0.1)),
) )
}), }),
(WhiteFlower, Surface, |_, col| { (WhiteFlower, Ground, |_, col| {
( (
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -84,7 +84,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.1)), Some((0.0, 100.0, 0.1)),
) )
}), }),
(YellowFlower, Surface, |_, col| { (YellowFlower, Ground, |_, col| {
( (
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -93,7 +93,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.1)), Some((0.0, 100.0, 0.1)),
) )
}), }),
(Cotton, Surface, |_, col| { (Cotton, Ground, |_, col| {
( (
close(col.temp, CONFIG.temperate_temp, 0.7).min(close( close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
col.humidity, col.humidity,
@ -105,7 +105,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 256.0, 0.25)), Some((0.0, 256.0, 0.25)),
) )
}), }),
(Sunflower, Surface, |_, col| { (Sunflower, Ground, |_, col| {
( (
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -114,7 +114,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 100.0, 0.15)), Some((0.0, 100.0, 0.15)),
) )
}), }),
(WildFlax, Surface, |_, col| { (WildFlax, Ground, |_, col| {
( (
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -124,7 +124,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
) )
}), }),
// Herbs and Spices // Herbs and Spices
(LingonBerry, Surface, |_, col| { (LingonBerry, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.5)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.5))
* MUSH_FACT * MUSH_FACT
@ -132,7 +132,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None, None,
) )
}), }),
(LeafyPlant, Surface, |_, col| { (LeafyPlant, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.3)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.3))
* GRASS_FACT * GRASS_FACT
@ -140,7 +140,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None, None,
) )
}), }),
(JungleLeafyPlant, Surface, |_, col| { (JungleLeafyPlant, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* GRASS_FACT * GRASS_FACT
@ -148,7 +148,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.15, 64.0, 0.2)), Some((0.15, 64.0, 0.2)),
) )
}), }),
(Fern, Surface, |_, col| { (Fern, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.forest_hum, 0.5)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.forest_hum, 0.5))
* GRASS_FACT * GRASS_FACT
@ -156,7 +156,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 64.0, 0.2)), Some((0.0, 64.0, 0.2)),
) )
}), }),
(JungleFern, Surface, |_, col| { (JungleFern, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -165,7 +165,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 84.0, 0.35)), Some((0.0, 84.0, 0.35)),
) )
}), }),
(Blueberry, Surface, |_, col| { (Blueberry, Ground, |_, col| {
( (
close(col.temp, CONFIG.temperate_temp, 0.5).min(close( close(col.temp, CONFIG.temperate_temp, 0.5).min(close(
col.humidity, col.humidity,
@ -176,7 +176,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None, None,
) )
}), }),
(Pumpkin, Surface, |_, col| { (Pumpkin, Ground, |_, col| {
( (
close(col.temp, CONFIG.temperate_temp, 0.5).min(close( close(col.temp, CONFIG.temperate_temp, 0.5).min(close(
col.humidity, col.humidity,
@ -189,23 +189,23 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
}), }),
// Collectable Objects // Collectable Objects
// Only spawn twigs in temperate forests // Only spawn twigs in temperate forests
(Twigs, Surface, |_, col| { (Twigs, Ground, |_, col| {
( (
(col.tree_density * 1.25 - 0.25).powf(0.5).max(0.0) * 0.75e-3, (col.tree_density * 1.25 - 0.25).powf(0.5).max(0.0) * 0.75e-3,
None, None,
) )
}), }),
(Stones, Surface, |chunk, _| { (Stones, Ground, |chunk, _| {
((chunk.rockiness - 0.5).max(0.025) * 1.0e-3, None) ((chunk.rockiness - 0.5).max(0.025) * 1.0e-3, None)
}), }),
(Copper, Surface, |chunk, _| { (Copper, Ground, |chunk, _| {
((chunk.rockiness - 0.5).max(0.0) * 1.5e-3, None) ((chunk.rockiness - 0.5).max(0.0) * 1.5e-3, None)
}), }),
(Tin, Surface, |chunk, _| { (Tin, Ground, |chunk, _| {
((chunk.rockiness - 0.5).max(0.0) * 1.5e-3, None) ((chunk.rockiness - 0.5).max(0.0) * 1.5e-3, None)
}), }),
// Don't spawn Mushrooms in snowy regions // Don't spawn Mushrooms in snowy regions
(Mushroom, Surface, |_, col| { (Mushroom, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.forest_hum, 0.35)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT, * MUSH_FACT,
@ -213,7 +213,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
) )
}), }),
// Grass // Grass
(ShortGrass, Surface, |_, col| { (ShortGrass, Ground, |_, col| {
( (
close(col.temp, 0.2, 0.75).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.2, 0.75).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* GRASS_FACT * GRASS_FACT
@ -221,7 +221,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.3, 64.0, 0.3)), Some((0.3, 64.0, 0.3)),
) )
}), }),
(MediumGrass, Surface, |_, col| { (MediumGrass, Ground, |_, col| {
( (
close(col.temp, 0.2, 0.6).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.2, 0.6).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* GRASS_FACT * GRASS_FACT
@ -229,7 +229,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.3, 64.0, 0.3)), Some((0.3, 64.0, 0.3)),
) )
}), }),
(LongGrass, Surface, |_, col| { (LongGrass, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.35).min(close(col.humidity, CONFIG.jungle_hum, 0.3)) close(col.temp, 0.3, 0.35).min(close(col.humidity, CONFIG.jungle_hum, 0.3))
* GRASS_FACT * GRASS_FACT
@ -237,7 +237,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.1, 48.0, 0.3)), Some((0.1, 48.0, 0.3)),
) )
}), }),
(JungleRedGrass, Surface, |_, col| { (JungleRedGrass, Ground, |_, col| {
( (
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4)) close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density * col.tree_density
@ -247,7 +247,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
) )
}), }),
// Jungle Sprites // Jungle Sprites
// (LongGrass, Surface, |c, col| { // (LongGrass, Ground, |c, col| {
// ( // (
// close(col.temp, CONFIG.tropical_temp, 0.4).min(close( // close(col.temp, CONFIG.tropical_temp, 0.4).min(close(
// col.humidity, // col.humidity,
@ -257,7 +257,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
// Some((0.0, 60.0, 5.0)), // Some((0.0, 60.0, 5.0)),
// ) // )
// }), // }),
/*(WheatGreen, Surface, |c, col| { /*(WheatGreen, Ground, |c, col| {
( (
close(col.temp, 0.4, 0.2).min(close(col.humidity, CONFIG.forest_hum, 0.1)) close(col.temp, 0.4, 0.2).min(close(col.humidity, CONFIG.forest_hum, 0.1))
* MUSH_FACT * MUSH_FACT
@ -265,7 +265,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None, None,
) )
}),*/ }),*/
(GrassSnow, Surface, |_, col| { (GrassSnow, Ground, |_, col| {
( (
close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close( close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close(
col.humidity, col.humidity,
@ -276,7 +276,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.0, 48.0, 0.2)), Some((0.0, 48.0, 0.2)),
) )
}), }),
(Moonbell, Surface, |_, col| { (Moonbell, Ground, |_, col| {
( (
close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close( close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close(
col.humidity, col.humidity,
@ -287,7 +287,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
) )
}), }),
// Savanna Plants // Savanna Plants
(SavannaGrass, Surface, |_, col| { (SavannaGrass, Ground, |_, col| {
( (
{ {
let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25); let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25);
@ -297,7 +297,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.15, 64.0, 0.2)), Some((0.15, 64.0, 0.2)),
) )
}), }),
(TallSavannaGrass, Surface, |_, col| { (TallSavannaGrass, Ground, |_, col| {
( (
{ {
let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25); let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25);
@ -307,7 +307,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.1, 48.0, 0.2)), Some((0.1, 48.0, 0.2)),
) )
}), }),
(RedSavannaGrass, Surface, |_, col| { (RedSavannaGrass, Ground, |_, col| {
( (
{ {
let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25); let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25);
@ -317,7 +317,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
Some((0.15, 48.0, 0.25)), Some((0.15, 48.0, 0.25)),
) )
}), }),
(SavannaBush, Surface, |_, col| { (SavannaBush, Ground, |_, col| {
( (
{ {
let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25); let savanna = close(col.temp, 1.0, 0.4) * close(col.humidity, 0.2, 0.25);
@ -328,43 +328,43 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
) )
}), }),
// Desert Plants // Desert Plants
(DeadBush, Surface, |_, col| { (DeadBush, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.95).min(close(col.humidity, 0.0, 0.3)) * MUSH_FACT * 7.5, close(col.temp, 1.0, 0.95).min(close(col.humidity, 0.0, 0.3)) * MUSH_FACT * 7.5,
None, None,
) )
}), }),
(Pyrebloom, Surface, |_, col| { (Pyrebloom, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.95).min(close(col.humidity, 0.0, 0.3)) * MUSH_FACT * 0.35, close(col.temp, 1.0, 0.95).min(close(col.humidity, 0.0, 0.3)) * MUSH_FACT * 0.35,
None, None,
) )
}), }),
(LargeCactus, Surface, |_, col| { (LargeCactus, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 1.5, close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 1.5,
None, None,
) )
}), }),
(RoundCactus, Surface, |_, col| { (RoundCactus, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5, close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5,
None, None,
) )
}), }),
(ShortCactus, Surface, |_, col| { (ShortCactus, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5, close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5,
None, None,
) )
}), }),
(MedFlatCactus, Surface, |_, col| { (MedFlatCactus, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5, close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5,
None, None,
) )
}), }),
(ShortFlatCactus, Surface, |_, col| { (ShortFlatCactus, Ground, |_, col| {
( (
close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5, close(col.temp, 1.0, 0.25).min(close(col.humidity, 0.0, 0.1)) * MUSH_FACT * 2.5,
None, None,
@ -630,7 +630,9 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
* GRASS_FACT * GRASS_FACT
* 100.0 * 100.0
* ((col.alt - CONFIG.sea_level) / 12.0).clamped(0.0, 1.0) * ((col.alt - CONFIG.sea_level) / 12.0).clamped(0.0, 1.0)
* col.water_dist.map_or(0.0, |d| 1.0 / (1.0 + (d.abs() * 0.4).powi(2))), * col
.water_dist
.map_or(0.0, |d| 1.0 / (1.0 + (d.abs() * 0.4).powi(2))),
Some((0.0, 128.0, 0.35)), Some((0.0, 128.0, 0.35)),
) )
}), }),
@ -640,11 +642,13 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
* GRASS_FACT * GRASS_FACT
* 100.0 * 100.0
* ((col.alt - CONFIG.sea_level) / 12.0).clamped(0.0, 1.0) * ((col.alt - CONFIG.sea_level) / 12.0).clamped(0.0, 1.0)
* col.water_dist.map_or(0.0, |d| 1.0 / (1.0 + (d.abs() * 0.40).powi(2))), * col
.water_dist
.map_or(0.0, |d| 1.0 / (1.0 + (d.abs() * 0.40).powi(2))),
Some((0.2, 128.0, 0.5)), Some((0.2, 128.0, 0.5)),
) )
}), }),
(Reed, Surface, |_, col| { (Reed, Ground, |_, col| {
( (
close(col.humidity, CONFIG.jungle_hum, 0.9) close(col.humidity, CONFIG.jungle_hum, 0.9)
* col * col
@ -697,20 +701,18 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
if let Some((kind, water_mode)) = kind { if let Some((kind, water_mode)) = kind {
let (alt, is_under): (_, fn(Block) -> bool) = match water_mode { let (alt, is_under): (_, fn(Block) -> bool) = match water_mode {
Surface | Underwater => (col.alt as i32, |block| block.is_solid()), Ground | Underwater => (col.alt as i32, |block| block.is_solid()),
Floating => (col.water_level as i32, |block| !block.is_air()), Floating => (col.water_level as i32, |block| !block.is_air()),
}; };
// Find the intersection between ground and air, if there is one near the // Find the intersection between ground and air, if there is one near the
// surface // Ground
if let Some(solid_end) = (-4..8) if let Some(solid_end) = (-4..8)
.find(|z| { .find(|z| is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z))))
is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)))
})
.and_then(|solid_start| { .and_then(|solid_start| {
(1..8).map(|z| solid_start + z).find(|z| { (1..8)
!is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z))) .map(|z| solid_start + z)
}) .find(|z| !is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z))))
}) })
{ {
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end), |block| { canvas.map(Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end), |block| {