Skip to content

fix: Fix raycasting "pass-through" collision inaccuracies with better modelling#3906

Merged
spydon merged 2 commits intomainfrom
luan.fix-hitboxes
Apr 20, 2026
Merged

fix: Fix raycasting "pass-through" collision inaccuracies with better modelling#3906
spydon merged 2 commits intomainfrom
luan.fix-hitboxes

Conversation

@luanpotter
Copy link
Copy Markdown
Member

@luanpotter luanpotter commented Apr 19, 2026

Description

Fix raycasting "pass-through" collision inaccuracies with better modelling.

I started by first principles with the formula and told the clanker to implement, so please review with some grains of salt!

The code before had some unnecessary complexity trying to check which side it was before using the intersection formula, so this is a simpler more direct approach.

There is still epsilon wrangling, in fact it is more in your face than ever, but I couldn't find a way to not have it starting from the vector2s data.

I am very open to other suggestions or alternatives here and happy to move implementation forward!

Before:
image

After:
image
image

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@luanpotter luanpotter force-pushed the luan.fix-hitboxes branch 4 times, most recently from c873073 to 405f7b6 Compare April 20, 2026 00:02
@luanpotter luanpotter marked this pull request as ready for review April 20, 2026 00:14
@luanpotter luanpotter requested a review from a team April 20, 2026 00:14
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks sensible, fix the variable names to up the readability though.

Comment thread packages/flame/lib/src/collisions/hitboxes/circle_hitbox.dart
Comment thread packages/flame/lib/src/collisions/hitboxes/circle_hitbox.dart Outdated
Comment thread packages/flame/lib/src/collisions/hitboxes/circle_hitbox.dart
@spydon spydon enabled auto-merge (squash) April 20, 2026 15:34
@spydon spydon merged commit 6337980 into main Apr 20, 2026
8 checks passed
@spydon spydon deleted the luan.fix-hitboxes branch April 20, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants