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:
parent
b9f9cb8495
commit
2ce2d997be
9 changed files with 88 additions and 11 deletions
|
|
@ -70,6 +70,7 @@ function cam_planes_update(render3d_st: mut Render3dState) -> void {
|
|||
# is a sphere (float bits) at least partly inside the side planes of the view?
|
||||
function cam_sphere_visible(render3d_st: Render3dState, x: float, y: float, z: float, r: float) -> bool {
|
||||
if render3d_st.cam_planes == null { return true }
|
||||
if r3d_beyond_fog(render3d_st, x, y, z, r) { return false }
|
||||
let nr = -r
|
||||
for p in 0 .. 4 {
|
||||
let o = p * 4
|
||||
|
|
@ -78,6 +79,14 @@ function cam_sphere_visible(render3d_st: Render3dState, x: float, y: float, z: f
|
|||
}
|
||||
return true
|
||||
}
|
||||
# is a sphere wholly past the fog wall? Nothing there is seen, so nothing there is drawn or animated
|
||||
export function r3d_beyond_fog(render3d_st: Render3dState, x: float, y: float, z: float, r: float) -> bool {
|
||||
let w = render3d_st.r3d_fog_wall
|
||||
if w <= 0.0 { return false }
|
||||
let dx = x - render3d_st.cam_pos[0]; let dy = y - render3d_st.cam_pos[1]; let dz = z - render3d_st.cam_pos[2]
|
||||
let far = w + R3D_FOG_MARGIN + r
|
||||
return dx * dx + dy * dy + dz * dz > far * far
|
||||
}
|
||||
# fly: forward/strafe in metres, turn in radians
|
||||
function cam_move(render3d_st: mut Render3dState, fwd: float, strafe: float, up: float, dyaw: float, dpitch: float) -> void {
|
||||
render3d_st.cam_yaw = render3d_st.cam_yaw + dyaw
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue