[PR #7202] [MERGED] Let particles in open air skip the collision resolution #7408

Closed
opened 2026-11-03 06:39:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7202
Author: @ludovic111
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: perf/particle-collide-air


📝 Commits (1)

  • cf1ead6 Let particles in open air skip the collision resolution

📊 Changes

3 files changed (+183 additions, -8 deletions)

View changed files

📝 crates/horizon-client-render/src/collisions.rs (+168 -7)
📝 crates/horizon-client-render/src/particles.rs (+8 -1)
📝 crates/horizon-world/src/block_collision.rs (+7 -0)

📄 Description

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

Each tick, every moving particle with physics ran the full entity movement resolution (Entity.collideBoundingBox(null, …)): a BlockCollisionScan iterator, try_resolve_step_movement, and their shape vectors. It did this even in open air, where the scan finds nothing. In stress_particles that was ~2.4 ms per tick on the Mac mini: 36 % in the scan, 13 % in Aabb::new, 11 % in the step machinery.

SceneCollisions::cells_without_collision first decides, from the same data the scan reads, that the scan would find no shape:

  • Cells. It walks the scan's cells (one past the box on every side, the corners skipped).
  • Inner cells. No block there can collide (may_collide, the scan's own empty_shape flag).
  • Outer cells. None of their sections holds a block that reaches out of its cell (the scan's may_reach_out, now shared).

In that case the resolution returns the movement unchanged (no shapes → resolve_borrowed_shape_movement returns it; particles have no border, no entity shapes and max_step 0), so the particle gets it directly. Anything it is unsure of goes through the resolution as before: a reaching block in a nearby section, a global palette, a box over 4096 cells, or a state outside the registry.

Exactness

  • New test cells_without_collision_leave_the_movement_as_resolving_does:
    • World: 4000 random boxes (0.2 and 0.6 wide) and movements (up to 1.5 per axis), in the real 26.3 collision registry. They are swept near the scene's stone floor, a stepped pyramid, torches (no collision shape) and a fence (a shape reaching into the cell above).
    • Check: wherever the shortcut is taken, the full resolution returns the movement to the bit. Both paths are taken more than 500 times each.
  • Parity harnesses run on playhorizon at head 2b146370b, the same code as the head:
    • particle_providers (every particle type ticked in air and over a stone floor), block_particles, emitter_particles, entity_particles, marker_particles;
    • result: 5 passed, probes rebuilt, Java oracle runs from the shim cache.

A/B: stress_particles

Setup: Mac mini M4 Pro, RD 16, 1280×720 offscreen, 10 s; 3 alternating pairs, base 0ac35dac75. The Mac was shared, load ~20–30.

Metric base this PR change
client tick 3.24 / 3.70 / 3.58 ms 2.74 / 2.73 / 2.58 ms −24 % (3.51 → 2.68)
1 % low fps 209.3 / 182.1 / 186.4 205.2 / 219.7 / 234.7 +14 % (193 → 220)
avg fps 832 / 657 / 678 647 / 698 / 761 noise (load)

A first version that only checked whole sections changed nothing here (3.4 → 3.4 ms). The scene's floor shares its 16-block section with the particles, as terrain usually does, hence the per-cell check.

Checks (playhorizon, head 2b146370b; the head only rewords the commit)

cargo fmt --all -- --check                                   ok
cargo clippy --profile fast -p horizon-client -p horizon-client-lib -p horizon-client-render --lib --bins --tests -- -D warnings   ok, 0 diagnostics
cargo test -p horizon-client-render --lib section_tests      1 passed
cargo test -p horizon-client-render --lib particles          15 passed (1 ignored)
cargo test -p horizon-client-render --lib collisions         10 passed
python3 tools/parity.py particle_providers block_particles emitter_particles entity_particles marker_particles   5 passed

🤖 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/7202 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/particle-collide-air` --- ### 📝 Commits (1) - [`cf1ead6`](https://github.com/horizon-rust/horizon/commit/cf1ead6ba981b6f0e1a5b44d4a2a9bd64fb9038e) Let particles in open air skip the collision resolution ### 📊 Changes **3 files changed** (+183 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/collisions.rs` (+168 -7) 📝 `crates/horizon-client-render/src/particles.rs` (+8 -1) 📝 `crates/horizon-world/src/block_collision.rs` (+7 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Each tick, every moving particle with physics ran the full entity movement resolution (`Entity.collideBoundingBox(null, …)`): a `BlockCollisionScan` iterator, `try_resolve_step_movement`, and their shape vectors. It did this even in open air, where the scan finds nothing. In `stress_particles` that was ~2.4 ms per tick on the Mac mini: 36 % in the scan, 13 % in `Aabb::new`, 11 % in the step machinery. `SceneCollisions::cells_without_collision` first decides, from the same data the scan reads, that the scan would find no shape: - **Cells.** It walks the scan's cells (one past the box on every side, the corners skipped). - **Inner cells.** No block there can collide (`may_collide`, the scan's own `empty_shape` flag). - **Outer cells.** None of their sections holds a block that reaches out of its cell (the scan's `may_reach_out`, now shared). In that case the resolution returns the movement unchanged (no shapes → `resolve_borrowed_shape_movement` returns it; particles have no border, no entity shapes and `max_step` 0), so the particle gets it directly. Anything it is unsure of goes through the resolution as before: a reaching block in a nearby section, a global palette, a box over 4096 cells, or a state outside the registry. ### Exactness - New test `cells_without_collision_leave_the_movement_as_resolving_does`: - **World:** 4000 random boxes (0.2 and 0.6 wide) and movements (up to 1.5 per axis), in the real 26.3 collision registry. They are swept near the scene's stone floor, a stepped pyramid, torches (no collision shape) and a fence (a shape reaching into the cell above). - **Check:** wherever the shortcut is taken, the full resolution returns the movement to the bit. Both paths are taken more than 500 times each. - **Parity harnesses run on playhorizon at head 2b146370b**, the same code as the head: - particle_providers (every particle type ticked in air and over a stone floor), block_particles, emitter_particles, entity_particles, marker_particles; - result: 5 passed, probes rebuilt, Java oracle runs from the shim cache. ### A/B: `stress_particles` Setup: Mac mini M4 Pro, RD 16, 1280×720 offscreen, 10 s; 3 alternating pairs, base `0ac35dac75`. The Mac was shared, load ~20–30. | Metric | base | this PR | change | |---|---|---|---| | client tick | 3.24 / 3.70 / 3.58 ms | 2.74 / 2.73 / 2.58 ms | **−24 %** (3.51 → 2.68) | | 1 % low fps | 209.3 / 182.1 / 186.4 | 205.2 / 219.7 / 234.7 | **+14 %** (193 → 220) | | avg fps | 832 / 657 / 678 | 647 / 698 / 761 | noise (load) | A first version that only checked whole sections changed nothing here (3.4 → 3.4 ms). The scene's floor shares its 16-block section with the particles, as terrain usually does, hence the per-cell check. ### Checks (playhorizon, head 2b146370b; the head only rewords the commit) ``` cargo fmt --all -- --check ok cargo clippy --profile fast -p horizon-client -p horizon-client-lib -p horizon-client-render --lib --bins --tests -- -D warnings ok, 0 diagnostics cargo test -p horizon-client-render --lib section_tests 1 passed cargo test -p horizon-client-render --lib particles 15 passed (1 ignored) cargo test -p horizon-client-render --lib collisions 10 passed python3 tools/parity.py particle_providers block_particles emitter_particles entity_particles marker_particles 5 passed ``` 🤖 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-03 06:39:07 +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#7408
No description provided.