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 {
Underwater,
Floating,
Surface,
Ground,
}
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)>)
// Flowers
(BlueFlower, Surface, |_, col| {
(BlueFlower, Ground, |_, col| {
(
close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
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)),
)
}),
(PinkFlower, Surface, |_, col| {
(PinkFlower, Ground, |_, col| {
(
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(PurpleFlower, Surface, |_, col| {
(PurpleFlower, Ground, |_, col| {
(
close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
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)),
)
}),
(RedFlower, Surface, |_, col| {
(RedFlower, Ground, |_, col| {
(
close(col.temp, CONFIG.tropical_temp, 0.7).min(close(
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)),
)
}),
(WhiteFlower, Surface, |_, col| {
(WhiteFlower, Ground, |_, col| {
(
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(YellowFlower, Surface, |_, col| {
(YellowFlower, Ground, |_, col| {
(
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(Cotton, Surface, |_, col| {
(Cotton, Ground, |_, col| {
(
close(col.temp, CONFIG.temperate_temp, 0.7).min(close(
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)),
)
}),
(Sunflower, Surface, |_, col| {
(Sunflower, Ground, |_, col| {
(
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(WildFlax, Surface, |_, col| {
(WildFlax, Ground, |_, col| {
(
close(col.temp, 0.0, 0.7).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density
@ -124,7 +124,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
)
}),
// 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))
* MUSH_FACT
@ -132,7 +132,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None,
)
}),
(LeafyPlant, Surface, |_, col| {
(LeafyPlant, Ground, |_, col| {
(
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.3))
* GRASS_FACT
@ -140,7 +140,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None,
)
}),
(JungleLeafyPlant, Surface, |_, col| {
(JungleLeafyPlant, Ground, |_, col| {
(
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(Fern, Surface, |_, col| {
(Fern, Ground, |_, col| {
(
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.forest_hum, 0.5))
* 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)),
)
}),
(JungleFern, Surface, |_, col| {
(JungleFern, Ground, |_, col| {
(
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(Blueberry, Surface, |_, col| {
(Blueberry, Ground, |_, col| {
(
close(col.temp, CONFIG.temperate_temp, 0.5).min(close(
col.humidity,
@ -176,7 +176,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None,
)
}),
(Pumpkin, Surface, |_, col| {
(Pumpkin, Ground, |_, col| {
(
close(col.temp, CONFIG.temperate_temp, 0.5).min(close(
col.humidity,
@ -189,23 +189,23 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
}),
// Collectable Objects
// 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,
None,
)
}),
(Stones, Surface, |chunk, _| {
(Stones, Ground, |chunk, _| {
((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)
}),
(Tin, Surface, |chunk, _| {
(Tin, Ground, |chunk, _| {
((chunk.rockiness - 0.5).max(0.0) * 1.5e-3, None)
}),
// 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))
* MUSH_FACT,
@ -213,7 +213,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
)
}),
// Grass
(ShortGrass, Surface, |_, col| {
(ShortGrass, Ground, |_, col| {
(
close(col.temp, 0.2, 0.75).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(MediumGrass, Surface, |_, col| {
(MediumGrass, Ground, |_, col| {
(
close(col.temp, 0.2, 0.6).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* 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)),
)
}),
(LongGrass, Surface, |_, col| {
(LongGrass, Ground, |_, col| {
(
close(col.temp, 0.3, 0.35).min(close(col.humidity, CONFIG.jungle_hum, 0.3))
* 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)),
)
}),
(JungleRedGrass, Surface, |_, col| {
(JungleRedGrass, Ground, |_, col| {
(
close(col.temp, 0.3, 0.4).min(close(col.humidity, CONFIG.jungle_hum, 0.4))
* col.tree_density
@ -247,7 +247,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
)
}),
// Jungle Sprites
// (LongGrass, Surface, |c, col| {
// (LongGrass, Ground, |c, col| {
// (
// close(col.temp, CONFIG.tropical_temp, 0.4).min(close(
// 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)),
// )
// }),
/*(WheatGreen, Surface, |c, col| {
/*(WheatGreen, Ground, |c, col| {
(
close(col.temp, 0.4, 0.2).min(close(col.humidity, CONFIG.forest_hum, 0.1))
* MUSH_FACT
@ -265,7 +265,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
None,
)
}),*/
(GrassSnow, Surface, |_, col| {
(GrassSnow, Ground, |_, col| {
(
close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close(
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)),
)
}),
(Moonbell, Surface, |_, col| {
(Moonbell, Ground, |_, col| {
(
close(col.temp, CONFIG.snow_temp - 0.2, 0.4).min(close(
col.humidity,
@ -287,7 +287,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
)
}),
// Savanna Plants
(SavannaGrass, Surface, |_, col| {
(SavannaGrass, Ground, |_, col| {
(
{
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)),
)
}),
(TallSavannaGrass, Surface, |_, col| {
(TallSavannaGrass, Ground, |_, col| {
(
{
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)),
)
}),
(RedSavannaGrass, Surface, |_, col| {
(RedSavannaGrass, Ground, |_, col| {
(
{
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)),
)
}),
(SavannaBush, Surface, |_, col| {
(SavannaBush, Ground, |_, col| {
(
{
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
(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,
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,
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,
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,
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,
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,
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,
None,
@ -630,7 +630,9 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
* GRASS_FACT
* 100.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)),
)
}),
@ -640,11 +642,13 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
* GRASS_FACT
* 100.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)),
)
}),
(Reed, Surface, |_, col| {
(Reed, Ground, |_, col| {
(
close(col.humidity, CONFIG.jungle_hum, 0.9)
* col
@ -697,20 +701,18 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
if let Some((kind, water_mode)) = kind {
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()),
};
// Find the intersection between ground and air, if there is one near the
// surface
// Ground
if let Some(solid_end) = (-4..8)
.find(|z| {
is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)))
})
.find(|z| is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z))))
.and_then(|solid_start| {
(1..8).map(|z| solid_start + z).find(|z| {
!is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)))
})
(1..8)
.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| {