feat(modapi): world.ray and rayAll: what a ray hits by kind, which actor, one passed through #2662

Merged
HumanBean merged 2 commits from ChloeNow/Longshot:feat/modapi-world-rays into mod-api 2026-11-28 04:22:08 +00:00
Contributor

Summary

world.ray is in the Rust mod API, cast on the physics step's own thread, but Preview: no run had shown it, and
has("world.ray") had no answer at all (the feature table had no line for it, so it was false even with the Preview
list lifted). A first run shows the cast works, and shows its one guess was wrong: the "scenery" preset (48) is every
layer, Link included, so a ray down through him stopped on the top of his head, 1.17 m above his feet. A colliding
camera rig casts the same ray, so its eye would stop on Link too.

This makes rays a feature, with what other engines' raycasts offer (Unity's Raycast/RaycastAll, Unreal's line
traces, Godot's intersect_ray), on the same step-thread design:

  • ray(from, to, options?) and rayAll(from, to, options?) (new): the nearest hit, or every hit along the
    ray, nearest first, each body once and an actor's several bodies one hit (at most 16). rayAll is the game's own
    every-hit ray query (Havok's all-hits collector), built as the game builds it.
  • What it hits, by kind (RayOptions): ground, objects, characters, water on by default; player (Link)
    off, so a ray cast from Link doesn't stop on him at once. Each kind is the game's own entity layers, named in the
    binary and checked a bit at a time in a run of the C mod API's rays (#2422).
  • ignore: an actor's key; the ray passes through its bodies (their collision group, as the game's own helpers
    put it in a ray's filter).
  • What it hit (RayHit): position, normal, distance as before, plus kind, actorKey (the actor whose body it is,
    for a mod with actors.read) and inside (the ray started in it).
  • The camera's collide asks for the ground alone (Ask::scenery).
  • has("world.ray") is true where the build has the query and both step sites; has("world.rayAll") where it also
    has the every-hit query (rays.allInit, rays.hitsVtable, rays.hitsClear).

How, in short: the query is built as before, its filter set from preset 48 and then given the asked kinds' layers, and
an ignore group. ray's hit kind is the ray cast again with one kind's layers at a time until the same body (by its
handle) is hit; a ray of one kind costs one cast. rayAll is the game's own every-hit ray query: the ray query's cast
method reads a mode at +0x8c (0 Havok's closest-hit collector, the ground check's and ray's; 1 its all-hits
collector, each hit made a record in the query's hit list at +0x68). The game's f_83010540 (the water's surface and
the ground under it) builds one with f_83010ac0, which makes the list in the query's own buffer and sets the mode,
casts it with the same executor, walks the list and clears it; raw_all does the same. One cast, whatever the ray
passes through; each hit's kind is its body's own layer; each body's nearest record kept and an actor's bodies one hit
(their collision group: Link's two). Which actor a hit is: the listed actor one of whose bodies has the hit's handle, on
the main thread as the answer settles. A slot's ask and answer move behind a lock each that only the state's owner
takes, so they can carry the hits.

Read first: game/crates/game-core/src/rays.rs (Kind, Ask, Answer, raw, aim, classify, raw_all,
contacts_of, cast, the actors' bodies), its layout in layout/rays.rs (the every-hit query's at the end), the
rays.* named locations in game/sites/sites.toml, then ray_ask and the answers' JSON in
game/crates/api/src/services/world.rs; the schema's ray, rayAll (world.toml) and RayHit, RayKind,
RayOptions (types.toml). docs/dev/reference/world.md's Rays has what was read and run.

This is #2422's change, made again on the Rust mod API's own rays; #2422 (the C mod API) can close. Part of #1958's
Modding API; targets mod-api.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24. In the game, quick builds of this head,
through dev.py game-tests:

  • Link's house (kokiri-start), rays from 2 m above Link to 3 m below him, all answered a frame after they were
    asked: the default kinds meet the ground at his feet (y 118.44), no actor; player: true the top of his head with
    kind player and his key; with ignore his key, the ground; from his chest, him at once with inside;
    ground: false, a miss. rayAll with player: true: him once (two bodies) with his key, then the ground at his
    feet; with ignore his key, the ground alone.
  • Kinds, in Kokiri Forest (a second probe takes Link there with world.travel and casts straight down through
    every listed actor): the withered Deku Babas met as character with their own actorKey, by ray and rayAll;
    grass as object with its own key; the treasure chests and trees as object (no key: hit on a body their actor's
    list does not name, as documented). Water-only rays over a grid met the stream; at open water the default kinds met
    its surface as water, water: false the bed 0.20 m below, rayAll the surface then the bed. Under a ledge,
    rayAll gave the ledge's two ground bodies, then the water.
  • A colliding camera rig (on a local build with camera.override.collide's Preview lifted, not in this branch): the
    eye 6 m behind Link in his house, collide on, stopped 1.44 m from its pivot, short of the wall; off, 6.00 m; on
    again, 1.44 m.

Checks: cargo test -p game-core (rays: the query as the ground check builds it; ray's nearest by kind in a
made-up world answered as the executor does: the default kinds, the characters off, Link asked for and told from the
ground, from inside him, his group passed through, a hit past the end, nothing asked; every hit through the game's
every-hit query faked as the build has it: its constructor's list and mode, an executor filling the list in no order
with Link's two bodies and a floor's two triangles, each thing once and nearest first, kinds from the bodies' layers,
the group passed through, from inside Link, a miss, nothing asked making no query, every list cleared, a list not the
build's refused; without the sort it fails; the slots), -p api (the answers as RayHits, a key only with
actors.read, rayAll's list; the features), -p modtool, -p game-sites, -p sites; cargo check --workspace --all-targets; cargo run -p schema-gen -- --check; rustfmt. Tests that fail on mod-api itself and here, on
Windows: api's a_content_mods_changed_module_runs_again_and_its_outputs_are_served and modtool's
eden_and_ryujinx_mods_are_found_with_their_switches.

Still to test:

  • A colliding camera rig played by hand (camera.override.collide stays Preview here until its own change lifts it)
  • Linux, and clippy with warnings as errors: mise run rust and mise run test (by hand, or CI)

Measurements

Nothing measured: with no ray asked the step sites stay off, as before. A ray is the game's own query: ray one cast
plus one per kind tried to tell its kind (none when one kind is asked), rayAll one cast of the game's every-hit
query, whatever it passes through. They run on the physics step's thread, after its step.

Risks

Only mods that cast rays, and a colliding camera rig (still Preview), reach this code. The camera rig's ray now asks
for the ground alone (preset 48 hit Link before, the rig's own pivot). A build whose every-hit query differs (its hit
list's vtable not the build's) gets no rayAll: has() false, nothing read or cleared. The test game still has no world to cast against: has("world.ray") is false there, as
before (a fake caster for tests is a follow-up). The generated docs' schema hash conflicts with any other schema
change: whichever merges later needs cargo run -p schema-gen again.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary `world.ray` is in the Rust mod API, cast on the physics step's own thread, but Preview: no run had shown it, and `has("world.ray")` had no answer at all (the feature table had no line for it, so it was false even with the Preview list lifted). A first run shows the cast works, and shows its one guess was wrong: the "scenery" preset (48) is every layer, Link included, so a ray down through him stopped on the top of his head, 1.17 m above his feet. A colliding camera rig casts the same ray, so its eye would stop on Link too. This makes rays a feature, with what other engines' raycasts offer (Unity's `Raycast`/`RaycastAll`, Unreal's line traces, Godot's `intersect_ray`), on the same step-thread design: - **`ray(from, to, options?)`** and **`rayAll(from, to, options?)`** (new): the nearest hit, or every hit along the ray, nearest first, each body once and an actor's several bodies one hit (at most 16). `rayAll` is the game's own every-hit ray query (Havok's all-hits collector), built as the game builds it. - **What it hits, by kind** (`RayOptions`): `ground`, `objects`, `characters`, `water` on by default; `player` (Link) off, so a ray cast from Link doesn't stop on him at once. Each kind is the game's own entity layers, named in the binary and checked a bit at a time in a run of the C mod API's rays (#2422). - **`ignore`**: an actor's key; the ray passes through its bodies (their collision group, as the game's own helpers put it in a ray's filter). - **What it hit** (`RayHit`): position, normal, distance as before, plus `kind`, `actorKey` (the actor whose body it is, for a mod with `actors.read`) and `inside` (the ray started in it). - The camera's `collide` asks for the ground alone (`Ask::scenery`). - `has("world.ray")` is true where the build has the query and both step sites; `has("world.rayAll")` where it also has the every-hit query (`rays.allInit`, `rays.hitsVtable`, `rays.hitsClear`). How, in short: the query is built as before, its filter set from preset 48 and then given the asked kinds' layers, and an `ignore` group. `ray`'s hit kind is the ray cast again with one kind's layers at a time until the same body (by its handle) is hit; a ray of one kind costs one cast. `rayAll` is the game's own every-hit ray query: the ray query's cast method reads a mode at `+0x8c` (0 Havok's closest-hit collector, the ground check's and `ray`'s; 1 its all-hits collector, each hit made a record in the query's hit list at `+0x68`). The game's f_83010540 (the water's surface and the ground under it) builds one with f_83010ac0, which makes the list in the query's own buffer and sets the mode, casts it with the same executor, walks the list and clears it; `raw_all` does the same. One cast, whatever the ray passes through; each hit's kind is its body's own layer; each body's nearest record kept and an actor's bodies one hit (their collision group: Link's two). Which actor a hit is: the listed actor one of whose bodies has the hit's handle, on the main thread as the answer settles. A slot's ask and answer move behind a lock each that only the state's owner takes, so they can carry the hits. Read first: `game/crates/game-core/src/rays.rs` (`Kind`, `Ask`, `Answer`, `raw`, `aim`, `classify`, `raw_all`, `contacts_of`, `cast`, the actors' bodies), its layout in `layout/rays.rs` (the every-hit query's at the end), the `rays.*` named locations in `game/sites/sites.toml`, then `ray_ask` and the answers' JSON in `game/crates/api/src/services/world.rs`; the schema's `ray`, `rayAll` (`world.toml`) and `RayHit`, `RayKind`, `RayOptions` (`types.toml`). `docs/dev/reference/world.md`'s Rays has what was read and run. This is #2422's change, made again on the Rust mod API's own rays; #2422 (the C mod API) can close. Part of #1958's Modding API; targets `mod-api`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24. In the game, quick builds of this head, through `dev.py game-tests`: - **Link's house** (`kokiri-start`), rays from 2 m above Link to 3 m below him, all answered a frame after they were asked: the default kinds meet the ground at his feet (y 118.44), no actor; `player: true` the top of his head with `kind` `player` and his key; with `ignore` his key, the ground; from his chest, him at once with `inside`; `ground: false`, a miss. `rayAll` with `player: true`: him once (two bodies) with his key, then the ground at his feet; with `ignore` his key, the ground alone. - **Kinds, in Kokiri Forest** (a second probe takes Link there with `world.travel` and casts straight down through every listed actor): the withered Deku Babas met as `character` with their own `actorKey`, by `ray` and `rayAll`; grass as `object` with its own key; the treasure chests and trees as `object` (no key: hit on a body their actor's list does not name, as documented). Water-only rays over a grid met the stream; at open water the default kinds met its surface as `water`, `water: false` the bed 0.20 m below, `rayAll` the surface then the bed. Under a ledge, `rayAll` gave the ledge's two ground bodies, then the water. - **A colliding camera rig** (on a local build with `camera.override.collide`'s Preview lifted, not in this branch): the eye 6 m behind Link in his house, `collide` on, stopped 1.44 m from its pivot, short of the wall; off, 6.00 m; on again, 1.44 m. Checks: `cargo test -p game-core` (`rays`: the query as the ground check builds it; `ray`'s nearest by kind in a made-up world answered as the executor does: the default kinds, the characters off, Link asked for and told from the ground, from inside him, his group passed through, a hit past the end, nothing asked; every hit through the game's every-hit query faked as the build has it: its constructor's list and mode, an executor filling the list in no order with Link's two bodies and a floor's two triangles, each thing once and nearest first, kinds from the bodies' layers, the group passed through, from inside Link, a miss, nothing asked making no query, every list cleared, a list not the build's refused; without the sort it fails; the slots), `-p api` (the answers as RayHits, a key only with `actors.read`, `rayAll`'s list; the features), `-p modtool`, `-p game-sites`, `-p sites`; `cargo check --workspace --all-targets`; `cargo run -p schema-gen -- --check`; rustfmt. Tests that fail on `mod-api` itself and here, on Windows: `api`'s `a_content_mods_changed_module_runs_again_and_its_outputs_are_served` and `modtool`'s `eden_and_ryujinx_mods_are_found_with_their_switches`. **Still to test:** - A colliding camera rig played by hand (`camera.override.collide` stays Preview here until its own change lifts it) - Linux, and clippy with warnings as errors: `mise run rust` and `mise run test` (by hand, or CI) ## Measurements Nothing measured: with no ray asked the step sites stay off, as before. A ray is the game's own query: `ray` one cast plus one per kind tried to tell its kind (none when one kind is asked), `rayAll` one cast of the game's every-hit query, whatever it passes through. They run on the physics step's thread, after its step. ## Risks Only mods that cast rays, and a colliding camera rig (still Preview), reach this code. The camera rig's ray now asks for the ground alone (preset 48 hit Link before, the rig's own pivot). A build whose every-hit query differs (its hit list's vtable not the build's) gets no `rayAll`: `has()` false, nothing read or cleared. The test game still has no world to cast against: `has("world.ray")` is false there, as before (a fake caster for tests is a follow-up). The generated docs' schema hash conflicts with any other schema change: whichever merges later needs `cargo run -p schema-gen` again. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). <!-- Windows run as Testing says; clippy and Linux: CI --> - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. <!-- Windows built and played; Linux: CI --> - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(modapi): world.ray and rayAll: what a ray hits by kind, which actor, one passed through
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
35dd1e3505
world.ray was Preview, and has("world.ray") had no answer (the feature table had no line for it). A first run of the
step-thread cast shows it works, and that its "scenery" preset (48) is every layer, Link included: a ray down
through Link stopped on his head, as would a colliding camera rig's.

- ray(from, to, options?) and rayAll (new): the nearest hit, or every hit along the ray, nearest first, each body
  once, at most 16.
- RayOptions: ground, objects, characters, water on, player (Link) off by default; ignore, an actor's key whose
  bodies the ray passes through (their collision group, as f_80e86ac0 puts it in a ray's filter).
- RayHit: kind (RayKind), actorKey (for a mod with actors.read), inside, beside position, normal, distance.
- The camera rig's ray asks for the ground alone (Ask::scenery).
- has("world.ray") and has("world.rayAll") follow game_core::rays::features.

game_core::rays sets the filter's entity layers by kind (each checked a bit at a time in the C mod API's run, #2422),
tells a hit's kind by casting again with one kind at a time until the same body is hit, and for rayAll casts the
other kinds from just past each hit while stepping through the hit body with its own kind alone (an overlapping body
of that kind met at once is the same thing: Link's two bodies are one hit). A hit's actor is the listed actor one of
whose bodies has the hit's handle, found as the answer settles. A slot's ask and answer sit behind a lock each that
only the state's owner takes.

Tests: game-core's rays (the query with the kind's layers and the body handle; a made-up world answered as the
game's executor: the kind by a one-kind cast, every hit along the ray, Link's two bodies one hit with the floor at
his feet, Link passed through by his group, a ray from inside him, nothing asked a miss with no cast); api's world
(the answers as RayHits, the actor's key only with actors.read, rayAll's list) and features.

This replaces #2422, which made rays on the C mod API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 4060 Laptop, a quick build of this head: a probe mod's test passes in Link's house (dev.py game-tests, kokiri-start): rays down through Link meet the ground at his feet by default, his head with player: true and his key, the ground again with ignore his key, him at once from his chest (inside), and rayAll gives him once then the ground at his feet. Characters, objects and water are still to meet in this port.

Tested in game: Windows 11, RTX 4060 Laptop, a quick build of this head: a probe mod's test passes in Link's house (dev.py game-tests, kokiri-start): rays down through Link meet the ground at his feet by default, his head with player: true and his key, the ground again with ignore his key, him at once from his chest (inside), and rayAll gives him once then the ground at his feet. Characters, objects and water are still to meet in this port.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The new rayAll implementation can omit or repeat hits. Its behavior and physics-step cost also need broader in-game validation.

Adds kind filters, actor identification and ignore options to world rays, plus rayAll. The API is more useful to mods, but its repeated casts add physics-step work and currently do not reliably return every body.

Blocking (4): must change before merging.

  1. L1 game/crates/game-core/src/rays.rs:409: The fixed five-metre search limit silently drops later bodies of the same kind. (more on the line) Do: Find the exit without a fixed five-metre cutoff, or use a query that can exclude already reported bodies; add a test with a thick body and a later body of the same kind.
  2. L2 game/crates/game-core/src/rays.rs:413: Treating any same-kind body encountered at the current step as the previous body discards distinct overlapping or closely spaced bodies. (more on the line) Do: Track and exclude the actual hit handles while finding subsequent hits, and test distinct overlapping and closely spaced bodies of the same kind.
  3. L3 game/crates/game-core/src/rays.rs:404: The continuation excludes only the most recent kind, so it can report a previously returned body again. (more on the line) Do: Keep the handles already returned across the entire ray and exclude them from subsequent queries; test overlapping bodies of different kinds.
  4. L6: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 game/crates/game-core/src/rays.rs:409: The physics-step cost of the new multi-hit search has not been measured. (more on the line) Do: Measure frame times and physics-step time with representative single and multiple rayAll requests on the base and this head, using repeated runs in the same scene. (@fix does its part first: Replace the repeated 10 cm casts with a query that excludes reported bodies or otherwise bounds the work more tightly.)
  • L5 game/crates/api/src/services/camera.rs:420: The changed collision behavior and the remaining ray kinds need in-game validation on the affected paths. (more on the line) Do: Run the documented camera, character, object and water cases in game, and exercise the ray path on Linux.

@fix can do L1, L2, L3 and L4.

Checks: Still running: Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request).

More: does it help, other systems, switches, what was read

Does it help: Unproven: the Windows probe shows the ground and player cases working in Link's house, but characters, objects, water and the camera rig have not been exercised in this port. No timing comparison is supplied for the additional casts.

Other systems: The same casting path serves mod rays and colliding camera rigs on Windows and Linux. The reported run covers Windows and one NVIDIA GPU; Linux, the camera rig, other collision kinds and the cost of multiple rays remain untested.

Switches: No environment switches added or changed. RayOptions defaults ground, objects, characters and water on and player off; ignore is unset. Those defaults match the stated use, but the untested kinds still need validation.

Reviewed: 35dd1e3505 against 3391f978eb: Read the repository instructions and contribution rules, PR template, commit and diff, ray implementation and layout, world service, feature handling and schema. Skimmed the generated documentation and recorded run; the combined output of the full ray and feature file read was truncated, and the camera service and other documentation were read around the changes rather than in full. docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The commit records AI assistance in a Co-Authored-By trailer.
  • Miss answers are completed with the requested endpoint and distance when their slot is taken.
  • Slot asks and answers use mutexes and state publication; no new plain cross-thread access was identified.

Testing: Read-only review; no code, tests, or project scripts were run. The author reports a Windows game probe and Rust checks; CI still has checks running.

Overlaps and merge order: No overlapping pull request could be checked in the closed network; the description says this replaces #2422.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new rayAll implementation can omit or repeat hits. Its behavior and physics-step cost also need broader in-game validation. Adds kind filters, actor identification and ignore options to world rays, plus rayAll. The API is more useful to mods, but its repeated casts add physics-step work and currently do not reliably return every body. **Blocking (4)**: must change before merging. 1. **L1** `game/crates/game-core/src/rays.rs:409`: The fixed five-metre search limit silently drops later bodies of the same kind. (more on the line) **Do:** Find the exit without a fixed five-metre cutoff, or use a query that can exclude already reported bodies; add a test with a thick body and a later body of the same kind. 2. **L2** `game/crates/game-core/src/rays.rs:413`: Treating any same-kind body encountered at the current step as the previous body discards distinct overlapping or closely spaced bodies. (more on the line) **Do:** Track and exclude the actual hit handles while finding subsequent hits, and test distinct overlapping and closely spaced bodies of the same kind. 3. **L3** `game/crates/game-core/src/rays.rs:404`: The continuation excludes only the most recent kind, so it can report a previously returned body again. (more on the line) **Do:** Keep the handles already returned across the entire ray and exclude them from subsequent queries; test overlapping bodies of different kinds. 4. **L6**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `game/crates/game-core/src/rays.rs:409`: The physics-step cost of the new multi-hit search has not been measured. (more on the line) **Do:** Measure frame times and physics-step time with representative single and multiple rayAll requests on the base and this head, using repeated runs in the same scene. *(`@fix` does its part first: Replace the repeated 10 cm casts with a query that excludes reported bodies or otherwise bounds the work more tightly.)* - **L5** `game/crates/api/src/services/camera.rs:420`: The changed collision behavior and the remaining ray kinds need in-game validation on the affected paths. (more on the line) **Do:** Run the documented camera, character, object and water cases in game, and exercise the ray path on Linux. `@fix` can do L1, L2, L3 and L4. **Checks:** Still running: `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven: the Windows probe shows the ground and player cases working in Link's house, but characters, objects, water and the camera rig have not been exercised in this port. No timing comparison is supplied for the additional casts. **Other systems:** The same casting path serves mod rays and colliding camera rigs on Windows and Linux. The reported run covers Windows and one NVIDIA GPU; Linux, the camera rig, other collision kinds and the cost of multiple rays remain untested. **Switches:** No environment switches added or changed. RayOptions defaults ground, objects, characters and water on and player off; ignore is unset. Those defaults match the stated use, but the untested kinds still need validation. **Reviewed:** 35dd1e3505c4 against 3391f978ebd9: Read the repository instructions and contribution rules, PR template, commit and diff, ray implementation and layout, world service, feature handling and schema. Skimmed the generated documentation and recorded run; the combined output of the full ray and feature file read was truncated, and the camera service and other documentation were read around the changes rather than in full. docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The commit records AI assistance in a Co-Authored-By trailer. - Miss answers are completed with the requested endpoint and distance when their slot is taken. - Slot asks and answers use mutexes and state publication; no new plain cross-thread access was identified. **Testing:** Read-only review; no code, tests, or project scripts were run. The author reports a Windows game probe and Rust checks; CI still has checks running. **Overlaps and merge order:** No overlapping pull request could be checked in the closed network; the description says this replaces #2422. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -418,2 +418,3 @@
#[allow(clippy::cast_possible_truncation, reason = "a place in a map, within 100 km: a float's")]
let ask = game_core::rays::Ask { from: pivot.map(|v| v as f32), to: to.map(|v| v as f32) };
// (the scenery alone: never Link, whom the rig looks at, nor an actor walking by)
let ask = game_core::rays::Ask::scenery(pivot.map(|v| v as f32), to.map(|v| v as f32));
Member

L5 (should fix): The changed collision behavior and the remaining ray kinds need in-game validation on the affected paths.

When: The reported probe covers ground and player on Windows, but does not exercise a colliding camera rig or this implementation's character, object and water hits; Linux has not been run.

Do: Run the documented camera, character, object and water cases in game, and exercise the ray path on Linux.

**L5** (should fix): The changed collision behavior and the remaining ray kinds need in-game validation on the affected paths. *When:* The reported probe covers ground and player on Windows, but does not exercise a colliding camera rig or this implementation's character, object and water hits; Linux has not been run. **Do:** Run the documented camera, character, object and water cases in game, and exercise the ray path on Linux.
@ -129,0 +401,4 @@
if first >= line.len {
return Some(None);
}
let others = ask.kinds & !kind.bit();
Member

L3 (blocking): The continuation excludes only the most recent kind, so it can report a previously returned body again.

When: When a ray enters a player body and then an overlapping object, the cast for other kinds finds the object from inside it. Continuing after that object enables the player kind again while still inside the player, returning the player a second time and potentially alternating until the 16-hit limit.

Do: Keep the handles already returned across the entire ray and exclude them from subsequent queries; test overlapping bodies of different kinds.

**L3** (blocking): The continuation excludes only the most recent kind, so it can report a previously returned body again. *When:* When a ray enters a player body and then an overlapping object, the cast for other kinds finds the object from inside it. Continuing after that object enables the player kind again while still inside the player, returning the player a second time and potentially alternating until the 16-hit limit. **Do:** Keep the handles already returned across the entire ray and exclude them from subsequent queries; test overlapping bodies of different kinds.
@ -129,0 +406,4 @@
let other = raw(g, start, ask.to, layers_of(others), ask.group)?.map(|raw| Next { raw, start, kind: Err(others) });
let mut same_kind = None;
let mut s = first;
for _ in 0..THROUGH_STEPS {
Member

L1 (blocking): The fixed five-metre search limit silently drops later bodies of the same kind.

When: If a ray enters a ground body more than five metres thick and another ground body lies beyond it, all 50 casts still meet the first body. same_kind stays empty and rayAll omits the later body, even when the ray extends beyond it.

Do: Find the exit without a fixed five-metre cutoff, or use a query that can exclude already reported bodies; add a test with a thick body and a later body of the same kind.

**L1** (blocking): The fixed five-metre search limit silently drops later bodies of the same kind. *When:* If a ray enters a ground body more than five metres thick and another ground body lies beyond it, all 50 casts still meet the first body. same_kind stays empty and rayAll omits the later body, even when the ray extends beyond it. **Do:** Find the exit without a fixed five-metre cutoff, or use a query that can exclude already reported bodies; add a test with a thick body and a later body of the same kind.
Member

L4 (should fix): The physics-step cost of the new multi-hit search has not been measured.

When: A rayAll that enters a thick body can issue 50 additional queries for that hit, and a mod may request 64 rays in a frame; this work runs on the physics-step thread.

Do: Measure frame times and physics-step time with representative single and multiple rayAll requests on the base and this head, using repeated runs in the same scene.

**L4** (should fix): The physics-step cost of the new multi-hit search has not been measured. *When:* A rayAll that enters a thick body can issue 50 additional queries for that hit, and a mod may request 64 rays in a frame; this work runs on the physics-step thread. **Do:** Measure frame times and physics-step time with representative single and multiple rayAll requests on the base and this head, using repeated runs in the same scene.
@ -129,0 +410,4 @@
let at = line.at(s);
match raw(g, at, ask.to, kind.layers(), ask.group)? {
None => break,
Some(x) if same(&x, h) || dist(at, x.pos) < 1e-3 => {
Member

L2 (blocking): Treating any same-kind body encountered at the current step as the previous body discards distinct overlapping or closely spaced bodies.

When: After hitting one character, a second character overlapping it, or beginning within the next 10 cm step, is returned at the new cast's start. The distance check advances through it without ever adding its handle, so rayAll does not return each body.

Do: Track and exclude the actual hit handles while finding subsequent hits, and test distinct overlapping and closely spaced bodies of the same kind.

**L2** (blocking): Treating any same-kind body encountered at the current step as the previous body discards distinct overlapping or closely spaced bodies. *When:* After hitting one character, a second character overlapping it, or beginning within the next 10 cm step, is returned at the new cast's start. The distance check advances through it without ever adding its handle, so rayAll does not return each body. **Do:** Track and exclude the actual hit handles while finding subsequent hits, and test distinct overlapping and closely spaced bodies of the same kind.
Author
Contributor

Working on this now. My agent lost the plot at some point on RayAll especially. Havok has a built-in way to get all raycast hits, there's no reason we should be building our own. Cost shouldn't be able to be reduced now, since we're reflecting the games built-in raycast functions as we should be.

Will test the mod-api camera changes

Working on this now. My agent lost the plot at some point on RayAll especially. Havok has a built-in way to get all raycast hits, there's no reason we should be building our own. Cost shouldn't be able to be reduced now, since we're reflecting the games built-in raycast functions as we should be. Will test the mod-api camera changes
ChloeNow force-pushed feat/modapi-world-rays from 35dd1e3505
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 6193f97bc3
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
2026-11-28 00:59:45 +00:00
Compare
Author
Contributor

Review answered, on 6193f97b (rebased on current mod-api):

  • L1, L2, L3 (rayAll's stepping): fixed by taking the stepping out. rayAll is now the game's own every-hit ray query. The ray query's cast method has an all-hits mode (+0x8c = 1: Havok's all-hits collector, each hit a record in the query's hit list at +0x68), and the game builds such a query itself (f_83010540, with f_83010ac0). raw_all builds it the same way, casts it once with the same executor, and walks and clears the list as the game's reader does. Nothing is stepped or cut off: every body the ray crosses is in the list, each body once (an actor's several bodies as one, by their collision group), each hit's kind its body's own layer. game-core's tests fake the every-hit query as the build has it (overlapping bodies, hits out of order, a floor's two triangles, a group passed through).
  • L4 (cost): a rayAll is one cast of the game's own every-hit query, whatever it passes through; there is no work of ours left in it to bound.
  • L5: characters, objects and water ran in the game this time (Kokiri Forest: the Deku Babas and grass by their own keys, the chests, the stream's surface and its bed; Testing has the numbers). The camera rig's collide stays Preview in this branch; on a local build with it lifted, the eye 6 m behind Link stopped 1.44 m out, short of his house's wall (6.00 m with it off). A by-hand camera playtest is in Still to test, and Linux is CI's.
  • L6: rebased.
Review answered, on `6193f97b` (rebased on current `mod-api`): - **L1, L2, L3 (rayAll's stepping):** fixed by taking the stepping out. `rayAll` is now the game's own every-hit ray query. The ray query's cast method has an all-hits mode (`+0x8c` = 1: Havok's all-hits collector, each hit a record in the query's hit list at `+0x68`), and the game builds such a query itself (f_83010540, with f_83010ac0). `raw_all` builds it the same way, casts it once with the same executor, and walks and clears the list as the game's reader does. Nothing is stepped or cut off: every body the ray crosses is in the list, each body once (an actor's several bodies as one, by their collision group), each hit's kind its body's own layer. `game-core`'s tests fake the every-hit query as the build has it (overlapping bodies, hits out of order, a floor's two triangles, a group passed through). - **L4 (cost):** a `rayAll` is one cast of the game's own every-hit query, whatever it passes through; there is no work of ours left in it to bound. - **L5:** characters, objects and water ran in the game this time (Kokiri Forest: the Deku Babas and grass by their own keys, the chests, the stream's surface and its bed; Testing has the numbers). The camera rig's `collide` stays Preview in this branch; on a local build with it lifted, the eye 6 m behind Link stopped 1.44 m out, short of his house's wall (6.00 m with it off). A by-hand camera playtest is in Still to test, and Linux is CI's. - **L6:** rebased.
ChloeNow force-pushed feat/modapi-world-rays from 6193f97bc3
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 694a243848
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
2026-11-28 01:51:22 +00:00
Compare
Author
Contributor

Rebased again on current mod-api (#2657 and #2658 merged; only the generated docs conflicted): 694a2438. The ray probe passes in the game on it (built with #2663 on top). Note for whoever runs schema-gen --check on mod-api itself: game/settings_abi.h is committed one trailing newline short of what the generator writes, so the check reports it stale there too; this branch leaves that file as mod-api has it.

Rebased again on current `mod-api` (#2657 and #2658 merged; only the generated docs conflicted): `694a2438`. The ray probe passes in the game on it (built with #2663 on top). Note for whoever runs `schema-gen --check` on `mod-api` itself: `game/settings_abi.h` is committed one trailing newline short of what the generator writes, so the check reports it stale there too; this branch leaves that file as `mod-api` has it.
ChloeNow force-pushed feat/modapi-world-rays from 694a243848
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
to 494e13254d
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Failing after 9s
2026-11-28 02:26:05 +00:00
Compare
Author
Contributor

Rebased on current mod-api (f8193c1e): 494e1325, only the generated docs made again. cargo test -p game-core -p api -p game-sites -p sites, cargo check --workspace --all-targets and schema-gen --check as before (the api test that fails on mod-api itself, a_content_mods_changed_module_runs_again_and_its_outputs_are_served, still the one). settings_abi.h now matches its generator on mod-api, so my note about it above no longer applies.

Rebased on current `mod-api` (`f8193c1e`): `494e1325`, only the generated docs made again. `cargo test -p game-core -p api -p game-sites -p sites`, `cargo check --workspace --all-targets` and `schema-gen --check` as before (the api test that fails on `mod-api` itself, `a_content_mods_changed_module_runs_again_and_its_outputs_are_served`, still the one). `settings_abi.h` now matches its generator on `mod-api`, so my note about it above no longer applies.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The recorded game runs show the ray kinds and collision query working, and the repeated multi-hit search has been replaced. The pull request is still reported as unmergeable, so its mergeability needs to be settled. Nothing blocking is left. Recommend approval; not approved on the forge.

Adds filtered single-hit and multi-hit rays to the mod API, including hit kinds and actor identification. The multi-hit implementation now uses the game's collector in one cast, at the cost of reading and deduplicating its records.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • What is the current reason the forge reports the pull request as unmergeable after the rebase?

Since the last review (on 35dd1e3505)
Resolved: L1 (The fixed five-metre search limit silently drops later bodies of the same kind.); L2 (Treating any same-kind body encountered at the current step as the previous body discards…); L3 (The continuation excludes only the most recent kind, so it can report a previously returne…); L4 (The physics-step cost of the new multi-hit search has not been measured.); L5 (The changed collision behavior and the remaining ray kinds need in-game validation on the…); L6 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)

Also noticed (2; not asked for, not blocking)
  • Linux ray behavior and a by-hand camera playtest remain to be reported.
  • The every-hit collector's physics-step cost has not been measured.
More: does it help, other systems, switches, what was read

Does it help: Yes for the tested behavior: the author reports successful ray and rayAll probes on Windows in Link's house and Kokiri Forest. Physics-step cost has not been measured.

Other systems: The physics step and Preview camera collision use the ray path. Windows NVIDIA results are reported; Linux and a by-hand camera playtest remain unreported.

Switches: No switches added, changed or removed. Ray options default to ground, objects, characters and water on, and player off.

Reviewed: 494e13254d against f8193c1ed1: Read AGENTS.md, CONTRIBUTING.md, the ray implementation's production paths, the ray layout and calls, feature wiring, site changes, and the supplied description and comments. The full diff, remaining changed files, tests, generated documentation and linked project standards were not read in full; the named review checklist was absent.; nothing run (a code review).

Checked and fine:

  • The all-hit path sorts retained contacts by fraction and clears the recognized hit list after the cast.
  • The reported Windows probes cover default filtering, player inclusion, ignore, inside hits, actor keys and water.

Testing: No commands or tests were run. The author reports Windows in-game probes and game-free checks; Linux and a camera playtest remain outstanding.

Overlaps and merge order: The description identifies #2422 as the earlier C mod API change; its current status was not available.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The recorded game runs show the ray kinds and collision query working, and the repeated multi-hit search has been replaced. The pull request is still reported as unmergeable, so its mergeability needs to be settled. Nothing blocking is left. Recommend approval; not approved on the forge. Adds filtered single-hit and multi-hit rays to the mod API, including hit kinds and actor identification. The multi-hit implementation now uses the game's collector in one cast, at the cost of reading and deduplicating its records. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - What is the current reason the forge reports the pull request as unmergeable after the rebase? **Since the last review** (on 35dd1e3505c4) Resolved: L1 (The fixed five-metre search limit silently drops later bodies of the same kind.); L2 (Treating any same-kind body encountered at the current step as the previous body discards…); L3 (The continuation excludes only the most recent kind, so it can report a previously returne…); L4 (The physics-step cost of the new multi-hit search has not been measured.); L5 (The changed collision behavior and the remaining ray kinds need in-game validation on the…); L6 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - Linux ray behavior and a by-hand camera playtest remain to be reported. - The every-hit collector's physics-step cost has not been measured. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the tested behavior: the author reports successful ray and rayAll probes on Windows in Link's house and Kokiri Forest. Physics-step cost has not been measured. **Other systems:** The physics step and Preview camera collision use the ray path. Windows NVIDIA results are reported; Linux and a by-hand camera playtest remain unreported. **Switches:** No switches added, changed or removed. Ray options default to ground, objects, characters and water on, and player off. **Reviewed:** 494e13254da3 against f8193c1ed1bf: Read AGENTS.md, CONTRIBUTING.md, the ray implementation's production paths, the ray layout and calls, feature wiring, site changes, and the supplied description and comments. The full diff, remaining changed files, tests, generated documentation and linked project standards were not read in full; the named review checklist was absent.; nothing run (a code review). **Checked and fine:** - The all-hit path sorts retained contacts by fraction and clears the recognized hit list after the cast. - The reported Windows probes cover default filtering, player inclusion, ignore, inside hits, actor keys and water. **Testing:** No commands or tests were run. The author reports Windows in-game probes and game-free checks; Linux and a camera playtest remain outstanding. **Overlaps and merge order:** The description identifies #2422 as the earlier C mod API change; its current status was not available. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean changed title from WIP: feat(modapi): world.ray and rayAll: what a ray hits by kind, which actor, one passed through to feat(modapi): world.ray and rayAll: what a ray hits by kind, which actor, one passed through 2026-11-28 04:21:58 +00:00
HumanBean merged commit 67a113a710 into mod-api 2026-11-28 04:22:08 +00:00
HumanBean deleted branch feat/modapi-world-rays 2026-11-28 04:22:08 +00:00
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Failing after 9s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!2662
No description provided.