mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 14:00:26 +00:00
Discounted occupied flower columns
- Converted patch decorators also lose the share of surface columns that earlier surface patches in the declaring biomes already occupy, estimated from those patches' expected coverage in the catalog - Canopy and surface occupancy are combined into one vegetation occlusion estimate per decorated feature
This commit is contained in:
6 files changed
+94
-42
No files matched your search
@@ -115,7 +115,7 @@ public class FeatureConverterFormatTest {
|
||||
+ "{\"type\": \"minecraft:heightmap\", \"heightmap\": \"WORLD_SURFACE_WG\"}, {\"type\": \"minecraft:biome\"},"
|
||||
+ "{\"type\": \"minecraft:count\", \"count\": 96}," + PATCH_TAIL + "]");
|
||||
|
||||
JsonObject decorator = PatchDecoratorConverter.convert(lavender, index(), 0D);
|
||||
JsonObject decorator = PatchDecoratorConverter.convert(lavender, index(), VegetationOcclusion.Occlusion.NONE);
|
||||
|
||||
assertEquals(1.0D - Math.exp(-(15.0D * 96.0D * 0.25D) / 256.0D), decorator.get("chance").getAsDouble(), 0.000001D);
|
||||
assertTrue(decorator.get("chance").getAsDouble() < 1.0D);
|
||||
@@ -133,9 +133,11 @@ public class FeatureConverterFormatTest {
|
||||
+ "{\"type\": \"minecraft:heightmap\", \"heightmap\": \"MOTION_BLOCKING_NO_LEAVES\"}, {\"type\": \"minecraft:biome\"}]");
|
||||
|
||||
assertEquals(1.0D - Math.exp(-(4.0D * 0.5D) / 256.0D),
|
||||
PatchDecoratorConverter.convert(lavender, index(), 0.5D).get("chance").getAsDouble(), 0.000001D);
|
||||
PatchDecoratorConverter.convert(lavender, index(), new VegetationOcclusion.Occlusion(0.5D, 0D)).get("chance").getAsDouble(), 0.000001D);
|
||||
assertEquals(1.0D - Math.exp(-4.0D / 256.0D),
|
||||
PatchDecoratorConverter.convert(underLeaves, index(), 0.5D).get("chance").getAsDouble(), 0.000001D);
|
||||
PatchDecoratorConverter.convert(underLeaves, index(), new VegetationOcclusion.Occlusion(0.5D, 0D)).get("chance").getAsDouble(), 0.000001D);
|
||||
assertEquals(1.0D - Math.exp(-(4.0D * 0.25D) / 256.0D),
|
||||
PatchDecoratorConverter.convert(underLeaves, index(), new VegetationOcclusion.Occlusion(0D, 0.75D)).get("chance").getAsDouble(), 0.000001D);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,7 +154,7 @@ public class FeatureConverterFormatTest {
|
||||
{"type": "minecraft:biome"}]
|
||||
""");
|
||||
|
||||
JsonObject decorator = PatchDecoratorConverter.convert(flowers, index(), 0D);
|
||||
JsonObject decorator = PatchDecoratorConverter.convert(flowers, index(), VegetationOcclusion.Occlusion.NONE);
|
||||
|
||||
assertEquals(1.0D - Math.exp(-(0.5D * 0.2D * 0.25D) / 256.0D), decorator.get("chance").getAsDouble(), 0.000001D);
|
||||
assertEquals("minecraft:grass_block", decorator.getAsJsonArray("whitelist").get(0).getAsJsonObject().get("block").getAsString());
|
||||
@@ -167,8 +169,8 @@ public class FeatureConverterFormatTest {
|
||||
"{\"type\": \"minecraft:simple_block\", \"to_place\": \"minecraft:flower_plain\"}",
|
||||
"[{\"type\": \"minecraft:heightmap\", \"heightmap\": \"MOTION_BLOCKING\"}]");
|
||||
|
||||
assertThrows(IngestConversionException.class, () -> PatchDecoratorConverter.convert(seagrass, index(), 0D));
|
||||
IngestConversionException reference = assertThrows(IngestConversionException.class, () -> PatchDecoratorConverter.convert(plains, index(), 0D));
|
||||
assertThrows(IngestConversionException.class, () -> PatchDecoratorConverter.convert(seagrass, index(), VegetationOcclusion.Occlusion.NONE));
|
||||
IngestConversionException reference = assertThrows(IngestConversionException.class, () -> PatchDecoratorConverter.convert(plains, index(), VegetationOcclusion.Occlusion.NONE));
|
||||
assertTrue(reference.getMessage(), reference.getMessage().contains("minecraft:flower_plain"));
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ModIngesterFeatureTest {
|
||||
assertNotNull(mapleFlowers);
|
||||
assertNotNull(forestFlowers);
|
||||
assertEquals(2, forest.getAsJsonArray("decorators").size());
|
||||
double mapleCanopy = 1.0D - Math.exp(-CanopyEstimate.CROWN_COLUMNS / 256.0D);
|
||||
double mapleCanopy = 1.0D - Math.exp(-VegetationOcclusion.CROWN_COLUMNS / 256.0D);
|
||||
double openShare = 1.0D - mapleCanopy / 2.0D;
|
||||
assertEquals(1.0D - Math.exp(-(1.0D / 4.0D * 32.0D * 0.25D * openShare) / 256.0D), forestFlowers.get("chance").getAsDouble(), 0.000001D);
|
||||
JsonArray palette = forestFlowers.getAsJsonArray("palette");
|
||||
|
||||
+23
-7
@@ -33,26 +33,42 @@ import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CanopyEstimateTest {
|
||||
private static final double CANOPY = 1D - Math.exp(-10D * CanopyEstimate.CROWN_COLUMNS / 256D);
|
||||
public class VegetationOcclusionTest {
|
||||
private static final double CANOPY = 1D - Math.exp(-10D * VegetationOcclusion.CROWN_COLUMNS / 256D);
|
||||
private static final double GRASS_COVERAGE = 1D - Math.exp(-(24D * 32D * 0.25D) / 256D);
|
||||
|
||||
@Test
|
||||
public void flowersPlacedAfterTreesSeeTheTreeCanopy() {
|
||||
CanopyEstimate estimate = new CanopyEstimate(WorldgenCatalogIndex.of(catalog()));
|
||||
VegetationOcclusion estimate = new VegetationOcclusion(WorldgenCatalogIndex.of(catalog()));
|
||||
|
||||
assertEquals(CANOPY, estimate.occlusion("mod:flowers_after", Set.of("mod:woods")), 0.000001D);
|
||||
assertEquals(0D, estimate.occlusion("mod:flowers_before", Set.of("mod:woods")), 0.000001D);
|
||||
assertEquals(CANOPY / 2D, estimate.occlusion("mod:flowers_after", Set.of("mod:woods", "mod:meadow")), 0.000001D);
|
||||
assertEquals(CANOPY, estimate.occlusion("mod:flowers_after", Set.of("mod:woods")).canopy(), 0.000001D);
|
||||
assertEquals(0D, estimate.occlusion("mod:flowers_before", Set.of("mod:woods")).canopy(), 0.000001D);
|
||||
assertEquals(CANOPY / 2D, estimate.occlusion("mod:flowers_after", Set.of("mod:woods", "mod:meadow")).canopy(), 0.000001D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void surfacePatchesPlacedEarlierOccupyTheirShareOfColumns() {
|
||||
VegetationOcclusion estimate = new VegetationOcclusion(WorldgenCatalogIndex.of(catalog()));
|
||||
|
||||
assertEquals(GRASS_COVERAGE, estimate.occlusion("mod:flowers_after", Set.of("mod:woods")).occupancy(), 0.000001D);
|
||||
assertEquals(0D, estimate.occlusion("mod:flowers_before", Set.of("mod:woods")).occupancy(), 0.000001D);
|
||||
assertEquals(GRASS_COVERAGE / 2D, estimate.occlusion("mod:flowers_after", Set.of("mod:woods", "mod:meadow")).occupancy(), 0.000001D);
|
||||
}
|
||||
|
||||
private static WorldgenCatalog catalog() {
|
||||
List<CatalogBiome> biomes = List.of(
|
||||
biome("mod:woods", List.of("mod:flowers_before", "mod:oak_trees", "mod:flowers_after")),
|
||||
biome("mod:woods", List.of("mod:flowers_before", "mod:oak_trees", "mod:grass_patch", "mod:flowers_after")),
|
||||
biome("mod:meadow", List.of("mod:flowers_after")));
|
||||
List<CatalogPlacedFeature> features = new ArrayList<>();
|
||||
features.add(new CatalogPlacedFeature("mod:oak_trees", "mod:oak_trees", "minecraft:tree", JsonParser.parseString("{}"),
|
||||
JsonParser.parseString("[{\"type\": \"minecraft:count\", \"count\": 10}, {\"type\": \"minecraft:in_square\"},"
|
||||
+ "{\"type\": \"minecraft:surface_water_depth_filter\", \"max_water_depth\": 0}, {\"type\": \"minecraft:biome\"}]")));
|
||||
features.add(new CatalogPlacedFeature("mod:grass_patch", "mod:grass_patch", "minecraft:simple_block",
|
||||
JsonParser.parseString("{\"to_place\": {\"id\": \"minecraft:short_grass\"}}"),
|
||||
JsonParser.parseString("[{\"type\": \"minecraft:count\", \"count\": 24}, {\"type\": \"minecraft:in_square\"},"
|
||||
+ "{\"type\": \"minecraft:heightmap\", \"heightmap\": \"WORLD_SURFACE_WG\"}, {\"type\": \"minecraft:biome\"},"
|
||||
+ "{\"type\": \"minecraft:count\", \"count\": 32},"
|
||||
+ "{\"type\": \"minecraft:offset\", \"y\": {\"type\": \"minecraft:trapezoid\", \"min\": -3, \"max\": 3, \"plateau\": 0}}]")));
|
||||
return new WorldgenCatalog(WorldgenCatalog.FORMAT, "26.3", "fabric", 1L, "canopy", List.of(new CatalogNamespace("mod", "Mod", "1")),
|
||||
biomes, features, List.of(), List.of(), List.of(), Map.of());
|
||||
}
|
||||
Reference in new issue
Block a user