Skip to content

Commit

Permalink
Fix bug where chunk on the edge of the selection when the chunk coord…
Browse files Browse the repository at this point in the history
…inate are negative had wildy wrong biome colors due to off by 1 error when testing if the chunk is loaded caused by int division rounding behavior
  • Loading branch information
aTom3333 committed Dec 18, 2023
1 parent 699071a commit 2cdf221
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static public void chunk2DBlur(ChunkPosition cp, int blurRadius, int samplingY,
SummedAreaTable table = new SummedAreaTable(blurRadius);
for(int x = -blurRadius; x < 16 + blurRadius; ++x) {
for(int z = -blurRadius; z < 16 + blurRadius; ++z) {
ChunkPosition ccp = new ChunkPosition((cp.x * 16 + x) / 16, (cp.z * 16 + z) / 16);
ChunkPosition ccp = new ChunkPosition(Math.floorDiv(cp.x * 16 + x, 16), Math.floorDiv(cp.z * 16 + z, 16));
if (nonEmptyChunks.contains(ccp)) {
int biomeId = biomeIdx.get(cp.x * 16 + x, samplingY, cp.z * 16 + z);
if(biomeId != -1) {
Expand Down Expand Up @@ -298,7 +298,7 @@ static public void chunk3DBlur(ChunkPosition cp, int blurRadius, int minY, int m
for(int y = minY - blurRadius; y < maxY + blurRadius; ++y) {
for(int x = -blurRadius; x < 16 + blurRadius; ++x) {
for(int z = -blurRadius; z < 16 + blurRadius; ++z) {
ChunkPosition ccp = new ChunkPosition((cp.x * 16 + x) / 16, (cp.z * 16 + z) / 16);
ChunkPosition ccp = new ChunkPosition(Math.floorDiv(cp.x * 16 + x, 16), Math.floorDiv(cp.z * 16 + z, 16));
if (nonEmptyChunks.contains(ccp)) {
int biomeId = biomeIdx.get(cp.x * 16 + x, y, cp.z * 16 + z);
if(biomeId != -1) {
Expand Down

0 comments on commit 2cdf221

Please sign in to comment.