render3d: terrain_baked_at - a map's terrain and sun shadow taken from its bakes at start and on a swap
The game names the tiles' and the shadow's bake files (key, version) before the map is made; r3d_init's terrain step and terrain_reload then open them with terrain_from_baked / terrain_shadow_from_bytes and generate nothing, and fall back to the survey (saying so once) when a bake is missing or stale. Without the call nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f02eab5c51
commit
06d828a296
5 changed files with 53 additions and 2 deletions
|
|
@ -413,7 +413,7 @@ const TERRAIN_INIT_STEPS: int = 4
|
|||
function terrain_init_step(render3d_st: mut Render3dState, i: int) -> void {
|
||||
if i == 0 { if not render3d_st.tt_baked { terrain_generate(render3d_st) }; return }
|
||||
# a baked terrain whose shadow came from its own bake (terrain_shadow_from_bytes) keeps it
|
||||
if i == 1 { if not (render3d_st.tt_baked and render3d_st.ter_shadow_tex != 0) { terrain_bake_shadow(render3d_st) }; return }
|
||||
if i == 1 { if not (render3d_st.tt_baked and render3d_st.tb_shadow_ok) { terrain_bake_shadow(render3d_st) }; return }
|
||||
if i == 2 { terrain_load_textures(render3d_st); return }
|
||||
terrain_init_finish(render3d_st)
|
||||
}
|
||||
|
|
@ -850,6 +850,14 @@ function terrain_reload(render3d_st: mut Render3dState, dem: string, emin: float
|
|||
terrain_unload(render3d_st)
|
||||
render3d_st.TERRAIN_HALF = half
|
||||
render3d_st.ter_ox = ox; render3d_st.ter_oz = oz
|
||||
render3d_st.r3d_dem_ox = ox; render3d_st.r3d_dem_oz = oz
|
||||
# a swap to a map that has its bake: the tiles and the shadow read, the bounds from the tiles
|
||||
if terrain_baked_try(render3d_st) {
|
||||
if not render3d_st.tb_shadow_ok { terrain_bake_shadow(render3d_st) }
|
||||
cdlod_bounds(render3d_st)
|
||||
gpu_check(render3d_st, "terrain reload")
|
||||
return
|
||||
}
|
||||
if len(dem) > 0 { terrain_use_dem(render3d_st, dem, emin, emax, base, ox, oz) }
|
||||
if len(ortho) > 0 { terrain_use_ortho(render3d_st, ortho) }
|
||||
terrain_generate(render3d_st)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue