[PR #1111] [MERGED] Cave culling: see the world from above or below its height #3056

Closed
opened 2026-11-02 16:01:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1111
Author: @ludovic111
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: fix/occlusion-camera-above-world


📝 Commits (1)

  • 4eaa025 Cave culling: see the world from above or below its height

📊 Changes

1 file changed (+162 additions, -15 deletions)

View changed files

📝 crates/horizon-client/src/gfx/occlusion.rs (+162 -15)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #1037 (reported by @rdbtCVS).

What

Fly up past y 352 and every chunk disappeared. The cave culling search (crates/horizon-client/src/gfx/occlusion.rs) started from the camera's own section. It could step only one section past the top of the world, so from two sections above it (y 352 in the overworld) it reached nothing.

Vanilla's SectionOcclusionGraph.initializeQueueForFullUpdate handles a camera outside the world's height differently. It seeds the queue with every section of the world's top layer around the camera (the bottom layer when the camera is below the world). Each seed is entered from above (below), with sourceDirection set, and its travelled directions point away from the camera's column. The seeds are sorted by the squared distance from the camera's block to each section's centre, a stable sort over the x-then-z loop. Horizon now does the same (Graph::seed_outside). The searched box is the world's height plus its two outer layers, wherever the camera is. Vanilla seeds only columns within the view distance; this search covers its whole box, as it already does from inside the world.

Rebased on #1094 (vanilla's graph rules): seeds use its entry-face mask, and the distant ray test applies to them as in vanilla. A sample above the world counts as visible, so seeds seen from high up pass the test. The reference implementation in the tests (reference, vanilla's runUpdates as written) now also seeds from outside the world the way vanilla does. same_sections_as_vanilla already had two cameras outside a 6-section world, one section below it and one above, and now compares them against vanilla's seeding cell for cell.

Screenshots

Spectator at 97.5 420 -39.5 looking down (pitch 70), render distance 24, seed 12345, Mac mini, --offscreen + horizon-ctl screenshot. The terrain on the right is this branch after the rebase. That session was shorter, so less of the area had been generated.

main this PR (before the rebase) this PR (rebased on #1094)
main before the rebase rebased

Checks (rebased branch, 4eaa0251)

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p horizon-client --all-targets -- -D warnings (with set -o pipefail): clean.
  • cargo test -p horizon-client: all pass. That includes same_sections_as_vanilla with its outside cameras and two new tests: a_camera_outside_the_world_sees_it_from_its_top_or_bottom (cameras at 6, 9 and 40 sections up and 1 and 7 below a 6-section world see exactly the columns in range) and a_closed_top_layer_hides_the_world_from_above (a closed top layer hides what is under it, and seeds never step back out).
  • tools/parity.py --changed origin/main on the rebased branch (Mac mini): 101 harnesses depend on gfx/occlusion.rs (through the client), and all 101 pass, world_spawn included. Before the rebase, the 142 harnesses that depend on the four P4 branches all passed on their merge onto main ae21bd54. Nothing failed, so no rerun on plain main was needed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1111 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/occlusion-camera-above-world` --- ### 📝 Commits (1) - [`4eaa025`](https://github.com/horizon-rust/horizon/commit/4eaa0251e284d0fa87bdf81973158678d5273914) Cave culling: see the world from above or below its height ### 📊 Changes **1 file changed** (+162 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx/occlusion.rs` (+162 -15) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #1037 (reported by @rdbtCVS). ## What Fly up past y 352 and every chunk disappeared. The cave culling search (`crates/horizon-client/src/gfx/occlusion.rs`) started from the camera's own section. It could step only one section past the top of the world, so from two sections above it (y 352 in the overworld) it reached nothing. Vanilla's `SectionOcclusionGraph.initializeQueueForFullUpdate` handles a camera outside the world's height differently. It seeds the queue with every section of the world's top layer around the camera (the bottom layer when the camera is below the world). Each seed is entered from above (below), with `sourceDirection` set, and its travelled directions point away from the camera's column. The seeds are sorted by the squared distance from the camera's block to each section's centre, a stable sort over the x-then-z loop. Horizon now does the same (`Graph::seed_outside`). The searched box is the world's height plus its two outer layers, wherever the camera is. Vanilla seeds only columns within the view distance; this search covers its whole box, as it already does from inside the world. Rebased on #1094 (vanilla's graph rules): seeds use its entry-face mask, and the distant ray test applies to them as in vanilla. A sample above the world counts as visible, so seeds seen from high up pass the test. The reference implementation in the tests (`reference`, vanilla's `runUpdates` as written) now also seeds from outside the world the way vanilla does. `same_sections_as_vanilla` already had two cameras outside a 6-section world, one section below it and one above, and now compares them against vanilla's seeding cell for cell. ## Screenshots Spectator at 97.5 420 -39.5 looking down (pitch 70), render distance 24, seed 12345, Mac mini, `--offscreen` + `horizon-ctl screenshot`. The terrain on the right is this branch after the rebase. That session was shorter, so less of the area had been generated. | main | this PR (before the rebase) | this PR (rebased on #1094) | |---|---|---| | ![main](https://raw.githubusercontent.com/ludovic111/horizon/19af88feacb47d176f00f7af5c82a476dd707206/p4/1037-main-y420.png) | ![before the rebase](https://raw.githubusercontent.com/ludovic111/horizon/19af88feacb47d176f00f7af5c82a476dd707206/p4/1037-branch-y420.png) | ![rebased](https://raw.githubusercontent.com/ludovic111/horizon/e22427163ea73d7b4e361191858107c364e4508a/p4/1037-branch-rebased-y420.png) | ## Checks (rebased branch, 4eaa0251) - `cargo fmt --all -- --check`: clean. - `cargo clippy -p horizon-client --all-targets -- -D warnings` (with `set -o pipefail`): clean. - `cargo test -p horizon-client`: all pass. That includes `same_sections_as_vanilla` with its outside cameras and two new tests: `a_camera_outside_the_world_sees_it_from_its_top_or_bottom` (cameras at 6, 9 and 40 sections up and 1 and 7 below a 6-section world see exactly the columns in range) and `a_closed_top_layer_hides_the_world_from_above` (a closed top layer hides what is under it, and seeds never step back out). - `tools/parity.py --changed origin/main` on the rebased branch (Mac mini): 101 harnesses depend on `gfx/occlusion.rs` (through the client), and **all 101 pass**, world_spawn included. Before the rebase, the 142 harnesses that depend on the four P4 branches all passed on their merge onto main ae21bd54. Nothing failed, so no rerun on plain main was needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 16:01:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3056
No description provided.