Skip to content

Commit

Permalink
weight samples like reference implementation to prevent weird flow pa…
Browse files Browse the repository at this point in the history
…tterns
  • Loading branch information
douira committed Dec 11, 2024
1 parent 6972baf commit a7c43f2
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,8 @@ private float fluidHeight(BlockAndTintGetter world, Fluid fluid, BlockPos blockP
}
}

// if the block is air and there's either air or water below it, actually return a valid 0 sample that will bend the fluid downwards.
// this is important to maintain the sloped shape of diagonal waterfalls
if (blockState.isAir()) {
var downBlockState = world.getBlockState(this.scratchPos.setWithOffset(blockPos, Direction.DOWN));
if (downBlockState.isAir() || downBlockState.getFluidState().getType().isSame(fluid)) {
return 0.0f;
}
if (!blockState.isSolid()) {
return 0.0f;
}

return DISCARD_SAMPLE;
Expand Down Expand Up @@ -294,12 +289,6 @@ private float fluidCornerHeight(BlockAndTintGetter world, BlockPos origin, Fluid
// gather the samples and reset
float result = this.scratchHeight / this.scratchSamples;

// shallow water is flattened somewhat to compensate for the fact that many air samples (height zero)
// that are otherwise taken into account with the reference implementation are discarded
if (result < FULL_HEIGHT) {
result -= (FULL_HEIGHT - result) * FLATTENING_FACTOR;
result = Math.max(result, 0.0f);
}
this.scratchHeight = 0.0f;
this.scratchSamples = 0;

Expand Down

0 comments on commit a7c43f2

Please sign in to comment.