Solver-agnostic ray/line picking on the physicsData seam - #157
Merged
Conversation
Add a pluggable physicsQuery resource + pickRay/pickRayEach actions fulfilled by both rapierSolver and joltSolver. Supports picking with or without radius (thin ray or swept sphere), nearest-hit and zero-alloc all-hits iteration, verified by an abstract conformance suite run against both engines. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a pluggable, solver-agnostic spatial-query seam for picking on
@adobe/data-gpu/physics, fulfilled interchangeably by both reference solvers.physicsQueryresource +pickRay/pickRayEachactions on thephysicsDataseam. The active solver publishes its engine-backedimplementation once its WASM world is live; consumers pick without knowing
which solver is running.
radiusswept alongthe segment, behind one option.
pickRayreturns the nearest collider as a fresh, retainablePhysicsHit(entity, parametric α ∈ [0,1] matching graphics
PickHit, world point,ray-opposing normal).
pickRayEachvisits every collider along the segment, nearest first, withearly-out, passing a single reused (zero-allocation) hit.
castRayAndGetNormal/castShape/intersectionsWithRay; JoltNarrowPhaseQuery.CastRay/CastShapewith all-hit collectors. Entity resolved via bodyuserData.Radius all-hits is native on Jolt; the Rapier compat binding has no swept-shape
all-hits query, so a radius
pickRayEachdegrades to the nearest hit there(documented on the interface). Graphics
picking(renderable-Model AABB) isleft untouched — physics picking is collider-based and separate.
Testing
pick-ray-conformance.test.ts) run against bothsolvers: entity/α/point/normal, nearest-of-several, clean miss, with/without
radius, all-hits ordering + early-out, and the zero-alloc scratch-reuse vs.
fresh-
castRaycontract.orientNormalAgainstRayhelper.🤖 Generated with Claude Code