Biome API: Fix absent water decorations and dust, in deep water ()

Previously, the biomemap was 'BIOME_NONE' for a mapchunk column if a
stone surface was not found in it, causing water surface decorations
and water surface dust to fail.

Store the biome ID of the biome calculated at a water surface and add
it to the biomemap if the biomemap is 'BIOME_NONE' for the mapchunk
column. The biome calculated at a stone surface still has priority
for the biomemap entry, as it should.

Edit an incorrect comment.
This commit is contained in:
Paramat 2018-06-21 19:28:54 +01:00 committed by GitHub
parent 525fa9145e
commit 8d3190e77a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

@ -655,6 +655,7 @@ void MapgenBasic::generateBiomes()
for (s16 z = node_min.Z; z <= node_max.Z; z++) for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) { for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
Biome *biome = NULL; Biome *biome = NULL;
biome_t water_biome_index = 0;
u16 depth_top = 0; u16 depth_top = 0;
u16 base_filler = 0; u16 base_filler = 0;
u16 depth_water_top = 0; u16 depth_water_top = 0;
@ -697,6 +698,11 @@ void MapgenBasic::generateBiomes()
if (biomemap[index] == BIOME_NONE && is_stone_surface) if (biomemap[index] == BIOME_NONE && is_stone_surface)
biomemap[index] = biome->index; biomemap[index] = biome->index;
// Store biome of first water surface detected, as a fallback
// entry for the biomemap.
if (water_biome_index == 0 && is_water_surface)
water_biome_index = biome->index;
depth_top = biome->depth_top; depth_top = biome->depth_top;
base_filler = MYMAX(depth_top + base_filler = MYMAX(depth_top +
biome->depth_filler + biome->depth_filler +
@ -763,6 +769,11 @@ void MapgenBasic::generateBiomes()
VoxelArea::add_y(em, vi, -1); VoxelArea::add_y(em, vi, -1);
} }
// If no stone surface detected in mapchunk column and a water surface
// biome fallback exists, add it to the biomemap. This avoids water
// surface decorations failing in deep water.
if (biomemap[index] == BIOME_NONE && water_biome_index != 0)
biomemap[index] = water_biome_index;
} }
} }

@ -194,9 +194,9 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
humidmap = noise_humidity->result; humidmap = noise_humidity->result;
biomemap = new biome_t[m_csize.X * m_csize.Z]; biomemap = new biome_t[m_csize.X * m_csize.Z];
// Initialise with the ID of the default biome so that cavegen can get // Initialise with the ID of 'BIOME_NONE' so that cavegen can get the
// biomes when biome generation (which calculates the biomemap IDs) is // fallback biome when biome generation (which calculates the biomemap IDs)
// disabled. // is disabled.
memset(biomemap, 0, sizeof(biome_t) * m_csize.X * m_csize.Z); memset(biomemap, 0, sizeof(biome_t) * m_csize.X * m_csize.Z);
} }