fix: Raycast annotations show collider coverage without covered UI targets#1500
Conversation
Use reachable raycast samples to derive both the representative click point and the PhysicsCollider bounds, so annotated screenshots show sampled hit coverage instead of a tiny marker around one point. Keep raw degenerate bounds in JSON and expand only the overlay drawing for visibility, preserving SimX/SimY as the actual click target.
📝 WalkthroughWalkthroughThis PR reworks reachable-sample cluster construction in ChangesReachable cluster and collider bounds refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant RaycastGridAnnotator
participant RaycastHitClusterer
participant RaycastSampleCoverage
RaycastGridAnnotator->>RaycastGridAnnotator: CreateClusterSampleCoverage
RaycastGridAnnotator->>RaycastHitClusterer: CreateReachableCluster(samples, IsSampleOccludedByUi)
RaycastHitClusterer->>RaycastHitClusterer: filter occluded samples
RaycastHitClusterer-->>RaycastGridAnnotator: RaycastClusterInfo(representative, samples) or null
alt reachable cluster is null
RaycastGridAnnotator->>RaycastGridAnnotator: skip cluster
else reachable cluster exists
RaycastGridAnnotator->>RaycastGridAnnotator: CalculateSampleCellBounds(samples, coverage)
RaycastGridAnnotator->>RaycastGridAnnotator: build PhysicsCollider element with BoundsMin/Max
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Packages/src/Editor/Utils/UIElementAnnotator.cs">
<violation number="1" location="Packages/src/Editor/Utils/UIElementAnnotator.cs:458">
P2: Physics collider coverage boxes can become too small again in low-resolution captures because the new minimum box size is applied in pre-scale pixels while the final image is post-scaled. It would be safer to scale `MIN_VISIBLE_PHYSICS_COLLIDER_BOX_SIZE` the same way border metrics are scaled so minimum on-image visibility stays consistent across `ResolutionScale` values.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Treat each dense raycast hit as representing its sampled cell area, then clamp the resulting PhysicsCollider bounds to the captured Game View. This avoids frames that shrink inward from the visible collider area by half a sampling step.
Make annotated screenshots display the sampled reachable cells behind each PhysicsCollider bbox so the visual overlay reflects UI occlusion and sparse collider shapes more clearly. Add a maintained raycast annotation demo scene for manual visual checks without adding heavy PlayMode screenshot tests.
There was a problem hiding this comment.
1 issue found across 10 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Drop the translucent sampled-cell fill after user feedback showed the bbox-only annotation is easier to read. Keep the sampled-cell bbox behavior and the maintained raycast annotation demo scene for future visual checks.
Summary
Assets/Scenes/RaycastAnnotationDemoScene.unityas a maintained visual fixture for raycast annotation checks.User Impact
Changes
Verification
uloop compile --force-recompile true --wait-for-domain-reload trueuloop run-tests --test-mode EditMode --filter-type regex --filter-value ".*(RaycastGridAnnotatorTests|UIElementAnnotatorTests).*"Assets/Scenes/RaycastAnnotationDemoScene.unity:.uloop/outputs/Screenshots/Rendering_20260704_162611_908.png