Also add the liquids to the material cache key hash.

This commit is contained in:
Relintai 2022-02-18 23:10:57 +01:00
parent 9eb61941f5
commit 9c580fce42

View File

@ -83,6 +83,31 @@ void TerrainLibraryMergerPCM::_material_cache_get_key(Ref<TerrainChunk> chunk) {
} }
} }
uint8_t *liquid_ch = chunk->channel_get(TerrainChunkDefault::DEFAULT_CHANNEL_LIQUID_TYPE);
if (liquid_ch) {
for (uint32_t i = 0; i < size; ++i) {
uint8_t v = liquid_ch[i];
if (v == 0) {
continue;
}
int ssize = surfaces.size();
bool found = false;
for (uint8_t j = 0; j < ssize; ++j) {
if (surfaces[j] == v) {
found = true;
break;
}
}
if (!found) {
surfaces.push_back(v);
}
}
}
if (surfaces.size() == 0) { if (surfaces.size() == 0) {
chunk->material_cache_key_set(0); chunk->material_cache_key_set(0);
chunk->material_cache_key_has_set(false); chunk->material_cache_key_has_set(false);