mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 05:50:39 +00:00
Point basis samples carry terrain slope
Routing, validation and the valley solver sampled basis columns with slope 0; the forward slope now rides on every point sample.
This commit is contained in:
1 parent
2585b2105a
commit
5b1b636539
3 files changed
+22
-4
No files matched your search
+3
-1
@@ -106,7 +106,9 @@ final class IrisHydrologyRoutingTerrainSampler implements HydrologyNaturalTerrai
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HydrologyTerrainSample sampleBasis(int blockX, int blockZ) {
|
public HydrologyTerrainSample sampleBasis(int blockX, int blockZ) {
|
||||||
return basis(blockX, blockZ).terrain();
|
// Point samples carry the forward slope; the aligned grid derives its own from neighbouring bases.
|
||||||
|
TerrainBasis basis = basis(blockX, blockZ);
|
||||||
|
return basis.terrain().withSlope(localSlope(blockX, blockZ, basis.naturalHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainBasis basis(int blockX, int blockZ) {
|
TerrainBasis basis(int blockX, int blockZ) {
|
||||||
|
|||||||
+1
-3
@@ -387,9 +387,7 @@ public final class IrisHydrologyRuntime implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HydrologyTerrainSample createDetailedTerrainSample(int x, int z) {
|
private HydrologyTerrainSample createDetailedTerrainSample(int x, int z) {
|
||||||
IrisHydrologyRoutingTerrainSampler.TerrainBasis basis = routingTerrainSampler.basis(x, z);
|
return routingTerrainSampler.sampleBasis(x, z);
|
||||||
double slope = routingTerrainSampler.localSlope(x, z, basis.naturalHeight());
|
|
||||||
return basis.terrain().withSlope(slope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisHydrologyRoutingTerrainSampler.TerrainBasis createTerrainBasis(
|
private IrisHydrologyRoutingTerrainSampler.TerrainBasis createTerrainBasis(
|
||||||
|
|||||||
+18
@@ -93,6 +93,24 @@ public class IrisHydrologyRoutingTerrainSamplerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void pointBasisSamplesCarryTheForwardSlope() {
|
||||||
|
IrisHydrologyRoutingTerrainSampler sampler = sampler(64);
|
||||||
|
int[][] points = {{0, 0}, {-129, -257}, {37, 1024}};
|
||||||
|
|
||||||
|
for (int[] point : points) {
|
||||||
|
int x = point[0];
|
||||||
|
int z = point[1];
|
||||||
|
double expected = IrisHydrologyRoutingTerrainSampler.localSlope(
|
||||||
|
height(x, z), height(x + 3, z), height(x, z + 3));
|
||||||
|
|
||||||
|
double actual = sampler.sampleBasis(x, z).slope();
|
||||||
|
|
||||||
|
assertTrue(expected > 0D);
|
||||||
|
assertEquals(Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(actual));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void adjacentGridsShareBasesAndProduceIdenticalOverlap() {
|
public void adjacentGridsShareBasesAndProduceIdenticalOverlap() {
|
||||||
AtomicInteger calls = new AtomicInteger();
|
AtomicInteger calls = new AtomicInteger();
|
||||||
|
|||||||
Reference in new issue
Block a user