From 31df4dba9f77b4a6bdf8ff57e4b3982086fca248 Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Tue, 29 Sep 2026 17:57:15 +0300 Subject: [PATCH] render3d: terrain_tiles_close - the tiles let go of their file before its map pack is unmounted A world swap unmounts the old map pack before terrain_reload, and the tiles' file (a baked file in that pack) stayed open until terrain_unload. terrain_tiles_close closes it and stops the page pool; the next map's terrain_from_baked / terrain_reload opens its own and makes the pool again. Co-Authored-By: Claude Opus 5.5 --- packages/ludic.render3d/terrain_ltt2_read.ludic | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/ludic.render3d/terrain_ltt2_read.ludic b/packages/ludic.render3d/terrain_ltt2_read.ludic index 99b7f7a0..6f5a4f3d 100644 --- a/packages/ludic.render3d/terrain_ltt2_read.ludic +++ b/packages/ludic.render3d/terrain_ltt2_read.ludic @@ -192,3 +192,12 @@ function ltt2_bake_base(path: string, key: string, version: int) -> int { free(h) return base } + +# The map's tiles let go of the file they read from, before the pack that holds it is unmounted (a world +# swap): the file closed and the page pool stopped. Until terrain_reload (or terrain_from_baked) opens the +# next map's, the GPU keeps what is resident and the coarse level, and a query answers 0. Nothing else +# render3d reads from a bake stays open: the shadow's and the textures' bytes are copied and closed. +export function terrain_tiles_close(render3d_st: mut Render3dState) -> void { + tt_close(render3d_st) + render3d_st.tp_on = false +}