[PR #789] [MERGED] Cull boats, paintings, item frames, armor stands, TNT, tridents and fireworks like vanilla #2812

Closed
opened 2026-11-02 15:59:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/entity-culling


📝 Commits (2)

  • 01f4c56 Cull boats, paintings, item frames, armor stands, TNT and tridents like vanilla
  • e8eaaf5 Rerun CI (flaky options_ui test, #802)

📊 Changes

8 files changed (+176 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/armor_stands.rs (+26 -0)
📝 crates/horizon-client/src/game/boats.rs (+12 -1)
📝 crates/horizon-client/src/game/entity_culling.rs (+61 -0)
📝 crates/horizon-client/src/game/fireworks.rs (+14 -0)
📝 crates/horizon-client/src/game/frames.rs (+18 -0)
📝 crates/horizon-client/src/game/paintings.rs (+9 -0)
📝 crates/horizon-client/src/game/tnt.rs (+17 -0)
📝 crates/horizon-client/src/game/trident.rs (+19 -0)

📄 Description

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

The cost

Boats, paintings, item frames, armor stands, primed TNT, thrown tridents and firework rockets were drawn every frame wherever they were in the loaded world. Every armor stand, item frame and painting of every loaded village or base went through its model, item resolution and per-vertex occlusion test, even far behind the camera. Mobs and (since #735) minecarts already follow vanilla's culling; these did not.

The change

EntityRenderer.shouldRender for each of them, through one helper in game/entity_culling.rs:

Entity Range (shouldRenderAtSqrDistance, from the current position) Culling box (interpolated, grown by 0.5)
boat, raft 64 × the box's mean edge × entity distance (about 71 blocks at 100%) its box
primed TNT the same (about 63 blocks) its box
painting the same, by its size (44 blocks for 1×1, 172 for 4×4) its box
item frame 16 × 64 × entity distance (1,024 blocks; ItemFrame) its box; a block wide with a map
armor stand 256 × the box's mean edge, ignoring the option (254 blocks; 4 × 64 for a marker's empty box; ArmorStand) its box, 0.5 larger with a dragon head (LivingEntityRenderer)
trident ten times the default (320 blocks; AbstractArrow) its box grown by 1.5 more (ThrownTridentRenderer)
firework rocket 64 blocks (FireworkRocketEntity) its box

The fishing bobber is unchanged: vanilla never frustum-culls it (FishingHookRenderer.affectedByCulling), and Horizon only draws the player's own, which is always within the 64 blocks.

Performance

Mac mini M4 Pro (Metal), offscreen 1280×720, seed 1234, spectator, entity distance 100%. About 525 boats, armor stands, item frames and paintings were placed on a 160-block square around the camera, with ticks frozen. The camera turned 15° between 2.5 s segments. Culling was switched off and on in ABBA order with a local-only switch (not in this PR), 12 pairs. The machine was heavily loaded by other sessions.

culling off (main) this PR better in
prepare phase, where entity geometry is built (ms) 3.60 1.82 11/12
CPU ms/frame 8.47 6.48 9/12
avg FPS 107 141 8/12
render phase (ms) 4.37 4.15 7/12
GPU ms/frame 0.26 0.34 3/12

The entities' share of the GPU frame is small either way. Culling only removes vertices, so it cannot add GPU work; I can't explain the 0.08 ms rise and read it as noise from the shared GPU.

Picture

Same game, ticks frozen, HUD hidden. Every kind that can be summoned in Horizon (boats, armor stands, item frames with an item or a map, paintings, hopper and chest minecarts) was placed in 16 directions at 6–300 blocks. Each of 6 views was captured with culling on, off, and on again (the noise floor):

View (yaw, pitch) on vs off (pixels) on vs on again
0, 10 318 0
45, 0 424 3
100, −15 821 0
200, 20 625 4
300, 5 2,923 2,648
22, 35 492 282

The only differences are distant entities past vanilla's range, now hidden as in vanilla: small paintings past 44 blocks, boats past 71. Nothing at the screen edges changes, so the frustum test hides nothing visible. Primed TNT, thrown tridents and firework rockets cannot be summoned in Horizon (/summon only loads saved entity types), so they were not captured. They use the same helper with vanilla's numbers above.

Checks

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib: 839 passed, 0 failed.
  • tools/parity.py --changed origin/main: 89 passed, 0 failed (#788 and #789 merged together on main, 11 changed files).

🤖 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/789 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/entity-culling` --- ### 📝 Commits (2) - [`01f4c56`](https://github.com/horizon-rust/horizon/commit/01f4c56dc10baa1ddaf442b4542c29207a193d65) Cull boats, paintings, item frames, armor stands, TNT and tridents like vanilla - [`e8eaaf5`](https://github.com/horizon-rust/horizon/commit/e8eaaf59d79332a5861f1410e17c4e0e17791a99) Rerun CI (flaky options_ui test, #802) ### 📊 Changes **8 files changed** (+176 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/armor_stands.rs` (+26 -0) 📝 `crates/horizon-client/src/game/boats.rs` (+12 -1) 📝 `crates/horizon-client/src/game/entity_culling.rs` (+61 -0) 📝 `crates/horizon-client/src/game/fireworks.rs` (+14 -0) 📝 `crates/horizon-client/src/game/frames.rs` (+18 -0) 📝 `crates/horizon-client/src/game/paintings.rs` (+9 -0) 📝 `crates/horizon-client/src/game/tnt.rs` (+17 -0) 📝 `crates/horizon-client/src/game/trident.rs` (+19 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## The cost Boats, paintings, item frames, armor stands, primed TNT, thrown tridents and firework rockets were drawn every frame wherever they were in the loaded world. Every armor stand, item frame and painting of every loaded village or base went through its model, item resolution and per-vertex occlusion test, even far behind the camera. Mobs and (since #735) minecarts already follow vanilla's culling; these did not. ## The change `EntityRenderer.shouldRender` for each of them, through one helper in `game/entity_culling.rs`: | Entity | Range (`shouldRenderAtSqrDistance`, from the current position) | Culling box (interpolated, grown by 0.5) | | --- | --- | --- | | boat, raft | 64 × the box's mean edge × entity distance (about 71 blocks at 100%) | its box | | primed TNT | the same (about 63 blocks) | its box | | painting | the same, by its size (44 blocks for 1×1, 172 for 4×4) | its box | | item frame | 16 × 64 × entity distance (1,024 blocks; `ItemFrame`) | its box; a block wide with a map | | armor stand | 256 × the box's mean edge, ignoring the option (254 blocks; 4 × 64 for a marker's empty box; `ArmorStand`) | its box, 0.5 larger with a dragon head (`LivingEntityRenderer`) | | trident | ten times the default (320 blocks; `AbstractArrow`) | its box grown by 1.5 more (`ThrownTridentRenderer`) | | firework rocket | 64 blocks (`FireworkRocketEntity`) | its box | The fishing bobber is unchanged: vanilla never frustum-culls it (`FishingHookRenderer.affectedByCulling`), and Horizon only draws the player's own, which is always within the 64 blocks. ## Performance Mac mini M4 Pro (Metal), offscreen 1280×720, seed 1234, spectator, entity distance 100%. About 525 boats, armor stands, item frames and paintings were placed on a 160-block square around the camera, with ticks frozen. The camera turned 15° between 2.5 s segments. Culling was switched off and on in ABBA order with a local-only switch (not in this PR), 12 pairs. The machine was heavily loaded by other sessions. | | culling off (main) | this PR | better in | | --- | --- | --- | --- | | prepare phase, where entity geometry is built (ms) | 3.60 | 1.82 | 11/12 | | CPU ms/frame | 8.47 | 6.48 | 9/12 | | avg FPS | 107 | 141 | 8/12 | | render phase (ms) | 4.37 | 4.15 | 7/12 | | GPU ms/frame | 0.26 | 0.34 | 3/12 | The entities' share of the GPU frame is small either way. Culling only removes vertices, so it cannot add GPU work; I can't explain the 0.08 ms rise and read it as noise from the shared GPU. ## Picture Same game, ticks frozen, HUD hidden. Every kind that can be summoned in Horizon (boats, armor stands, item frames with an item or a map, paintings, hopper and chest minecarts) was placed in 16 directions at 6–300 blocks. Each of 6 views was captured with culling on, off, and on again (the noise floor): | View (yaw, pitch) | on vs off (pixels) | on vs on again | | --- | --- | --- | | 0, 10 | 318 | 0 | | 45, 0 | 424 | 3 | | 100, −15 | 821 | 0 | | 200, 20 | 625 | 4 | | 300, 5 | 2,923 | 2,648 | | 22, 35 | 492 | 282 | The only differences are distant entities past vanilla's range, now hidden as in vanilla: small paintings past 44 blocks, boats past 71. Nothing at the screen edges changes, so the frustum test hides nothing visible. Primed TNT, thrown tridents and firework rockets cannot be summoned in Horizon (`/summon` only loads saved entity types), so they were not captured. They use the same helper with vanilla's numbers above. ## Checks - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib`: 839 passed, 0 failed. - `tools/parity.py --changed origin/main`: 89 passed, 0 failed (#788 and #789 merged together on main, 11 changed files). 🤖 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 15:59:15 +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#2812
No description provided.