Fill ocean water across entire tile to fix missing harbor water

Coastal areas like Booty Bay had gaps in ocean water where MH2O
data didn't cover harbor chunks (only 34/256 chunks had ocean
entries). For sea-level ocean surfaces (type=2, height~0), the
mask is now initialized to fully visible instead of empty, letting
depth testing against terrain handle land occlusion naturally.
This commit is contained in:
Kelsi 2026-02-26 02:28:26 -08:00
parent c2b271df6f
commit c0c5b75e94

View file

@ -710,10 +710,14 @@ void WaterRenderer::loadFromTerrain(const pipeline::ADTTerrain& terrain, bool ap
const int gridH = MERGED_W + 1;
surface.heights.resize(gridW * gridH, groupHeight);
// Initialize mask (128×128 sub-tiles, all masked OUT)
// Initialize mask (128×128 sub-tiles)
// Mask uses LSB bit order: tileIndex = row * 128 + col
const int maskBytes = (MERGED_W * MERGED_W + 7) / 8;
surface.mask.resize(maskBytes, 0);
// For ocean water (basicType 1) at sea level, fill the entire tile.
// Depth testing against terrain handles land occlusion naturally.
uint8_t basicType = (key.liquidType == 0) ? 0 : ((key.liquidType - 1) % 4);
bool isOcean = (basicType == 1) && (std::abs(groupHeight) < 1.0f);
surface.mask.resize(maskBytes, isOcean ? 0xFF : 0x00);
// ── Fill from each contributing chunk ──
for (const auto& info : chunkLayers) {