render3d: the fog wall culls on the CPU - nothing past it costs a draw, a vertex or a caster

cam_sphere_visible refuses a sphere wholly past the wall (terrain patches, scatter cells, stream
chunks, grass tiles, water), actors past it are skipped for draws, casters and outlines, the grass
reach and the streams' generate-and-gather reach end at it, and the card shadows cast only from
the wall's share of a layer (fog_casters.ludic, rebuilt every 4 m). r3d_beyond_fog is exported for
the game to skip animating what will not be drawn. Render-only: no query of the ground or the world
changes, and off is the old frame (0 pixels over 8 against 160ce96, twice per side).

Draws per frame at the overlook: 2757 off, 1104 at 175 m, 484 at 30 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 15:38:00 +03:00
parent b9f9cb8495
commit 2ce2d997be
9 changed files with 88 additions and 11 deletions

View file

@ -221,7 +221,9 @@ function stream_update(render3d_st: mut Render3dState, s: Stream, cam_x: float,
render3d_st.stream_walks += 1
render3d_st.stream_walk_no += 1
let tw = gl_now_us()
let r = int(s.reach / s.size) + 1
# past the fog wall nothing is generated, gathered or kept wanted
let reach = r3d_reach(render3d_st, s.reach)
let r = int(reach / s.size) + 1
# rings outward from the camera's cell: the nearest chunks are generated first
var ring = 0
while ring <= r {
@ -236,7 +238,7 @@ function stream_update(render3d_st: mut Render3dState, s: Stream, cam_x: float,
let dx = wx - cam_x; let dz = wz - cam_z
let d = Math.sqrt(dx * dx + dz * dz)
let band = stream_band(s, d)
if band < 4 and band >= s.min_band and d < s.reach + s.size {
if band < 4 and band >= s.min_band and d < reach + s.size {
let key = stream_key(cx, cz, band)
var c = stream_find(s, key)
if c != null { c.used = render3d_st.stream_walk_no }